chenshudong 1 місяць тому
батько
коміт
90b85ad2b3

+ 1 - 1
airport-admin/src/main/java/com/sundot/airport/web/controller/system/SysUserController.java

@@ -715,7 +715,7 @@ public class SysUserController extends BaseController {
715 715
         } else {
716 716
             List<QualificationStats> qualificationLevelStats = systemResult.getQualificationLevelStats();
717 717
             if (qualificationLevelStats != null) {
718
-                final String FIRST_LEVEL = "LEVEL_ONE";
718
+                final String FIRST_LEVEL = "高级";
719 719
                 Integer reduce = qualificationLevelStats.stream()
720 720
                         .filter(qualificationStats -> FIRST_LEVEL.equals(qualificationStats.getLevelName()))
721 721
                         .map(QualificationStats::getCount)

+ 66 - 7
airport-system/src/main/java/com/sundot/airport/system/service/portrait/QualificationLevelIndicator.java

@@ -1,21 +1,17 @@
1 1
 package com.sundot.airport.system.service.portrait;
2 2
 
3
-import cn.hutool.core.collection.CollectionUtil;
4
-import com.sundot.airport.common.core.domain.entity.SysUser;
5 3
 import com.sundot.airport.common.domain.portrait.BaseModuleIndicatorResult;
6 4
 import com.sundot.airport.common.domain.portrait.IndicatorCalculateParams;
7 5
 import com.sundot.airport.common.enums.portrait.IndicatorType;
8 6
 import com.sundot.airport.common.enums.portrait.UserType;
9 7
 import com.sundot.airport.common.service.portrait.Indicator;
10
-import com.sundot.airport.common.utils.SecurityUtils;
11 8
 import com.sundot.airport.system.domain.portrait.IndicatorResult;
12
-import com.sundot.airport.system.mapper.SysUserMapper;
9
+import com.sundot.airport.system.domain.portrait.QualificationStats;
13 10
 import com.sundot.airport.system.mapper.portrait.QualificationLevelIndicatorMapper;
14 11
 import org.springframework.beans.factory.annotation.Autowired;
15 12
 import org.springframework.stereotype.Component;
16 13
 
17 14
 import java.util.List;
18
-import java.util.stream.Collectors;
19 15
 
20 16
 /**
21 17
  * 资质等级指标类
@@ -69,13 +65,76 @@ public class QualificationLevelIndicator implements Indicator<Object> {
69 65
         List<Long> userIds = params.getUserIds();
70 66
         if (UserType.PERSONAL.equals(userType)) {
71 67
             // 个人资质等级
72
-            this.value = mapper.queryPersonalQualificationLevel(userId);
68
+            String level = mapper.queryPersonalQualificationLevel(userId);
69
+            this.value = convertToDisplayLevel(level);
73 70
         } else {
74 71
             // 组织资质等级统计
75
-            this.value = mapper.queryOrgQualificationLevelStats(userIds, userType);
72
+            List<QualificationStats> stats = mapper.queryOrgQualificationLevelStats(userIds, userType);
73
+            this.value = convertStatsToDisplayLevel(stats);
76 74
         }
77 75
     }
78 76
 
77
+    /**
78
+     * 将数据库枚举值转换为显示名称(初级、中级、高级)
79
+     *
80
+     * @param dbValue 数据库枚举值(如 LEVEL_ONE)
81
+     * @return 显示名称(如 高级)
82
+     */
83
+    private String convertToDisplayLevel(String dbValue) {
84
+        if (dbValue == null || dbValue.trim().isEmpty()) {
85
+            return null;
86
+        }
87
+        switch (dbValue.toUpperCase()) {
88
+            case "LEVEL_FIVE":
89
+                return "初级";
90
+            case "LEVEL_FOUR":
91
+                return "中级";
92
+            case "LEVEL_ONE":
93
+            case "LEVEL_TWO":
94
+            case "LEVEL_THREE":
95
+                return "高级";
96
+            default:
97
+                return dbValue;
98
+        }
99
+    }
100
+
101
+    /**
102
+     * 将资质等级统计列表转换为显示名称
103
+     *
104
+     * @param statsList 原始统计列表
105
+     * @return 转换后的统计列表
106
+     */
107
+    private List<QualificationStats> convertStatsToDisplayLevel(List<QualificationStats> statsList) {
108
+        if (statsList == null || statsList.isEmpty()) {
109
+            return statsList;
110
+        }
111
+
112
+        // 按新的分类(初级、中级、高级)重新分组统计
113
+        java.util.Map<String, QualificationStats> groupedStats = new java.util.HashMap<>();
114
+        int totalCount = statsList.stream().mapToInt(QualificationStats::getCount).sum();
115
+
116
+        for (QualificationStats stat : statsList) {
117
+            String displayLevel = convertToDisplayLevel(stat.getLevelName());
118
+
119
+            if (!groupedStats.containsKey(displayLevel)) {
120
+                QualificationStats newStat = new QualificationStats();
121
+                newStat.setLevelName(displayLevel);
122
+                newStat.setCount(stat.getCount());
123
+                newStat.setTotalCount(totalCount);
124
+                newStat.setPercentage(stat.getPercentage());
125
+                groupedStats.put(displayLevel, newStat);
126
+            } else {
127
+                // 合并相同等级的统计(如一级、二级、三级都合并为高级)
128
+                QualificationStats existing = groupedStats.get(displayLevel);
129
+                existing.setCount(existing.getCount() + stat.getCount());
130
+                // 重新计算百分比
131
+                existing.setPercentage(Math.round(existing.getCount() * 100.0 / totalCount * 100.0) / 100.0);
132
+            }
133
+        }
134
+
135
+        return new java.util.ArrayList<>(groupedStats.values());
136
+    }
137
+
79 138
     @Override
80 139
     public void setResult(BaseModuleIndicatorResult result) {
81 140
         if (result instanceof IndicatorResult) {

+ 3 - 20
airport-system/src/main/resources/mapper/portrait/QualificationLevelIndicatorMapper.xml

@@ -20,13 +20,7 @@
20 20
 
21 21
     <!-- 查询个人资质等级 -->
22 22
     <select id="queryPersonalQualificationLevel" parameterType="Long" resultType="String">
23
-        SELECT
24
-            CASE
25
-                WHEN qualification_level = 'LEVEL_FIVE' THEN '初级'
26
-                WHEN qualification_level = 'LEVEL_FOUR' THEN '中级'
27
-                WHEN qualification_level IN ('LEVEL_ONE', 'LEVEL_TWO', 'LEVEL_THREE') THEN '高级'
28
-                ELSE NULL
29
-                END as qualification_level
23
+        SELECT qualification_level
30 24
         FROM sys_user
31 25
         WHERE user_id = #{userId}
32 26
     </select>
@@ -34,12 +28,7 @@
34 28
     <!-- 查询组织资质等级统计 -->
35 29
     <select id="queryOrgQualificationLevelStats" resultMap="QualificationStatsResult">
36 30
         SELECT
37
-        CASE
38
-        WHEN qualification_level = 'LEVEL_FIVE' THEN '初级'
39
-        WHEN qualification_level = 'LEVEL_FOUR' THEN '中级'
40
-        WHEN qualification_level IN ('LEVEL_ONE', 'LEVEL_TWO', 'LEVEL_THREE') THEN '高级'
41
-        ELSE '未知'
42
-        END as level_name,
31
+        qualification_level as level_name,
43 32
         COUNT(*) as count,
44 33
         (SELECT COUNT(*) FROM sys_user WHERE user_id in
45 34
         <include refid="userIdsCondition"/>
@@ -51,13 +40,7 @@
51 40
         <include refid="userIdsCondition"/>
52 41
         and del_flag='0' and status='0'
53 42
         AND qualification_level IS NOT NULL
54
-        GROUP BY
55
-        CASE
56
-        WHEN qualification_level = 'LEVEL_FIVE' THEN '初级'
57
-        WHEN qualification_level = 'LEVEL_FOUR' THEN '中级'
58
-        WHEN qualification_level IN ('LEVEL_ONE', 'LEVEL_TWO', 'LEVEL_THREE') THEN '高级'
59
-        ELSE '未知'
60
-        END
43
+        GROUP BY qualification_level
61 44
     </select>
62 45
 
63 46
 </mapper>