|
|
@@ -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) {
|