Explorar o código

Merge remote-tracking branch 'origin/master'

wangxx hai 1 mes
pai
achega
c8b4a360b9

+ 24 - 0
airport-ledger/src/main/java/com/sundot/airport/ledger/domain/ScoreEvent.java

@@ -54,6 +54,18 @@ public class ScoreEvent extends BaseEntity {
54 54
     @Excel(name = "位置")
55 55
     private String location;
56 56
 
57
+    @Excel(name = "责任人ID")
58
+    private Long personId;
59
+
60
+    @Excel(name = "部门ID")
61
+    private Long deptId;
62
+
63
+    @Excel(name = "队室ID/班组ID")
64
+    private Long teamId;
65
+
66
+    @Excel(name = "小组ID")
67
+    private Long groupId;
68
+
57 69
     @Excel(name = "责任人")
58 70
     private String personName;
59 71
 
@@ -129,6 +141,18 @@ public class ScoreEvent extends BaseEntity {
129 141
     public String getLocation() { return location; }
130 142
     public void setLocation(String location) { this.location = location; }
131 143
 
144
+    public Long getPersonId() { return personId; }
145
+    public void setPersonId(Long personId) { this.personId = personId; }
146
+
147
+    public Long getDeptId() { return deptId; }
148
+    public void setDeptId(Long deptId) { this.deptId = deptId; }
149
+
150
+    public Long getTeamId() { return teamId; }
151
+    public void setTeamId(Long teamId) { this.teamId = teamId; }
152
+
153
+    public Long getGroupId() { return groupId; }
154
+    public void setGroupId(Long groupId) { this.groupId = groupId; }
155
+
132 156
     public String getPersonName() { return personName; }
133 157
     public void setPersonName(String personName) { this.personName = personName; }
134 158
 

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

@@ -1,10 +1,15 @@
1 1
 package com.sundot.airport.ledger.service.impl;
2 2
 
3
+import cn.hutool.core.util.StrUtil;
3 4
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5
+import com.sundot.airport.common.core.domain.entity.SysDept;
6
+import com.sundot.airport.common.core.domain.entity.SysUser;
4 7
 import com.sundot.airport.common.utils.DateUtils;
5 8
 import com.sundot.airport.ledger.domain.*;
6 9
 import com.sundot.airport.ledger.mapper.*;
7 10
 import com.sundot.airport.ledger.service.ILedgerSyncService;
11
+import com.sundot.airport.system.mapper.SysDeptMapper;
12
+import com.sundot.airport.system.mapper.SysUserMapper;
8 13
 import org.springframework.beans.factory.annotation.Autowired;
9 14
 import org.springframework.stereotype.Service;
10 15
 import org.springframework.transaction.annotation.Transactional;
@@ -53,9 +58,13 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
53 58
     @Autowired private ScoreEventMapper scoreEventMapper;
54 59
     @Autowired private ScoreDimensionMapper dimensionMapper;
55 60
     @Autowired private ScoreIndicatorMapper indicatorMapper;
61
+    @Autowired private SysDeptMapper sysDeptMapper;
62
+    @Autowired private SysUserMapper sysUserMapper;
56 63
 
57 64
     // ── Dimension ID cache (loaded once) ─────────────────────
58 65
     private final Map<String, Long> dimCache = new HashMap<>();
66
+    private final Map<String, Long> deptCache = new HashMap<>();
67
+    private final Map<String, Long> userCache = new HashMap<>();
59 68
 
60 69
     // ── Constants: Indicator IDs(与 score.sql 中的显式 ID 对应)─
61 70
     // dim1 安全防控能力
@@ -113,6 +122,8 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
113 122
     @Transactional(rollbackFor = Exception.class)
114 123
     public SyncResult syncAll() {
115 124
         loadDimCache();
125
+        loadDeptCache();
126
+        loadUserCache();
116 127
         StringBuilder sb = new StringBuilder();
117 128
         int totalIns = 0, totalSkip = 0;
118 129
         for (String type : Arrays.asList(
@@ -132,6 +143,8 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
132 143
     @Transactional(rollbackFor = Exception.class)
133 144
     public SyncResult syncByType(String ledgerType) {
134 145
         loadDimCache();
146
+        loadDeptCache();
147
+        loadUserCache();
135 148
         return doSync(ledgerType);
136 149
     }
137 150
 
@@ -427,6 +440,16 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
427 440
         dimensionMapper.selectList(new ScoreDimension()).forEach(d -> dimCache.put(d.getName(), d.getId()));
428 441
     }
429 442
 
443
+    private void loadDeptCache() {
444
+        if (!deptCache.isEmpty()) return;
445
+        sysDeptMapper.selectDeptList(new SysDept()).forEach(d -> deptCache.put(d.getDeptName(), d.getDeptId()));
446
+    }
447
+
448
+    private void loadUserCache() {
449
+        if (!userCache.isEmpty()) return;
450
+        sysUserMapper.selectUserList(new SysUser()).forEach(d -> userCache.put(d.getNickName(), d.getUserId()));
451
+    }
452
+
430 453
     private final Map<Long, ScoreIndicator> indCache = new HashMap<>();
431 454
     private ScoreIndicator getIndicator(long id) {
432 455
         return indCache.computeIfAbsent(id, indicatorMapper::selectById);
@@ -475,6 +498,18 @@ public class LedgerSyncServiceImpl implements ILedgerSyncService {
475 498
         e.setEvidenceFile(evidenceFile);
476 499
         e.setCreateBy("system");
477 500
         e.setCreateTime(DateUtils.getNowDate());
501
+        if (StrUtil.isNotEmpty(e.getPersonName())) {
502
+            e.setPersonId(userCache.get(e.getPersonName()));
503
+        }
504
+        if (StrUtil.isNotEmpty(e.getGroupName())) {
505
+            e.setGroupId(deptCache.get(e.getGroupName()));
506
+        }
507
+        if (StrUtil.isNotEmpty(e.getTeamName())) {
508
+            e.setTeamId(deptCache.get(e.getTeamName()));
509
+        }
510
+        if (StrUtil.isNotEmpty(e.getDeptName())) {
511
+            e.setDeptId(deptCache.get(e.getDeptName()));
512
+        }
478 513
         return e;
479 514
     }
480 515
 }