|
|
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
4
|
4
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
5
|
5
|
import com.sundot.airport.common.core.domain.entity.SysDept;
|
|
6
|
6
|
import com.sundot.airport.common.core.domain.entity.SysUser;
|
|
|
7
|
+import com.sundot.airport.system.domain.SysPost;
|
|
|
8
|
+import com.sundot.airport.system.domain.BasePosition;
|
|
7
|
9
|
import com.sundot.airport.ledger.domain.*;
|
|
8
|
10
|
import com.sundot.airport.ledger.domain.LedgerDailyTraining;
|
|
9
|
11
|
import com.sundot.airport.ledger.domain.LedgerLeaderDuty;
|
|
|
@@ -18,6 +20,8 @@ import com.sundot.airport.ledger.service.ILedgerDormFireSafetyService;
|
|
18
|
20
|
import com.sundot.airport.ledger.service.ILedgerTrainingIssueService;
|
|
19
|
21
|
import com.sundot.airport.system.mapper.SysDeptMapper;
|
|
20
|
22
|
import com.sundot.airport.system.mapper.SysUserMapper;
|
|
|
23
|
+import com.sundot.airport.system.mapper.SysPostMapper;
|
|
|
24
|
+import com.sundot.airport.system.mapper.BasePositionMapper;
|
|
21
|
25
|
import org.apache.poi.ss.usermodel.*;
|
|
22
|
26
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
23
|
27
|
import org.springframework.stereotype.Service;
|
|
|
@@ -60,6 +64,8 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
60
|
64
|
@Autowired private IScoreEventService scoreEventService;
|
|
61
|
65
|
@Autowired private SysUserMapper sysUserMapper;
|
|
62
|
66
|
@Autowired private SysDeptMapper sysDeptMapper;
|
|
|
67
|
+ @Autowired private SysPostMapper sysPostMapper;
|
|
|
68
|
+ @Autowired private BasePositionMapper basePositionMapper;
|
|
63
|
69
|
|
|
64
|
70
|
// 导入缓存(在导入开始时构建,导入结束后释放)
|
|
65
|
71
|
private ImportCache importCache;
|
|
|
@@ -390,10 +396,44 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
390
|
396
|
o.setRecordDate(date(c, 0));
|
|
391
|
397
|
o.setEventDesc(str(c, 1));
|
|
392
|
398
|
o.setEventType(str(c, 2));
|
|
393
|
|
- o.setResponsibleName(str(c, 4));
|
|
|
399
|
+ o.setFlightNo(str(c, 3));
|
|
|
400
|
+ String responsibleName = str(c, 4);
|
|
|
401
|
+ o.setResponsibleName(responsibleName);
|
|
394
|
402
|
o.setTeamName(str(c, 5));
|
|
395
|
|
- o.setEvidenceFile(str(c, 10));
|
|
396
|
|
- o.setRemark(str(c, 8));
|
|
|
403
|
+ o.setInvolvedItems(str(c, 6));
|
|
|
404
|
+ o.setPosition(str(c, 7));
|
|
|
405
|
+ o.setArea(str(c, 8));
|
|
|
406
|
+ o.setChannelNo(str(c, 9));
|
|
|
407
|
+ o.setImage(str(c, 10));
|
|
|
408
|
+
|
|
|
409
|
+ // 使用缓存查找组织信息
|
|
|
410
|
+ Map<String, Long> orgInfo = resolveOrgInfoByNameWithCache(responsibleName);
|
|
|
411
|
+ if (!orgInfo.isEmpty()) {
|
|
|
412
|
+ o.setResponsibleId(orgInfo.get("userId"));
|
|
|
413
|
+ o.setDeptId(orgInfo.get("deptId"));
|
|
|
414
|
+ o.setTeamId(orgInfo.get("teamId"));
|
|
|
415
|
+ o.setGroupId(orgInfo.get("groupId"));
|
|
|
416
|
+ }
|
|
|
417
|
+
|
|
|
418
|
+ // 根据岗位名称和区域名称查找ID
|
|
|
419
|
+ if (importCache != null) {
|
|
|
420
|
+ String positionName = str(c, 7);
|
|
|
421
|
+ if (positionName != null && !positionName.trim().isEmpty()) {
|
|
|
422
|
+ Long positionId = importCache.getPositionIdByName(positionName.trim());
|
|
|
423
|
+ if (positionId != null) {
|
|
|
424
|
+ o.setPositionId(positionId);
|
|
|
425
|
+ }
|
|
|
426
|
+ }
|
|
|
427
|
+
|
|
|
428
|
+ String areaName = str(c, 8);
|
|
|
429
|
+ if (areaName != null && !areaName.trim().isEmpty()) {
|
|
|
430
|
+ Long areaId = importCache.getAreaIdByName(areaName.trim());
|
|
|
431
|
+ if (areaId != null) {
|
|
|
432
|
+ o.setAreaId(areaId);
|
|
|
433
|
+ }
|
|
|
434
|
+ }
|
|
|
435
|
+ }
|
|
|
436
|
+
|
|
397
|
437
|
o.setImportBatch(batchNo);
|
|
398
|
438
|
o.setSourceType("1");
|
|
399
|
439
|
o.setCreateBy(username);
|
|
|
@@ -448,6 +488,25 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
448
|
488
|
o.setTeamId(orgInfo.get("teamId"));
|
|
449
|
489
|
o.setGroupId(orgInfo.get("groupId"));
|
|
450
|
490
|
}
|
|
|
491
|
+
|
|
|
492
|
+ // 根据岗位名称和工作区域名称查找ID
|
|
|
493
|
+ if (importCache != null) {
|
|
|
494
|
+ String positionName = str(c, 7);
|
|
|
495
|
+ if (positionName != null && !positionName.trim().isEmpty()) {
|
|
|
496
|
+ Long positionId = importCache.getPositionIdByName(positionName.trim());
|
|
|
497
|
+ if (positionId != null) {
|
|
|
498
|
+ o.setPositionId(positionId);
|
|
|
499
|
+ }
|
|
|
500
|
+ }
|
|
|
501
|
+
|
|
|
502
|
+ String areaName = str(c, 4);
|
|
|
503
|
+ if (areaName != null && !areaName.trim().isEmpty()) {
|
|
|
504
|
+ Long areaId = importCache.getAreaIdByName(areaName.trim());
|
|
|
505
|
+ if (areaId != null) {
|
|
|
506
|
+ o.setAreaId(areaId);
|
|
|
507
|
+ }
|
|
|
508
|
+ }
|
|
|
509
|
+ }
|
|
451
|
510
|
|
|
452
|
511
|
o.setImportBatch(batchNo);
|
|
453
|
512
|
o.setSourceType("1");
|
|
|
@@ -920,10 +979,15 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
920
|
979
|
private static class ImportCache {
|
|
921
|
980
|
private final Map<String, SysUser> userCache; // Map<昵称, 用户>
|
|
922
|
981
|
private final Map<Long, SysDept> deptCache; // Map<部门ID, 部门>
|
|
|
982
|
+ private final Map<String, Long> positionCache; // Map<岗位名称, 岗位ID>
|
|
|
983
|
+ private final Map<String, Long> areaCache; // Map<区域名称, 区域ID>
|
|
923
|
984
|
|
|
924
|
|
- public ImportCache(Map<String, SysUser> userCache, Map<Long, SysDept> deptCache) {
|
|
|
985
|
+ public ImportCache(Map<String, SysUser> userCache, Map<Long, SysDept> deptCache,
|
|
|
986
|
+ Map<String, Long> positionCache, Map<String, Long> areaCache) {
|
|
925
|
987
|
this.userCache = userCache;
|
|
926
|
988
|
this.deptCache = deptCache;
|
|
|
989
|
+ this.positionCache = positionCache;
|
|
|
990
|
+ this.areaCache = areaCache;
|
|
927
|
991
|
}
|
|
928
|
992
|
|
|
929
|
993
|
public SysUser getUserByNickName(String nickName) {
|
|
|
@@ -933,6 +997,14 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
933
|
997
|
public SysDept getDeptById(Long deptId) {
|
|
934
|
998
|
return deptCache.get(deptId);
|
|
935
|
999
|
}
|
|
|
1000
|
+
|
|
|
1001
|
+ public Long getPositionIdByName(String positionName) {
|
|
|
1002
|
+ return positionCache.get(positionName);
|
|
|
1003
|
+ }
|
|
|
1004
|
+
|
|
|
1005
|
+ public Long getAreaIdByName(String areaName) {
|
|
|
1006
|
+ return areaCache.get(areaName);
|
|
|
1007
|
+ }
|
|
936
|
1008
|
}
|
|
937
|
1009
|
|
|
938
|
1010
|
// ════════════════════════════════════════════════════════════════
|
|
|
@@ -1019,8 +1091,33 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
|
|
1019
|
1091
|
}
|
|
1020
|
1092
|
}
|
|
1021
|
1093
|
|
|
|
1094
|
+ // 构建岗位缓存:Map<岗位名称, 岗位ID>
|
|
|
1095
|
+ Map<String, Long> positionCache = new HashMap<>();
|
|
|
1096
|
+ List<SysPost> allPosts = sysPostMapper.selectPostAll();
|
|
|
1097
|
+ if (allPosts != null) {
|
|
|
1098
|
+ for (SysPost post : allPosts) {
|
|
|
1099
|
+ if (post.getPostName() != null && !post.getPostName().trim().isEmpty()) {
|
|
|
1100
|
+ positionCache.put(post.getPostName().trim(), post.getPostId());
|
|
|
1101
|
+ }
|
|
|
1102
|
+ }
|
|
|
1103
|
+ }
|
|
|
1104
|
+
|
|
|
1105
|
+ // 构建区域缓存:Map<区域名称, 区域ID>
|
|
|
1106
|
+ // 从base_position表查询position_type='REGIONAL'的区域
|
|
|
1107
|
+ Map<String, Long> areaCache = new HashMap<>();
|
|
|
1108
|
+ BasePosition queryPosition = new BasePosition();
|
|
|
1109
|
+ queryPosition.setPositionType("REGIONAL");
|
|
|
1110
|
+ List<BasePosition> allAreas = basePositionMapper.selectBasePositionList(queryPosition);
|
|
|
1111
|
+ if (allAreas != null) {
|
|
|
1112
|
+ for (BasePosition area : allAreas) {
|
|
|
1113
|
+ if (area.getName() != null && !area.getName().trim().isEmpty()) {
|
|
|
1114
|
+ areaCache.put(area.getName().trim(), area.getId());
|
|
|
1115
|
+ }
|
|
|
1116
|
+ }
|
|
|
1117
|
+ }
|
|
|
1118
|
+
|
|
1022
|
1119
|
// 创建统一缓存对象
|
|
1023
|
|
- this.importCache = new ImportCache(userCache, deptCache);
|
|
|
1120
|
+ this.importCache = new ImportCache(userCache, deptCache, positionCache, areaCache);
|
|
1024
|
1121
|
}
|
|
1025
|
1122
|
|
|
1026
|
1123
|
/**
|