|
|
@@ -1479,6 +1479,55 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
|
|
1479
|
1479
|
Integer integer = rankMap.get(targetId);
|
|
1480
|
1480
|
result.setStationRanking(integer);
|
|
1481
|
1481
|
}
|
|
|
1482
|
+ } else if (ObjUtil.isNotNull(brigadeId)) {
|
|
|
1483
|
+ // 大队级
|
|
|
1484
|
+ Long finalbrigadeId = brigadeId;
|
|
|
1485
|
+ target = all.stream().filter(item -> ObjUtil.equals(item.getCheckedBrigadeId(), finalbrigadeId)).collect(Collectors.toList());
|
|
|
1486
|
+ if (CollUtil.isEmpty(target)) {
|
|
|
1487
|
+ return null;
|
|
|
1488
|
+ }
|
|
|
1489
|
+ // 本站排名处理
|
|
|
1490
|
+ List<CheckLargeScreenCorrectionPortraitSqlDto> stationList = all;
|
|
|
1491
|
+ Map<Long, Long> brigadeIdCountMap = stationList.stream().collect(Collectors.groupingBy(CheckLargeScreenCorrectionPortraitSqlDto::getCheckedBrigadeId, Collectors.counting()));
|
|
|
1492
|
+ Map<Long, Long> tempMap = new HashMap<>();
|
|
|
1493
|
+ List<SysDept> deptList = sysDeptService.selectDeptInfoAll(new SysDept());
|
|
|
1494
|
+ deptList = deptList.stream().filter(item -> StrUtil.equals(DeptType.BRIGADE.getCode(), item.getDeptType())).collect(Collectors.toList());
|
|
|
1495
|
+ if (CollUtil.isNotEmpty(deptList)) {
|
|
|
1496
|
+ List<Long> brigadeIdList = deptList.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList());
|
|
|
1497
|
+ brigadeIdList.forEach(item -> {
|
|
|
1498
|
+ tempMap.put(item, brigadeIdCountMap.getOrDefault(item, 0L));
|
|
|
1499
|
+ });
|
|
|
1500
|
+ result.setStationTotal(brigadeIdList.size());
|
|
|
1501
|
+ // 1. 按值升序排序
|
|
|
1502
|
+ List<Map.Entry<Long, Long>> sortedEntries = tempMap.entrySet()
|
|
|
1503
|
+ .stream()
|
|
|
1504
|
+ .sorted(Map.Entry.comparingByValue())
|
|
|
1505
|
+ .collect(Collectors.toList());
|
|
|
1506
|
+ // 2. 计算排名(考虑并列情况)
|
|
|
1507
|
+ Map<Long, Integer> rankMap = new HashMap<>();
|
|
|
1508
|
+ int currentRank = 1;
|
|
|
1509
|
+ Long prevValue = null;
|
|
|
1510
|
+ int sameValueCount = 1; // 记录相同值的用户数
|
|
|
1511
|
+ for (int i = 0; i < sortedEntries.size(); i++) {
|
|
|
1512
|
+ Map.Entry<Long, Long> entry = sortedEntries.get(i);
|
|
|
1513
|
+ Long currentValue = entry.getValue();
|
|
|
1514
|
+ if (prevValue != null && !currentValue.equals(prevValue)) {
|
|
|
1515
|
+ // 如果当前值与前一个值不同,更新排名
|
|
|
1516
|
+ currentRank += sameValueCount;
|
|
|
1517
|
+ sameValueCount = 1;
|
|
|
1518
|
+ } else if (prevValue != null) {
|
|
|
1519
|
+ // 如果当前值与前一个值相同,排名不变,但增加相同值的计数
|
|
|
1520
|
+ sameValueCount++;
|
|
|
1521
|
+ }
|
|
|
1522
|
+ // 存储用户ID和排名
|
|
|
1523
|
+ rankMap.put(entry.getKey(), currentRank);
|
|
|
1524
|
+ prevValue = currentValue;
|
|
|
1525
|
+ }
|
|
|
1526
|
+ // 3. 查询指定排名
|
|
|
1527
|
+ Long targetId = brigadeId;
|
|
|
1528
|
+ Integer integer = rankMap.get(targetId);
|
|
|
1529
|
+ result.setStationRanking(integer);
|
|
|
1530
|
+ }
|
|
1482
|
1531
|
} else {
|
|
1483
|
1532
|
// 站级
|
|
1484
|
1533
|
target = all;
|