Преглед на файлове

ledger_seizure_stats表新增字段和导入功能字段数据新增

wangxx преди 1 месец
родител
ревизия
959231fdb2

+ 98 - 0
airport-ledger/src/main/java/com/sundot/airport/ledger/domain/LedgerSeizureStats.java

@@ -27,36 +27,83 @@ public class LedgerSeizureStats extends BaseEntity {
27 27
     @Excel(name = "部门名称")
28 28
     private String deptName;
29 29
 
30
+    private Long deptId;
31
+
30 32
     @Excel(name = "队室/班组")
31 33
     private String teamName;
32 34
 
35
+    private Long teamId;
36
+
37
+    @Excel(name = "工作区域")
38
+    private String workArea;
39
+
40
+    @Excel(name = "安检资格证书等级")
41
+    private String qualificationLevel;
42
+
43
+    @Excel(name = "岗位")
44
+    private String position;
45
+
33 46
     @Excel(name = "小组")
34 47
     private String groupName;
35 48
 
49
+    private Long groupId;
50
+
36 51
     @Excel(name = "查获人")
37 52
     private String inspectorName;
38 53
 
54
+    private Long inspectorId;
55
+
39 56
     @Excel(name = "通道号")
40 57
     private String channelNo;
41 58
 
42 59
     @Excel(name = "旅客姓名")
43 60
     private String passengerName;
44 61
 
62
+    @Excel(name = "旅客性别")
63
+    private String passengerGender;
64
+
65
+    @Excel(name = "旅客民族")
66
+    private String passengerEthnicity;
67
+
68
+    @Excel(name = "旅客年龄")
69
+    private Integer passengerAge;
70
+
45 71
     @Excel(name = "航班号")
46 72
     private String flightNo;
47 73
 
74
+    @Excel(name = "目的地")
75
+    private String destination;
76
+
77
+    @Excel(name = "进/出港")
78
+    private String inOutPort;
79
+
80
+    @Excel(name = "违规主体")
81
+    private String violationSubject;
82
+
48 83
     @Excel(name = "违规品类别")
49 84
     private String itemCategory;
50 85
 
86
+    @Excel(name = "二级分类")
87
+    private String secondaryCategory;
88
+
51 89
     @Excel(name = "违规品名称")
52 90
     private String itemName;
53 91
 
54 92
     @Excel(name = "数量")
55 93
     private Integer itemQuantity;
56 94
 
95
+    @Excel(name = "查获数量")
96
+    private Integer seizureQuantity;
97
+
57 98
     @Excel(name = "藏匿部位")
58 99
     private String concealmentPart;
59 100
 
101
+    @Excel(name = "事件简况")
102
+    private String eventBrief;
103
+
104
+    @Excel(name = "队室内勤")
105
+    private String teamInternalDuty;
106
+
60 107
     @Excel(name = "检查方式")
61 108
     private String checkMethod;
62 109
 
@@ -95,36 +142,87 @@ public class LedgerSeizureStats extends BaseEntity {
95 142
     public String getDeptName() { return deptName; }
96 143
     public void setDeptName(String deptName) { this.deptName = deptName; }
97 144
 
145
+    public Long getDeptId() { return deptId; }
146
+    public void setDeptId(Long deptId) { this.deptId = deptId; }
147
+
98 148
     public String getTeamName() { return teamName; }
99 149
     public void setTeamName(String teamName) { this.teamName = teamName; }
100 150
 
151
+    public Long getTeamId() { return teamId; }
152
+    public void setTeamId(Long teamId) { this.teamId = teamId; }
153
+
154
+    public String getWorkArea() { return workArea; }
155
+    public void setWorkArea(String workArea) { this.workArea = workArea; }
156
+
157
+    public String getQualificationLevel() { return qualificationLevel; }
158
+    public void setQualificationLevel(String qualificationLevel) { this.qualificationLevel = qualificationLevel; }
159
+
160
+    public String getPosition() { return position; }
161
+    public void setPosition(String position) { this.position = position; }
162
+
101 163
     public String getGroupName() { return groupName; }
102 164
     public void setGroupName(String groupName) { this.groupName = groupName; }
103 165
 
166
+    public Long getGroupId() { return groupId; }
167
+    public void setGroupId(Long groupId) { this.groupId = groupId; }
168
+
104 169
     public String getInspectorName() { return inspectorName; }
105 170
     public void setInspectorName(String inspectorName) { this.inspectorName = inspectorName; }
106 171
 
172
+    public Long getInspectorId() { return inspectorId; }
173
+    public void setInspectorId(Long inspectorId) { this.inspectorId = inspectorId; }
174
+
107 175
     public String getChannelNo() { return channelNo; }
108 176
     public void setChannelNo(String channelNo) { this.channelNo = channelNo; }
109 177
 
110 178
     public String getPassengerName() { return passengerName; }
111 179
     public void setPassengerName(String passengerName) { this.passengerName = passengerName; }
112 180
 
181
+    public String getPassengerGender() { return passengerGender; }
182
+    public void setPassengerGender(String passengerGender) { this.passengerGender = passengerGender; }
183
+
184
+    public String getPassengerEthnicity() { return passengerEthnicity; }
185
+    public void setPassengerEthnicity(String passengerEthnicity) { this.passengerEthnicity = passengerEthnicity; }
186
+
187
+    public Integer getPassengerAge() { return passengerAge; }
188
+    public void setPassengerAge(Integer passengerAge) { this.passengerAge = passengerAge; }
189
+
113 190
     public String getFlightNo() { return flightNo; }
114 191
     public void setFlightNo(String flightNo) { this.flightNo = flightNo; }
115 192
 
193
+    public String getDestination() { return destination; }
194
+    public void setDestination(String destination) { this.destination = destination; }
195
+
196
+    public String getInOutPort() { return inOutPort; }
197
+    public void setInOutPort(String inOutPort) { this.inOutPort = inOutPort; }
198
+
199
+    public String getViolationSubject() { return violationSubject; }
200
+    public void setViolationSubject(String violationSubject) { this.violationSubject = violationSubject; }
201
+
116 202
     public String getItemCategory() { return itemCategory; }
117 203
     public void setItemCategory(String itemCategory) { this.itemCategory = itemCategory; }
118 204
 
205
+    public String getSecondaryCategory() { return secondaryCategory; }
206
+    public void setSecondaryCategory(String secondaryCategory) { this.secondaryCategory = secondaryCategory; }
207
+
119 208
     public String getItemName() { return itemName; }
120 209
     public void setItemName(String itemName) { this.itemName = itemName; }
121 210
 
122 211
     public Integer getItemQuantity() { return itemQuantity; }
123 212
     public void setItemQuantity(Integer itemQuantity) { this.itemQuantity = itemQuantity; }
124 213
 
214
+    public Integer getSeizureQuantity() { return seizureQuantity; }
215
+    public void setSeizureQuantity(Integer seizureQuantity) { this.seizureQuantity = seizureQuantity; }
216
+
125 217
     public String getConcealmentPart() { return concealmentPart; }
126 218
     public void setConcealmentPart(String concealmentPart) { this.concealmentPart = concealmentPart; }
127 219
 
220
+    public String getEventBrief() { return eventBrief; }
221
+    public void setEventBrief(String eventBrief) { this.eventBrief = eventBrief; }
222
+
223
+    public String getTeamInternalDuty() { return teamInternalDuty; }
224
+    public void setTeamInternalDuty(String teamInternalDuty) { this.teamInternalDuty = teamInternalDuty; }
225
+
128 226
     public String getCheckMethod() { return checkMethod; }
129 227
     public void setCheckMethod(String checkMethod) { this.checkMethod = checkMethod; }
130 228
 

+ 169 - 4
airport-ledger/src/main/java/com/sundot/airport/ledger/service/impl/LedgerCombinedImportServiceImpl.java

@@ -2,6 +2,8 @@ package com.sundot.airport.ledger.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.sundot.airport.common.core.domain.entity.SysDept;
6
+import com.sundot.airport.common.core.domain.entity.SysUser;
5 7
 import com.sundot.airport.ledger.domain.*;
6 8
 import com.sundot.airport.ledger.domain.LedgerDailyTraining;
7 9
 import com.sundot.airport.ledger.domain.LedgerLeaderDuty;
@@ -14,6 +16,8 @@ import com.sundot.airport.ledger.service.ILedgerLeaderDutyService;
14 16
 import com.sundot.airport.ledger.service.ILedgerHealthSoldierService;
15 17
 import com.sundot.airport.ledger.service.ILedgerDormFireSafetyService;
16 18
 import com.sundot.airport.ledger.service.ILedgerTrainingIssueService;
19
+import com.sundot.airport.system.mapper.SysDeptMapper;
20
+import com.sundot.airport.system.mapper.SysUserMapper;
17 21
 import org.apache.poi.ss.usermodel.*;
18 22
 import org.springframework.beans.factory.annotation.Autowired;
19 23
 import org.springframework.stereotype.Service;
@@ -54,6 +58,11 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
54 58
     @Autowired private ILedgerDormFireSafetyService dormFireSafetyService;
55 59
     @Autowired private ILedgerTrainingIssueService trainingIssueService;
56 60
     @Autowired private IScoreEventService scoreEventService;
61
+    @Autowired private SysUserMapper sysUserMapper;
62
+    @Autowired private SysDeptMapper sysDeptMapper;
63
+
64
+    // 导入缓存(在导入开始时构建,导入结束后释放)
65
+    private ImportCache importCache;
57 66
 
58 67
     // ── Sheet 名称 → 处理方法路由表 ──────────────────────────────────
59 68
     private static final Map<String, String> SHEET_ROUTE = new LinkedHashMap<>();
@@ -91,6 +100,9 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
91 100
     public Map<String, String> importAll(MultipartFile file, String batchNo, String username) throws Exception {
92 101
         Map<String, String> result = new LinkedHashMap<>();
93 102
         try (Workbook wb = WorkbookFactory.create(file.getInputStream())) {
103
+            // 构建导入缓存
104
+            buildImportCache();
105
+            
94 106
             for (Map.Entry<String, String> entry : SHEET_ROUTE.entrySet()) {
95 107
                 String sheetName = entry.getKey();
96 108
                 String handler   = entry.getValue();
@@ -106,6 +118,9 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
106 118
                     result.put(sheetName, "错误: " + e.getMessage());
107 119
                 }
108 120
             }
121
+        } finally {
122
+            // 导入完成后释放缓存
123
+            clearImportCache();
109 124
         }
110 125
         return result;
111 126
     }
@@ -389,8 +404,11 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
389 404
     }
