vehicle_model.dart 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /// 用车申请单,对应 [OA_VEHICLE] 表。
  2. ///
  3. /// 字段名采用 camelCase,fromJson 将大写下划线映射。
  4. /// 瞬态字段:applicantName、deptName、isAuditApproved。
  5. class VehicleModel {
  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 purpose; // 用车目的 (PURPOSE)
  11. final String reason; // 用车事由 (REASON)
  12. final String origin; // 始发地地址 (ORIGIN)
  13. final double? originLongitude; // 始发地经度 (ORIGIN_LONGITUDE)
  14. final double? originLatitude; // 始发地纬度 (ORIGIN_LATITUDE)
  15. final String destinAdr; // 目的地地址 (DESTIN_ADR)
  16. final double? destLongitude; // 目的地经度 (DEST_LONGITUDE)
  17. final double? destLatitude; // 目的地纬度 (DEST_LATITUDE)
  18. final int passengerCount; // 同行人数 (PASSENGER_COUNT)
  19. final String passengerName; // 同行人姓名 (PASSENGER_NAME)
  20. final String licensePlate; // 车牌号 (LICENSEPLATE)
  21. final String vehicleType; // 车辆类型 (VEHICLE_TYPE)
  22. final String brand; // 品牌型号 (BRAND)
  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. final bool isReturn; // 是否已还车 (IS_RETURN: 'T'/'F')
  32. final DateTime? returnTime; // 实际归还时间 (RETURN_TIME)
  33. final double odometer; // 里程表读数 (ODOMETER)
  34. final double amtn; // 路桥费/停车费等实际费用 (AMTN)
  35. final String remark; // 费用明细备注 (REMARK)
  36. // ── 瞬态字段(API 从 ERP 实时查询,非存储) ──
  37. final String applicantName;
  38. final String deptName;
  39. final bool isAuditApproved;
  40. const VehicleModel({
  41. this.ycNo = '',
  42. this.ycDd,
  43. this.salNo = '',
  44. this.dep = '',
  45. this.purpose = '',
  46. this.reason = '',
  47. this.origin = '',
  48. this.originLongitude,
  49. this.originLatitude,
  50. this.destinAdr = '',
  51. this.destLongitude,
  52. this.destLatitude,
  53. this.passengerCount = 1,
  54. this.passengerName = '',
  55. this.licensePlate = '',
  56. this.vehicleType = '',
  57. this.brand = '',
  58. this.seats = 0,
  59. this.driverName = '',
  60. this.startTime,
  61. this.endTime,
  62. this.usr = '',
  63. this.recordDd,
  64. this.chkMan = '',
  65. this.clsDate,
  66. this.isReturn = false,
  67. this.returnTime,
  68. this.odometer = 0.0,
  69. this.amtn = 0.0,
  70. this.remark = '',
  71. this.applicantName = '',
  72. this.deptName = '',
  73. this.isAuditApproved = false,
  74. });
  75. factory VehicleModel.fromJson(Map<String, dynamic> json) {
  76. return VehicleModel(
  77. ycNo: json['YC_NO'] as String? ?? '',
  78. ycDd: json['YC_DD'] != null ? DateTime.tryParse(json['YC_DD'] as String) : null,
  79. salNo: json['SAL_NO'] as String? ?? '',
  80. dep: json['DEP'] as String? ?? '',
  81. purpose: json['PURPOSE'] as String? ?? '',
  82. reason: json['REASON'] as String? ?? '',
  83. origin: json['ORIGIN'] as String? ?? '',
  84. originLongitude: (json['ORIGIN_LONGITUDE'] as num?)?.toDouble(),
  85. originLatitude: (json['ORIGIN_LATITUDE'] as num?)?.toDouble(),
  86. destinAdr: json['DESTIN_ADR'] as String? ?? json['DESTIN_ADR'] as String? ?? '',
  87. destLongitude: (json['DEST_LONGITUDE'] as num?)?.toDouble(),
  88. destLatitude: (json['DEST_LATITUDE'] as num?)?.toDouble(),
  89. passengerCount: json['PASSENGER_COUNT'] as int? ?? 1,
  90. passengerName: json['PASSENGER_NAME'] as String? ?? '',
  91. licensePlate: json['LICENSEPLATE'] as String? ?? '',
  92. vehicleType: json['VEHICLE_TYPE'] as String? ?? '',
  93. brand: json['BRAND'] as String? ?? '',
  94. seats: json['SEATS'] as int? ?? 0,
  95. driverName: json['DRIVER_NAME'] as String? ?? '',
  96. startTime: json['START_TIME'] != null ? DateTime.tryParse(json['START_TIME'] as String) : null,
  97. endTime: json['END_TIME'] != null ? DateTime.tryParse(json['END_TIME'] as String) : null,
  98. usr: json['USR'] as String? ?? '',
  99. recordDd: json['RECORD_DD'] != null ? DateTime.tryParse(json['RECORD_DD'] as String) : null,
  100. chkMan: json['CHK_MAN'] as String? ?? '',
  101. clsDate: json['CLS_DATE'] != null ? DateTime.tryParse(json['CLS_DATE'] as String) : null,
  102. isReturn: json['IS_RETURN'] == 'T',
  103. returnTime: json['RETURN_TIME'] != null ? DateTime.tryParse(json['RETURN_TIME'] as String) : null,
  104. odometer: (json['ODOMETER'] as num?)?.toDouble() ?? 0.0,
  105. amtn: (json['AMTN'] as num?)?.toDouble() ?? 0.0,
  106. remark: json['REMARK'] as String? ?? '',
  107. applicantName: json['applicantName'] as String? ?? json['SAL_NO'] as String? ?? '',
  108. deptName: json['deptName'] as String? ?? json['DEP'] as String? ?? '',
  109. isAuditApproved: (json['clsDate'] != null && (json['clsDate'] as String).isNotEmpty) ||
  110. (json['CHK_MAN'] as String?)?.isNotEmpty == true,
  111. );
  112. }
  113. Map<String, dynamic> toJson() => {
  114. 'YC_NO': ycNo,
  115. 'YC_DD': ycDd?.toIso8601String(),
  116. 'SAL_NO': salNo,
  117. 'DEP': dep,
  118. 'PURPOSE': purpose,
  119. 'REASON': reason,
  120. 'ORIGIN': origin,
  121. 'ORIGIN_LONGITUDE': originLongitude,
  122. 'ORIGIN_LATITUDE': originLatitude,
  123. 'DESTIN_ADR': destinAdr,
  124. 'DEST_LONGITUDE': destLongitude,
  125. 'DEST_LATITUDE': destLatitude,
  126. 'PASSENGER_COUNT': passengerCount,
  127. 'PASSENGER_NAME': passengerName,
  128. 'LICENSEPLATE': licensePlate,
  129. 'VEHICLE_TYPE': vehicleType,
  130. 'BRAND': brand,
  131. 'SEATS': seats,
  132. 'DRIVER_NAME': driverName,
  133. 'START_TIME': startTime?.toIso8601String(),
  134. 'END_TIME': endTime?.toIso8601String(),
  135. 'USR': usr,
  136. 'RECORD_DD': recordDd?.toIso8601String(),
  137. 'CHK_MAN': chkMan,
  138. 'CLS_DATE': clsDate?.toIso8601String(),
  139. 'IS_RETURN': isReturn ? 'T' : 'F',
  140. 'RETURN_TIME': returnTime?.toIso8601String(),
  141. 'ODOMETER': odometer,
  142. 'AMTN': amtn,
  143. 'REMARK': remark,
  144. };
  145. VehicleModel copyWith({
  146. String? ycNo,
  147. DateTime? ycDd,
  148. String? salNo,
  149. String? dep,
  150. String? purpose,
  151. String? reason,
  152. String? origin,
  153. double? originLongitude,
  154. double? originLatitude,
  155. String? destinAdr,
  156. double? destLongitude,
  157. double? destLatitude,
  158. int? passengerCount,
  159. String? passengerName,
  160. String? licensePlate,
  161. String? vehicleType,
  162. String? brand,
  163. int? seats,
  164. String? driverName,
  165. DateTime? startTime,
  166. DateTime? endTime,
  167. String? usr,
  168. DateTime? recordDd,
  169. String? chkMan,
  170. DateTime? clsDate,
  171. bool? isReturn,
  172. DateTime? returnTime,
  173. double? odometer,
  174. double? amtn,
  175. String? remark,
  176. String? applicantName,
  177. String? deptName,
  178. bool? isAuditApproved,
  179. }) {
  180. return VehicleModel(
  181. ycNo: ycNo ?? this.ycNo,
  182. ycDd: ycDd ?? this.ycDd,
  183. salNo: salNo ?? this.salNo,
  184. dep: dep ?? this.dep,
  185. purpose: purpose ?? this.purpose,
  186. reason: reason ?? this.reason,
  187. origin: origin ?? this.origin,
  188. originLongitude: originLongitude ?? this.originLongitude,
  189. originLatitude: originLatitude ?? this.originLatitude,
  190. destinAdr: destinAdr ?? this.destinAdr,
  191. destLongitude: destLongitude ?? this.destLongitude,
  192. destLatitude: destLatitude ?? this.destLatitude,
  193. passengerCount: passengerCount ?? this.passengerCount,
  194. passengerName: passengerName ?? this.passengerName,
  195. licensePlate: licensePlate ?? this.licensePlate,
  196. vehicleType: vehicleType ?? this.vehicleType,
  197. brand: brand ?? this.brand,
  198. seats: seats ?? this.seats,
  199. driverName: driverName ?? this.driverName,
  200. startTime: startTime ?? this.startTime,
  201. endTime: endTime ?? this.endTime,
  202. usr: usr ?? this.usr,
  203. recordDd: recordDd ?? this.recordDd,
  204. chkMan: chkMan ?? this.chkMan,
  205. clsDate: clsDate ?? this.clsDate,
  206. isReturn: isReturn ?? this.isReturn,
  207. returnTime: returnTime ?? this.returnTime,
  208. odometer: odometer ?? this.odometer,
  209. amtn: amtn ?? this.amtn,
  210. remark: remark ?? this.remark,
  211. applicantName: applicantName ?? this.applicantName,
  212. deptName: deptName ?? this.deptName,
  213. isAuditApproved: isAuditApproved ?? this.isAuditApproved,
  214. );
  215. }
  216. }