소스 검색

Merge remote-tracking branch 'origin/master'

sunpanhu 4 주 전
부모
커밋
1235b52a8a

+ 57 - 0
airport-admin/src/main/java/com/sundot/airport/web/controller/score/ScoreEventController.java

@@ -3,6 +3,7 @@ package com.sundot.airport.web.controller.score;
3 3
 import com.alibaba.excel.EasyExcel;
4 4
 import com.alibaba.excel.context.AnalysisContext;
5 5
 import com.alibaba.excel.event.AnalysisEventListener;
6
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
6 7
 import com.sundot.airport.common.annotation.Log;
7 8
 import com.sundot.airport.common.core.controller.BaseController;
8 9
 import com.sundot.airport.common.core.domain.AjaxResult;
@@ -11,7 +12,10 @@ import com.sundot.airport.common.enums.BusinessType;
11 12
 import com.sundot.airport.common.utils.DateUtils;
12 13
 import com.sundot.airport.common.utils.poi.ExcelUtil;
13 14
 import com.sundot.airport.ledger.domain.ScoreEvent;
15
+import com.sundot.airport.ledger.domain.ScoreIndicator;
16
+import com.sundot.airport.ledger.mapper.ScoreIndicatorMapper;
14 17
 import com.sundot.airport.ledger.service.IScoreEventService;
18
+import com.sundot.airport.ledger.service.IScoreIndicatorService;
15 19
 import org.springframework.beans.factory.annotation.Autowired;
16 20
 import org.springframework.security.access.prepost.PreAuthorize;
17 21
 import org.springframework.validation.annotation.Validated;