390 405
 
391 406
     /** 9. 2026查获违规品统计 → ledger_seizure_stats
392
-     * R2: 查获时间(0) ...(1,2) 部门/队室(3) 区域(4) 安检员(5) ...
393
-     *     航班号(8) ... 旅客姓名(12) ... 违规类别(16) 物品种类(17) ...(18) 数量(19)
407
+     * R2: 查获时间(0) 信息提取(1) 信息提取2(2) 部门/队室(3) 工作区域(4) 安检员(5)
408
+     *     安检资格证书等级(6) 岗位(7) 航班号(8) 目的地(9) 进/出港(10) 违规主体(11)
409
+     *     旅客姓名(12) 旅客性别(13) 旅客民族(14) 旅客年龄(15) 违规类别(16)
410
+     *     违规物品种类(17) 二级分类(18) 数量(19) 事件简况(20) 查获位置(21)
411
+     *     处理结果(22) 班组(23) 队室内勤(24) 备注(25) 查获数量(26)
394 412
      */
395 413
     private int doSeizureStats(Sheet sheet, String batchNo, String username) {
396 414
         List<LedgerSeizureStats> list = new ArrayList<>();
@@ -398,12 +416,39 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
398 416
             LedgerSeizureStats o = new LedgerSeizureStats();
399 417
             o.setRecordDate(date(c, 0));
400 418
             o.setTeamName(str(c, 3));
401
-            o.setInspectorName(str(c, 5));
419
+            o.setWorkArea(str(c, 4));
420
+            String inspectorName = str(c, 5);
421
+            o.setInspectorName(inspectorName);
422
+            o.setQualificationLevel(str(c, 6));
423
+            o.setPosition(str(c, 7));
402 424
             o.setFlightNo(str(c, 8));
425
+            o.setDestination(str(c, 9));
426
+            o.setInOutPort(str(c, 10));
427
+            o.setViolationSubject(str(c, 11));
403 428
             o.setPassengerName(str(c, 12));
429
+            o.setPassengerGender(str(c, 13));
430
+            o.setPassengerEthnicity(str(c, 14));
431
+            o.setPassengerAge(integer(c, 15));
404 432
             o.setItemCategory(str(c, 16));
405
-            o.setItemName(str(c, 17));
433
+            o.setItemName(str(c, 17));  // 违规物品种类
434
+            o.setSecondaryCategory(str(c, 18));
406 435
             o.setItemQuantity(integer(c, 19));
436
+            o.setEventBrief(str(c, 20));
437
+            o.setConcealmentPart(str(c, 21));   // 查获位置
438
+            o.setHandlingMethod(str(c, 22));  // 处理结果
439
+            o.setTeamInternalDuty(str(c, 24));
440
+            o.setRemark(str(c, 25));
441
+            o.setSeizureQuantity(integer(c, 26));  // 查获数量
442
+                
443
+            // 使用缓存查找组织信息
444
+            Map<String, Long> orgInfo = resolveOrgInfoByNameWithCache(inspectorName);
445
+            if (!orgInfo.isEmpty()) {
446
+                o.setInspectorId(orgInfo.get("userId"));
447
+                o.setDeptId(orgInfo.get("deptId"));
448
+                o.setTeamId(orgInfo.get("teamId"));
449
+                o.setGroupId(orgInfo.get("groupId"));
450
+            }
451
+                
407 452
             o.setImportBatch(batchNo);
408 453
             o.setSourceType("1");
409 454
             o.setCreateBy(username);
@@ -864,4 +909,124 @@ public class LedgerCombinedImportServiceImpl implements ILedgerCombinedImportSer
864 909
         }
