pre_check_in_data.dart 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import 'package:get/get.dart';
  2. import '../../../utils/index.dart';
  3. import '../../enums/index.dart';
  4. class PreCheckInData {
  5. PreCheckInData({
  6. this.allowFieldWork,
  7. this.requiredFieldWorkRemarks,
  8. this.canCheckIn,
  9. this.checkItemList,
  10. this.workPlaceList,
  11. });
  12. bool? allowFieldWork;
  13. bool? requiredFieldWorkRemarks;
  14. bool? canCheckIn;
  15. List<AttendanceV2Record>? checkItemList;
  16. List<WorkPlaceList>? workPlaceList;
  17. factory PreCheckInData.fromJson(Map<String, dynamic> json) => PreCheckInData(
  18. allowFieldWork: json["allowFieldWork"],
  19. requiredFieldWorkRemarks: json["requiredFieldWorkRemarks"],
  20. canCheckIn: json["canCheckIn"],
  21. checkItemList: json["checkItemList"] == null
  22. ? []
  23. : List<AttendanceV2Record>.from(json["checkItemList"]!
  24. .map((x) => AttendanceV2Record.fromJson(x))),
  25. workPlaceList: json["workPlaceList"] == null
  26. ? []
  27. : List<WorkPlaceList>.from(
  28. json["workPlaceList"]!.map((x) => WorkPlaceList.fromJson(x))),
  29. );
  30. Map<String, dynamic> toJson() => {
  31. "allowFieldWork": allowFieldWork,
  32. "requiredFieldWorkRemarks": requiredFieldWorkRemarks,
  33. "canCheckIn": canCheckIn,
  34. "checkItemList": checkItemList == null
  35. ? []
  36. : List<dynamic>.from(checkItemList!.map((x) => x.toJson())),
  37. "workPlaceList": workPlaceList == null
  38. ? []
  39. : List<dynamic>.from(workPlaceList!.map((x) => x.toJson())),
  40. };
  41. }
  42. class AttendanceV2Record {
  43. AttendanceV2Record(
  44. {this.id,
  45. this.userId,
  46. this.recordDateString,
  47. this.recordDate,
  48. this.preDutyTime,
  49. this.preDutyTimeBeforeLimit,
  50. this.preDutyTimeAfterLimit,
  51. this.sourceType,
  52. this.checkInResult,
  53. this.checkInType,
  54. this.sourceDevice,
  55. this.description,
  56. this.groupId,
  57. this.groupCheckType,
  58. this.groupName,
  59. this.shiftId,
  60. this.shiftName,
  61. this.createTime,
  62. this.updateTime,
  63. this.sequence,
  64. this.fieldWork});
  65. String? id;
  66. String? userId;
  67. String? recordDateString;
  68. String? recordDate;
  69. String? preDutyTime;
  70. String? preDutyTimeBeforeLimit;
  71. String? preDutyTimeAfterLimit;
  72. String? sourceType;
  73. String? checkInResult;
  74. String? checkInType;
  75. String? sourceDevice;
  76. String? description;
  77. String? groupId;
  78. String? groupName;
  79. String? groupCheckType; // 1 固定班制 2 自由打卡 3 排班制
  80. String? shiftId;
  81. String? shiftName;
  82. String? createTime;
  83. String? updateTime;
  84. String? sequence;
  85. bool? fieldWork; // 是否外勤
  86. // 是否最后一条已经打卡过的数据
  87. bool isLastRecord = false;
  88. String checkInTypeText() {
  89. if (checkInType == 'OffDuty') {
  90. return 'attendance_offDuty'.tr;
  91. }
  92. return 'attendance_onDuty'.tr;
  93. }
  94. String resultText() {
  95. if (checkInResult == AttendanceV2RecordResultEnum.Normal.key) {
  96. return AttendanceV2RecordResultEnum.Normal.name;
  97. } else if (checkInResult == AttendanceV2RecordResultEnum.Early.key) {
  98. return AttendanceV2RecordResultEnum.Early.name;
  99. } else if (checkInResult == AttendanceV2RecordResultEnum.Late.key) {
  100. return AttendanceV2RecordResultEnum.Late.name;
  101. } else if (checkInResult == AttendanceV2RecordResultEnum.SeriousLate.key) {
  102. return AttendanceV2RecordResultEnum.SeriousLate.name;
  103. } else if (checkInResult == AttendanceV2RecordResultEnum.Absenteeism.key) {
  104. return AttendanceV2RecordResultEnum.Absenteeism.name;
  105. } else if (checkInResult == AttendanceV2RecordResultEnum.NotSigned.key) {
  106. return AttendanceV2RecordResultEnum.NotSigned.name;
  107. }
  108. return '';
  109. }
  110. factory AttendanceV2Record.fromJson(Map<String, dynamic> json) =>
  111. AttendanceV2Record(
  112. id: json["id"],
  113. userId: json["userId"],
  114. recordDateString: json["recordDateString"],
  115. recordDate: json["recordDate"],
  116. preDutyTime: json["preDutyTime"],
  117. preDutyTimeBeforeLimit: json["preDutyTimeBeforeLimit"],
  118. preDutyTimeAfterLimit: json["preDutyTimeAfterLimit"],
  119. sourceType: json["sourceType"],
  120. checkInResult: json["checkInResult"],
  121. checkInType: json["checkInType"],
  122. sourceDevice: json["sourceDevice"],
  123. description: json["description"],
  124. groupId: json["groupId"],
  125. groupName: json["groupName"],
  126. groupCheckType: json["groupCheckType"],
  127. shiftId: json["shiftId"],
  128. shiftName: json["shiftName"],
  129. createTime: json["createTime"],
  130. updateTime: json["updateTime"],
  131. sequence: json["sequence"],
  132. fieldWork: json["fieldWork"],
  133. );
  134. Map<String, dynamic> toJson() => {
  135. "id": id,
  136. "userId": userId,
  137. "recordDateString": recordDateString,
  138. "recordDate": recordDate,
  139. "preDutyTime": preDutyTime,
  140. "preDutyTimeBeforeLimit": preDutyTimeBeforeLimit,
  141. "preDutyTimeAfterLimit": preDutyTimeAfterLimit,
  142. "sourceType": sourceType,
  143. "checkInResult": checkInResult,
  144. "checkInType": checkInType,
  145. "sourceDevice": sourceDevice,
  146. "description": description,
  147. "groupId": groupId,
  148. "groupName": groupName,
  149. "groupCheckType": groupCheckType,
  150. "shiftId": shiftId,
  151. "shiftName": shiftName,
  152. "createTime": createTime,
  153. "updateTime": updateTime,
  154. "sequence": sequence,
  155. "fieldWork": fieldWork,
  156. };
  157. }
  158. class WorkPlaceList {
  159. WorkPlaceList({
  160. this.id,
  161. this.placeName,
  162. this.placeAlias,
  163. this.creator,
  164. this.longitude,
  165. this.latitude,
  166. this.gpsLng,
  167. this.gpsLat,
  168. this.errorRange,
  169. this.description,
  170. this.createTime,
  171. this.updateTime,
  172. this.sequence,
  173. });
  174. String? id;
  175. String? placeName;
  176. String? placeAlias;
  177. String? creator;
  178. String? longitude;
  179. String? latitude;
  180. String? gpsLng; // wgs84坐标
  181. String? gpsLat; // wgs84坐标
  182. int? errorRange;
  183. String? description;
  184. String? createTime;
  185. String? updateTime;
  186. String? sequence;
  187. factory WorkPlaceList.fromJson(Map<String, dynamic> json) => WorkPlaceList(
  188. id: json["id"],
  189. placeName: json["placeName"],
  190. placeAlias: json["placeAlias"],
  191. creator: json["creator"],
  192. longitude: json["longitude"],
  193. latitude: json["latitude"],
  194. gpsLng: json["gpsLng"],
  195. gpsLat: json["gpsLat"],
  196. errorRange: json["errorRange"],
  197. description: json["description"],
  198. createTime: json["createTime"],
  199. updateTime: json["updateTime"],
  200. sequence: json["sequence"],
  201. );
  202. /// 获取正确的坐标 gps [gpsLat] [gpsLng]
  203. /// 如果有 gps 坐标直接返回,没有就拿百度坐标通过计算返回
  204. List<double> getLngLat() {
  205. final lat = double.tryParse(gpsLat ?? '0') ?? 0;
  206. final lng = double.tryParse(gpsLng ?? '0') ?? 0;
  207. if (lat == 0 && lng == 0) {
  208. OLogger.i("没有 gps 坐标??,开始转化!!!");
  209. final bdLat = double.tryParse(latitude ?? '0') ?? 0;
  210. final bdLng = double.tryParse(longitude ?? '0') ?? 0;
  211. return BaiduLocationTransformHelper.bd09towgs84(bdLng, bdLat);
  212. } else {
  213. return [lng, lat];
  214. }
  215. }
  216. Map<String, dynamic> toJson() => {
  217. "id": id,
  218. "placeName": placeName,
  219. "placeAlias": placeAlias,
  220. "creator": creator,
  221. "longitude": longitude,
  222. "latitude": latitude,
  223. "gpsLng": gpsLng,
  224. "gpsLat": gpsLat,
  225. "errorRange": errorRange,
  226. "description": description,
  227. "createTime": createTime,
  228. "updateTime": updateTime,
  229. "sequence": sequence,
  230. };
  231. }