|
|
@@ -334,10 +334,8 @@ public class BlockedDashboardServiceImpl implements IBlockedDashboardService {
|
|
334
|
334
|
public List<BlockedRankingDTO> getSupervisorRanking(BlockedDashboardQueryDTO queryDTO) {
|
|
335
|
335
|
List<BlockedRankingDTO> resultList = blockedDashboardMapper.selectSupervisorRanking(queryDTO);
|
|
336
|
336
|
if (CollectionUtil.isNotEmpty(resultList)) {
|
|
337
|
|
- // 计算排名
|
|
338
|
|
- for (int i = 0; i < resultList.size(); i++) {
|
|
339
|
|
- resultList.get(i).setRank(i + 1);
|
|
340
|
|
- }
|
|
|
337
|
+ // 计算并列排名并限制前30条
|
|
|
338
|
+ return calculateDenseRankingWithLimit(resultList, 30);
|
|
341
|
339
|
}
|
|
342
|
340
|
return resultList != null ? resultList : Collections.emptyList();
|
|
343
|
341
|
}
|
|
|
@@ -352,10 +350,8 @@ public class BlockedDashboardServiceImpl implements IBlockedDashboardService {
|
|
352
|
350
|
public List<BlockedRankingDTO> getTeamLeaderRanking(BlockedDashboardQueryDTO queryDTO) {
|
|
353
|
351
|
List<BlockedRankingDTO> resultList = blockedDashboardMapper.selectTeamLeaderRanking(queryDTO);
|
|
354
|
352
|
if (CollectionUtil.isNotEmpty(resultList)) {
|
|
355
|
|
- // 计算排名
|
|
356
|
|
- for (int i = 0; i < resultList.size(); i++) {
|
|
357
|
|
- resultList.get(i).setRank(i + 1);
|
|
358
|
|
- }
|
|
|
353
|
+ // 计算并列排名并限制前30条
|
|
|
354
|
+ return calculateDenseRankingWithLimit(resultList, 30);
|
|
359
|
355
|
}
|
|
360
|
356
|
return resultList != null ? resultList : Collections.emptyList();
|
|
361
|
357
|
}
|
|
|
@@ -370,10 +366,8 @@ public class BlockedDashboardServiceImpl implements IBlockedDashboardService {
|
|
370
|
366
|
public List<BlockedRankingDTO> getReviewedUserRanking(BlockedDashboardQueryDTO queryDTO) {
|
|
371
|
367
|
List<BlockedRankingDTO> resultList = blockedDashboardMapper.selectReviewedUserRanking(queryDTO);
|
|
372
|
368
|
if (CollectionUtil.isNotEmpty(resultList)) {
|
|
373
|
|
- // 计算排名
|
|
374
|
|
- for (int i = 0; i < resultList.size(); i++) {
|
|
375
|
|
- resultList.get(i).setRank(i + 1);
|
|
376
|
|
- }
|
|
|
369
|
+ // 计算并列排名并限制前30条
|
|
|
370
|
+ return calculateDenseRankingWithLimit(resultList, 30);
|
|
377
|
371
|
}
|
|
378
|
372
|
return resultList != null ? resultList : Collections.emptyList();
|
|
379
|
373
|
}
|
|
|
@@ -521,7 +515,7 @@ public class BlockedDashboardServiceImpl implements IBlockedDashboardService {
|
|
521
|
515
|
// 3. 批量查询所有部门信息,构建大队ID映射缓存
|
|
522
|
516
|
Map<Long, Long> deptToBrigadeMap = buildDeptToBrigadeMap(allDeptIds);
|
|
523
|
517
|
|
|
524
|
|
- // 4. 在Java层按大队分组统计
|
|
|
518
|
+ // 4. 按大队分组统计
|
|
525
|
519
|
Map<Long, BlockedCertificateLevelDTO> brigadeMap = new LinkedHashMap<>();
|
|
526
|
520
|
|
|
527
|
521
|
for (Map<String, Object> row : rawData) {
|
|
|
@@ -776,6 +770,10 @@ public class BlockedDashboardServiceImpl implements IBlockedDashboardService {
|
|
776
|
770
|
@Override
|
|
777
|
771
|
public List<BlockedRankingDTO> getBrigadeSupervisorRanking(BlockedDashboardQueryDTO queryDTO) {
|
|
778
|
772
|
List<BlockedRankingDTO> resultList = blockedDashboardMapper.selectBrigadeSupervisorRanking(queryDTO);
|
|
|
773
|
+ if (CollectionUtil.isNotEmpty(resultList)) {
|
|
|
774
|
+ // 计算并列排名并限制前10条
|
|
|
775
|
+ return calculateDenseRankingWithLimit(resultList, 10);
|
|
|
776
|
+ }
|
|
779
|
777
|
return resultList != null ? resultList : Collections.emptyList();
|
|
780
|
778
|
}
|
|
781
|
779
|
|
|
|
@@ -785,14 +783,18 @@ public class BlockedDashboardServiceImpl implements IBlockedDashboardService {
|
|
785
|
783
|
* 数据筛选:分管班组长不为空
|
|
786
|
784
|
* 排行字段:分管班组长
|
|
787
|
785
|
* 排行依据:统计记录总数
|
|
788
|
|
- * 显示行数:显示前10行
|
|
|
786
|
+ * 显示行数:显示前10条(并列排名)
|
|
789
|
787
|
*
|
|
790
|
788
|
* @param queryDTO 查询参数
|
|
791
|
|
- * @return 班组排行榜列表(前10名)
|
|
|
789
|
+ * @return 班组排行榜列表(前10条)
|
|
792
|
790
|
*/
|
|
793
|
791
|
@Override
|
|
794
|
792
|
public List<BlockedRankingDTO> getBrigadeTeamLeaderRanking(BlockedDashboardQueryDTO queryDTO) {
|
|
795
|
793
|
List<BlockedRankingDTO> resultList = blockedDashboardMapper.selectBrigadeTeamLeaderRanking(queryDTO);
|
|
|
794
|
+ if (CollectionUtil.isNotEmpty(resultList)) {
|
|
|
795
|
+ // 计算并列排名并限制前10条
|
|
|
796
|
+ return calculateDenseRankingWithLimit(resultList, 10);
|
|
|
797
|
+ }
|
|
796
|
798
|
return resultList != null ? resultList : Collections.emptyList();
|
|
797
|
799
|
}
|
|
798
|
800
|
|
|
|
@@ -802,14 +804,18 @@ public class BlockedDashboardServiceImpl implements IBlockedDashboardService {
|
|
802
|
804
|
* 数据筛选:被回查人不为空
|
|
803
|
805
|
* 排行字段:被回查人
|
|
804
|
806
|
* 排行依据:统计记录总数
|
|
805
|
|
- * 显示行数:显示前10行
|
|
|
807
|
+ * 显示行数:显示前10条(并列排名)
|
|
806
|
808
|
*
|
|
807
|
809
|
* @param queryDTO 查询参数
|
|
808
|
|
- * @return 人员排行榜列表(前10名)
|
|
|
810
|
+ * @return 人员排行榜列表(前10条)
|
|
809
|
811
|
*/
|
|
810
|
812
|
@Override
|
|
811
|
813
|
public List<BlockedRankingDTO> getBrigadeReviewedUserRanking(BlockedDashboardQueryDTO queryDTO) {
|
|
812
|
814
|
List<BlockedRankingDTO> resultList = blockedDashboardMapper.selectBrigadeReviewedUserRanking(queryDTO);
|
|
|
815
|
+ if (CollectionUtil.isNotEmpty(resultList)) {
|
|
|
816
|
+ // 计算并列排名并限制前10条
|
|
|
817
|
+ return calculateDenseRankingWithLimit(resultList, 10);
|
|
|
818
|
+ }
|
|
813
|
819
|
return resultList != null ? resultList : Collections.emptyList();
|
|
814
|
820
|
}
|
|
815
|
821
|
|
|
|
@@ -997,4 +1003,42 @@ public class BlockedDashboardServiceImpl implements IBlockedDashboardService {
|
|
997
|
1003
|
return levelCode;
|
|
998
|
1004
|
}
|
|
999
|
1005
|
}
|
|
|
1006
|
+
|
|
|
1007
|
+ /**
|
|
|
1008
|
+ * 计算并列排名并限制前N条
|
|
|
1009
|
+ * 并列排名规则:相同totalCount的记录排名相同,下一个不同值的排名紧接其后
|
|
|
1010
|
+ * 限制规则:只返回排名序号 <= maxRank 的记录
|
|
|
1011
|
+ *
|
|
|
1012
|
+ * @param resultList 排行榜数据列表(已按totalCount降序排序)
|
|
|
1013
|
+ * @param maxRank 最大排名序号(站级30,大队10)
|
|
|
1014
|
+ * @return 过滤后的排行榜列表
|
|
|
1015
|
+ */
|
|
|
1016
|
+ private List<BlockedRankingDTO> calculateDenseRankingWithLimit(List<BlockedRankingDTO> resultList, int maxRank) {
|
|
|
1017
|
+ if (resultList == null || resultList.isEmpty()) {
|
|
|
1018
|
+ return resultList;
|
|
|
1019
|
+ }
|
|
|
1020
|
+
|
|
|
1021
|
+ List<BlockedRankingDTO> result = new ArrayList<>();
|
|
|
1022
|
+ int currentRank = 1; // 当前排名
|
|
|
1023
|
+ Integer previousCount = null; // 上一个记录的totalCount
|
|
|
1024
|
+
|
|
|
1025
|
+ for (BlockedRankingDTO item : resultList) {
|
|
|
1026
|
+ Integer currentCount = item.getTotalCount();
|
|
|
1027
|
+
|
|
|
1028
|
+ // 如果totalCount与上一个不同,更新排名
|
|
|
1029
|
+ if (previousCount == null || !currentCount.equals(previousCount)) {
|
|
|
1030
|
+ // 如果当前排名已经超过限制,停止添加
|
|
|
1031
|
+ if (currentRank > maxRank) {
|
|
|
1032
|
+ break;
|
|
|
1033
|
+ }
|
|
|
1034
|
+ previousCount = currentCount;
|
|
|
1035
|
+ }
|
|
|
1036
|
+
|
|
|
1037
|
+ // 设置排名并添加到结果列表
|
|
|
1038
|
+ item.setRank(currentRank);
|
|
|
1039
|
+ result.add(item);
|
|
|
1040
|
+ }
|
|
|
1041
|
+
|
|
|
1042
|
+ return result;
|
|
|
1043
|
+ }
|
|
1000
|
1044
|
}
|