chenshudong пре 1 недеља
родитељ
комит
9850c30b71

+ 26 - 0
airport-ledger/src/main/java/com/sundot/airport/ledger/service/impl/LedgerSyncServiceImpl.java

@@ -10,8 +10,10 @@ import com.sundot.airport.common.utils.DateUtils;
10
 import com.sundot.airport.ledger.domain.*;
10
 import com.sundot.airport.ledger.domain.*;
11
 import com.sundot.airport.ledger.mapper.*;
11
 import com.sundot.airport.ledger.mapper.*;
12
 import com.sundot.airport.ledger.service.ILedgerSyncService;
12
 import com.sundot.airport.ledger.service.ILedgerSyncService;
13
+import com.sundot.airport.system.domain.BasePosition;
13
 import com.sundot.airport.system.mapper.SysDeptMapper;
14
 import com.sundot.airport.system.mapper.SysDeptMapper;
14
 import com.sundot.airport.system.mapper.SysUserMapper;
15
 import com.sundot.airport.system.mapper.SysUserMapper;
16
+import com.sundot.airport.system.service.IBasePositionService;
15
 import org.springframework.beans.factory.annotation.Autowired;
17
 import org.springframework.beans.factory.annotation.Autowired;
16
 import org.springframework.stereotype.Service;
18
 import org.springframework.stereotype.Service;
17
 import org.springframework.transaction.annotation.Transactional;
19
 import org.springframework.transaction.annotation.Transactional;
@@ -62,11 +64,13 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
62
     @Autowired private ScoreIndicatorMapper indicatorMapper;
64
     @Autowired private ScoreIndicatorMapper indicatorMapper;
63
     @Autowired private SysDeptMapper sysDeptMapper;
65
     @Autowired private SysDeptMapper sysDeptMapper;
64
     @Autowired private SysUserMapper sysUserMapper;
66
     @Autowired private SysUserMapper sysUserMapper;
67
+    @Autowired private IBasePositionService basePositionService;
65
 
68
 
66
     // ── Dimension ID cache (loaded once) ─────────────────────
69
     // ── Dimension ID cache (loaded once) ─────────────────────
67
     private final Map<String, Long> dimCache = new HashMap<>();
70
     private final Map<String, Long> dimCache = new HashMap<>();
68
     private final Map<String, Long> deptCache = new HashMap<>();
71
     private final Map<String, Long> deptCache = new HashMap<>();
69
     private final Map<String, Long> userCache = new HashMap<>();
72
     private final Map<String, Long> userCache = new HashMap<>();
73
+    private final Map<Long, BasePosition> positionCache = new HashMap<>();
70
 
74
 
71
     // ── Constants: Indicator IDs(与 score.sql 中的显式 ID 对应)─
75
     // ── Constants: Indicator IDs(与 score.sql 中的显式 ID 对应)─
72
     // dim1 安全防控能力
76
     // dim1 安全防控能力
@@ -127,6 +131,7 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
127
             loadDimCache();
131
             loadDimCache();
128
             loadDeptCache();
132
             loadDeptCache();
129
             loadUserCache();
133
             loadUserCache();
134
+            loadPositionCache();
130
             StringBuilder sb = new StringBuilder();
135
             StringBuilder sb = new StringBuilder();
131
             int totalIns = 0, totalSkip = 0;
136
             int totalIns = 0, totalSkip = 0;
132
             for (String type : Arrays.asList(
137
             for (String type : Arrays.asList(
@@ -153,6 +158,7 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
153
             loadDimCache();
158
             loadDimCache();
154
             loadDeptCache();
159
             loadDeptCache();
155
             loadUserCache();
160
             loadUserCache();
161
+            loadPositionCache();
156
             return doSync(ledgerType);
162
             return doSync(ledgerType);
157
         } finally {
163
         } finally {
158
             // 同步完成后清除缓存
164
             // 同步完成后清除缓存
@@ -551,6 +557,19 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
551
         sysUserMapper.selectUserList(new SysUser()).forEach(d -> userCache.put(d.getNickName(), d.getUserId()));
557
         sysUserMapper.selectUserList(new SysUser()).forEach(d -> userCache.put(d.getNickName(), d.getUserId()));
552
     }
558
     }
553
 
559
 
560
+    /** 缓存所有区域-航站楼关系 */
561
+    private void loadPositionCache() {
562
+        if (!positionCache.isEmpty()) return;
563
+        List<BasePosition> basePositionList = basePositionService.selectBasePositionListTree(new BasePosition());
564
+        basePositionList.forEach(terminl -> {
565
+            if (terminl.getChildren() != null && !terminl.getChildren().isEmpty()) {
566
+                terminl.getChildren().forEach(regional -> {
567
+                    positionCache.put(((BasePosition) regional).getId(), terminl);
568
+                });
569
+            }
570
+        });
571
+    }
572
+
554
     /**
573
     /**
555
      * 清除所有缓存
574
      * 清除所有缓存
556
      */
575
      */
@@ -558,6 +577,7 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
558
         dimCache.clear();
577
         dimCache.clear();
559
         deptCache.clear();
578
         deptCache.clear();
560
         userCache.clear();
579
         userCache.clear();
580
+        positionCache.clear();
561
         indCache.clear();
581
         indCache.clear();
562
         indicatorNameToIdCache.clear();
582
         indicatorNameToIdCache.clear();
563
     }
583
     }
@@ -705,6 +725,12 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
705
         e.setChannelName(channelNo);
725
         e.setChannelName(channelNo);
706
         e.setRegionalName(location);
726
         e.setRegionalName(location);
707
         e.setRegionalId(areaId);
727
         e.setRegionalId(areaId);
728
+        // 通过区域查找航站楼
729
+        BasePosition terminl = positionCache.get(e.getRegionalId());
730
+        if (terminl != null) {
731
+            e.setTerminlId(terminl.getId());
732
+            e.setTerminlName(terminl.getName());
733
+        }
708
         e.setPostId(positionId);
734
         e.setPostId(positionId);
709
         e.setPostName(position);
735
         e.setPostName(position);
710
         // 通过人员名称解析组织信息(ID和名称)
736
         // 通过人员名称解析组织信息(ID和名称)