Bladeren bron

组织画像-标准执行

chenshudong 4 maanden geleden
bovenliggende
commit
7f862ea64f

+ 10 - 0
airport-check/src/main/java/com/sundot/airport/check/domain/CheckLargeScreenCorrectionPortraitDto.java

@@ -29,6 +29,16 @@ public class CheckLargeScreenCorrectionPortraitDto {
29 29
     private Integer stationTotal;
30 30
 
31 31
     /**
32
+     * 本大队总排名
33
+     */
34
+    private Integer brigadeRanking;
35
+
36
+    /**
37
+     * 本大队总人数
38
+     */
39
+    private Integer brigadeTotal;
40
+
41
+    /**
32 42
      * 本科总排名
33 43
      */
34 44
     private Integer departmentRanking;

+ 10 - 0
airport-check/src/main/java/com/sundot/airport/check/domain/CheckLargeScreenCorrectionPortraitSqlDto.java

@@ -20,6 +20,16 @@ public class CheckLargeScreenCorrectionPortraitSqlDto implements Serializable {
20 20
     private Long id;
21 21
 
22 22
     /**
23
+     * 被检查大队ID
24
+     */
25
+    private Long checkedBrigadeId;
26
+
27
+    /**
28
+     * 被检查大队名称
29
+     */
30
+    private String checkedBrigadeName;
31
+
32
+    /**
23 33
      * 被检查科室ID
24 34
      */
25 35
     private Long checkedDepartmentId;

+ 181 - 11
airport-check/src/main/java/com/sundot/airport/check/service/impl/CheckLargeScreenServiceImpl.java

@@ -948,12 +948,32 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
948 948
                 }
949 949
             });
950 950
         }
951
+        //补充被检查班科室数据
952
+        List<Long> checkedTeamIdListTemp = all.stream().filter(item -> ObjectUtil.isNull(item.getCheckedDepartmentId())).map(CheckLargeScreenCorrectionPortraitSqlDto::getCheckedTeamId).distinct().collect(Collectors.toList());
953
+        if (CollUtil.isNotEmpty(checkedTeamIdListTemp)) {
954
+            List<SysDept> checkedTeamListTemp = sysDeptService.selectDeptByIdList(checkedTeamIdListTemp);
955
+            if (CollUtil.isNotEmpty(checkedTeamListTemp)) {
956
+                Map<Long, Long> deptIdMap = checkedTeamListTemp.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getParentId, (oldValue, newValue) -> newValue));
957
+                List<Long> checkedDepartmentIdListTemp = checkedTeamListTemp.stream().map(SysDept::getParentId).collect(Collectors.toList());
958
+                List<SysDept> checkedDepartmentListTemp = sysDeptService.selectDeptByIdList(checkedDepartmentIdListTemp);
959
+                if (CollUtil.isNotEmpty(checkedDepartmentListTemp)) {
960
+                    Map<Long, String> deptMap = checkedDepartmentListTemp.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName, (oldValue, newValue) -> newValue));
961
+                    all.forEach(item -> {
962
+                        if (ObjectUtil.isNull(item.getCheckedDepartmentId())) {
963
+                            item.setCheckedDepartmentId(deptIdMap.getOrDefault(item.getCheckedTeamId(), 0L));
964
+                            item.setCheckedTeamName(deptMap.getOrDefault(item.getCheckedDepartmentId(), ""));
965
+                        }
966
+                    });
967
+                }
968
+            }
969
+        }
951 970
 
952 971
         // 查询条件处理
972
+        Long brigadeId = dto.getCheckedBrigadeId();
953 973
         Long departmentId = dto.getCheckedDepartmentId();
954 974
         Long teamId = dto.getCheckedTeamId();
955 975
         Long userId = dto.getCheckedUserId();