@@ -34,6 +38,9 @@ public class ScoreEventController extends BaseController {
34 38
     @Autowired
35 39
     private IScoreEventService service;
36 40
 
41
+    @Autowired
42
+    private IScoreIndicatorService indicatorService;
43
+
37 44
     @PreAuthorize("@ss.hasPermi('score:event:list')")
38 45
     @GetMapping("/list")
39 46
     public TableDataInfo list(ScoreEvent query) {
@@ -62,6 +69,10 @@ public class ScoreEventController extends BaseController {
62 69
         entity.setSourceType("1");
63 70
         entity.setCreateBy(getUsername());
64 71
         entity.setCreateTime(DateUtils.getNowDate());
72
+        
73
+        // 通过指标名称查找并设置ID
74
+        resolveIndicatorIds(entity);
75
+        
65 76
         // 计算 totalScore
66 77
         BigDecimal score = entity.getScoreValue() != null ? entity.getScoreValue() : BigDecimal.ZERO;
67 78
         BigDecimal cascade = entity.getCascadeScore() != null ? entity.getCascadeScore() : BigDecimal.ZERO;
@@ -75,6 +86,10 @@ public class ScoreEventController extends BaseController {
75 86
     public AjaxResult edit(@Validated @RequestBody ScoreEvent entity) {
76 87
         entity.setUpdateBy(getUsername());
77 88
         entity.setUpdateTime(DateUtils.getNowDate());
89
+        
90
+        // 通过指标名称查找并设置ID
91
+        resolveIndicatorIds(entity);
92
+        
78 93
         BigDecimal score = entity.getScoreValue() != null ? entity.getScoreValue() : BigDecimal.ZERO;
79 94
         BigDecimal cascade = entity.getCascadeScore() != null ? entity.getCascadeScore() : BigDecimal.ZERO;
80 95
         entity.setTotalScore(score.add(cascade));
@@ -109,4 +124,46 @@ public class ScoreEventController extends BaseController {
109 124
         service.batchInsert(list);
110 125
         return AjaxResult.success("导入成功,共" + list.size() + "条");
111 126
     }
127
+
128
+    /**
129
+     * 通过指标名称查找并设置ID
130
+     */
131
+    private void resolveIndicatorIds(ScoreEvent entity) {
132
+        // 通过二级指标名称查找ID
133
+        if (entity.getLevel2Name() != null && !entity.getLevel2Name().trim().isEmpty()) {
134
+            Long level2Id = findIndicatorIdByName(entity.getLevel2Name().trim());
135
+            if (level2Id != null) {
136
+                entity.setLevel2Id(level2Id);
137
+            }
138
+        }
139
+        
140
+        // 通过三级指标名称查找ID
141
+        if (entity.getLevel3Name() != null && !entity.getLevel3Name().trim().isEmpty()) {
142
+            Long level3Id = findIndicatorIdByName(entity.getLevel3Name().trim());
143
+            if (level3Id != null) {
144
+                entity.setLevel3Id(level3Id);
145
+            }
146
+        }
147
+        
148
+        // 通过四级指标名称查找ID
149
+        if (entity.getLevel4Name() != null && !entity.getLevel4Name().trim().isEmpty()) {
150
+            Long level4Id = findIndicatorIdByName(entity.getLevel4Name().trim());
151
+            if (level4Id != null) {
152
+                entity.setLevel4Id(level4Id);
153
+            }
154
+        }
155
+    }
156
+
157
+    /**
158
+     * 通过名称查找指标ID
159
+     */
160
+    private Long findIndicatorIdByName(String name) {
161
+        if (name == null || name.trim().isEmpty()) {
162
+            return null;
163
+        }
164
+        LambdaQueryWrapper<ScoreIndicator> wrapper = new LambdaQueryWrapper<>();
165
+        wrapper.eq(ScoreIndicator::getName, name.trim());
166
+        ScoreIndicator indicator = indicatorService.getOne(wrapper);
167
+        return indicator != null ? indicator.getId() : null;
168
+    }
112 169
 }

+ 66 - 35
airport-ledger/src/main/java/com/sundot/airport/ledger/service/impl/LedgerCombinedImportServiceImpl.java

@@ -201,14 +201,17 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
201 201
             o.setTeamInternalDuty(str(c, 23));  // 队室内勤
202 202
             o.setTeamLeader(str(c, 24));        // 队室负责人
203 203
             
204
-            // 根据责任人名称查找组织ID
204
+            // 根据责任人名称查找组织ID和名称
205 205
             if (inspectedName != null && !inspectedName.trim().isEmpty()) {
206
-                Map<String, Long> orgInfo = resolveOrgInfoByNameWithCache(inspectedName);
206
+                Map<String, Object> orgInfo = resolveOrgInfoByNameWithCache(inspectedName);
207 207
                 if (!orgInfo.isEmpty()) {
208
-                    o.setInspectedId(orgInfo.get("userId"));
209
-                    o.setDeptId(orgInfo.get("deptId"));
210
-                    o.setTeamId(orgInfo.get("teamId"));
211
-                    o.setGroupId(orgInfo.get("groupId"));
208
+                    o.setInspectedId((Long) orgInfo.get("userId"));
209
+                    o.setDeptId((Long) orgInfo.get("deptId"));
210
+                    o.setDeptName((String) orgInfo.get("deptName"));
211
+                    o.setTeamId((Long) orgInfo.get("teamId"));
212
+                    o.setTeamName((String) orgInfo.get("teamName"));
213
+                    o.setGroupId((Long) orgInfo.get("groupId"));
214
+                    o.setGroupName((String) orgInfo.get("groupName"));
212 215
                 }
213 216
             }
214 217
             
@@ -315,14 +318,17 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
315 318
             o.setRemark(str(c, 27));            // 备注
316 319
             o.setTeamLeader(str(c, 28));        // 队室负责人
317 320
             
318
-            // 根据责任人名称查找组织ID
321
+            // 根据责任人名称查找组织ID和名称
319 322
             if (inspectorName != null && !inspectorName.trim().isEmpty()) {
320
-                Map<String, Long> orgInfo = resolveOrgInfoByNameWithCache(inspectorName);
323
+                Map<String, Object> orgInfo = resolveOrgInfoByNameWithCache(inspectorName);
321 324
                 if (!orgInfo.isEmpty()) {
322
-                    o.setInspectorId(orgInfo.get("userId"));
323
-                    o.setDeptId(orgInfo.get("deptId"));
324
-                    o.setTeamId(orgInfo.get("teamId"));
325
-                    o.setGroupId(orgInfo.get("groupId"));
325
+                    o.setInspectorId((Long) orgInfo.get("userId"));
326
+                    o.setDeptId((Long) orgInfo.get("deptId"));
327
+                    o.setDeptName((String) orgInfo.get("deptName"));
328
+                    o.setTeamId((Long) orgInfo.get("teamId"));
329
+                    o.setTeamName((String) orgInfo.get("teamName"));
330
+                    o.setGroupId((Long) orgInfo.get("groupId"));
331
+                    o.setGroupName((String) orgInfo.get("groupName"));
326 332
                 }
327 333
             }
328 334
             
@@ -473,12 +479,15 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
473 479
             
474 480
             // 使用缓存查找组织信息(根据被测人名称)
475 481
             if (testedName != null && !testedName.trim().isEmpty()) {
476
-                Map<String, Long> orgInfo = resolveOrgInfoByNameWithCache(testedName);
482
+                Map<String, Object> orgInfo = resolveOrgInfoByNameWithCache(testedName);
477 483
                 if (!orgInfo.isEmpty()) {
478
-                    o.setTestedId(orgInfo.get("userId"));
479
-                    o.setDeptId(orgInfo.get("deptId"));
480
-                    o.setTeamId(orgInfo.get("teamId"));
481
-                    o.setGroupId(orgInfo.get("groupId"));
484
+                    o.setTestedId((Long) orgInfo.get("userId"));
485
+                    o.setDeptId((Long) orgInfo.get("deptId"));
486
+                    o.setDeptName((String) orgInfo.get("deptName"));
487
+                    o.setTeamId((Long) orgInfo.get("teamId"));
488
+                    o.setTeamName((String) orgInfo.get("teamName"));
489
+                    o.setGroupId((Long) orgInfo.get("groupId"));
490
+                    o.setGroupName((String) orgInfo.get("groupName"));
482 491
                 }
483 492
             }
484 493
             
@@ -583,13 +592,16 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
583 592
             o.setChannelNo(str(c, 9));
584 593
             o.setImage(str(c, 10));
585 594
             
586
-            // 使用缓存查找组织信息
587
-            Map<String, Long> orgInfo = resolveOrgInfoByNameWithCache(responsibleName);
595
+            // 使用缓存查找组织信息和名称
596
+            Map<String, Object> orgInfo = resolveOrgInfoByNameWithCache(responsibleName);
588 597
             if (!orgInfo.isEmpty()) {
589
-                o.setResponsibleId(orgInfo.get("userId"));
590
-                o.setDeptId(orgInfo.get("deptId"));
591
-                o.setTeamId(orgInfo.get("teamId"));
592
-                o.setGroupId(orgInfo.get("groupId"));
598
+                o.setResponsibleId((Long) orgInfo.get("userId"));
599
+                o.setDeptId((Long) orgInfo.get("deptId"));
600
+                o.setDeptName((String) orgInfo.get("deptName"));
601
+                o.setTeamId((Long) orgInfo.get("teamId"));
602
+                o.setTeamName((String) orgInfo.get("teamName"));
603
+                o.setGroupId((Long) orgInfo.get("groupId"));
604
+                o.setGroupName((String) orgInfo.get("groupName"));
593 605
             }
594 606
             
595 607
             // 根据岗位名称和区域名称查找ID
@@ -657,13 +669,16 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
657 669
             o.setRemark(str(c, 25));
658 670
             o.setSeizureQuantity(integer(c, 26));  // 查获数量
659 671
                 
660
-            // 使用缓存查找组织信息
661
-            Map<String, Long> orgInfo = resolveOrgInfoByNameWithCache(inspectorName);
672
+            // 使用缓存查找组织信息和名称
673
+            Map<String, Object> orgInfo = resolveOrgInfoByNameWithCache(inspectorName);
662 674
             if (!orgInfo.isEmpty()) {
663
-                o.setInspectorId(orgInfo.get("userId"));
664
-                o.setDeptId(orgInfo.get("deptId"));
665
-                o.setTeamId(orgInfo.get("teamId"));
666
-                o.setGroupId(orgInfo.get("groupId"));
675
+                o.setInspectorId((Long) orgInfo.get("userId"));
676
+                o.setDeptId((Long) orgInfo.get("deptId"));
677
+                o.setDeptName((String) orgInfo.get("deptName"));
678
+                o.setTeamId((Long) orgInfo.get("teamId"));
679
+                o.setTeamName((String) orgInfo.get("teamName"));
680
+                o.setGroupId((Long) orgInfo.get("groupId"));
681
+                o.setGroupName((String) orgInfo.get("groupName"));
667 682
             }
668 683
             
669 684
             // 根据岗位名称和工作区域名称查找ID
@@ -1193,8 +1208,8 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
1193 1208
      * @param personName 人员名称
1194 1209
      * @return Map包含: userId, deptId(BRIGADE), teamId(MANAGER), groupId(TEAMS)
1195 1210
      */
1196
-    private Map<String, Long> resolveOrgInfoByNameWithCache(String personName) {
1197
-        Map<String, Long> result = new HashMap<>();
1211
+    private Map<String, Object> resolveOrgInfoByNameWithCache(String personName) {
1212
+        Map<String, Object> result = new HashMap<>();
1198 1213
         if (personName == null || personName.trim().isEmpty() || importCache == null) {
1199 1214
             return result;
1200 1215
         }
@@ -1217,25 +1232,41 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
1217 1232
 
1218 1233
         String deptType = userDept.getDeptType();
1219 1234
 
1220
-        // 3. 根据部门类型递归获取各级组织ID
1235
+        // 3. 根据部门类型递归获取各级组织ID和名称
1221 1236
         if ("BRIGADE".equals(deptType)) {
1222 1237
             // 用户部门是大队
1223 1238
             result.put("deptId", user.getDeptId());
1239
+            result.put("deptName", userDept.getDeptName());
1224 1240
         } else if ("MANAGER".equals(deptType)) {
1225 1241
             // 用户部门是队室/班组,向上找大队
1226 1242
             result.put("teamId", user.getDeptId());
1243
+            result.put("teamName", userDept.getDeptName());
1227 1244
             if (userDept.getParentId() != null && userDept.getParentId() != 0) {
1228 1245
                 result.put("deptId", userDept.getParentId());
1246
+                // 从缓存中获取父级部门(大队)
1247
+                SysDept parentDept = importCache.getDeptById(userDept.getParentId());
1248
+                if (parentDept != null) {
1249
+                    result.put("deptName", parentDept.getDeptName());
1250
+                }
1229 1251
             }
1230 1252
         } else if ("TEAMS".equals(deptType)) {
1231 1253
             // 用户部门是小组,向上找队室和大队
1232 1254
             result.put("groupId", user.getDeptId());
1255
+            result.put("groupName", userDept.getDeptName());
1233 1256
             if (userDept.getParentId() != null && userDept.getParentId() != 0) {
1234 1257
                 result.put("teamId", userDept.getParentId());
1235
-                // 从缓存中获取父级部门
1258
+                // 从缓存中获取父级部门(队室)
1236 1259
                 SysDept parentDept = importCache.getDeptById(userDept.getParentId());
1237
-                if (parentDept != null && parentDept.getParentId() != null && parentDept.getParentId() != 0) {
1238
-                    result.put("deptId", parentDept.getParentId());
1260
+                if (parentDept != null) {
1261
+                    result.put("teamName", parentDept.getDeptName());
1262
+                    if (parentDept.getParentId() != null && parentDept.getParentId() != 0) {
1263
+                        result.put("deptId", parentDept.getParentId());
1264
+                        // 从缓存中获取祖父级部门(大队)
1265
+                        SysDept grandParentDept = importCache.getDeptById(parentDept.getParentId());
1266
+                        if (grandParentDept != null) {
1267
+                            result.put("deptName", grandParentDept.getDeptName());
1268
+                        }
1269
+                    }
1239 1270
                 }
1240 1271
             }
1241 1272
         }

+ 147 - 33
airport-ledger/src/main/java/com/sundot/airport/ledger/service/impl/LedgerSyncServiceImpl.java

@@ -121,31 +121,41 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
121 121
     @Override
122 122
     @Transactional(rollbackFor = Exception.class)
123 123
     public SyncResult syncAll() {
124
-        loadDimCache();
125
-        loadDeptCache();
126
-        loadUserCache();
127
-        StringBuilder sb = new StringBuilder();
128
-        int totalIns = 0, totalSkip = 0;
129
-        for (String type : Arrays.asList(
130
-                "supervision_problem", "realtime_interception", "security_test",
131
-                "unsafe_event", "seizure_stats", "reward_approval",
132
-                "service_patrol", "complaint", "terminal_bonus", "exam_score")) {
133
-            SyncResult r = doSync(type);
134
-            sb.append(type).append(":+").append(r.getTotalInserted())
135
-              .append("/skip").append(r.getTotalSkipped()).append("  ");
136
-            totalIns += r.getTotalInserted();
137
-            totalSkip += r.getTotalSkipped();
124
+        try {
125
+            loadDimCache();
126
+            loadDeptCache();
127
+            loadUserCache();
128
+            StringBuilder sb = new StringBuilder();
129
+            int totalIns = 0, totalSkip = 0;
130
+            for (String type : Arrays.asList(
131
+                    "supervision_problem", "realtime_interception", "security_test",
132
+                    "unsafe_event", "seizure_stats", "reward_approval",
133
+                    "service_patrol", "complaint", "terminal_bonus", "exam_score")) {
134
+                SyncResult r = doSync(type);
135
+                sb.append(type).append(":+").append(r.getTotalInserted())
136
+                  .append("/skip").append(r.getTotalSkipped()).append("  ");
137
+                totalIns += r.getTotalInserted();
138
+                totalSkip += r.getTotalSkipped();
139
+            }
140
+            return new SyncResult(totalIns, totalSkip, sb.toString());
141
+        } finally {
142
+            // 同步完成后清除缓存
143
+            clearCaches();
138 144
         }
139
-        return new SyncResult(totalIns, totalSkip, sb.toString());
140 145
     }
141 146
 
142 147
     @Override
143 148
     @Transactional(rollbackFor = Exception.class)
144 149
     public SyncResult syncByType(String ledgerType) {
145
-        loadDimCache();
146
-        loadDeptCache();
147
-        loadUserCache();
148
-        return doSync(ledgerType);
150
+        try {
151
+            loadDimCache();
152
+            loadDeptCache();
153
+            loadUserCache();
154
+            return doSync(ledgerType);
155
+        } finally {
156
+            // 同步完成后清除缓存
157
+            clearCaches();
158
+        }
149 159
     }
150 160
 
151 161
     // ═════════════════════════════════════════════════════════
@@ -158,7 +168,7 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
158 168
             case "realtime_interception": return syncRealtimeInterception();
159 169
             case "security_test":         return syncSecurityTest();
160 170
             case "unsafe_event":          return syncUnsafeEvent();
161
-            case "seizure_stats":         return syncSeizureStats();
171
+//            case "seizure_stats":         return syncSeizureStats();
162 172
             case "reward_approval":       return syncRewardApproval();
163 173
             case "service_patrol":        return syncServicePatrol();
164 174
             case "complaint":             return syncComplaint();
@@ -182,7 +192,7 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
182 192
             String src = "supervision_problem:" + row.getId();
183 193
             if (existsBySrc(src)) { skip++; continue; }
184 194
             if (!hasName(row.getInspectedName())) { skip++; continue; }
185
-            // 按问题层级选取L3指标和默认分值(修正:取problemLevel字段)
195
+            // 按问题层级选取L3指标和默认分值
186 196
             String level = row.getProblemLevel() != null ? row.getProblemLevel() : "";
187 197
             long l3Id; BigDecimal defaultSv;
188 198
             if (level.contains("上级")) { l3Id = IND_SUPERVISION_L3_LEADER; defaultSv = BigDecimal.valueOf(-1.20); }
@@ -213,10 +223,10 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
213 223
             // 取【问题层级】字段,站层级扣1分,部门层级扣0.8分,其它层级跳过
214 224
             String level = row.getProblemLevel() != null ? row.getProblemLevel() : "";
215 225
             long l3Id; BigDecimal sv;
216
-            if (level.contains("站层级")) {
226
+            if (level.contains("站")) {
217 227
                 l3Id = IND_INTERCEPT_L3_STATION;
218 228
                 sv = row.getDeductScore() != null ? row.getDeductScore().negate() : NEG_ONE;
219
-            } else if (level.contains("部门层级")) {
229
+            } else if (level.contains("部门")) {
220 230
                 l3Id = IND_INTERCEPT_L3_DEPT;
221 231
                 sv = row.getDeductScore() != null ? row.getDeductScore().negate() : NEG_08;
222 232
             } else {
@@ -463,7 +473,96 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
463 473
         sysUserMapper.selectUserList(new SysUser()).forEach(d -> userCache.put(d.getNickName(), d.getUserId()));
464 474
     }
465 475
 
476
+    /**
477
+     * 清除所有缓存
478
+     */
479
+    private void clearCaches() {
480
+        dimCache.clear();
481
+        deptCache.clear();
482
+        userCache.clear();
483
+        indCache.clear();
484
+        indicatorNameToIdCache.clear();
485
+    }
486
+
487
+    /**
488
+     * 通过用户名称解析组织信息(ID和名称)
489
+     * @param personName 人员名称
490
+     * @return Map包含: userId, deptId, deptName, teamId, teamName, groupId, groupName
491
+     */
492
+    private Map<String, Object> resolveOrgInfoByName(String personName) {
493
+        Map<String, Object> result = new HashMap<>();
494
+        if (personName == null || personName.trim().isEmpty()) {
495
+            return result;
496
+        }
497
+
498
+        String name = personName.trim();
499
+        
500
+        // 1. 从缓存中查找用户
501
+        Long userId = userCache.get(name);
502
+        if (userId == null) {
503
+            return result;
504
+        }
505
+        result.put("userId", userId);
506
+
507
+        // 2. 查询用户详情获取部门ID
508
+        SysUser user = sysUserMapper.selectUserById(userId);
509
+        if (user == null || user.getDeptId() == null) {
510
+            return result;
511
+        }
512
+
513
+        // 3. 从缓存中获取用户部门信息
514
+        SysDept userDept = sysDeptMapper.selectDeptById(user.getDeptId());
515
+        if (userDept == null) {
516
+            return result;
517
+        }
518
+
519
+        String deptType = userDept.getDeptType();
520
+
521
+        // 4. 根据部门类型递归获取各级组织ID和名称
522
+        if ("BRIGADE".equals(deptType)) {
523
+            // 用户部门是大队
524
+            result.put("deptId", user.getDeptId());
525
+            result.put("deptName", userDept.getDeptName());
526
+        } else if ("MANAGER".equals(deptType)) {
527
+            // 用户部门是队室/班组,向上找大队
528
+            result.put("teamId", user.getDeptId());
529
+            result.put("teamName", userDept.getDeptName());
530
+            if (userDept.getParentId() != null && userDept.getParentId() != 0) {
531
+                result.put("deptId", userDept.getParentId());
532
+                // 获取父级部门(大队)
533
+                SysDept parentDept = sysDeptMapper.selectDeptById(userDept.getParentId());
534
+                if (parentDept != null) {
535
+                    result.put("deptName", parentDept.getDeptName());
536
+                }
537
+            }
538
+        } else if ("TEAMS".equals(deptType)) {
539
+            // 用户部门是小组,向上找队室和大队
540
+            result.put("groupId", user.getDeptId());
541
+            result.put("groupName", userDept.getDeptName());
542
+            if (userDept.getParentId() != null && userDept.getParentId() != 0) {
543
+                result.put("teamId", userDept.getParentId());
544
+                // 获取父级部门(队室)
545
+                SysDept parentDept = sysDeptMapper.selectDeptById(userDept.getParentId());
546
+                if (parentDept != null) {
547
+                    result.put("teamName", parentDept.getDeptName());
548
+                    if (parentDept.getParentId() != null && parentDept.getParentId() != 0) {
549
+                        result.put("deptId", parentDept.getParentId());
550
+                        // 获取祖父级部门(大队)
551
+                        SysDept grandParentDept = sysDeptMapper.selectDeptById(parentDept.getParentId());
552
+                        if (grandParentDept != null) {
553
+                            result.put("deptName", grandParentDept.getDeptName());
554
+                        }
555
+                    }
556
+                }
557
+            }
558
+        }
559
+
560
+        return result;
561
+    }
562
+
466 563
     private final Map<Long, ScoreIndicator> indCache = new HashMap<>();
564
+    private final Map<String, Long> indicatorNameToIdCache = new HashMap<>(); // 指标名称到ID的映射
565
+    
467 566
     private ScoreIndicator getIndicator(long id) {
468 567
         return indCache.computeIfAbsent(id, indicatorMapper::selectById);
469 568
     }
@@ -488,12 +587,24 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
488 587
                 .filter(x -> x.getValue().equals(dimId)).map(Map.Entry::getKey).findFirst().orElse("") : "");
489 588
         if (lv2 != null) {
490 589
             e.setIndicatorId(lv2.getId());
590
+            e.setLevel2Id(lv2.getId());
491 591
             e.setLevel2Name(lv2.getName());
492 592
         }
493 593
         if (lv3 != null) {
494 594
             e.setIndicatorId(lv3.getId());
495 595
             e.setLevel3Id(lv3.getId());
496 596
             e.setLevel3Name(lv3.getName());
597
+            // 如果lv3有父级(即lv2),确保level2Id也被设置
598
+            if (lv3.getParentId() != null && lv3.getParentId() != 0) {
599
+                e.setLevel2Id(lv3.getParentId());
600
+                // 通过ID获取lv2的名称(如果之前没设置)
601
+                if (e.getLevel2Name() == null) {
602
+                    ScoreIndicator parentLv2 = getIndicator(lv3.getParentId());
603
+                    if (parentLv2 != null) {
604
+                        e.setLevel2Name(parentLv2.getName());
605
+                    }
606
+                }
607
+            }
497 608
         } else if (lv2 != null) {
498 609
             e.setIndicatorId(lv2.getId());
499 610
         }
@@ -511,18 +622,21 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
511 622
         e.setEvidenceFile(evidenceFile);
512 623
         e.setCreateBy("system");
513 624
         e.setCreateTime(DateUtils.getNowDate());
625
+        
626
+        // 通过人员名称解析组织信息(ID和名称)
514 627
         if (StrUtil.isNotEmpty(e.getPersonName())) {
515
-            e.setPersonId(userCache.get(e.getPersonName()));
516
-        }
517
-        if (StrUtil.isNotEmpty(e.getGroupName())) {
518
-            e.setGroupId(deptCache.get(e.getGroupName()));
519
-        }
520
-        if (StrUtil.isNotEmpty(e.getTeamName())) {
521
-            e.setTeamId(deptCache.get(e.getTeamName()));
522
-        }
523
-        if (StrUtil.isNotEmpty(e.getDeptName())) {
524
-            e.setDeptId(deptCache.get(e.getDeptName()));
628
+            Map<String, Object> orgInfo = resolveOrgInfoByName(e.getPersonName());
629
+            if (!orgInfo.isEmpty()) {
630
+                e.setPersonId((Long) orgInfo.get("userId"));
631
+                e.setDeptId((Long) orgInfo.get("deptId"));
632
+                e.setDeptName((String) orgInfo.get("deptName"));
633
+                e.setTeamId((Long) orgInfo.get("teamId"));
634
+                e.setTeamName((String) orgInfo.get("teamName"));
635
+                e.setGroupId((Long) orgInfo.get("groupId"));
636
+                e.setGroupName((String) orgInfo.get("groupName"));
637
+            }
525 638
         }
639
+        
526 640
         return e;
527 641
     }
528 642
 }