vehicle_report_model.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /// 用车报表汇总
  2. class VehicleReportSummary {
  3. final int totalTrips;
  4. final double totalMileage;
  5. final int notReturnedCount;
  6. final double totalCost;
  7. const VehicleReportSummary({
  8. this.totalTrips = 0,
  9. this.totalMileage = 0,
  10. this.notReturnedCount = 0,
  11. this.totalCost = 0,
  12. });
  13. factory VehicleReportSummary.fromJson(Map<String, dynamic> json) {
  14. return VehicleReportSummary(
  15. totalTrips: json['totalTrips'] as int? ?? 0,
  16. totalMileage: (json['totalMileage'] as num?)?.toDouble() ?? 0,
  17. notReturnedCount: json['notReturnedCount'] as int? ?? 0,
  18. totalCost: (json['totalCost'] as num?)?.toDouble() ?? 0,
  19. );
  20. }
  21. }
  22. /// 月度用车数据
  23. class VehicleMonthlyItem {
  24. final int month;
  25. final int trips;
  26. final double cost;
  27. final double mileage;
  28. final int count;
  29. const VehicleMonthlyItem({
  30. this.month = 0,
  31. this.trips = 0,
  32. this.cost = 0,
  33. this.mileage = 0,
  34. this.count = 0,
  35. });
  36. factory VehicleMonthlyItem.fromJson(Map<String, dynamic> json) {
  37. return VehicleMonthlyItem(
  38. month: json['month'] as int? ?? 0,
  39. trips: json['trips'] as int? ?? 0,
  40. cost: (json['cost'] as num?)?.toDouble() ?? 0,
  41. mileage: (json['mileage'] as num?)?.toDouble() ?? 0,
  42. count: json['count'] as int? ?? 0,
  43. );
  44. }
  45. }
  46. /// 用车报表完整数据
  47. class VehicleReportData {
  48. final VehicleReportSummary summary;
  49. final List<VehicleMonthlyItem> monthly;
  50. const VehicleReportData({
  51. this.summary = const VehicleReportSummary(),
  52. this.monthly = const [],
  53. });
  54. factory VehicleReportData.fromJson(Map<String, dynamic> json) {
  55. return VehicleReportData(
  56. summary: json['summary'] != null
  57. ? VehicleReportSummary.fromJson(
  58. json['summary'] as Map<String, dynamic>,
  59. )
  60. : const VehicleReportSummary(),
  61. monthly:
  62. (json['monthly'] as List<dynamic>?)
  63. ?.map(
  64. (e) => VehicleMonthlyItem.fromJson(e as Map<String, dynamic>),
  65. )
  66. .toList() ??
  67. [],
  68. );
  69. }
  70. }
  71. /// 下属用车对比数据
  72. class VehicleSubordinateItem {
  73. final String usr;
  74. final String usrName;
  75. final int trips;
  76. final double cost;
  77. const VehicleSubordinateItem({
  78. this.usr = '',
  79. this.usrName = '',
  80. this.trips = 0,
  81. this.cost = 0,
  82. });
  83. factory VehicleSubordinateItem.fromJson(Map<String, dynamic> json) {
  84. return VehicleSubordinateItem(
  85. usr: json['usr'] as String? ?? '',
  86. usrName: json['usrName'] as String? ?? '',
  87. trips: json['trips'] as int? ?? 0,
  88. cost: (json['cost'] as num?)?.toDouble() ?? 0,
  89. );
  90. }
  91. }
  92. /// 用车报表明细
  93. class VehicleReportDetailItem {
  94. final String billNo;
  95. final String? billDate;
  96. final String applicantName;
  97. final String licensePlate;
  98. final String originAdr;
  99. final String destAdr;
  100. final double mileage;
  101. final String reason;
  102. const VehicleReportDetailItem({
  103. this.billNo = '',
  104. this.billDate,
  105. this.applicantName = '',
  106. this.licensePlate = '',
  107. this.originAdr = '',
  108. this.destAdr = '',
  109. this.mileage = 0,
  110. this.reason = '',
  111. });
  112. factory VehicleReportDetailItem.fromJson(Map<String, dynamic> json) {
  113. return VehicleReportDetailItem(
  114. billNo: json['billNo'] as String? ?? '',
  115. billDate: json['billDate'] as String?,
  116. applicantName: json['applicantName'] as String? ?? '',
  117. licensePlate: json['licensePlate'] as String? ?? '',
  118. originAdr: json['originAdr'] as String? ?? '',
  119. destAdr: json['destAdr'] as String? ?? '',
  120. mileage: (json['mileage'] as num?)?.toDouble() ?? 0,
  121. reason: json['reason'] as String? ?? '',
  122. );
  123. }
  124. }