소스 검색

导入修改

wangxx 1 주 전
부모
커밋
902651d705

+ 43 - 77
airport-admin/src/main/java/com/sundot/airport/web/controller/ledger/LedgerImportController.java

@@ -1,13 +1,12 @@
1 1
 package com.sundot.airport.web.controller.ledger;
2 2
 
3
-import com.alibaba.excel.EasyExcel;
4
-import com.alibaba.excel.context.AnalysisContext;
5
-import com.alibaba.excel.event.AnalysisEventListener;
3
+import com.sundot.airport.common.utils.poi.ExcelUtil;
6 4
 import com.sundot.airport.common.annotation.Log;
7 5
 import com.sundot.airport.common.core.controller.BaseController;
8 6
 import com.sundot.airport.common.core.domain.AjaxResult;
9 7
 import com.sundot.airport.common.enums.BusinessType;
10 8
 import com.sundot.airport.common.utils.DateUtils;
9
+import com.sundot.airport.common.utils.poi.ExcelUtil;
11 10
 import com.sundot.airport.ledger.domain.*;
12 11
 import com.sundot.airport.ledger.service.*;
13 12
 import com.sundot.airport.ledger.service.ILedgerCombinedImportService;
@@ -66,9 +65,8 @@ public class LedgerImportController extends BaseController {
66 65
     @PostMapping("/supervisionProblem")
67 66
     public AjaxResult importSupervisionProblem(@RequestParam("file") MultipartFile file) throws Exception {
68 67
         String batchNo = generateBatchNo();
69
-        List<LedgerSupervisionProblem> list = new ArrayList<>();
70
-        EasyExcel.read(file.getInputStream(), LedgerSupervisionProblem.class,
71
-                new SimpleListener<>(list)).sheet().doRead();
68
+        ExcelUtil<LedgerSupervisionProblem> util = new ExcelUtil<>(LedgerSupervisionProblem.class);
69
+        List<LedgerSupervisionProblem> list = util.importExcel(file.getInputStream());
72 70
         list.forEach(item -> {
73 71
             item.setImportBatch(batchNo);
74 72
             item.setSourceType("1");
@@ -83,9 +81,8 @@ public class LedgerImportController extends BaseController {
83 81
     @PostMapping("/patrolInspection")
84 82
     public AjaxResult importPatrolInspection(@RequestParam("file") MultipartFile file) throws Exception {
85 83
         String batchNo = generateBatchNo();
86
-        List<LedgerPatrolInspection> list = new ArrayList<>();
87
-        EasyExcel.read(file.getInputStream(), LedgerPatrolInspection.class,
88
-                new SimpleListener<>(list)).sheet().doRead();
84
+        ExcelUtil<LedgerPatrolInspection> util = new ExcelUtil<>(LedgerPatrolInspection.class);
85
+        List<LedgerPatrolInspection> list = util.importExcel(file.getInputStream());
89 86
         list.forEach(item -> {
90 87
             item.setImportBatch(batchNo);
91 88
             item.setSourceType("1");
@@ -100,9 +97,8 @@ public class LedgerImportController extends BaseController {
100 97
     @PostMapping("/realtimeInterception")
101 98
     public AjaxResult importRealtimeInterception(@RequestParam("file") MultipartFile file) throws Exception {
102 99
         String batchNo = generateBatchNo();
103
-        List<LedgerRealtimeInterception> list = new ArrayList<>();
104
-        EasyExcel.read(file.getInputStream(), LedgerRealtimeInterception.class,
105
-                new SimpleListener<>(list)).sheet().doRead();
100
+        ExcelUtil<LedgerRealtimeInterception> util = new ExcelUtil<>(LedgerRealtimeInterception.class);
101
+        List<LedgerRealtimeInterception> list = util.importExcel(file.getInputStream());
106 102
         list.forEach(item -> {
107 103
             item.setImportBatch(batchNo);
108 104
             item.setSourceType("1");
@@ -117,9 +113,8 @@ public class LedgerImportController extends BaseController {
117 113
     @PostMapping("/servicePatrol")
118 114
     public AjaxResult importServicePatrol(@RequestParam("file") MultipartFile file) throws Exception {
119 115
         String batchNo = generateBatchNo();
120
-        List<LedgerServicePatrol> list = new ArrayList<>();
121
-        EasyExcel.read(file.getInputStream(), LedgerServicePatrol.class,
122
-                new SimpleListener<>(list)).sheet().doRead();
116
+        ExcelUtil<LedgerServicePatrol> util = new ExcelUtil<>(LedgerServicePatrol.class);
117
+        List<LedgerServicePatrol> list = util.importExcel(file.getInputStream());
123 118
         list.forEach(item -> {
124 119
             item.setImportBatch(batchNo);
125 120
             item.setSourceType("1");
@@ -134,9 +129,8 @@ public class LedgerImportController extends BaseController {
134 129
     @PostMapping("/complaint")
135 130
     public AjaxResult importComplaint(@RequestParam("file") MultipartFile file) throws Exception {
136 131
         String batchNo = generateBatchNo();
137
-        List<LedgerComplaint> list = new ArrayList<>();
138
-        EasyExcel.read(file.getInputStream(), LedgerComplaint.class,
139
-                new SimpleListener<>(list)).sheet().doRead();
132
+        ExcelUtil<LedgerComplaint> util = new ExcelUtil<>(LedgerComplaint.class);
133
+        List<LedgerComplaint> list = util.importExcel(file.getInputStream());
140 134
         list.forEach(item -> {
141 135
             item.setImportBatch(batchNo);
142 136
             item.setSourceType("1");
@@ -151,9 +145,8 @@ public class LedgerImportController extends BaseController {
151 145
     @PostMapping("/securityTest")
152 146
     public AjaxResult importSecurityTest(@RequestParam("file") MultipartFile file) throws Exception {
153 147
         String batchNo = generateBatchNo();
154
-        List<LedgerSecurityTest> list = new ArrayList<>();
155
-        EasyExcel.read(file.getInputStream(), LedgerSecurityTest.class,
156
-                new SimpleListener<>(list)).sheet().doRead();
148
+        ExcelUtil<LedgerSecurityTest> util = new ExcelUtil<>(LedgerSecurityTest.class);
149
+        List<LedgerSecurityTest> list = util.importExcel(file.getInputStream());
157 150
         list.forEach(item -> {
158 151
             item.setImportBatch(batchNo);
159 152
             item.setSourceType("1");
@@ -168,9 +161,8 @@ public class LedgerImportController extends BaseController {
168 161
     @PostMapping("/channelPassRate")
169 162
     public AjaxResult importChannelPassRate(@RequestParam("file") MultipartFile file) throws Exception {
170 163
         String batchNo = generateBatchNo();
171
-        List<LedgerChannelPassRate> list = new ArrayList<>();
172
-        EasyExcel.read(file.getInputStream(), LedgerChannelPassRate.class,
173
-                new SimpleListener<>(list)).sheet().doRead();
164
+        ExcelUtil<LedgerChannelPassRate> util = new ExcelUtil<>(LedgerChannelPassRate.class);
165
+        List<LedgerChannelPassRate> list = util.importExcel(file.getInputStream());
174 166
         list.forEach(item -> {
175 167
             item.setImportBatch(batchNo);
176 168
             item.setSourceType("1");
@@ -185,9 +177,8 @@ public class LedgerImportController extends BaseController {
185 177
     @PostMapping("/unsafeEvent")
186 178
     public AjaxResult importUnsafeEvent(@RequestParam("file") MultipartFile file) throws Exception {
187 179
         String batchNo = generateBatchNo();
188
-        List<LedgerUnsafeEvent> list = new ArrayList<>();
189
-        EasyExcel.read(file.getInputStream(), LedgerUnsafeEvent.class,
190
-                new SimpleListener<>(list)).sheet().doRead();
180
+        ExcelUtil<LedgerUnsafeEvent> util = new ExcelUtil<>(LedgerUnsafeEvent.class);
181
+        List<LedgerUnsafeEvent> list = util.importExcel(file.getInputStream());
191 182
         list.forEach(item -> {
192 183
             item.setImportBatch(batchNo);
193 184
             item.setSourceType("1");
@@ -202,9 +193,8 @@ public class LedgerImportController extends BaseController {
202 193
     @PostMapping("/seizureStats")
203 194
     public AjaxResult importSeizureStats(@RequestParam("file") MultipartFile file) throws Exception {
204 195
         String batchNo = generateBatchNo();
205
-        List<LedgerSeizureStats> list = new ArrayList<>();
206
-        EasyExcel.read(file.getInputStream(), LedgerSeizureStats.class,
207
-                new SimpleListener<>(list)).sheet().doRead();
196
+        ExcelUtil<LedgerSeizureStats> util = new ExcelUtil<>(LedgerSeizureStats.class);
197
+        List<LedgerSeizureStats> list = util.importExcel(file.getInputStream());
208 198
         list.forEach(item -> {
209 199
             item.setImportBatch(batchNo);
210 200
             item.setSourceType("1");
@@ -219,9 +209,8 @@ public class LedgerImportController extends BaseController {
219 209
     @PostMapping("/terminalBonus")
220 210
     public AjaxResult importTerminalBonus(@RequestParam("file") MultipartFile file) throws Exception {
221 211
         String batchNo = generateBatchNo();
222
-        List<LedgerTerminalBonus> list = new ArrayList<>();
223
-        EasyExcel.read(file.getInputStream(), LedgerTerminalBonus.class,
224
-                new SimpleListener<>(list)).sheet().doRead();
212
+        ExcelUtil<LedgerTerminalBonus> util = new ExcelUtil<>(LedgerTerminalBonus.class);
213
+        List<LedgerTerminalBonus> list = util.importExcel(file.getInputStream());
225 214
         list.forEach(item -> {
226 215
             item.setImportBatch(batchNo);
227 216
             item.setSourceType("1");
@@ -236,9 +225,8 @@ public class LedgerImportController extends BaseController {
236 225
     @PostMapping("/examScore")
237 226
     public AjaxResult importExamScore(@RequestParam("file") MultipartFile file) throws Exception {
238 227
         String batchNo = generateBatchNo();
239
-        List<LedgerExamScore> list = new ArrayList<>();
240
-        EasyExcel.read(file.getInputStream(), LedgerExamScore.class,
241
-                new SimpleListener<>(list)).sheet().doRead();
228
+        ExcelUtil<LedgerExamScore> util = new ExcelUtil<>(LedgerExamScore.class);
229
+        List<LedgerExamScore> list = util.importExcel(file.getInputStream());
242 230
         list.forEach(item -> {
243 231
             item.setImportBatch(batchNo);
244 232
             item.setSourceType("1");
@@ -253,9 +241,9 @@ public class LedgerImportController extends BaseController {
253 241
     @PostMapping("/rewardApproval")
254 242
     public AjaxResult importRewardApproval(@RequestParam("file") MultipartFile file) throws Exception {
255 243
         String batchNo = generateBatchNo();
256
-        List<LedgerRewardApproval> list = new ArrayList<>();
257
-        EasyExcel.read(file.getInputStream(), LedgerRewardApproval.class,
258
-                new SimpleListener<>(list)).sheet().doRead();
244
+        ExcelUtil<LedgerRewardApproval> util =
245
+            new ExcelUtil<>(LedgerRewardApproval.class);
246
+        List<LedgerRewardApproval> list = util.importExcel(file.getInputStream());
259 247
         list.forEach(item -> {
260 248
             item.setImportBatch(batchNo);
261 249
             item.setSourceType("1");
@@ -270,9 +258,8 @@ public class LedgerImportController extends BaseController {
270 258
     @PostMapping("/dailyTraining")
271 259
     public AjaxResult importDailyTraining(@RequestParam("file") MultipartFile file) throws Exception {
272 260
         String batchNo = generateBatchNo();
273
-        List<LedgerDailyTraining> list = new ArrayList<>();
274
-        EasyExcel.read(file.getInputStream(), LedgerDailyTraining.class,
275
-                new SimpleListener<>(list)).headRowNumber(2).sheet().doRead();
261
+        ExcelUtil<LedgerDailyTraining> util = new ExcelUtil<>(LedgerDailyTraining.class);
262
+        List<LedgerDailyTraining> list = util.importExcel(file.getInputStream());
276 263
         list.forEach(item -> { item.setImportBatch(batchNo); item.setSourceType("1"); item.setCreateBy(getUsername()); });
277 264
         dailyTrainingService.batchInsert(list);
278 265
         return AjaxResult.success("导入成功,共" + list.size() + "条");
@@ -283,9 +270,8 @@ public class LedgerImportController extends BaseController {
283 270
     @PostMapping("/leaderDuty")
284 271
     public AjaxResult importLeaderDuty(@RequestParam("file") MultipartFile file) throws Exception {
285 272
         String batchNo = generateBatchNo();
286
-        List<LedgerLeaderDuty> list = new ArrayList<>();
287
-        EasyExcel.read(file.getInputStream(), LedgerLeaderDuty.class,
288
-                new SimpleListener<>(list)).headRowNumber(2).sheet().doRead();
273
+        ExcelUtil<LedgerLeaderDuty> util = new ExcelUtil<>(LedgerLeaderDuty.class);
274
+        List<LedgerLeaderDuty> list = util.importExcel(file.getInputStream());
289 275
         list.forEach(item -> { item.setImportBatch(batchNo); item.setSourceType("1"); item.setCreateBy(getUsername()); });
290 276
         leaderDutyService.batchInsert(list);
291 277
         return AjaxResult.success("导入成功,共" + list.size() + "条");
@@ -296,9 +282,8 @@ public class LedgerImportController extends BaseController {
296 282
     @PostMapping("/healthSoldier")
297 283
     public AjaxResult importHealthSoldier(@RequestParam("file") MultipartFile file) throws Exception {
298 284
         String batchNo = generateBatchNo();
299
-        List<LedgerHealthSoldier> list = new ArrayList<>();
300
-        EasyExcel.read(file.getInputStream(), LedgerHealthSoldier.class,
301
-                new SimpleListener<>(list)).headRowNumber(2).sheet().doRead();
285
+        ExcelUtil<LedgerHealthSoldier> util = new ExcelUtil<>(LedgerHealthSoldier.class);
286
+        List<LedgerHealthSoldier> list = util.importExcel(file.getInputStream());
302 287
         list.forEach(item -> { item.setImportBatch(batchNo); item.setSourceType("1"); item.setCreateBy(getUsername()); });
303 288
         healthSoldierService.batchInsert(list);
304 289
         return AjaxResult.success("导入成功,共" + list.size() + "条");
@@ -309,9 +294,8 @@ public class LedgerImportController extends BaseController {
309 294
     @PostMapping("/dormFireSafety")
310 295
     public AjaxResult importDormFireSafety(@RequestParam("file") MultipartFile file) throws Exception {
311 296
         String batchNo = generateBatchNo();
312
-        List<LedgerDormFireSafety> list = new ArrayList<>();
313
-        EasyExcel.read(file.getInputStream(), LedgerDormFireSafety.class,
314
-                new SimpleListener<>(list)).headRowNumber(2).sheet().doRead();
297
+        ExcelUtil<LedgerDormFireSafety> util = new ExcelUtil<>(LedgerDormFireSafety.class);
298
+        List<LedgerDormFireSafety> list = util.importExcel(file.getInputStream());
315 299
         list.forEach(item -> { item.setImportBatch(batchNo); item.setSourceType("1"); item.setCreateBy(getUsername()); });
316 300
         dormFireSafetyService.batchInsert(list);
317 301
         return AjaxResult.success("导入成功,共" + list.size() + "条");
@@ -322,9 +306,8 @@ public class LedgerImportController extends BaseController {
322 306
     @PostMapping("/trainingIssue")
323 307
     public AjaxResult importTrainingIssue(@RequestParam("file") MultipartFile file) throws Exception {
324 308
         String batchNo = generateBatchNo();
325
-        List<LedgerTrainingIssue> list = new ArrayList<>();
326
-        EasyExcel.read(file.getInputStream(), LedgerTrainingIssue.class,
327
-                new SimpleListener<>(list)).headRowNumber(2).sheet().doRead();
309
+        ExcelUtil<LedgerTrainingIssue> util = new ExcelUtil<>(LedgerTrainingIssue.class);
310
+        List<LedgerTrainingIssue> list = util.importExcel(file.getInputStream());
328 311
         list.forEach(item -> { item.setImportBatch(batchNo); item.setSourceType("1"); item.setCreateBy(getUsername()); });
329 312
         trainingIssueService.batchInsert(list);
330 313
         return AjaxResult.success("导入成功,共" + list.size() + "条");
@@ -339,9 +322,8 @@ public class LedgerImportController extends BaseController {
339 322
     @PostMapping("/rewardPenalty")
340 323
     public AjaxResult importRewardPenalty(@RequestParam("file") MultipartFile file) throws Exception {
341 324
         String batchNo = generateBatchNo();
342
-        List<LedgerRewardPenalty> list = new ArrayList<>();
343
-        EasyExcel.read(file.getInputStream(), LedgerRewardPenalty.class,
344
-                new SimpleListener<>(list)).headRowNumber(2).sheet().doRead();
325
+        ExcelUtil<LedgerRewardPenalty> util = new ExcelUtil<>(LedgerRewardPenalty.class);
326
+        List<LedgerRewardPenalty> list = util.importExcel(file.getInputStream());
345 327
         list.forEach(item -> { item.setImportBatch(batchNo); item.setSourceType("1"); item.setCreateBy(getUsername()); });
346 328
         rewardPenaltyService.batchInsert(list);
347 329
         return AjaxResult.success("导入成功,共" + list.size() + "条");
@@ -356,9 +338,8 @@ public class LedgerImportController extends BaseController {
356 338
     @PostMapping("/leaveSpecial")
357 339
     public AjaxResult importLeaveSpecial(@RequestParam("file") MultipartFile file) throws Exception {
358 340
         String batchNo = generateBatchNo();
359
-        List<LedgerLeaveSpecial> list = new ArrayList<>();
360
-        EasyExcel.read(file.getInputStream(), LedgerLeaveSpecial.class,
361
-                new SimpleListener<>(list)).headRowNumber(2).sheet().doRead();
341
+        ExcelUtil<LedgerLeaveSpecial> util = new ExcelUtil<>(LedgerLeaveSpecial.class);
342
+        List<LedgerLeaveSpecial> list = util.importExcel(file.getInputStream());
362 343
         list.forEach(item -> { item.setImportBatch(batchNo); item.setSourceType("1"); item.setCreateBy(getUsername()); });
363 344
         leaveSpecialService.batchInsert(list);
364 345
         return AjaxResult.success("导入成功,共" + list.size() + "条");
@@ -373,9 +354,8 @@ public class LedgerImportController extends BaseController {
373 354
     @PostMapping("/bannerLetter")
374 355
     public AjaxResult importBannerLetter(@RequestParam("file") MultipartFile file) throws Exception {
375 356
         String batchNo = generateBatchNo();
376
-        List<LedgerBannerLetter> list = new ArrayList<>();
377
-        EasyExcel.read(file.getInputStream(), LedgerBannerLetter.class,
378
-                new SimpleListener<>(list)).headRowNumber(2).sheet().doRead();
357
+        ExcelUtil<LedgerBannerLetter> util = new ExcelUtil<>(LedgerBannerLetter.class);
358
+        List<LedgerBannerLetter> list = util.importExcel(file.getInputStream());
379 359
         list.forEach(item -> { item.setImportBatch(batchNo); item.setSourceType("1"); item.setCreateBy(getUsername()); });
380 360
         bannerLetterService.batchInsert(list);
381 361
         return AjaxResult.success("导入成功,共" + list.size() + "条");
@@ -414,19 +394,5 @@ public class LedgerImportController extends BaseController {
414 394
         return AjaxResult.success("清理完成,共删除 " + total + " 条记录", result);
415 395
     }
416 396
 
417
-    /**
418
-     * 通用 EasyExcel 监听器 - 简单收集行到列表
419
-     */
420
-    private static class SimpleListener<T> extends AnalysisEventListener<T> {
421
-        private final List<T> list;
422
-        SimpleListener(List<T> list) { this.list = list; }
423 397
 
424
-        @Override
425
-        public void invoke(T data, AnalysisContext context) {
426
-            list.add(data);
427
-        }
428
-
429
-        @Override
430
-        public void doAfterAllAnalysed(AnalysisContext context) {}
431
-    }
432 398
 }

+ 2 - 0
airport-ledger/src/main/java/com/sundot/airport/ledger/service/impl/DeptPortraitServiceImpl.java

@@ -4,6 +4,7 @@ import com.sundot.airport.common.core.domain.entity.SysRole;
4 4
 import com.sundot.airport.common.core.domain.entity.SysUser;
5 5
 import com.sundot.airport.common.core.domain.entity.SysDept;
6 6
 import com.sundot.airport.common.enums.DeptTypeEnum;
7
+import com.sundot.airport.common.enums.ScoreLevelEnum;
7 8
 import com.sundot.airport.common.exception.ServiceException;
8 9
 import com.sundot.airport.ledger.domain.ScoreDimension;
9 10
 import com.sundot.airport.ledger.domain.ScoreEvent;
@@ -381,6 +382,7 @@ public class DeptPortraitServiceImpl implements IDeptPortraitService {
381 382
 
382 383
         ScoreDimension dq = new ScoreDimension();
383 384
         dq.setStatus("0");
385
+        dq.setOrg(ScoreLevelEnum.PERSON.getCode());
384 386
         List<ScoreDimension> dims = scoreDimensionMapper.selectList(dq);
385 387
         dims.sort(Comparator.comparing(d -> d.getSortOrder() == null ? 999 : d.getSortOrder()));
386 388