Ver código fonte

Merge remote-tracking branch 'origin/feature/dev' into feature/dev

wangxx 1 mês atrás
pai
commit
6c4df38f3e

+ 32 - 0
airport-admin/src/main/java/com/sundot/airport/web/controller/equipment/EquipmentLedgerController.java

@@ -21,6 +21,7 @@ import com.sundot.airport.equipment.domain.EquipmentLedger;
21 21
 import com.sundot.airport.equipment.service.IEquipmentLedgerService;
22 22
 import com.sundot.airport.common.utils.poi.ExcelUtil;
23 23
 import com.sundot.airport.common.core.page.TableDataInfo;
24
+import org.springframework.web.multipart.MultipartFile;
24 25
 
25 26
 /**
26 27
  * 设备台账Controller
@@ -107,4 +108,35 @@ public class EquipmentLedgerController extends BaseController {
107 108
     public AjaxResult remove(@PathVariable Long[] ids) {
108 109
         return toAjax(equipmentLedgerService.deleteEquipmentLedgerByIds(ids));
109 110
     }
111
+
112
+    /**
113
+     * 导入设备台账列表
114
+     */
115
+    @PreAuthorize("@ss.hasPermi('equipment:ledger:import')")
116
+    @Log(title = "导入设备台账列表", businessType = BusinessType.IMPORT)
117
+    @PostMapping("/importData")
118
+    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
119
+        ExcelUtil<EquipmentLedger> util = new ExcelUtil<>(EquipmentLedger.class);
120
+        List<EquipmentLedger> list = util.importExcel(file.getInputStream());
121
+        String message = equipmentLedgerService.importData(list, updateSupport);
122
+        return success(message);
123
+    }
124
+
125
+    /**
126
+     * 获取导入模板
127
+     */
128
+    @PostMapping("/importTemplate")
129
+    public void importTemplate(HttpServletResponse response) {
130
+        ExcelUtil<EquipmentLedger> util = new ExcelUtil<>(EquipmentLedger.class);
131
+        util.importTemplateExcel(response, "设备台账数据导入模板");
132
+    }
133
+
134
+    /**
135
+     * 设备台账通知
136
+     */
137
+    @GetMapping("/notice")
138
+    public AjaxResult notice(EquipmentLedger equipmentLedger) {
139
+        List<EquipmentLedger> list = equipmentLedgerService.notice(equipmentLedger);
140
+        return success(list);
141
+    }
110 142
 }

+ 33 - 29
airport-admin/src/main/java/com/sundot/airport/web/controller/item/HkOperationDataController.java

@@ -74,8 +74,14 @@ public class HkOperationDataController extends BaseController {
74 74
     }
75 75
 
76 76
     /**
77
-     * 导入客户原始格式的每日运行数据统计表
78
-     * Excel结构:前4行为标题/分组表头,第5行起为数据,列按固定位置映射
77
+     * 导入每日运行数据(按导入模板格式)
78
+     * Excel结构:第1行为表头,第2行起为数据,共24列
79
+     * col0=日期  col1=A区  col2=B区  col3=贵宾  col4=国内旅检  col5=国际旅检
80
+     * col6=贵宾通道  col7=T1回流通道  col8=T1行检  col9=一楼员工
81
+     * col10=T2回流通道  col11=T2行检  col12=三楼东区员工  col13=一楼中心区员工
82
+     * col14=负一楼西区员工  col15=三楼西区员工  col16=国内货站  col17=道口(国内货站)
83
+     * col18=南侧车检  col19=防爆(国内货站)  col20=国际货站  col21=道口(国际货站)
84
+     * col22=北侧车检  col23=防爆(国际货站)
79 85
      */
80 86
     @Log(title = "每日运行数据", businessType = BusinessType.IMPORT)
81 87
     @PostMapping("/importData")