865 910
         return count;
866 911
     }
912
+
913
+    // ════════════════════════════════════════════════════════════════
914
+    //  导入缓存类
915
+    // ════════════════════════════════════════════════════════════════
916
+
917
+    /**
918
+     * 导入时的统一缓存,避免重复查询数据库
919
+     */
920
+    private static class ImportCache {
921
+        private final Map<String, SysUser> userCache;      // Map<昵称, 用户>
922
+        private final Map<Long, SysDept> deptCache;        // Map<部门ID, 部门>
923
+
924
+        public ImportCache(Map<String, SysUser> userCache, Map<Long, SysDept> deptCache) {
925
+            this.userCache = userCache;
926
+            this.deptCache = deptCache;
927
+        }
928
+
929
+        public SysUser getUserByNickName(String nickName) {
930
+            return userCache.get(nickName);
931
+        }
932
+
933
+        public SysDept getDeptById(Long deptId) {
934
+            return deptCache.get(deptId);
935
+        }
936
+    }
937
+
938
+    // ════════════════════════════════════════════════════════════════
939
+    //  辅助方法:根据人员名称补充组织信息
940
+    // ════════════════════════════════════════════════════════════════
941
+
942
+    /**
943
+     * 根据人员名称查找用户,并补充组织架构ID
944
+     * @param personName 人员名称
945
+     * @return Map包含: userId, deptId(BRIGADE), teamId(MANAGER), groupId(TEAMS)
946
+     */
947
+    private Map<String, Long> resolveOrgInfoByNameWithCache(String personName) {
948
+        Map<String, Long> result = new HashMap<>();
949
+        if (personName == null || personName.trim().isEmpty() || importCache == null) {
950
+            return result;
951
+        }
952
+
953
+        String name = personName.trim();
954
+        
955
+        // 1. 从缓存中查找用户
956
+        SysUser user = importCache.getUserByNickName(name);
957
+        if (user == null || user.getDeptId() == null) {
958
+            return result;
959
+        }
960
+
961
+        result.put("userId", user.getUserId());
962
+
963
+        // 2. 从缓存中获取用户部门信息
964
+        SysDept userDept = importCache.getDeptById(user.getDeptId());
965
+        if (userDept == null) {
966
+            return result;
967
+        }
968
+
969
+        String deptType = userDept.getDeptType();
970
+
971
+        // 3. 根据部门类型递归获取各级组织ID
972
+        if ("BRIGADE".equals(deptType)) {
973
+            // 用户部门是大队
974
+            result.put("deptId", user.getDeptId());
975
+        } else if ("MANAGER".equals(deptType)) {
976
+            // 用户部门是队室/班组,向上找大队
977
+            result.put("teamId", user.getDeptId());
978
+            if (userDept.getParentId() != null && userDept.getParentId() != 0) {
979
+                result.put("deptId", userDept.getParentId());
980
+            }
981
+        } else if ("TEAMS".equals(deptType)) {
982
+            // 用户部门是小组,向上找队室和大队
983
+            result.put("groupId", user.getDeptId());
984
+            if (userDept.getParentId() != null && userDept.getParentId() != 0) {
985
+                result.put("teamId", userDept.getParentId());
986
+                // 从缓存中获取父级部门
987
+                SysDept parentDept = importCache.getDeptById(userDept.getParentId());
988
+                if (parentDept != null && parentDept.getParentId() != null && parentDept.getParentId() != 0) {
989
+                    result.put("deptId", parentDept.getParentId());
990
+                }
991
+            }
992
+        }
993
+
994
+        return result;
995
+    }
996
+
997
+    /**
998
+     * 构建导入缓存
999
+     */
1000
+    private void buildImportCache() {
1001
+        // 构建用户缓存:Map<昵称, SysUser>
1002
+        Map<String, SysUser> userCache = new HashMap<>();
1003
+        List<SysUser> allUsers = sysUserMapper.selectUserList(new SysUser());
1004
+        if (allUsers != null) {
1005
+            for (SysUser user : allUsers) {
1006
+                if (user.getNickName() != null && !user.getNickName().trim().isEmpty()) {
1007
+                    userCache.put(user.getNickName().trim(), user);
1008
+                }
1009
+            }
1010
+        }
1011
+
1012
+        // 构建部门缓存:Map<部门ID, SysDept>
1013
+        Map<Long, SysDept> deptCache = new HashMap<>();
1014
+        SysDept queryDept = new SysDept();
1015
+        List<SysDept> allDepts = sysDeptMapper.selectDeptList(queryDept);
1016
+        if (allDepts != null) {
1017
+            for (SysDept dept : allDepts) {
1018
+                deptCache.put(dept.getDeptId(), dept);
1019
+            }
1020
+        }
1021
+
1022
+        // 创建统一缓存对象
1023
+        this.importCache = new ImportCache(userCache, deptCache);
1024
+    }
1025
+
1026
+    /**
1027
+     * 释放导入缓存
1028
+     */
1029
+    private void clearImportCache() {
1030
+        this.importCache = null;
1031
+    }
867 1032
 }

Файловите разлики са ограничени, защото са твърде много
+ 20 - 2
airport-ledger/src/main/resources/mapper/ledger/LedgerSeizureStatsMapper.xml