Просмотр исходного кода

Merge branch 'feature/master-homepage-20260115' into develop

chenshudong месяцев назад: 2
Родитель
Сommit
1e4b877733

+ 12 - 1
airport-admin/src/main/java/com/sundot/airport/web/controller/system/SysHomePageController.java

@@ -140,7 +140,18 @@ public class SysHomePageController extends BaseController {
140 140
                 SysDept brigade = deptList.stream().filter(item -> StrUtil.equals(DeptType.BRIGADE.getCode(), item.getDeptType())).findFirst().orElse(null);
141 141
                 SysDept station = deptList.stream().filter(item -> StrUtil.equals(DeptType.STATION.getCode(), item.getDeptType())).findFirst().orElse(null);
142 142
 
143
-                // 添加班组、科室、大队、站点信息
143
+                // 支持dataSource参数:individual=个人数据,team=班组数据(默认)
144
+                // 仅对班组长权限生效
145
+                if (DataPermissionType.TEAM == dataPermission.getPermissionType() && "individual".equalsIgnoreCase(dto.getDataSource())) {
146
+                    // 返回班组长个人数据(类似安检员视角)
147
+                    SysHomePageDetailQueryParamDto userDto = new SysHomePageDetailQueryParamDto();
148
+                    userDto.setId(getUserId());
149
+                    userDto.setName(getLoginUser().getUser().getNickName());
150
+                    userDto.setType(HomePageQueryEnum.USER.getCode());
151
+                    dtoList.add(userDto);
152
+                }
153
+
154
+                // 添加班组、主管、大队、站点信息
144 155
                 if (ObjectUtil.isNotNull(team)) {
145 156
                     SysHomePageDetailQueryParamDto teamDto = new SysHomePageDetailQueryParamDto();
146 157
                     teamDto.setId(team.getDeptId());

+ 8 - 0
airport-common/src/main/java/com/sundot/airport/common/core/domain/BaseLargeScreenQueryParamDto.java

@@ -100,4 +100,12 @@ public class BaseLargeScreenQueryParamDto implements Serializable {
100 100
      */
101 101
     @ApiModelProperty("大队id")
102 102
     private Long inspectBrigadeId;
103
+
104
+    /**
105
+     * 数据来源(仅班组长角色生效)
106
+     * individual:返回班组长个人数据
107
+     * team或不传:返回班组数据(默认)
108
+     */
109
+    @ApiModelProperty("数据来源:individual=个人数据,team=班组数据")
110
+    private String dataSource;
103 111
 }

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

@@ -148,9 +148,9 @@ public class AccuracyStatisticsDTO implements Serializable {
148 148
     private java.util.List<RankingItem> brigadeRankingList;
149 149
 
150 150
     /**
151
-     * 本大队内Top班组(大队长视角)
151
+     * 本大队内Top主管(大队长视角)
152 152
      */
153
-    private java.util.List<RankingItem> topTeamsInBrigade;
153
+    private java.util.List<RankingItem> topKezhangInBrigade;
154 154
 
155 155
     /**
156 156
      * 站级内Top班组

+ 7 - 0
airport-exam/src/main/java/com/sundot/airport/exam/dto/AccuracyStatisticsQueryDTO.java

@@ -54,4 +54,11 @@ public class AccuracyStatisticsQueryDTO implements Serializable {
54 54
      * 部门类型(STATION/BRIGADE/MANAGER/TEAMS)
55 55
      */
56 56
     private String deptType;
57
+
58
+    /**
59
+     * 数据来源(仅班组长角色生效)
60
+     * individual:返回班组长个人数据
61
+     * team或不传:返回班组数据(默认)
62
+     */
63
+    private String dataSource;
57 64
 }

+ 309 - 28
airport-exam/src/main/java/com/sundot/airport/exam/service/impl/AccuracyStatisticsServiceImpl.java

@@ -233,8 +233,8 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
233 233
                 // 安检员
234 234
                 calculateSecurityCheckData(result, currentUserId, hierarchy, startDate, endDate);
235 235
             } else if (RoleTypeEnum.banzuzhang.getCode().equals(roleKey)) {
236
-                // 班组长
237
-                calculateTeamLeaderData(result, currentUserId, hierarchy, startDate, endDate);
236
+                // 班组长(支持dataSource参数)
237
+                calculateTeamLeaderData(result, currentUserId, hierarchy, startDate, endDate, query);
238 238
             } else if (RoleTypeEnum.kezhang.getCode().equals(roleKey)) {
239 239
                 // 主管
240 240
                 calculateManagerData(result, currentUserId, hierarchy, startDate, endDate);
@@ -328,10 +328,22 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
328 328
 
329 329
     /**
330 330
      * 班组长数据计算
331
-     * 正确率:班平均、主管平均、大队平均、站平均
332
-     * 排名:主管排名、大队排名、全站排名(班组排名)
331
+     * 支持dataSource参数:
332
+     * - individual:返回班组长个人数据(个人正确率、个人在各层级的排名)
333
+     * - team或空:返回班组数据(班组正确率、班组在各层级的排名)
333 334
      */
334
-    private void calculateTeamLeaderData(AccuracyStatisticsDTO result, Long userId, DeptHierarchy hierarchy, Date startDate, Date endDate) {
335
+    private void calculateTeamLeaderData(AccuracyStatisticsDTO result, Long userId, DeptHierarchy hierarchy, Date startDate, Date endDate, AccuracyStatisticsQueryDTO query) {
336
+        // 根据dataSource参数决定返回个人数据还是班组数据
337
+        if (query != null && "individual".equalsIgnoreCase(query.getDataSource())) {
338
+            // 返回班组长个人数据(类似安检员的数据)
339
+            log.info("班组长 {} 查询个人数据(dataSource=individual)", userId);
340
+            calculateSecurityCheckData(result, userId, hierarchy, startDate, endDate);
341
+            return;
342
+        }
343
+
344
+        // 默认返回班组数据(dataSource为"team"或未指定)
345
+        log.info("班组长 {} 查询班组数据(dataSource={})", userId, query != null ? query.getDataSource() : "null");
346
+
335 347
         // 班平均、主管平均、大队平均、站平均
336 348
         if (hierarchy.teamId != null) {
337 349
             result.setTeamAvgAccuracy(calculateDeptAvgAccuracy(hierarchy.teamId, startDate, endDate));
@@ -408,7 +420,7 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
408 420
     /**
409 421
      * 大队长数据计算
410 422
      * 正确率:大队平均、站平均
411
-     * 本大队抽问抽答正确率前三的班组
423
+     * 本大队正确率前三的主管
412 424
      * 全站排名:大队排名/全站大队数总和
413 425
      */
414 426
     private void calculateBrigadeLeaderData(AccuracyStatisticsDTO result, DeptHierarchy hierarchy, Date startDate, Date endDate) {
@@ -420,12 +432,12 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
420 432
             result.setSiteAvgAccuracy(calculateDeptAvgAccuracy(hierarchy.stationId, startDate, endDate));
421 433
         }
422 434
 
423
-        // 本大队抽问抽答正确率前三的班组
435
+        // 本大队正确率前三的主管
424 436
         if (hierarchy.brigadeId != null) {
425
-            List<TeamAccuracyInfo> teamsInBrigade = calculateTeamAccuraciesUnderDept(hierarchy.brigadeId, startDate, endDate);
426
-            if (!teamsInBrigade.isEmpty()) {
427
-                List<AccuracyStatisticsDTO.RankingItem> topTeams = convertToTeamRankingItems(teamsInBrigade, 3, true, hierarchy.brigadeId);
428
-                result.setTopTeamsInBrigade(topTeams);
437
+            List<TeamAccuracyInfo> managersInBrigade = calculateManagerAccuraciesUnderBrigade(hierarchy.brigadeId, startDate, endDate);
438
+            if (!managersInBrigade.isEmpty()) {
439
+                List<AccuracyStatisticsDTO.RankingItem> topManagers = convertToRankingItems(managersInBrigade, 3, true);
440
+                result.setTopKezhangInBrigade(topManagers);
429 441
             }
430 442
         }
431 443
 
@@ -771,8 +783,8 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
771 783
             // 安检员
772 784
             calculateSecurityCheckData(result, userId, hierarchy, startDate, endDate);
773 785
         } else if (RoleTypeEnum.banzuzhang.getCode().equals(roleKey)) {
774
-            // 班组长
775
-            calculateTeamLeaderData(result, userId, hierarchy, startDate, endDate);
786
+            // 班组长(支持dataSource参数)
787
+            calculateTeamLeaderData(result, userId, hierarchy, startDate, endDate, query);
776 788
         } else if (RoleTypeEnum.kezhang.getCode().equals(roleKey)) {
777 789
             // 主管
778 790
             calculateManagerData(result, userId, hierarchy, startDate, endDate);
@@ -861,11 +873,8 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
861 873
             initDeptCache();
862 874
 
863 875
             DailyTaskAccuracyRankingDto result = new DailyTaskAccuracyRankingDto();
864
-
865
-            // 获取当前用户信息
866
-            Long currentUserId = SecurityUtils.getUserId();
867
-            Long currentDeptId = SecurityUtils.getDeptId();
868
-            SysUser currentUser = userService.selectUserById(currentUserId);
876
+            result.setTotal(0);
877
+            result.setRank(0);
869 878
 
870 879
             // 解析日期范围
871 880
             Date startDate = dto.getStartDate();
@@ -874,8 +883,41 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
874 883
                 endDate = DateUtils.addSeconds(DateUtils.truncate(endDate, Calendar.DAY_OF_MONTH), 86399);
875 884
             }
876 885
 
877
-            // 获取当前用户的部门层级(使用缓存)
878
-            DeptHierarchy hierarchy = getDeptHierarchyCached(currentDeptId);
886
+            // 处理用户排名(userId不为空时)
887
+            if (dto.getUserId() != null) {
888
+                return getUserAccuracyRanking(dto.getUserId(), startDate, endDate);
889
+            }
890
+
891
+            // 处理部门排名(deptId不为空时,支持dataSource参数)
892
+            if (dto.getDeptId() != null) {
893
+                return getDeptAccuracyRanking(dto.getDeptId(), dto.getDataSource(), startDate, endDate);
894
+            }
895
+
896
+            // 默认:获取当前用户的排名
897
+            Long currentUserId = SecurityUtils.getUserId();
898
+            return getUserAccuracyRanking(currentUserId, startDate, endDate);
899
+
900
+        } finally {
901
+            // 清理缓存,避免内存泄漏
902
+            clearDeptCache();
903
+        }
904
+    }
905
+
906
+    /**
907
+     * 获取用户的正确率排名
908
+     */
909
+    private DailyTaskAccuracyRankingDto getUserAccuracyRanking(Long userId, Date startDate, Date endDate) {
910
+        DailyTaskAccuracyRankingDto result = new DailyTaskAccuracyRankingDto();
911
+
912
+        SysUser user = userService.selectUserById(userId);
913
+        if (user == null) {
914
+            result.setTotal(0);
915
+            result.setRank(0);
916
+            return result;
917
+        }
918
+
919
+        // 获取用户的部门层级
920
+        DeptHierarchy hierarchy = getDeptHierarchyCached(user.getDeptId());
879 921
 
880 922
         // 获取同级别的所有用户正确率排名
881 923
         List<UserAccuracyInfo> userRankings = calculateUserRankingsInScope(hierarchy, startDate, endDate);
@@ -898,17 +940,25 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
898 940
         int currentUserRank = 0;
899 941
         BigDecimal currentUserAccuracy = BigDecimal.ZERO;
900 942
         for (int i = 0; i < userRankings.size(); i++) {
901
-            if (currentUserId.equals(userRankings.get(i).userId)) {
943
+            if (userId.equals(userRankings.get(i).userId)) {
902 944
                 currentUserRank = i + 1;
903 945
                 currentUserAccuracy = userRankings.get(i).accuracy;
904 946
                 break;
905 947
             }
906 948
         }
907 949
 
908
-        result.setId(currentUserId);
909
-        result.setName(currentUser != null ? currentUser.getNickName() : "");
910
-        result.setRank(currentUserRank);
911
-        result.setTotal(userRankings.size());
950
+        result.setId(userId);
951
+        result.setName(user.getNickName());
952
+
953
+        // 如果找不到当前用户,说明该用户没有答题记录,排在最后(正确率为0)
954
+        if (currentUserRank == 0) {
955
+            currentUserRank = userRankings.size() + 1;
956
+            result.setRank(currentUserRank);
957
+            result.setTotal(userRankings.size() + 1);
958
+        } else {
959
+            result.setRank(currentUserRank);
960
+            result.setTotal(userRankings.size());
961
+        }
912 962
         result.setAccuracyRate(currentUserAccuracy);
913 963
 
914 964
         // 设置奖牌类型
@@ -918,11 +968,242 @@ public class AccuracyStatisticsServiceImpl implements IAccuracyStatisticsService
918 968
             result.setMedalTypeDesc(medalType.getDesc());
919 969
         }
920 970
 
971
+        return result;
972
+    }
973
+
974
+    /**
975
+     * 获取部门的正确率排名(支持dataSource参数,适配美兰4级组织结构)
976
+     * dataSource=individual时:
977
+     *   - 班组(TEAMS):返回班组长的个人排名
978
+     *   - 主管(MANAGER):返回主管在大队中的排名
979
+     *   - 大队(BRIGADE):返回大队在站级中的排名
980
+     *   - 站级(STATION):返回站级数据
981
+     * dataSource=team或空时:返回部门排名(默认)
982
+     */
983
+    private DailyTaskAccuracyRankingDto getDeptAccuracyRanking(Long deptId, String dataSource, Date startDate, Date endDate) {
984
+        DailyTaskAccuracyRankingDto result = new DailyTaskAccuracyRankingDto();
985
+        result.setTotal(0);
986
+        result.setRank(0);
987
+
988
+        DeptCache cache = getDeptCache();
989
+        SysDept sysDept = cache != null ? cache.deptMap.get(deptId) : deptService.selectDeptById(deptId);
990
+        if (sysDept == null) {
991
+            log.warn("部门{}不存在,返回空结果", deptId);
921 992
             return result;
922
-        } finally {
923
-            // 清理缓存,避免内存泄漏
924
-            clearDeptCache();
925 993
         }
994
+
995
+        String deptType = sysDept.getDeptType();
996
+        DeptHierarchy hierarchy = getDeptHierarchyCached(deptId);
997
+
998
+        // 处理dataSource=individual的情况
999
+        if ("individual".equalsIgnoreCase(dataSource)) {
1000
+            if (StrUtil.equals(DeptType.TEAMS.getCode(), deptType)) {
1001
+                // 班组:获取班组长的个人排名
1002
+                Long teamLeaderId = getTeamLeaderId(deptId);
1003
+                if (teamLeaderId != null) {
1004
+                    log.info("班组{},dataSource=individual,返回班组长{}的个人排名", deptId, teamLeaderId);
1005
+                    return getUserAccuracyRanking(teamLeaderId, startDate, endDate);
1006
+                } else {
1007
+                    log.warn("未找到班组{}的班组长,返回空结果", deptId);
1008
+                    return result;
1009
+                }
1010
+            } else if (StrUtil.equals(DeptType.MANAGER.getCode(), deptType)) {
1011
+                // 主管:返回主管在大队中的排名
1012
+                log.info("主管{},dataSource=individual,返回主管在大队中的排名", deptId);
1013
+                return getManagerInBrigadeRanking(sysDept, hierarchy, startDate, endDate);
1014
+            } else if (StrUtil.equals(DeptType.BRIGADE.getCode(), deptType)) {
1015
+                // 大队:返回大队在站级中的排名
1016
+                log.info("大队{},dataSource=individual,返回大队在站级中的排名", deptId);
1017
+                return getBrigadeInStationRanking(sysDept, hierarchy, startDate, endDate);
1018
+            } else if (StrUtil.equals(DeptType.STATION.getCode(), deptType)) {
1019
+                // 站级:返回站级数据
1020
+                log.info("站级{},dataSource=individual,返回站级数据", deptId);
1021
+                result.setId(sysDept.getDeptId());
1022
+                result.setName(sysDept.getDeptName());
1023
+                BigDecimal accuracy = calculateDeptAvgAccuracy(deptId, startDate, endDate);
1024
+                result.setAccuracyRate(accuracy);
1025
+                result.setRank(1);
1026
+                result.setTotal(1);
1027
+                return result;
1028
+            }
1029
+        }
1030
+
1031
+        // 默认:返回部门排名(dataSource=team或未指定)
1032
+        log.info("dataSource={},返回部门排名", dataSource);
1033
+        return getDeptDefaultRanking(sysDept, hierarchy, startDate, endDate);
1034
+    }
1035
+
1036
+    /**
1037
+     * 获取班组的班组长userId
1038
+     */
1039
+    private Long getTeamLeaderId(Long teamDeptId) {
1040
+        List<SysUser> users = userService.selectUserListByRoleKeyAndDeptId(
1041
+                Collections.singletonList(RoleTypeEnum.banzuzhang.getCode()), teamDeptId);
1042
+        if (users != null && !users.isEmpty()) {
1043
+            return users.get(0).getUserId();
1044
+        }
1045
+        return null;
1046
+    }
1047
+
1048
+    /**
1049
+     * 获取主管在大队中的排名
1050
+     */
1051
+    private DailyTaskAccuracyRankingDto getManagerInBrigadeRanking(SysDept managerDept, DeptHierarchy hierarchy, Date startDate, Date endDate) {
1052
+        DailyTaskAccuracyRankingDto result = new DailyTaskAccuracyRankingDto();
1053
+        result.setId(managerDept.getDeptId());
1054
+        result.setName(managerDept.getDeptName());
1055
+
1056
+        if (hierarchy.brigadeId == null) {
1057
+            result.setRank(1);
1058
+            result.setTotal(1);
1059
+            result.setAccuracyRate(calculateDeptAvgAccuracy(managerDept.getDeptId(), startDate, endDate));
1060
+            return result;
1061
+        }
1062
+
1063
+        // 获取大队下所有主管的排名
1064
+        List<TeamAccuracyInfo> managersInBrigade = calculateManagerAccuraciesUnderBrigade(hierarchy.brigadeId, startDate, endDate);
1065
+
1066
+        // 设置排名列表
1067
+        List<DailyTaskAccuracyRankingItemDto> rankingList = new ArrayList<>();
1068
+        for (int i = 0; i < managersInBrigade.size(); i++) {
1069
+            TeamAccuracyInfo info = managersInBrigade.get(i);
1070
+            DailyTaskAccuracyRankingItemDto item = new DailyTaskAccuracyRankingItemDto();
1071
+            item.setId(info.deptId);
1072
+            item.setName(info.deptName);
1073
+            item.setAccuracyRate(info.accuracy);
1074
+            item.setRank(i + 1);
1075
+            rankingList.add(item);
1076
+        }
1077
+        result.setRankingList(rankingList);
1078
+
1079
+        // 查找当前主管的排名
1080
+        AccuracyStatisticsDTO.RankingInfo rankingInfo = findTeamRanking(managerDept.getDeptId(), managersInBrigade);
1081
+        result.setRank(rankingInfo.getRank());
1082
+        result.setTotal(rankingInfo.getTotal());
1083
+
1084
+        // 设置正确率
1085
+        BigDecimal accuracy = calculateDeptAvgAccuracy(managerDept.getDeptId(), startDate, endDate);
1086
+        result.setAccuracyRate(accuracy);
1087
+
1088
+        // 设置奖牌类型
1089
+        if (rankingInfo.getTotal() > 0 && rankingInfo.getRank() > 0) {
1090
+            MedalTypeEnum medalType = calculateMedalType(rankingInfo.getRank(), rankingInfo.getTotal());
1091
+            result.setMedalType(medalType.getCode());
1092
+            result.setMedalTypeDesc(medalType.getDesc());
1093
+        }
1094
+
1095
+        return result;
1096
+    }
1097
+
1098
+    /**
1099
+     * 获取大队在站级中的排名
1100
+     */
1101
+    private DailyTaskAccuracyRankingDto getBrigadeInStationRanking(SysDept brigadeDept, DeptHierarchy hierarchy, Date startDate, Date endDate) {
1102
+        DailyTaskAccuracyRankingDto result = new DailyTaskAccuracyRankingDto();
1103
+        result.setId(brigadeDept.getDeptId());
1104
+        result.setName(brigadeDept.getDeptName());
1105
+
1106
+        if (hierarchy.stationId == null) {
1107
+            result.setRank(1);
1108
+            result.setTotal(1);
1109
+            result.setAccuracyRate(calculateDeptAvgAccuracy(brigadeDept.getDeptId(), startDate, endDate));
1110
+            return result;
1111
+        }
1112
+
1113
+        // 获取站级下所有大队的排名
1114
+        List<TeamAccuracyInfo> brigadesInStation = calculateBrigadeAccuraciesUnderStation(hierarchy.stationId, startDate, endDate);
1115
+
1116
+        // 设置排名列表
1117
+        List<DailyTaskAccuracyRankingItemDto> rankingList = new ArrayList<>();
1118
+        for (int i = 0; i < brigadesInStation.size(); i++) {
1119
+            TeamAccuracyInfo info = brigadesInStation.get(i);
1120
+            DailyTaskAccuracyRankingItemDto item = new DailyTaskAccuracyRankingItemDto();
1121
+            item.setId(info.deptId);
1122
+            item.setName(info.deptName);
1123
+            item.setAccuracyRate(info.accuracy);
1124
+            item.setRank(i + 1);
1125
+            rankingList.add(item);
1126
+        }
1127
+        result.setRankingList(rankingList);
1128
+
1129
+        // 查找当前大队的排名
1130
+        AccuracyStatisticsDTO.RankingInfo rankingInfo = findTeamRanking(brigadeDept.getDeptId(), brigadesInStation);
1131
+        result.setRank(rankingInfo.getRank());
1132
+        result.setTotal(rankingInfo.getTotal());
1133
+
1134
+        // 设置正确率
1135
+        BigDecimal accuracy = calculateDeptAvgAccuracy(brigadeDept.getDeptId(), startDate, endDate);
1136
+        result.setAccuracyRate(accuracy);
1137
+
1138
+        // 设置奖牌类型
1139
+        if (rankingInfo.getTotal() > 0 && rankingInfo.getRank() > 0) {
1140
+            MedalTypeEnum medalType = calculateMedalType(rankingInfo.getRank(), rankingInfo.getTotal());
1141
+            result.setMedalType(medalType.getCode());
1142
+            result.setMedalTypeDesc(medalType.getDesc());
1143
+        }
1144
+
1145
+        return result;
1146
+    }
1147
+
1148
+    /**
1149
+     * 获取部门的默认排名(班组在主管中的排名)
1150
+     */
1151
+    private DailyTaskAccuracyRankingDto getDeptDefaultRanking(SysDept dept, DeptHierarchy hierarchy, Date startDate, Date endDate) {
1152
+        DailyTaskAccuracyRankingDto result = new DailyTaskAccuracyRankingDto();
1153
+        result.setId(dept.getDeptId());
1154
+        result.setName(dept.getDeptName());
1155
+
1156
+        String deptType = dept.getDeptType();
1157
+
1158
+        if (StrUtil.equals(DeptType.TEAMS.getCode(), deptType)) {
1159
+            // 班组:返回班组在主管中的排名
1160
+            if (hierarchy.managerId != null) {
1161
+                List<TeamAccuracyInfo> teamsInManager = calculateTeamAccuraciesUnderDept(hierarchy.managerId, startDate, endDate);
1162
+
1163
+                // 设置排名列表
1164
+                List<DailyTaskAccuracyRankingItemDto> rankingList = new ArrayList<>();
1165
+                for (int i = 0; i < teamsInManager.size(); i++) {
1166
+                    TeamAccuracyInfo info = teamsInManager.get(i);
1167
+                    DailyTaskAccuracyRankingItemDto item = new DailyTaskAccuracyRankingItemDto();
1168
+                    item.setId(info.deptId);
1169
+                    item.setName(info.deptName);
1170
+                    item.setAccuracyRate(info.accuracy);
1171
+                    item.setRank(i + 1);
1172
+                    rankingList.add(item);
1173
+                }
1174
+                result.setRankingList(rankingList);
1175
+
1176
+                AccuracyStatisticsDTO.RankingInfo rankingInfo = findTeamRanking(dept.getDeptId(), teamsInManager);
1177
+                result.setRank(rankingInfo.getRank());
1178
+                result.setTotal(rankingInfo.getTotal());
1179
+            } else {
1180
+                result.setRank(1);
1181
+                result.setTotal(1);
1182
+            }
1183
+        } else if (StrUtil.equals(DeptType.MANAGER.getCode(), deptType)) {
1184
+            // 主管:返回主管在大队中的排名
1185
+            return getManagerInBrigadeRanking(dept, hierarchy, startDate, endDate);
1186
+        } else if (StrUtil.equals(DeptType.BRIGADE.getCode(), deptType)) {
1187
+            // 大队:返回大队在站级中的排名
1188
+            return getBrigadeInStationRanking(dept, hierarchy, startDate, endDate);
1189
+        } else {
1190
+            // 站级
1191
+            result.setRank(1);
1192
+            result.setTotal(1);
1193
+        }
1194
+
1195
+        // 设置正确率
1196
+        BigDecimal accuracy = calculateDeptAvgAccuracy(dept.getDeptId(), startDate, endDate);
1197
+        result.setAccuracyRate(accuracy);
1198
+
1199
+        // 设置奖牌类型
1200
+        if (result.getTotal() > 0 && result.getRank() > 0) {
1201
+            MedalTypeEnum medalType = calculateMedalType(result.getRank(), result.getTotal());
1202
+            result.setMedalType(medalType.getCode());
1203
+            result.setMedalTypeDesc(medalType.getDesc());
1204
+        }
1205
+
1206
+        return result;
926 1207
     }
927 1208
 
928 1209
     @Override