Explorar el Código

给抽问抽答统计,站级增加:"主管正确率排名
正序前三名和倒序后三名的主管,展示名称为“一大队方圆主管”,后面标注正确率"

simonlll hace 2 meses
padre
commit
04f39af2bc

+ 6 - 1
airport-exam/src/main/java/com/sundot/airport/exam/dto/AccuracyStatisticsDTO.java

@@ -118,11 +118,16 @@ public class AccuracyStatisticsDTO implements Serializable {
118 118
     private RankingInfo deptInSiteRanking;
119 119
 
120 120
     /**
121
-     * Top主管(科室)
121
+     * Top主管(科室)- 正序前三名
122 122
      */
123 123
     private java.util.List<RankingItem> topDepts;
124 124
 
125 125
     /**
126
+     * Bottom主管(科室)- 倒序后三名
127
+     */
128
+    private java.util.List<RankingItem> bottomDepts;
129
+
130
+    /**
126 131
      * 站级内Top班组
127 132
      */
128 133
     private java.util.List<RankingItem> topTeamsInSite;

+ 77 - 0
airport-exam/src/main/java/com/sundot/airport/exam/service/impl/AccuracyStatisticsServiceImpl.java

@@ -1035,6 +1035,21 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
1035 1035
             }
1036 1036
         }
1037 1037
 
1038
+        // 站长用户特殊处理:返回主管正确率排名前三和后三
1039
+        if (hierarchy.stationId != null && hierarchy.managerId == null && hierarchy.teamId == null) {
1040
+            // 当前用户是站长,计算所有主管的排名
1041
+            List<TeamAccuracyInfo> managersInStation = calculateManagerAccuraciesUnderStation(hierarchy.stationId, startDate, endDate);
1042
+            if (!managersInStation.isEmpty()) {
1043
+                // Top主管(取前3)- 格式如"一大队方圆主管"
1044
+                List<AccuracyStatisticsDTO.RankingItem> topDepts = convertToManagerRankingItems(managersInStation, 3, true);
1045
+                result.setTopDepts(topDepts);
1046
+
1047
+                // Bottom主管(取后3)- 格式如"一大队方圆主管"
1048
+                List<AccuracyStatisticsDTO.RankingItem> bottomDepts = convertToManagerRankingItems(managersInStation, 3, false);
1049
+                result.setBottomDepts(bottomDepts);
1050
+            }
1051
+        }
1052
+
1038 1053
         // 主管用户特殊处理:主管内Top班组
1039 1054
         if (hierarchy.teamId == null && hierarchy.managerId != null) {
1040 1055
             // 当前用户是主管,计算该主管下的班组排名
@@ -1212,6 +1227,68 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
1212 1227
     }
1213 1228
 
1214 1229
     /**
1230
+     * 将主管排名列表转换为RankingItem列表,名称格式为"大队名+主管名"
1231
+     * @param rankings 排名列表(已按正确率降序排序)
1232
+     * @param limit 取多少个
1233
+     * @param fromTop true=从头取(Top),false=从尾取(Bottom)
1234
+     */
1235
+    private List<AccuracyStatisticsDTO.RankingItem> convertToManagerRankingItems(List<TeamAccuracyInfo> rankings, int limit, boolean fromTop) {
1236
+        List<AccuracyStatisticsDTO.RankingItem> result = new ArrayList<>();
1237
+
1238
+        if (rankings.isEmpty()) {
1239
+            return result;
1240
+        }
1241
+
1242
+        int size = rankings.size();
1243
+        int actualLimit = Math.min(limit, size);
1244
+
1245
+        if (fromTop) {
1246
+            // 取前N个
1247
+            for (int i = 0; i < actualLimit; i++) {
1248
+                TeamAccuracyInfo info = rankings.get(i);
1249
+                AccuracyStatisticsDTO.RankingItem item = new AccuracyStatisticsDTO.RankingItem();
1250
+                item.setId(info.deptId);
1251
+                item.setName(getManagerDisplayName(info.deptId, info.deptName));
1252
+                item.setAccuracy(info.accuracy);
1253
+                item.setRank(i + 1);
1254
+                result.add(item);
1255
+            }
1256
+        } else {
1257
+            // 取后N个(倒序)
1258
+            for (int i = size - actualLimit; i < size; i++) {
1259
+                TeamAccuracyInfo info = rankings.get(i);
1260
+                AccuracyStatisticsDTO.RankingItem item = new AccuracyStatisticsDTO.RankingItem();
1261
+                item.setId(info.deptId);
1262
+                item.setName(getManagerDisplayName(info.deptId, info.deptName));
1263
+                item.setAccuracy(info.accuracy);
1264
+                item.setRank(i + 1);
1265
+                result.add(item);
1266
+            }
1267
+        }
1268
+
1269
+        return result;
1270
+    }
1271
+
1272
+    /**
1273
+     * 获取主管显示名称,格式为"大队名+主管名",如"一大队方圆主管"
1274
+     */
1275
+    private String getManagerDisplayName(Long managerId, String managerName) {
1276
+        SysDept managerDept = deptService.selectDeptById(managerId);
1277
+        if (managerDept == null) {
1278
+            return managerName;
1279
+        }
1280
+        // 获取主管所属大队
1281
+        Long brigadeId = managerDept.getParentId();
1282
+        if (brigadeId != null) {
1283
+            SysDept brigadeDept = deptService.selectDeptById(brigadeId);
1284
+            if (brigadeDept != null && StrUtil.equals(DeptType.BRIGADE.getCode(), brigadeDept.getDeptType())) {
1285
+                return brigadeDept.getDeptName() + managerName;
1286
+            }
1287
+        }
1288
+        return managerName;
1289
+    }
1290
+
1291
+    /**
1215 1292
      * 班组/部门正确率信息
1216 1293
      */
1217 1294
     private static class TeamAccuracyInfo {