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