vehicle_apply_model.dart 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /// 用车申请单,对应 [OA_VEHICLE] 表。
  2. ///
  3. /// 字段名采用 camelCase,fromJson 将大写下划线映射。
  4. /// 瞬态字段:applicantName、salName、deptName、isAuditApproved。
  5. class VehicleApplyModel {
  6. final String ycNo; // 用车申请单号 (YC_NO)
  7. final DateTime? ycDd; // 申请日期 (YC_DD)
  8. final String salNo; // 申请人 (SAL_NO)
  9. final String dep; // 所属部门 (DEP)
  10. final String reason; // 用车事由 (REASON)
  11. final String originAdr; // 始发地地址 (ORIGIN_ADR)
  12. final double? originLongitude; // 始发地经度 (ORIGIN_LONGITUDE)
  13. final double? originLatitude; // 始发地纬度 (ORIGIN_LATITUDE)
  14. final String destAdr; // 目的地地址 (DEST_ADR)
  15. final double? destLongitude; // 目的地经度 (DEST_LONGITUDE)
  16. final double? destLatitude; // 目的地纬度 (DEST_LATITUDE)
  17. final int passengerCount; // 同行人数 (PASSENGER_COUNT)
  18. final String passengerName; // 同行人姓名 (PASSENGER_NAME)
  19. final String licensePlate; // 车牌号 (LICENSEPLATE)
  20. final String vehicleType; // 车辆类型 (VEHICLE_TYPE)
  21. final String brand; // 品牌型号 (BRAND)
  22. final int odometerBegin; // 出发前里程表读数 (ODOMETER_BEGIN)
  23. final int seats; // 核定座位数 (SEATS)
  24. final String driverName; // 默认驾驶员 (DRIVER_NAME)
  25. final DateTime? startTime; // 预计出车时间 (START_TIME)
  26. final DateTime? endTime; // 预计还车时间 (END_TIME)
  27. final String usr; // 录入人 (USR)
  28. final DateTime? recordDd; // 录入日期 (RECORD_DD)
  29. final String chkMan; // 审核人 (CHK_MAN)
  30. final DateTime? clsDate; // 终审日期 (CLS_DATE)
  31. // ── 还车登记字段 ──
  32. final bool isReturn; // 是否已还车 (IS_RETURN: 'T'/'F')
  33. final DateTime? returnTime; // 实际归还时间 (RETURN_TIME)
  34. final int odometerEnd; // 还车里程表读数 (ODOMETER_END)
  35. final double amtn; // 路桥费/停车费等实际费用 (AMTN 28,8)
  36. final String remark; // 费用明细备注 (REMARK)
  37. final String usrCheck; // 验车人 (USR_CHECK)
  38. final DateTime? checkDd; // 验车日期 (CHECK_DD)
  39. // ── 瞬态字段(API 从 ERP 实时查询,非存储) ──
  40. final String applicantName;
  41. final String salName;
  42. final String deptName;
  43. final bool isAuditApproved;
  44. const VehicleApplyModel({
  45. this.ycNo = '',
  46. this.ycDd,
  47. this.salNo = '',
  48. this.dep = '',
  49. this.reason = '',
  50. this.originAdr = '',
  51. this.originLongitude,
  52. this.originLatitude,
  53. this.destAdr = '',
  54. this.destLongitude,
  55. this.destLatitude,
  56. this.passengerCount = 1,
  57. this.passengerName = '',
  58. this.licensePlate = '',
  59. this.vehicleType = '',
  60. this.brand = '',
  61. this.odometerBegin = 0,
  62. this.seats = 0,
  63. this.driverName = '',
  64. this.startTime,
  65. this.endTime,
  66. this.usr = '',
  67. this.recordDd,
  68. this.chkMan = '',
  69. this.clsDate,
  70. this.isReturn = false,
  71. this.returnTime,
  72. this.odometerEnd = 0,
  73. this.amtn = 0.0,
  74. this.remark = '',
  75. this.usrCheck = '',
  76. this.checkDd,
  77. this.applicantName = '',
  78. this.salName = '',
  79. this.deptName = '',
  80. this.isAuditApproved = false,
  81. });
  82. factory VehicleApplyModel.fromJson(Map<String, dynamic> json) {
  83. return VehicleApplyModel(
  84. ycNo: json['YC_NO'] as String? ?? '',
  85. ycDd: json['YC_DD'] != null
  86. ? DateTime.tryParse(json['YC_DD'] as String)
  87. : null,
  88. salNo: json['SAL_NO'] as String? ?? '',
  89. dep: json['DEP'] as String? ?? '',
  90. reason: json['REASON'] as String? ?? '',
  91. originAdr: json['ORIGIN_ADR'] as String? ?? '',
  92. originLongitude: (json['ORIGIN_LONGITUDE'] as num?)?.toDouble(),
  93. originLatitude: (json['ORIGIN_LATITUDE'] as num?)?.toDouble(),
  94. destAdr: json['DEST_ADR'] as String? ?? '',
  95. destLongitude: (json['DEST_LONGITUDE'] as num?)?.toDouble(),
  96. destLatitude: (json['DEST_LATITUDE'] as num?)?.toDouble(),
  97. passengerCount: json['PASSENGER_COUNT'] as int? ?? 1,
  98. passengerName: json['PASSENGER_NAME'] as String? ?? '',
  99. licensePlate: json['LICENSEPLATE'] as String? ?? '',
  100. vehicleType: json['VEHICLE_TYPE'] as String? ?? '',
  101. brand: json['BRAND'] as String? ?? '',
  102. odometerBegin: json['ODOMETER_BEGIN'] as int? ?? 0,
  103. seats: json['SEATS'] as int? ?? 0,
  104. driverName: json['DRIVER_NAME'] as String? ?? '',
  105. startTime: json['START_TIME'] != null
  106. ? DateTime.tryParse(json['START_TIME'] as String)
  107. : null,
  108. endTime: json['END_TIME'] != null
  109. ? DateTime.tryParse(json['END_TIME'] as String)
  110. : null,
  111. usr: json['USR'] as String? ?? '',
  112. recordDd: json['RECORD_DD'] != null
  113. ? DateTime.tryParse(json['RECORD_DD'] as String)
  114. : null,
  115. chkMan: json['CHK_MAN'] as String? ?? '',
  116. clsDate: json['CLS_DATE'] != null
  117. ? DateTime.tryParse(json['CLS_DATE'] as String)
  118. : null,
  119. isReturn:
  120. (json['IsReturn'] ?? json['IS_RETURN']) == true ||
  121. json['IS_RETURN'] == 'T',
  122. returnTime: json['RETURN_TIME'] != null
  123. ? DateTime.tryParse(json['RETURN_TIME'] as String)
  124. : null,
  125. odometerEnd: json['ODOMETER_END'] as int? ?? 0,
  126. amtn: (json['AMTN'] as num?)?.toDouble() ?? 0.0,
  127. remark: json['REMARK'] as String? ?? '',
  128. usrCheck: json['USR_CHECK'] as String? ?? '',
  129. checkDd: json['CHECK_DD'] != null
  130. ? DateTime.tryParse(json['CHECK_DD'] as String)
  131. : null,
  132. applicantName:
  133. json['SAL_NAME'] as String? ??
  134. json['applicantName'] as String? ??
  135. json['SAL_NO'] as String? ??
  136. '',
  137. salName: json['SAL_NAME'] as String? ?? json['salName'] as String? ?? '',
  138. deptName:
  139. json['DEP_NAME'] as String? ??
  140. json['deptName'] as String? ??
  141. json['DEP'] as String? ??
  142. '',
  143. isAuditApproved:
  144. json['IsAuditApproved'] == true ||
  145. (json['clsDate'] != null && (json['clsDate'] as String).isNotEmpty) ||
  146. (json['CHK_MAN'] as String?)?.isNotEmpty == true,
  147. );
  148. }
  149. Map<String, dynamic> toJson() => {
  150. 'YC_NO': ycNo,
  151. 'YC_DD': ycDd?.toIso8601String(),
  152. 'SAL_NO': salNo,
  153. 'DEP': dep,
  154. 'REASON': reason,
  155. 'ORIGIN_ADR': originAdr,
  156. 'ORIGIN_LONGITUDE': originLongitude,
  157. 'ORIGIN_LATITUDE': originLatitude,
  158. 'DEST_ADR': destAdr,
  159. 'DEST_LONGITUDE': destLongitude,
  160. 'DEST_LATITUDE': destLatitude,
  161. 'PASSENGER_COUNT': passengerCount,
  162. 'PASSENGER_NAME': passengerName,
  163. 'LICENSEPLATE': licensePlate,
  164. 'VEHICLE_TYPE': vehicleType,
  165. 'BRAND': brand,
  166. 'ODOMETER_BEGIN': odometerBegin,
  167. 'SEATS': seats,
  168. 'DRIVER_NAME': driverName,
  169. 'START_TIME': startTime?.toIso8601String(),
  170. 'END_TIME': endTime?.toIso8601String(),
  171. 'USR': usr,
  172. 'RECORD_DD': recordDd?.toIso8601String(),
  173. 'CHK_MAN': chkMan,
  174. 'CLS_DATE': clsDate?.toIso8601String(),
  175. 'IS_RETURN': isReturn ? 'T' : 'F',
  176. 'RETURN_TIME': returnTime?.toIso8601String(),
  177. 'ODOMETER_END': odometerEnd,
  178. 'AMTN': amtn,
  179. 'REMARK': remark,
  180. 'USR_CHECK': usrCheck,
  181. 'CHECK_DD': checkDd?.toIso8601String(),
  182. };
  183. VehicleApplyModel copyWith({
  184. String? ycNo,
  185. DateTime? ycDd,
  186. String? salNo,
  187. String? dep,
  188. String? reason,
  189. String? originAdr,
  190. double? originLongitude,
  191. double? originLatitude,
  192. String? destAdr,
  193. double? destLongitude,
  194. double? destLatitude,
  195. int? passengerCount,
  196. String? passengerName,
  197. String? licensePlate,
  198. String? vehicleType,
  199. String? brand,
  200. int? odometerBegin,
  201. int? seats,
  202. String? driverName,
  203. DateTime? startTime,
  204. DateTime? endTime,
  205. String? usr,
  206. DateTime? recordDd,
  207. String? chkMan,
  208. DateTime? clsDate,
  209. bool? isReturn,
  210. DateTime? returnTime,
  211. int? odometerEnd,
  212. double? amtn,
  213. String? remark,
  214. String? usrCheck,
  215. DateTime? checkDd,
  216. String? applicantName,
  217. String? salName,
  218. String? deptName,
  219. bool? isAuditApproved,
  220. }) {
  221. return VehicleApplyModel(
  222. ycNo: ycNo ?? this.ycNo,
  223. ycDd: ycDd ?? this.ycDd,
  224. salNo: salNo ?? this.salNo,
  225. dep: dep ?? this.dep,
  226. reason: reason ?? this.reason,
  227. originAdr: originAdr ?? this.originAdr,
  228. originLongitude: originLongitude ?? this.originLongitude,
  229. originLatitude: originLatitude ?? this.originLatitude,
  230. destAdr: destAdr ?? this.destAdr,
  231. destLongitude: destLongitude ?? this.destLongitude,
  232. destLatitude: destLatitude ?? this.destLatitude,
  233. passengerCount: passengerCount ?? this.passengerCount,
  234. passengerName: passengerName ?? this.passengerName,
  235. licensePlate: licensePlate ?? this.licensePlate,
  236. vehicleType: vehicleType ?? this.vehicleType,
  237. brand: brand ?? this.brand,
  238. odometerBegin: odometerBegin ?? this.odometerBegin,
  239. seats: seats ?? this.seats,
  240. driverName: driverName ?? this.driverName,
  241. startTime: startTime ?? this.startTime,
  242. endTime: endTime ?? this.endTime,
  243. usr: usr ?? this.usr,
  244. recordDd: recordDd ?? this.recordDd,
  245. chkMan: chkMan ?? this.chkMan,
  246. clsDate: clsDate ?? this.clsDate,
  247. isReturn: isReturn ?? this.isReturn,
  248. returnTime: returnTime ?? this.returnTime,
  249. odometerEnd: odometerEnd ?? this.odometerEnd,
  250. amtn: amtn ?? this.amtn,
  251. remark: remark ?? this.remark,
  252. usrCheck: usrCheck ?? this.usrCheck,
  253. checkDd: checkDd ?? this.checkDd,
  254. applicantName: applicantName ?? this.applicantName,
  255. salName: salName ?? this.salName,
  256. deptName: deptName ?? this.deptName,
  257. isAuditApproved: isAuditApproved ?? this.isAuditApproved,
  258. );
  259. }
  260. }