956
-        if (ObjUtil.isNull(dto.getCheckedDepartmentId()) && ObjUtil.isNull(dto.getCheckedTeamId()) && ObjUtil.isNull(dto.getCheckedUserId())) {
976
+        if (ObjUtil.isNull(dto.getCheckedBrigadeId()) && ObjUtil.isNull(dto.getCheckedDepartmentId()) && ObjUtil.isNull(dto.getCheckedTeamId()) && ObjUtil.isNull(dto.getCheckedUserId())) {
957 977
             List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
958 978
             if (CollUtil.isEmpty(roles)) {
959 979
                 return null;
@@ -962,17 +982,21 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
962 982
             if (roleKeyList.contains(RoleTypeEnum.admin.getCode())) {
963 983
                 dto.setIsSelfCheck(null);
964 984
             } else if (roleKeyList.contains(RoleTypeEnum.test.getCode()) || roleKeyList.contains(RoleTypeEnum.zhijianke.getCode())) {
965
-                dto.setIsSelfCheck(null);
985
+                dto.setIsSelfCheck(0);
986
+            } else if (roleKeyList.contains(RoleTypeEnum.jingli.getCode()) || roleKeyList.contains(RoleTypeEnum.xingzheng.getCode())) {
987
+                dto.setIsSelfCheck(0);
988
+                brigadeId = SecurityUtils.getLoginUser().getDeptId();
989
+                dto.setCheckedBrigadeId(brigadeId);
966 990
             } else if (roleKeyList.contains(RoleTypeEnum.kezhang.getCode())) {
967
-                dto.setIsSelfCheck(null);
991
+                dto.setIsSelfCheck(0);
968 992
                 departmentId = SecurityUtils.getLoginUser().getDeptId();
969 993
                 dto.setCheckedDepartmentId(departmentId);
970 994
             } else if (roleKeyList.contains(RoleTypeEnum.banzuzhang.getCode())) {
971
-                dto.setIsSelfCheck(null);
995
+                dto.setIsSelfCheck(0);
972 996
                 teamId = SecurityUtils.getLoginUser().getDeptId();
973 997
                 dto.setCheckedTeamId(teamId);
974 998
             } else if (roleKeyList.contains(RoleTypeEnum.SecurityCheck.getCode())) {
975
-                dto.setIsSelfCheck(null);
999
+                dto.setIsSelfCheck(0);
976 1000
                 userId = SecurityUtils.getLoginUser().getUserId();
977 1001
                 dto.setCheckedUserId(userId);
978 1002
             } else {
@@ -986,6 +1010,8 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
986 1010
                 dto.setCheckedTeamId(teamId);
987 1011
             } else if (ObjUtil.isNotNull(departmentId)) {
988 1012
                 dto.setCheckedDepartmentId(departmentId);
1013
+            } else if (ObjUtil.isNotNull(brigadeId)) {
1014
+                dto.setCheckedBrigadeId(brigadeId);
989 1015
             } else {
990 1016
                 return null;
991 1017
             }
@@ -1000,6 +1026,11 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
1000 1026
                 if (roleKeyList.contains(RoleTypeEnum.admin.getCode()) || roleKeyList.contains(RoleTypeEnum.test.getCode()) || roleKeyList.contains(RoleTypeEnum.zhijianke.getCode())) {
1001 1027
                     userId = null;
1002 1028
                     dto.setCheckedUserId(userId);
1029
+                } else if (roleKeyList.contains(RoleTypeEnum.jingli.getCode()) || roleKeyList.contains(RoleTypeEnum.xingzheng.getCode())) {
1030
+                    userId = null;
1031
+                    dto.setCheckedUserId(userId);
1032
+                    brigadeId = sysUser.getDeptId();
1033
+                    dto.setCheckedBrigadeId(brigadeId);
1003 1034
                 } else if (roleKeyList.contains(RoleTypeEnum.kezhang.getCode())) {
1004 1035
                     userId = null;
1005 1036
                     dto.setCheckedUserId(userId);
@@ -1021,7 +1052,8 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
1021 1052
                 List<SysDept> deptList = sysDeptService.selectAllDept(sysUser.getDeptId());
1022 1053
                 if (CollUtil.isNotEmpty(deptList)) {
1023 1054
                     SysDept team = deptList.stream().filter(item -> StrUtil.equals(DeptType.TEAMS.getCode(), item.getDeptType())).findFirst().orElse(null);
1024
-                    SysDept department = deptList.stream().filter(item -> StrUtil.equals(DeptType.DEPARTMENT.getCode(), item.getDeptType())).findFirst().orElse(null);
1055
+                    SysDept department = deptList.stream().filter(item -> StrUtil.equals(DeptType.MANAGER.getCode(), item.getDeptType())).findFirst().orElse(null);
1056
+                    SysDept brigade = deptList.stream().filter(item -> StrUtil.equals(DeptType.BRIGADE.getCode(), item.getDeptType())).findFirst().orElse(null);
1025 1057
                     SysDept station = deptList.stream().filter(item -> StrUtil.equals(DeptType.STATION.getCode(), item.getDeptType())).findFirst().orElse(null);
1026 1058
                     // 本班排名处理
1027 1059
                     if (ObjUtil.isNotNull(team)) {
@@ -1115,6 +1147,52 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
1115 1147
                             }
1116 1148
                         }
1117 1149
                     }
1150
+                    // 本大队排名处理
1151
+                    if (ObjUtil.isNotNull(brigade)) {
1152
+                        List<CheckLargeScreenCorrectionPortraitSqlDto> brigadeList = all.stream().filter(item -> ObjUtil.equals(item.getCheckedBrigadeId(), brigade.getDeptId())).collect(Collectors.toList());
1153
+                        if (CollUtil.isNotEmpty(brigadeList)) {
1154
+                            Map<Long, Long> userIdCountMap = brigadeList.stream().collect(Collectors.groupingBy(CheckLargeScreenCorrectionPortraitSqlDto::getUserId, Collectors.counting()));
1155
+                            Map<Long, Long> tempMap = new HashMap<>();
1156
+                            List<SysUser> sysUserTempList = sysUserService.selectUserByDeptId(brigade.getDeptId());
1157
+                            sysUserTempList = sysUserTempList.stream().filter(item -> item.getRoles().stream().anyMatch(sysRole -> RoleTypeEnum.banzuzhang.getCode().equals(sysRole.getRoleKey()) || RoleTypeEnum.SecurityCheck.getCode().equals(sysRole.getRoleKey()))).collect(Collectors.toList());
1158
+                            if (CollUtil.isNotEmpty(sysUserTempList)) {
1159
+                                List<Long> sysUserIdTempList = sysUserTempList.stream().map(SysUser::getUserId).distinct().collect(Collectors.toList());
1160
+                                sysUserIdTempList.forEach(item -> {
1161
+                                    tempMap.put(item, userIdCountMap.getOrDefault(item, 0L));
1162
+                                });
1163
+                                result.setBrigadeTotal(sysUserIdTempList.size());
1164
+                                // 1. 按值升序排序
1165
+                                List<Map.Entry<Long, Long>> sortedEntries = tempMap.entrySet()
1166
+                                        .stream()
1167
+                                        .sorted(Map.Entry.comparingByValue())
1168
+                                        .collect(Collectors.toList());
1169
+                                // 2. 计算排名(考虑并列情况)
1170
+                                Map<Long, Integer> rankMap = new HashMap<>();
1171
+                                int currentRank = 1;
1172
+                                Long prevValue = null;
1173
+                                int sameValueCount = 1; // 记录相同值的用户数
1174
+                                for (int i = 0; i < sortedEntries.size(); i++) {
1175
+                                    Map.Entry<Long, Long> entry = sortedEntries.get(i);
1176
+                                    Long currentValue = entry.getValue();
1177
+                                    if (prevValue != null && !currentValue.equals(prevValue)) {
1178
+                                        // 如果当前值与前一个值不同,更新排名
1179
+                                        currentRank += sameValueCount;
1180
+                                        sameValueCount = 1;
1181
+                                    } else if (prevValue != null) {
1182
+                                        // 如果当前值与前一个值相同,排名不变,但增加相同值的计数
1183
+                                        sameValueCount++;
1184
+                                    }
1185
+                                    // 存储用户ID和排名
1186
+                                    rankMap.put(entry.getKey(), currentRank);
1187
+                                    prevValue = currentValue;
1188
+                                }
1189
+                                // 3. 查询指定排名
1190
+                                Long targetId = userId;
1191
+                                Integer integer = rankMap.get(targetId);
1192
+                                result.setBrigadeRanking(integer);
1193
+                            }
1194
+                        }
1195
+                    }
1118 1196
                     // 本站排名处理
1119 1197
                     if (ObjUtil.isNotNull(station)) {
1120 1198
                         List<CheckLargeScreenCorrectionPortraitSqlDto> stationList = all;
@@ -1216,13 +1294,59 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
1216 1294
                     result.setDepartmentRanking(integer);
1217 1295
                 }
1218 1296
             }
1297
+            // 本大队排名处理
1298
+            SysDept sysDeptKs = sysDeptService.selectDeptById(ksId);
1299
+            Long ddId = sysDeptKs.getParentId();
1300
+            List<CheckLargeScreenCorrectionPortraitSqlDto> brigadeList = all.stream().filter(item -> ObjUtil.equals(item.getCheckedBrigadeId(), ddId)).collect(Collectors.toList());
1301
+            if (CollUtil.isNotEmpty(brigadeList)) {
1302
+                Map<Long, Long> teamIdCountMap = brigadeList.stream().collect(Collectors.groupingBy(CheckLargeScreenCorrectionPortraitSqlDto::getCheckedTeamId, Collectors.counting()));
1303
+                Map<Long, Long> tempMap = new HashMap<>();
1304
+                List<SysDept> deptList = sysDeptService.selectAllDept(ddId);
1305
+                deptList = deptList.stream().filter(item -> StrUtil.equals(DeptType.TEAMS.getCode(), item.getDeptType())).collect(Collectors.toList());
1306
+                if (CollUtil.isNotEmpty(deptList)) {
1307
+                    List<Long> teamIdTempList = deptList.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList());
1308
+                    teamIdTempList.forEach(item -> {
1309
+                        tempMap.put(item, teamIdCountMap.getOrDefault(item, 0L));
1310
+                    });
1311
+                    result.setBrigadeTotal(teamIdTempList.size());
1312
+                    // 1. 按值升序排序
1313
+                    List<Map.Entry<Long, Long>> sortedEntries = tempMap.entrySet()
1314
+                            .stream()
1315
+                            .sorted(Map.Entry.comparingByValue())
1316
+                            .collect(Collectors.toList());
1317
+                    // 2. 计算排名(考虑并列情况)
1318
+                    Map<Long, Integer> rankMap = new HashMap<>();
1319
+                    int currentRank = 1;
1320
+                    Long prevValue = null;
1321
+                    int sameValueCount = 1; // 记录相同值的用户数
1322
+                    for (int i = 0; i < sortedEntries.size(); i++) {
1323
+                        Map.Entry<Long, Long> entry = sortedEntries.get(i);
1324
+                        Long currentValue = entry.getValue();
1325
+                        if (prevValue != null && !currentValue.equals(prevValue)) {
1326
+                            // 如果当前值与前一个值不同,更新排名
1327
+                            currentRank += sameValueCount;
1328
+                            sameValueCount = 1;
1329
+                        } else if (prevValue != null) {
1330
+                            // 如果当前值与前一个值相同,排名不变,但增加相同值的计数
1331
+                            sameValueCount++;
1332
+                        }
1333
+                        // 存储用户ID和排名
1334
+                        rankMap.put(entry.getKey(), currentRank);
1335
+                        prevValue = currentValue;
1336
+                    }
1337
+                    // 3. 查询指定排名
1338
+                    Long targetId = teamId;
1339
+                    Integer integer = rankMap.get(targetId);
1340
+                    result.setBrigadeRanking(integer);
1341
+                }
1342
+            }
1219 1343
             // 本站排名处理
1220 1344
             List<CheckLargeScreenCorrectionPortraitSqlDto> stationList = all;
1221 1345
             if (CollUtil.isNotEmpty(stationList)) {
1222 1346
                 Map<Long, Long> teamIdCountMap = stationList.stream().collect(Collectors.groupingBy(CheckLargeScreenCorrectionPortraitSqlDto::getCheckedTeamId, Collectors.counting()));
1223 1347
                 Map<Long, Long> tempMap = new HashMap<>();
1224 1348
                 List<SysDept> deptList = sysDeptService.selectDeptInfoAll(new SysDept());
1225
-                deptList = deptList.stream().filter(item -> StrUtil.equals("TEAMS", item.getDeptType())).collect(Collectors.toList());
1349
+                deptList = deptList.stream().filter(item -> StrUtil.equals(DeptType.TEAMS.getCode(), item.getDeptType())).collect(Collectors.toList());
1226 1350
                 if (CollUtil.isNotEmpty(deptList)) {
1227 1351
                     List<Long> teamIdTempList = deptList.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList());
1228 1352
                     teamIdTempList.forEach(item -> {
@@ -1267,12 +1391,58 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
1267 1391
             if (CollUtil.isEmpty(target)) {
1268 1392
                 return null;
1269 1393
             }
1394
+            // 本大队排名处理
1395
+            SysDept sysDeptKs = sysDeptService.selectDeptById(departmentId);
1396
+            Long ddId = sysDeptKs.getParentId();
1397
+            List<CheckLargeScreenCorrectionPortraitSqlDto> brigadeList = all.stream().filter(item -> ObjUtil.equals(item.getCheckedBrigadeId(), ddId)).collect(Collectors.toList());
1398
+            if (CollUtil.isNotEmpty(brigadeList)) {
1399
+                Map<Long, Long> departmentIdCountMap = brigadeList.stream().collect(Collectors.groupingBy(CheckLargeScreenCorrectionPortraitSqlDto::getCheckedDepartmentId, Collectors.counting()));
1400
+                Map<Long, Long> tempMap = new HashMap<>();
1401
+                List<SysDept> deptList = sysDeptService.selectAllDept(ddId);
1402
+                deptList = deptList.stream().filter(item -> StrUtil.equals(DeptType.MANAGER.getCode(), item.getDeptType())).collect(Collectors.toList());
1403
+                if (CollUtil.isNotEmpty(deptList)) {
1404
+                    List<Long> departmentIdTempList = deptList.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList());
1405
+                    departmentIdTempList.forEach(item -> {
1406
+                        tempMap.put(item, departmentIdCountMap.getOrDefault(item, 0L));
1407
+                    });
1408
+                    result.setBrigadeTotal(departmentIdTempList.size());
1409
+                    // 1. 按值升序排序
1410
+                    List<Map.Entry<Long, Long>> sortedEntries = tempMap.entrySet()
1411
+                            .stream()
1412
+                            .sorted(Map.Entry.comparingByValue())
1413
+                            .collect(Collectors.toList());
1414
+                    // 2. 计算排名(考虑并列情况)
1415
+                    Map<Long, Integer> rankMap = new HashMap<>();
1416
+                    int currentRank = 1;
1417
+                    Long prevValue = null;
1418
+                    int sameValueCount = 1; // 记录相同值的用户数
1419
+                    for (int i = 0; i < sortedEntries.size(); i++) {
1420
+                        Map.Entry<Long, Long> entry = sortedEntries.get(i);
1421
+                        Long currentValue = entry.getValue();
1422
+                        if (prevValue != null && !currentValue.equals(prevValue)) {
1423
+                            // 如果当前值与前一个值不同,更新排名
1424
+                            currentRank += sameValueCount;
1425
+                            sameValueCount = 1;
1426
+                        } else if (prevValue != null) {
1427
+                            // 如果当前值与前一个值相同,排名不变,但增加相同值的计数
1428
+                            sameValueCount++;
1429
+                        }
1430
+                        // 存储用户ID和排名
1431
+                        rankMap.put(entry.getKey(), currentRank);
1432
+                        prevValue = currentValue;
1433
+                    }
1434
+                    // 3. 查询指定排名
1435
+                    Long targetId = departmentId;
1436
+                    Integer integer = rankMap.get(targetId);
1437
+                    result.setBrigadeRanking(integer);
1438
+                }
1439
+            }
1270 1440
             // 本站排名处理
1271 1441
             List<CheckLargeScreenCorrectionPortraitSqlDto> stationList = all;
1272 1442
             Map<Long, Long> departmentIdCountMap = stationList.stream().collect(Collectors.groupingBy(CheckLargeScreenCorrectionPortraitSqlDto::getCheckedDepartmentId, Collectors.counting()));
1273 1443
             Map<Long, Long> tempMap = new HashMap<>();
1274 1444
             List<SysDept> deptList = sysDeptService.selectDeptInfoAll(new SysDept());
1275
-            deptList = deptList.stream().filter(item -> StrUtil.equals("DEPARTMENT", item.getDeptType())).collect(Collectors.toList());
1445
+            deptList = deptList.stream().filter(item -> StrUtil.equals(DeptType.MANAGER.getCode(), item.getDeptType())).collect(Collectors.toList());
1276 1446
             if (CollUtil.isNotEmpty(deptList)) {
1277 1447
                 List<Long> departmentIdTempList = deptList.stream().map(SysDept::getDeptId).distinct().collect(Collectors.toList());
1278 1448
                 departmentIdTempList.forEach(item -> {
@@ -1324,13 +1494,13 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
1324 1494
         result.setOverTimeUnfinishedCount((int) correctionTypeMap.values().stream().filter(item -> StrUtil.equals("OVER_TIME_UNFINISHED", item)).count());
1325 1495
         result.setOtherCount((int) correctionTypeMap.values().stream().filter(item -> StrUtil.equals("OTHER", item)).count());
1326 1496
         // 部门及分类处理
1327
-        Map<String, Long> categoryCodeCountMap = target.stream().collect(Collectors.groupingBy(item -> item.getCheckedDepartmentId() + "***" + item.getCategoryCodeOne(), Collectors.counting()));
1497
+        Map<String, Long> categoryCodeCountMap = target.stream().collect(Collectors.groupingBy(item -> item.getCheckedBrigadeId() + "***" + item.getCategoryCodeOne(), Collectors.counting()));
1328 1498
         BaseCheckCategory baseCheckCategory = new BaseCheckCategory();
1329 1499
         baseCheckCategory.setLevel(1);
1330 1500
         List<BaseCheckCategory> baseCheckCategoryList = baseCheckCategoryService.selectBaseCheckCategoryList(baseCheckCategory);
1331 1501
         List<CheckLargeScreenProblemDto> resultItemTempList = new ArrayList<>();
1332
-        List<String> checkedDepartmentList = target.stream().map(item -> item.getCheckedDepartmentId() + "###" + item.getCheckedDepartmentName()).distinct().collect(Collectors.toList());
1333
-        checkedDepartmentList.forEach(item -> {
1502
+        List<String> checkedBrigadeList = target.stream().map(item -> item.getCheckedBrigadeId() + "###" + item.getCheckedBrigadeName()).distinct().collect(Collectors.toList());
1503
+        checkedBrigadeList.forEach(item -> {
1334 1504
             String[] split = item.split("###");
1335 1505
             Long deptId = Long.valueOf(split[0]);
1336 1506
             String deptName = split[1];

+ 2 - 0
airport-check/src/main/resources/mapper/check/CheckLargeScreenMapper.xml

@@ -661,6 +661,8 @@
661 661
 
662 662
     <select id="portrait" resultType="com.sundot.airport.check.domain.CheckLargeScreenCorrectionPortraitSqlDto">
663 663
         select cc.id id,
664
+        cc.checked_brigade_id checkedBrigadeId,
665
+        cc.checked_brigade_name checkedBrigadeName,
664 666
         cc.checked_department_id checkedDepartmentId,
665 667
         cc.checked_department_name checkedDepartmentName,
666 668
         cc.checked_team_id checkedTeamId,