@@ -95,8 +101,8 @@ public class HkOperationDataController extends BaseController {
95 101
         List<HkOperationData> list = new ArrayList<>();
96 102
         try (Workbook workbook = WorkbookFactory.create(is)) {
97 103
             Sheet sheet = workbook.getSheetAt(0);
98
-            // 前4行:标题、分组表头、子表头、列标题,数据从第5行(索引4)开始
99
-            for (int i = 4; i <= sheet.getLastRowNum(); i++) {
104
+            // 第1行(index=0)为表头,数据从第2行(index=1)开始
105
+            for (int i = 1; i <= sheet.getLastRowNum(); i++) {
100 106
                 Row row = sheet.getRow(i);
101 107
                 if (row == null) continue;
102 108
                 Cell dateCell = row.getCell(0);
@@ -104,36 +110,34 @@ public class HkOperationDataController extends BaseController {
104 110
                 if (dateCell.getCellType() != CellType.NUMERIC) continue;
105 111
 
106 112
                 HkOperationData data = new HkOperationData();
107
-                // col 0: 日期(Excel序列数或日期格式均支持)
108 113
                 if (DateUtil.isCellDateFormatted(dateCell)) {
109 114
                     data.setRecordDate(dateCell.getDateCellValue());
110 115
                 } else {
111 116
                     data.setRecordDate(DateUtil.getJavaDate(dateCell.getNumericCellValue()));
112 117
                 }
113
-                data.setAZone(intVal(row, 1));           // A区
114
-                data.setBZone(intVal(row, 2));           // B区
115
-                data.setVip(intVal(row, 3));             // 贵宾
116
-                data.setDomesticPassenger(intVal(row, 4)); // 国内旅检
117
-                data.setIntlPassenger(intVal(row, 5));   // 国际旅检
118
-                data.setVipChannel(intVal(row, 6));      // 贵宾通道
119
-                data.setT1ReturnChannel(intVal(row, 7)); // T1回流通道
120
-                data.setT1LuggageCheck(intVal(row, 8)); // T1行检
121
-                data.setFloor1Staff(intVal(row, 9));     // 一楼员工
122
-                data.setT2ReturnChannel(intVal(row, 10));// T2回流通道
123
-                data.setT2LuggageCheck(intVal(row, 11));// T2行检
124
-                data.setFloor3EastStaff(intVal(row, 12));    // 三楼东区员工
125
-                data.setFloor1CenterStaff(intVal(row, 13));  // 一楼中心区员工
126
-                data.setFloorB1WestStaff(intVal(row, 14));   // 负一楼西区员工
127
-                data.setFloor3WestStaff(intVal(row, 15));    // 三楼西区员工
128
-                data.setDomesticCargo(intVal(row, 16));  // 国内货站
129
-                data.setDomesticGate(intVal(row, 17));   // 道口(国内货站)
130
-                data.setSouthVehicleCheck(intVal(row, 18));  // 南侧车检
131
-                data.setDomesticBomb(intVal(row, 19));   // 防爆(国内货站)
132
-                data.setIntlCargo(intVal(row, 20));      // 国际货站
133
-                data.setIntlGate(intVal(row, 21));       // 道口(国际货站)
134
-                data.setNorthVehicleCheck(intVal(row, 22)); // 北侧车检
135
-                data.setIntlBomb(intVal(row, 23));       // 防爆(国际货站)
136
-                // col 24: 车检总数(公式列,不导入)
118
+                data.setAZone(intVal(row, 1));
119
+                data.setBZone(intVal(row, 2));
120
+                data.setVip(intVal(row, 3));
121
+                data.setDomesticPassenger(intVal(row, 4));
122
+                data.setIntlPassenger(intVal(row, 5));
123
+                data.setVipChannel(intVal(row, 6));
124
+                data.setT1ReturnChannel(intVal(row, 7));
125
+                data.setT1LuggageCheck(intVal(row, 8));
126
+                data.setFloor1Staff(intVal(row, 9));
127
+                data.setT2ReturnChannel(intVal(row, 10));
128
+                data.setT2LuggageCheck(intVal(row, 11));
129
+                data.setFloor3EastStaff(intVal(row, 12));
130
+                data.setFloor1CenterStaff(intVal(row, 13));
131
+                data.setFloorB1WestStaff(intVal(row, 14));
132
+                data.setFloor3WestStaff(intVal(row, 15));
133
+                data.setDomesticCargo(intVal(row, 16));
134
+                data.setDomesticGate(intVal(row, 17));
135
+                data.setSouthVehicleCheck(intVal(row, 18));
136
+                data.setDomesticBomb(intVal(row, 19));
137
+                data.setIntlCargo(intVal(row, 20));
138
+                data.setIntlGate(intVal(row, 21));
139
+                data.setNorthVehicleCheck(intVal(row, 22));
140
+                data.setIntlBomb(intVal(row, 23));
137 141
                 list.add(data);
138 142
             }
139 143
         }

+ 8 - 10
airport-admin/src/main/java/com/sundot/airport/web/controller/item/HkPendingConfiscateController.java

@@ -75,13 +75,12 @@ public class HkPendingConfiscateController extends BaseController {
75 75
     }
76 76
 
77 77
     /**
78
-     * 导入客户原始格式的待检区收缴数据
79
-     * Excel结构:
80
-     *   Row1: 分组表头(T1航站楼A区/B区, T2国内/国际/中转, 每日收缴总数)
81
-     *   Row2: 子列表头(火种/液态物品/其他)
82
-     *   Row3+: 数据,每天3个时间段(00:00-08:00 / 08:00-17:00 / 17:00-24:00)
83
-     *   日期列A跨行合并,需向下传递
84
-     *   col17-19(每日收缴总数)为公式列,跳过
78
+     * 导入待检区收缴数据(按导入模板格式)
79
+     * Excel结构:第1行为表头,第2行起为数据,每天3个时间段,日期列跨行合并
80
+     * col0=日期  col1=时间段
81
+     * col2-4=T1 A区(火种/液态物品/其他)  col5-7=T1 B区(火种/液态物品/其他)
82
+     * col8-10=T2国内(火种/液态物品/其他)  col11-13=T2国际(火种/液态物品/其他)
83
+     * col14-16=T2中转(火种/液态物品/其他)
85 84
      */
86 85
     @Log(title = "待检区收缴数据", businessType = BusinessType.IMPORT)
87 86
     @PostMapping("/importData")
@@ -102,8 +101,8 @@ public class HkPendingConfiscateController extends BaseController {
102 101
         try (Workbook workbook = WorkbookFactory.create(is)) {
103 102
             Sheet sheet = workbook.getSheetAt(0);
104 103
             Date lastDate = null;
105
-            // 前2行为表头,数据从第3行(index=2)开始
106
-            for (int i = 2; i <= sheet.getLastRowNum(); i++) {
104
+            // 第1行(index=0)为表头,数据从第2行(index=1)开始
105
+            for (int i = 1; i <= sheet.getLastRowNum(); i++) {
107 106
                 Row row = sheet.getRow(i);
108 107
                 if (row == null) continue;
109 108
 
@@ -142,7 +141,6 @@ public class HkPendingConfiscateController extends BaseController {
142 141
                 data.setT2TransitFireSource(intVal(row, 14));
143 142
                 data.setT2TransitLiquid(intVal(row, 15));
144 143
                 data.setT2TransitOther(intVal(row, 16));
145
-                // col17-19: 每日收缴总数(公式,跳过)
146 144
                 list.add(data);
147 145
             }
148 146
         }

+ 15 - 18
airport-admin/src/main/java/com/sundot/airport/web/controller/item/HkPersuadePowerBankController.java

@@ -75,12 +75,11 @@ public class HkPersuadePowerBankController extends BaseController {
75 75
     }
76 76
 
77 77
     /**
78
-     * 导入客户原始格式的劝阻充电宝数据
79
-     * Excel结构:
80
-     *   Row1: 分组表头(T1航站楼 / T2航站楼 / 每日劝阻总数)
81
-     *   Row2: 子列表头(召回充电宝/无3C标识/标识不清/超规数量/邮寄/自弃/暂存/总数)
82
-     *   Row3+: 数据,每天3个时间段,日期列A跨行合并需向下传递
83
-     *   col9=T1总数(公式)  col17=T2总数(公式)  col18-20=汇总(公式)  均跳过
78
+     * 导入劝阻充电宝数据(按导入模板格式)
79
+     * Excel结构:第1行为表头,第2行起为数据,每天3个时间段,日期列跨行合并
80
+     * col0=日期  col1=时间段
81
+     * col2-8=T1(召回充电宝/无3C标识/标识不清/超规数量/邮寄/自弃/暂存)
82
+     * col9-15=T2(召回充电宝/无3C标识/标识不清/超规数量/邮寄/自弃/暂存)
84 83
      */
85 84
     @Log(title = "劝阻充电宝数据", businessType = BusinessType.IMPORT)
86 85
     @PostMapping("/importData")
@@ -101,8 +100,8 @@ public class HkPersuadePowerBankController extends BaseController {
101 100
         try (Workbook workbook = WorkbookFactory.create(is)) {
102 101
             Sheet sheet = workbook.getSheetAt(0);
103 102
             Date lastDate = null;
104
-            // 前2行为表头,数据从第3行(index=2)开始
105
-            for (int i = 2; i <= sheet.getLastRowNum(); i++) {
103
+            // 第1行(index=0)为表头,数据从第2行(index=1)开始
104
+            for (int i = 1; i <= sheet.getLastRowNum(); i++) {
106 105
                 Row row = sheet.getRow(i);
107 106
                 if (row == null) continue;
108 107
 
@@ -129,16 +128,14 @@ public class HkPersuadePowerBankController extends BaseController {
129 128
                 data.setT1Mail(intVal(row, 6));
130 129
                 data.setT1Abandon(intVal(row, 7));
131 130
                 data.setT1TempStore(intVal(row, 8));
132
-                // col9: T1总数(公式,跳过)
133
-                // T2
134
-                data.setT2Recall(intVal(row, 10));
135
-                data.setT2No3c(intVal(row, 11));
136
-                data.setT2UnclearMark(intVal(row, 12));
137
-                data.setT2ExcessQty(intVal(row, 13));
138
-                data.setT2Mail(intVal(row, 14));
139
-                data.setT2Abandon(intVal(row, 15));
140
-                data.setT2TempStore(intVal(row, 16));
141
-                // col17: T2总数  col18-20: 汇总(公式,跳过)
131
+                // T2(模板无公式列,col9直接接T2)
132
+                data.setT2Recall(intVal(row, 9));
133
+                data.setT2No3c(intVal(row, 10));
134
+                data.setT2UnclearMark(intVal(row, 11));
135
+                data.setT2ExcessQty(intVal(row, 12));
136
+                data.setT2Mail(intVal(row, 13));
137
+                data.setT2Abandon(intVal(row, 14));
138
+                data.setT2TempStore(intVal(row, 15));
142 139
                 list.add(data);
143 140
             }
144 141
         }

+ 111 - 5
airport-equipment/src/main/java/com/sundot/airport/equipment/domain/EquipmentLedger.java

@@ -36,7 +36,7 @@ public class EquipmentLedger extends BaseEntity {
36 36
     private Long id;
37 37
 
38 38
     /** 设备编号 */
39
-    @Excel(name = "设备编号")
39
+    @Excel(name = "设备编号", type = Excel.Type.EXPORT)
40 40
     private String equipmentCode;
41 41
 
42 42
     /** 设备名称 */
@@ -90,7 +90,7 @@ public class EquipmentLedger extends BaseEntity {
90 90
     private String initialAcceptanceStatus;
91 91
 
92 92
     /** 使用状态 */
93
-    @Excel(name = "使用状态")
93
+    @Excel(name = "使用状态", readConverterExp = "IN_USE=在用,SEND_FOR_REPAIR=寄修,LEND=借出,DEACTIVATE=停用,NOT_ENABLED=未启用,SUSPEND_USE=暂停使用", combo = "在用,寄修,借出,停用,未启用,暂停使用")
94 94
     private String usageStatus;
95 95
 
96 96
     /** 报废日期 */
@@ -103,6 +103,30 @@ public class EquipmentLedger extends BaseEntity {
103 103
     @Excel(name = "安装位置")
104 104
     private String installationLocation;
105 105
 
106
+    /** 航站楼编码 */
107
+    @Excel(name = "航站楼编码", type = Excel.Type.EXPORT)
108
+    private String terminlCode;
109
+
110
+    /** 航站楼名称 */
111
+    @Excel(name = "航站楼名称")
112
+    private String terminlName;
113
+
114
+    /** 区域编码 */
115
+    @Excel(name = "区域编码", type = Excel.Type.EXPORT)
116
+    private String regionalCode;
117
+
118
+    /** 区域名称 */
119
+    @Excel(name = "区域名称")
120
+    private String regionalName;
121
+
122
+    /** 通道编码 */
123
+    @Excel(name = "通道编码", type = Excel.Type.EXPORT)
124
+    private String channelCode;
125
+
126
+    /** 通道名称 */
127
+    @Excel(name = "通道名称")
128
+    private String channelName;
129
+
106 130
     /** 定/自检日期 */
107 131
     @JsonFormat(pattern = "yyyy-MM-dd")
108 132
     @DateTimeFormat(pattern = "yyyy-MM-dd")
@@ -120,7 +144,7 @@ public class EquipmentLedger extends BaseEntity {
120 144
     private Date nextInspectionDueDate;
121 145
 
122 146
     /** 定/自检小组组长ID */
123
-    @Excel(name = "定/自检小组组长ID")
147
+    @Excel(name = "定/自检小组组长ID", type = Excel.Type.EXPORT)
124 148
     private Long inspectionTeamLeaderId;
125 149
 
126 150
     /** 定/自检小组组长名称 */
@@ -128,7 +152,7 @@ public class EquipmentLedger extends BaseEntity {
128 152
     private String inspectionTeamLeaderName;
129 153
 
130 154
     /** 定/自检小组组员1ID */
131
-    @Excel(name = "定/自检小组组员1ID")
155
+    @Excel(name = "定/自检小组组员1ID", type = Excel.Type.EXPORT)
132 156
     private Long inspectionTeamMember1Id;
133 157
 
134 158
     /** 定/自检小组组员1名称 */
@@ -136,7 +160,7 @@ public class EquipmentLedger extends BaseEntity {
136 160
     private String inspectionTeamMember1Name;
137 161
 
138 162
     /** 定/自检小组组员2ID */
139
-    @Excel(name = "定/自检小组组员2ID")
163
+    @Excel(name = "定/自检小组组员2ID", type = Excel.Type.EXPORT)
140 164
     private Long inspectionTeamMember2Id;
141 165
 
142 166
     /** 定/自检小组组员2名称 */
@@ -163,6 +187,18 @@ public class EquipmentLedger extends BaseEntity {
163 187
     @TableField(exist = false)
164 188
     private String colorType;
165 189
 
190
+    /** 查询最近定/自检到期日期开始日期 */
191
+    @TableField(exist = false)
192
+    @JsonFormat(pattern = "yyyy-MM-dd")
193
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
194
+    private Date startDate;
195
+
196
+    /** 查询最近定/自检到期日期结束日期 */
197
+    @TableField(exist = false)
198
+    @JsonFormat(pattern = "yyyy-MM-dd")
199
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
200
+    private Date endDate;
201
+
166 202
     public void setTenantId(String tenantId) {
167 203
         this.tenantId = tenantId;
168 204
     }
@@ -307,6 +343,54 @@ public class EquipmentLedger extends BaseEntity {
307 343
         return installationLocation;
308 344
     }
309 345
 
346
+    public String getTerminlCode() {
347
+        return terminlCode;
348
+    }
349
+
350
+    public void setTerminlCode(String terminlCode) {
351
+        this.terminlCode = terminlCode;
352
+    }
353
+
354
+    public String getTerminlName() {
355
+        return terminlName;
356
+    }
357
+
358
+    public void setTerminlName(String terminlName) {
359
+        this.terminlName = terminlName;
360
+    }
361
+
362
+    public String getRegionalCode() {
363
+        return regionalCode;
364
+    }
365
+
366
+    public void setRegionalCode(String regionalCode) {
367
+        this.regionalCode = regionalCode;
368
+    }
369
+
370
+    public String getRegionalName() {
371
+        return regionalName;
372
+    }
373
+
374
+    public void setRegionalName(String regionalName) {
375
+        this.regionalName = regionalName;
376
+    }
377
+
378
+    public String getChannelCode() {
379
+        return channelCode;
380
+    }
381
+
382
+    public void setChannelCode(String channelCode) {
383
+        this.channelCode = channelCode;
384
+    }
385
+
386
+    public String getChannelName() {
387
+        return channelName;
388
+    }
389
+
390
+    public void setChannelName(String channelName) {
391
+        this.channelName = channelName;
392
+    }
393
+
310 394
     public void setInspectionSelfCheckDate(Date inspectionSelfCheckDate) {
311 395
         this.inspectionSelfCheckDate = inspectionSelfCheckDate;
312 396
     }
@@ -419,6 +503,22 @@ public class EquipmentLedger extends BaseEntity {
419 503
         this.colorType = colorType;
420 504
     }
421 505
 
506
+    public Date getStartDate() {
507
+        return startDate;
508
+    }
509
+
510
+    public void setStartDate(Date startDate) {
511
+        this.startDate = startDate;
512
+    }
513
+
514
+    public Date getEndDate() {
515
+        return endDate;
516
+    }
517
+
518
+    public void setEndDate(Date endDate) {
519
+        this.endDate = endDate;
520
+    }
521
+
422 522
     @Override
423 523
     public String toString() {
424 524
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -445,6 +545,12 @@ public class EquipmentLedger extends BaseEntity {
445 545
                 .append("usageStatus", getUsageStatus())
446 546
                 .append("scrappingDate", getScrappingDate())
447 547
                 .append("installationLocation", getInstallationLocation())
548
+                .append("terminlCode", getTerminlCode())
549
+                .append("terminlName", getTerminlName())
550
+                .append("regionalCode", getRegionalCode())
551
+                .append("regionalName", getRegionalName())
552
+                .append("channelCode", getChannelCode())
553
+                .append("channelName", getChannelName())
448 554
                 .append("inspectionSelfCheckDate", getInspectionSelfCheckDate())
449 555
                 .append("inspectionSelfCheckCycle", getInspectionSelfCheckCycle())
450 556
                 .append("nextInspectionDueDate", getNextInspectionDueDate())

+ 17 - 0
airport-equipment/src/main/java/com/sundot/airport/equipment/service/IEquipmentLedgerService.java

@@ -80,4 +80,21 @@ public interface IEquipmentLedgerService extends IService<EquipmentLedger> {
80 80
      * @return 设备台账集合
81 81
      */
82 82
     public List<EquipmentLedger> selectTwoWeeksUpcomingInspectionList();
83
+
84
+    /**
85
+     * 导入设备台账列表
86
+     *
87
+     * @param list          数据列表
88
+     * @param updateSupport 是否更新支持
89
+     * @return 导入结果信息
90
+     */
91
+    public String importData(List<EquipmentLedger> list, boolean updateSupport);
92
+
93
+    /**
94
+     * 设备台账通知
95
+     *
96
+     * @param equipmentLedger 设备台账
97
+     * @return 设备台账集合
98
+     */
99
+    public List<EquipmentLedger> notice(EquipmentLedger equipmentLedger);
83 100
 }

+ 173 - 0
airport-equipment/src/main/java/com/sundot/airport/equipment/service/impl/EquipmentLedgerServiceImpl.java

@@ -1,6 +1,9 @@
1 1
 package com.sundot.airport.equipment.service.impl;
2 2
 
3
+import java.util.Collections;
3 4
 import java.util.List;
5
+import java.util.Map;
6
+import java.util.stream.Collectors;
4 7
 
5 8
 import cn.hutool.core.collection.CollUtil;
6 9
 import cn.hutool.core.util.ObjUtil;
@@ -8,6 +11,9 @@ import cn.hutool.core.util.StrUtil;
8 11
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
9 12
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10 13
 import com.sundot.airport.common.constant.Constants;
14
+import com.sundot.airport.common.core.domain.entity.SysDept;
15
+import com.sundot.airport.common.core.domain.entity.SysDictData;
16
+import com.sundot.airport.common.core.domain.entity.SysUser;
11 17
 import com.sundot.airport.common.core.redis.RedisSerialGenerator;
12 18
 import com.sundot.airport.common.domain.BaseAttachment;
13 19
 import com.sundot.airport.common.enums.BaseAttachmentSourceTypeEnum;
@@ -17,8 +23,14 @@ import com.sundot.airport.common.exception.ServiceException;
17 23
 import com.sundot.airport.common.service.IBaseAttachmentService;
18 24
 import com.sundot.airport.common.utils.DateUtils;
19 25
 import com.sundot.airport.common.utils.EquipmentDateUtils;
26
+import com.sundot.airport.common.utils.SecurityUtils;
20 27
 import com.sundot.airport.equipment.domain.EquipmentInspectionRecord;
21 28
 import com.sundot.airport.equipment.service.IEquipmentInspectionRecordService;
29
+import com.sundot.airport.system.domain.BasePosition;
30
+import com.sundot.airport.system.service.IBasePositionService;
31
+import com.sundot.airport.system.service.ISysDeptService;
32
+import com.sundot.airport.system.service.ISysDictDataService;
33
+import com.sundot.airport.system.service.ISysUserService;
22 34
 import org.springframework.beans.factory.annotation.Autowired;
23 35
 import org.springframework.stereotype.Service;
24 36
 import com.sundot.airport.equipment.mapper.EquipmentLedgerMapper;
@@ -42,6 +54,14 @@ public class EquipmentLedgerServiceImpl extends ServiceImpl<EquipmentLedgerMappe
42 54
     private IBaseAttachmentService baseAttachmentService;
43 55
     @Autowired
44 56
     private RedisSerialGenerator redisSerialGenerator;
57
+    @Autowired
58
+    private ISysDictDataService sysDictDataService;
59
+    @Autowired
60
+    private IBasePositionService basePositionService;
61
+    @Autowired
62
+    private ISysUserService sysUserService;
63
+    @Autowired
64
+    private ISysDeptService sysDeptService;
45 65
 
46 66
     /**
47 67
      * 查询设备台账
@@ -268,4 +288,157 @@ public class EquipmentLedgerServiceImpl extends ServiceImpl<EquipmentLedgerMappe
268 288
     public List<EquipmentLedger> selectTwoWeeksUpcomingInspectionList() {
269 289
         return equipmentLedgerMapper.selectTwoWeeksUpcomingInspectionList();
270 290
     }
291
+
292
+    /**
293
+     * 导入设备台账数据
294
+     *
295
+     * @param list            数据列表
296
+     * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
297
+     * @return 结果
298
+     */
299
+    @Transactional(rollbackFor = Exception.class)
300
+    @Override
301
+    public String importData(List<EquipmentLedger> list, boolean isUpdateSupport) {
302
+        if (CollUtil.isEmpty(list)) {
303
+            throw new ServiceException("导入设备台账数据不能为空!");
304
+        }
305
+
306
+        // 用户
307
+        List<SysUser> sysUserListAll = sysUserService.selectUserAll();
308
+        Map<String, Long> sysUserMap = sysUserListAll.stream().collect(Collectors.toMap(SysUser::getNickName, SysUser::getUserId, (oldValue, newValue) -> newValue));
309
+
310
+        // 航站楼
311
+        BasePosition terminlQuery = new BasePosition();
312
+        terminlQuery.setLevel(1);
313
+        List<BasePosition> terminlList = basePositionService.selectBasePositionList(terminlQuery);
314
+        Map<String, String> terminlMap = terminlList.stream().collect(Collectors.toMap(BasePosition::getName, BasePosition::getCode, (oldValue, newValue) -> newValue));
315
+
316
+        // 区域
317
+        BasePosition regionalQuery = new BasePosition();
318
+        regionalQuery.setLevel(2);
319
+        List<BasePosition> regionalList = basePositionService.selectBasePositionList(regionalQuery);
320
+        Map<String, String> regionalMap = regionalList.stream().collect(Collectors.toMap(BasePosition::getName, BasePosition::getCode, (oldValue, newValue) -> newValue));
321
+
322
+        // 通道
323
+        BasePosition channelQuery = new BasePosition();
324
+        channelQuery.setLevel(3);
325
+        List<BasePosition> channelList = basePositionService.selectBasePositionList(channelQuery);
326
+        Map<String, String> channelMap = channelList.stream().collect(Collectors.toMap(BasePosition::getName, BasePosition::getCode, (oldValue, newValue) -> newValue));
327
+
328
+        // 使用状态
329
+        SysDictData equipmentUsageStatusQuery = new SysDictData();
330
+        equipmentUsageStatusQuery.setDictType("equipment_usage_status");
331
+        List<SysDictData> equipmentUsageStatusList = sysDictDataService.selectDictDataList(equipmentUsageStatusQuery);
332
+        Map<String, String> equipmentUsageStatusMap = equipmentUsageStatusList.stream().collect(Collectors.toMap(SysDictData::getDictLabel, SysDictData::getDictValue));
333
+
334
+        int successNum = 0;
335
+        int failureNum = 0;
336
+        StringBuilder successMsg = new StringBuilder();
337
+        StringBuilder failureMsg = new StringBuilder();
338
+
339
+        for (EquipmentLedger data : list) {
340
+            // 根据名称填充ID字段
341
+            fillIdsByName(data, sysUserMap, terminlMap, regionalMap, channelMap, equipmentUsageStatusMap);
342
+            try {
343
+                if (ObjUtil.isNull(data.getEquipmentSerialNumber())) {
344
+                    failureNum++;
345
+                    failureMsg.append("<br/>" + failureNum + "、设备序列号【" + data.getEquipmentSerialNumber() + "】、设备名称【" + data.getEquipmentName() + "】设备序列号不能为空");
346
+                    continue;
347
+                }
348
+                if (ObjUtil.isNull(data.getEquipmentName())) {
349
+                    failureNum++;
350
+                    failureMsg.append("<br/>" + failureNum + "、设备序列号【" + data.getEquipmentSerialNumber() + "】、设备名称【" + data.getEquipmentName() + "】设备名称不能为空");
351
+                    continue;
352
+                }
353
+
354
+                // 查询是否已存在(根据【设备序列号】唯一)
355
+                EquipmentLedger queryParam = new EquipmentLedger();
356
+                queryParam.setEquipmentSerialNumber(data.getEquipmentSerialNumber());
357
+                List<EquipmentLedger> existingList = equipmentLedgerMapper.selectEquipmentLedgerList(queryParam);
358
+
359
+                if (CollUtil.isEmpty(existingList)) {
360
+                    // 新增
361
+                    data.setEquipmentCode(redisSerialGenerator.generate(Constants.EQUIPMENT_LEDGER));
362
+                    data.setCreateTime(DateUtils.getNowDate());
363
+                    equipmentLedgerMapper.insertEquipmentLedger(data);
364
+                    successNum++;
365
+                    successMsg.append("<br/>" + successNum + "、设备序列号【" + data.getEquipmentSerialNumber() + "】、设备名称【" + data.getEquipmentName() + "】导入成功");
366
+                } else if (isUpdateSupport) {
367
+                    // 更新
368
+                    EquipmentLedger old = existingList.get(0);
369
+                    data.setId(old.getId());
370
+                    data.setEquipmentCode(old.getEquipmentCode());
371
+                    data.setUpdateTime(DateUtils.getNowDate());
372
+                    equipmentLedgerMapper.updateEquipmentLedger(data);
373
+                    successNum++;
374
+                    successMsg.append("<br/>" + successNum + "、设备序列号【" + data.getEquipmentSerialNumber() + "】、设备名称【" + data.getEquipmentName() + "】更新成功");
375
+                } else {
376
+                    failureNum++;
377
+                    failureMsg.append("<br/>" + failureNum + "、设备序列号【" + data.getEquipmentSerialNumber() + "】、设备名称【" + data.getEquipmentName() + "】已存在");
378
+                }
379
+            } catch (Exception e) {
380
+                failureNum++;
381
+                String msg = "<br/>" + failureNum + "、设备序列号【" + data.getEquipmentSerialNumber() + "】、设备名称【" + data.getEquipmentName() + "】导入失败:";
382
+                failureMsg.append(msg + e.getMessage());
383
+            }
384
+        }
385
+
386
+        if (failureNum > 0) {
387
+            failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
388
+            throw new ServiceException(failureMsg.toString());
389
+        } else {
390
+            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
391
+        }
392
+        return successMsg.toString();
393
+    }
394
+
395
+    /**
396
+     * 根据名称填充ID字段
397
+     *
398
+     * @param data 速率数据
399
+     */
400
+    private void fillIdsByName(EquipmentLedger data, Map<String, Long> sysUserMap, Map<String, String> terminlMap, Map<String, String> regionalMap, Map<String, String> channelMap, Map<String, String> equipmentUsageStatusMap) {
401
+        // 定/自检小组组长
402
+        if (ObjUtil.isNotNull(data.getInspectionTeamLeaderName())) {
403
+            data.setInspectionTeamLeaderId(sysUserMap.get(data.getInspectionTeamLeaderName()));
404
+        }
405
+        // 定/自检小组组员1
406
+        if (ObjUtil.isNotNull(data.getInspectionTeamMember1Name())) {
407
+            data.setInspectionTeamMember1Id(sysUserMap.get(data.getInspectionTeamMember1Name()));
408
+        }
409
+        // 定/自检小组组员2
410
+        if (ObjUtil.isNotNull(data.getInspectionTeamMember2Name())) {
411
+            data.setInspectionTeamMember2Id(sysUserMap.get(data.getInspectionTeamMember2Name()));
412
+        }
413
+        // 航站楼
414
+        if (ObjUtil.isNotNull(data.getTerminlName())) {
415
+            data.setTerminlCode(terminlMap.get(data.getTerminlName()));
416
+        }
417
+        // 区域
418
+        if (ObjUtil.isNotNull(data.getRegionalName())) {
419
+            data.setRegionalCode(regionalMap.get(data.getRegionalName()));
420
+        }
421
+        // 通道
422
+        if (ObjUtil.isNotNull(data.getChannelName())) {
423
+            data.setChannelCode(channelMap.get(data.getChannelName()));
424
+        }
425
+    }
426
+
427
+    /**
428
+     * 设备台账通知
429
+     *
430
+     * @param equipmentLedger 设备台账
431
+     * @return 设备台账
432
+     */
433
+    @Override
434
+    public List<EquipmentLedger> notice(EquipmentLedger equipmentLedger) {
435
+        if (ObjUtil.isNull(SecurityUtils.getDeptId())) {
436
+            return Collections.emptyList();
437
+        }
438
+        SysDept sysDept = sysDeptService.selectDeptById(SecurityUtils.getDeptId());
439
+        if (!StrUtil.equals("设备维修中心", sysDept.getDeptName())) {
440
+            return Collections.emptyList();
441
+        }
442
+        return selectEquipmentLedgerList(equipmentLedger);
443
+    }
271 444
 }

+ 52 - 0
airport-equipment/src/main/resources/mapper/equipment/EquipmentLedgerMapper.xml

@@ -28,6 +28,12 @@
28 28
         <result property="usageStatus" column="usage_status"/>
29 29
         <result property="scrappingDate" column="scrapping_date"/>
30 30
         <result property="installationLocation" column="installation_location"/>
31
+        <result property="terminlCode" column="terminl_code"/>
32
+        <result property="terminlName" column="terminl_name"/>
33
+        <result property="regionalCode" column="regional_code"/>
34
+        <result property="regionalName" column="regional_name"/>
35
+        <result property="channelCode" column="channel_code"/>
36
+        <result property="channelName" column="channel_name"/>
31 37
         <result property="inspectionSelfCheckDate" column="inspection_self_check_date"/>
32 38
         <result property="inspectionSelfCheckCycle" column="inspection_self_check_cycle"/>
33 39
         <result property="nextInspectionDueDate" column="next_inspection_due_date"/>
@@ -63,6 +69,12 @@
63 69
                usage_status,
64 70
                scrapping_date,
65 71
                installation_location,
72
+               terminl_code,
73
+               terminl_name,
74
+               regional_code,
75
+               regional_name,
76
+               channel_code,
77
+               channel_name,
66 78
                inspection_self_check_date,
67 79
                inspection_self_check_cycle,
68 80
                next_inspection_due_date,
@@ -105,6 +117,24 @@
105 117
             <if test="installationLocation != null  and installationLocation != ''">and installation_location =
106 118
                 #{installationLocation}
107 119
             </if>
120
+            <if test="terminlCode != null  and terminlCode != ''">and terminl_code =
121
+                #{terminlCode}
122
+            </if>
123
+            <if test="terminlName != null  and terminlName != ''">and
124
+                terminl_name like concat('%', #{terminlName}, '%')
125
+            </if>
126
+            <if test="regionalCode != null  and regionalCode != ''">and regional_code =
127
+                #{regionalCode}
128
+            </if>
129
+            <if test="regionalName != null  and regionalName != ''">and
130
+                regional_name like concat('%', #{regionalName}, '%')
131
+            </if>
132
+            <if test="channelCode != null  and channelCode != ''">and channel_code =
133
+                #{channelCode}
134
+            </if>
135
+            <if test="channelName != null  and channelName != ''">and
136
+                channel_name like concat('%', #{channelName}, '%')
137
+            </if>
108 138
             <if test="inspectionSelfCheckDate != null ">and inspection_self_check_date = #{inspectionSelfCheckDate}</if>
109 139
             <if test="inspectionSelfCheckCycle != null ">and inspection_self_check_cycle = #{inspectionSelfCheckCycle}
110 140
             </if>
@@ -133,6 +163,10 @@
133 163
                 inspection_team_member2_name like concat('%', #{inspectionTeamUserName}, '%')
134 164
                 )
135 165
             </if>
166
+            <if test="startDate != null and endDate != null">
167
+                and (next_inspection_due_date >= #{startDate}
168
+                and next_inspection_due_date <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
169
+            </if>
136 170
             <choose>
137 171
                 <!-- 使用状态=在用 + 早于今天 -->
138 172
                 <when test="'RED'.equals(colorType)">
@@ -207,6 +241,12 @@
207 241
             <if test="usageStatus != null">usage_status,</if>
208 242
             <if test="scrappingDate != null">scrapping_date,</if>
209 243
             <if test="installationLocation != null">installation_location,</if>
244
+            <if test="terminlCode != null">terminl_code,</if>
245
+            <if test="terminlName != null">terminl_name,</if>
246
+            <if test="regionalCode != null">regional_code,</if>
247
+            <if test="regionalName != null">regional_name,</if>
248
+            <if test="channelCode != null">channel_code,</if>
249
+            <if test="channelName != null">channel_name,</if>
210 250
             <if test="inspectionSelfCheckDate != null">inspection_self_check_date,</if>
211 251
             <if test="inspectionSelfCheckCycle != null">inspection_self_check_cycle,</if>
212 252
             <if test="nextInspectionDueDate != null">next_inspection_due_date,</if>
@@ -240,6 +280,12 @@
240 280
             <if test="usageStatus != null">#{usageStatus},</if>
241 281
             <if test="scrappingDate != null">#{scrappingDate},</if>
242 282
             <if test="installationLocation != null">#{installationLocation},</if>
283
+            <if test="terminlCode != null">#{terminlCode},</if>
284
+            <if test="terminlName != null">#{terminlName},</if>
285
+            <if test="regionalCode != null">#{regionalCode},</if>
286
+            <if test="regionalName != null">#{regionalName},</if>
287
+            <if test="channelCode != null">#{channelCode},</if>
288
+            <if test="channelName != null">#{channelName},</if>
243 289
             <if test="inspectionSelfCheckDate != null">#{inspectionSelfCheckDate},</if>
244 290
             <if test="inspectionSelfCheckCycle != null">#{inspectionSelfCheckCycle},</if>
245 291
             <if test="nextInspectionDueDate != null">#{nextInspectionDueDate},</if>
@@ -279,6 +325,12 @@
279 325
             <if test="usageStatus != null">usage_status = #{usageStatus},</if>
280 326
             <if test="scrappingDate != null">scrapping_date = #{scrappingDate},</if>
281 327
             <if test="installationLocation != null">installation_location = #{installationLocation},</if>
328
+            <if test="terminlCode != null">terminl_code = #{terminlCode},</if>
329
+            <if test="terminlName != null">terminl_name = #{terminlName},</if>
330
+            <if test="regionalCode != null">regional_code = #{regionalCode},</if>
331
+            <if test="regionalName != null">regional_name = #{regionalName},</if>
332
+            <if test="channelCode != null">channel_code = #{channelCode},</if>
333
+            <if test="channelName != null">channel_name = #{channelName},</if>
282 334
             <if test="inspectionSelfCheckDate != null">inspection_self_check_date = #{inspectionSelfCheckDate},</if>
283 335
             <if test="inspectionSelfCheckCycle != null">inspection_self_check_cycle = #{inspectionSelfCheckCycle},</if>
284 336
             <if test="nextInspectionDueDate != null">next_inspection_due_date = #{nextInspectionDueDate},</if>