chenshudong 1 miesiąc temu
rodzic
commit
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
         } else {
715
         } else {
716
             List<QualificationStats> qualificationLevelStats = systemResult.getQualificationLevelStats();
716
             List<QualificationStats> qualificationLevelStats = systemResult.getQualificationLevelStats();
717
             if (qualificationLevelStats != null) {
717
             if (qualificationLevelStats != null) {
718
-                final String FIRST_LEVEL = "LEVEL_ONE";
718
+                final String FIRST_LEVEL = "高级";
719
                 Integer reduce = qualificationLevelStats.stream()
719
                 Integer reduce = qualificationLevelStats.stream()
720
                         .filter(qualificationStats -> FIRST_LEVEL.equals(qualificationStats.getLevelName()))
720
                         .filter(qualificationStats -> FIRST_LEVEL.equals(qualificationStats.getLevelName()))
721
                         .map(QualificationStats::getCount)
721
                         .map(QualificationStats::getCount)

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

@@ -1,21 +1,17 @@
1
 package com.sundot.airport.system.service.portrait;
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
 import com.sundot.airport.common.domain.portrait.BaseModuleIndicatorResult;
3
 import com.sundot.airport.common.domain.portrait.BaseModuleIndicatorResult;
6
 import com.sundot.airport.common.domain.portrait.IndicatorCalculateParams;
4
 import com.sundot.airport.common.domain.portrait.IndicatorCalculateParams;
7
 import com.sundot.airport.common.enums.portrait.IndicatorType;
5
 import com.sundot.airport.common.enums.portrait.IndicatorType;
8
 import com.sundot.airport.common.enums.portrait.UserType;
6
 import com.sundot.airport.common.enums.portrait.UserType;
9
 import com.sundot.airport.common.service.portrait.Indicator;
7
 import com.sundot.airport.common.service.portrait.Indicator;
10
-import com.sundot.airport.common.utils.SecurityUtils;
11
 import com.sundot.airport.system.domain.portrait.IndicatorResult;
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
 import com.sundot.airport.system.mapper.portrait.QualificationLevelIndicatorMapper;
10
 import com.sundot.airport.system.mapper.portrait.QualificationLevelIndicatorMapper;
14
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.stereotype.Component;
12
 import org.springframework.stereotype.Component;
16
 
13
 
17
 import java.util.List;
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
         List<Long> userIds = params.getUserIds();
65
         List<Long> userIds = params.getUserIds();
70
         if (UserType.PERSONAL.equals(userType)) {
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
         } else {
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
     @Override
138
     @Override
80
     public void setResult(BaseModuleIndicatorResult result) {
139
     public void setResult(BaseModuleIndicatorResult result) {
81
         if (result instanceof IndicatorResult) {
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
     <select id="queryPersonalQualificationLevel" parameterType="Long" resultType="String">
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
         FROM sys_user
24
         FROM sys_user
31
         WHERE user_id = #{userId}
25
         WHERE user_id = #{userId}
32
     </select>
26
     </select>
@@ -34,12 +28,7 @@
34
     <!-- 查询组织资质等级统计 -->
28
     <!-- 查询组织资质等级统计 -->
35
     <select id="queryOrgQualificationLevelStats" resultMap="QualificationStatsResult">
29
     <select id="queryOrgQualificationLevelStats" resultMap="QualificationStatsResult">
36
         SELECT
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
         COUNT(*) as count,
32
         COUNT(*) as count,
44
         (SELECT COUNT(*) FROM sys_user WHERE user_id in
33
         (SELECT COUNT(*) FROM sys_user WHERE user_id in
45
         <include refid="userIdsCondition"/>
34
         <include refid="userIdsCondition"/>
@@ -51,13 +40,7 @@
51
         <include refid="userIdsCondition"/>
40
         <include refid="userIdsCondition"/>
52
         and del_flag='0' and status='0'
41
         and del_flag='0' and status='0'
53
         AND qualification_level IS NOT NULL
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
     </select>
44
     </select>
62
 
45
 
63
 </mapper>
46
 </mapper>