Kaynağa Gözat

质控分析报告-质控活动-部门或用户筛选功能

chenshudong 3 hafta önce
ebeveyn
işleme
3b51a6c099

+ 7 - 0
airport-check/src/main/java/com/sundot/airport/check/domain/CheckLargeScreenPlanQueryParamDto.java

@@ -3,6 +3,8 @@ package com.sundot.airport.check.domain;
3 3
 import com.sundot.airport.common.core.domain.BaseLargeScreenQueryParamDto;
4 4
 import lombok.Data;
5 5
 
6
+import java.util.List;
7
+
6 8
 /**
7 9
  * 巡检大屏:巡检计划查询参数
8 10
  *
@@ -22,4 +24,9 @@ public class CheckLargeScreenPlanQueryParamDto extends BaseLargeScreenQueryParam
22 24
      */
23 25
     private Long createId;
24 26
 
27
+    /**
28
+     * 创建人ID列表
29
+     */
30
+    private List<Long> userIdList;
31
+
25 32
 }

+ 0 - 8
airport-check/src/main/java/com/sundot/airport/check/mapper/CheckLargeScreenMapper.java

@@ -281,14 +281,6 @@ public interface CheckLargeScreenMapper {
281 281
     public List<SysCheckAnalysisReportCheckProblemDistributionItemDto> problemDistributionStatistics(BaseLargeScreenQueryParamDto dto);
282 282
 
283 283
     /**
284
-     * 问题整改统计
285
-     *
286
-     * @param dto 大屏查询参数
287
-     * @return 问题整改统计
288
-     */
289
-    public List<SysCheckAnalysisReportCheckProblemCorrectionItemDto> problemCorrectionStatistics(BaseLargeScreenQueryParamDto dto);
290
-
291
-    /**
292 284
      * 使用报表-运行情况-巡检模块
293 285
      *
294 286
      * @param dto 大屏查询参数

+ 242 - 46
airport-check/src/main/java/com/sundot/airport/check/service/impl/CheckLargeScreenServiceImpl.java

@@ -67,6 +67,7 @@ import com.sundot.airport.common.enums.MedalTypeEnum;
67 67
 import com.sundot.airport.common.enums.RoleTypeEnum;
68 68
 import com.sundot.airport.common.enums.SourceTypeEnum;
69 69
 import com.sundot.airport.common.exception.ServiceException;
70
+import com.sundot.airport.common.utils.DeptUtils;
70 71
 import com.sundot.airport.common.utils.LargeScreenDateUtils;
71 72
 import com.sundot.airport.common.utils.SecurityUtils;
72 73
 import com.sundot.airport.common.utils.StringUtils;
@@ -2797,6 +2798,9 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
2797 2798
      */
2798 2799
     @Override
2799 2800
     public SysCheckAnalysisReportDto checkAnalysisReport(SysAnalysisReportParamDto paramDto) {
2801
+        if (ObjUtil.isNull(paramDto.getUserId()) && ObjUtil.isNull(paramDto.getDeptId())) {
2802
+            paramDto.setDeptId(DeptUtils.getTopSiteId(sysDeptService.selectDeptById(SecurityUtils.getDeptId())));
2803
+        }
2800 2804
         SysCheckAnalysisReportDto result = new SysCheckAnalysisReportDto();
2801 2805
         result.setCheckTaskDto(getCheckTaskDto(paramDto));
2802 2806
         result.setCheckProblemDiscoveryDto(getCheckProblemDiscoveryDto(paramDto));
@@ -2812,13 +2816,53 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
2812 2816
      * @return 任务计划安排统计
2813 2817
      */
2814 2818
     private SysCheckAnalysisReportCheckTaskDto getCheckTaskDto(SysAnalysisReportParamDto paramDto) {
2819
+        if (ObjectUtil.isNotNull(paramDto.getUserId())) {
2820
+            return null;
2821
+        }
2822
+        SysDept sysDept = sysDeptService.selectDeptById(paramDto.getDeptId());
2823
+        if (ObjUtil.isNull(sysDept)) {
2824
+            throw new ServiceException("【" + paramDto.getDeptId() + "】部门不存在");
2825
+        }
2826
+        if (!StrUtil.equals(DeptTypeEnum.STATION.getCode(), sysDept.getDeptType()) && !StrUtil.equals(DeptTypeEnum.BRIGADE.getCode(), sysDept.getDeptType()) && !StrUtil.equals(DeptTypeEnum.MANAGER.getCode(), sysDept.getDeptType())) {
2827
+            return null;
2828
+        }
2829
+        List<SysUser> sysUserList;
2830
+        if (StrUtil.equals(DeptTypeEnum.BRIGADE.getCode(), sysDept.getDeptType())) {
2831
+            sysUserList = sysUserService.selectUserListByRoleKeyAndDeptId(Arrays.asList(RoleTypeEnum.jingli.getCode(), RoleTypeEnum.xingzheng.getCode()), sysDept.getDeptId());
2832
+        } else if (StrUtil.equals(DeptTypeEnum.MANAGER.getCode(), sysDept.getDeptType())) {
2833
+            sysUserList = sysUserService.selectUserListByRoleKeyAndDeptId(Arrays.asList(RoleTypeEnum.kezhang.getCode()), sysDept.getDeptId());
2834
+        } else {
2835
+            sysUserList = Collections.emptyList();
2836
+        }
2815 2837
         SysCheckAnalysisReportCheckTaskDto checkTaskDto = new SysCheckAnalysisReportCheckTaskDto();
2816 2838
         List<SysCheckAnalysisReportCheckTaskItemDto> checkTaskItemDtoList = new ArrayList<>();
2817 2839
         paramDto.getDateRangeList().forEach(dateRange -> {
2840
+            List<CheckTask> checkTaskList = Collections.emptyList();
2818 2841
             CheckLargeScreenPlanQueryParamDto dto = new CheckLargeScreenPlanQueryParamDto();
2819 2842
             dto.setStartDate(dateRange.getStartDate());
2820 2843
             dto.setEndDate(dateRange.getEndDate());
2821
-            List<CheckTask> checkTaskList = checkLargeScreenMapper.planStatistics(dto);
2844
+            if (StrUtil.equals(DeptTypeEnum.STATION.getCode(), sysDept.getDeptType())) {
2845
+                dto.setIsSelfCheck(null);
2846
+                dto.setCreateId(null);
2847
+                dto.setUserIdList(null);
2848
+                checkTaskList = checkLargeScreenMapper.planStatistics(dto);
2849
+            } else if (StrUtil.equals(DeptTypeEnum.BRIGADE.getCode(), sysDept.getDeptType())) {
2850
+                if (!CollUtil.isEmpty(sysUserList)) {
2851
+                    List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).collect(Collectors.toList());
2852
+                    dto.setIsSelfCheck(1);
2853
+                    dto.setCreateId(null);
2854
+                    dto.setUserIdList(userIdList);
2855
+                    checkTaskList = checkLargeScreenMapper.planStatistics(dto);
2856
+                }
2857
+            } else {
2858
+                if (!CollUtil.isEmpty(sysUserList)) {
2859
+                    List<Long> userIdList = sysUserList.stream().map(SysUser::getUserId).collect(Collectors.toList());
2860
+                    dto.setIsSelfCheck(0);
2861
+                    dto.setCreateId(null);
2862
+                    dto.setUserIdList(userIdList);
2863
+                    checkTaskList = checkLargeScreenMapper.planStatistics(dto);
2864
+                }
2865
+            }
2822 2866
             Map<String, Long> map = checkTaskList.stream().collect(Collectors.groupingBy(CheckTask::getCheckCategory, Collectors.counting()));
2823 2867
 
2824 2868
             SysCheckAnalysisReportCheckTaskItemDto itemDtoSpecialTask = new SysCheckAnalysisReportCheckTaskItemDto();
@@ -2985,12 +3029,23 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
2985 3029
      * @return 问题发现统计
2986 3030
      */
2987 3031
     private SysCheckAnalysisReportCheckProblemDiscoveryDto getCheckProblemDiscoveryDto(SysAnalysisReportParamDto paramDto) {
3032
+        List<Long> userIdList = new ArrayList<>();
3033
+        if (ObjUtil.isNotNull(paramDto.getUserId())) {
3034
+            userIdList.add(paramDto.getUserId());
3035
+        } else {
3036
+            List<SysUser> sysUserList = sysUserService.selectUserByDeptId(paramDto.getDeptId());
3037
+            if (ObjUtil.isEmpty(sysUserList)) {
3038
+                return null;
3039
+            }
3040
+            userIdList.addAll(sysUserList.stream().map(SysUser::getUserId).collect(Collectors.toList()));
3041
+        }
2988 3042
         SysCheckAnalysisReportCheckProblemDiscoveryDto checkProblemDiscoveryDto = new SysCheckAnalysisReportCheckProblemDiscoveryDto();
2989 3043
         List<SysCheckAnalysisReportCheckProblemDiscoveryItemDto> checkProblemDiscoveryItemDtoList = new ArrayList<>();
2990 3044
         paramDto.getDateRangeList().forEach(dateRange -> {
2991 3045
             CheckLargeScreenPlanQueryParamDto dto = new CheckLargeScreenPlanQueryParamDto();
2992 3046
             dto.setStartDate(dateRange.getStartDate());
2993 3047
             dto.setEndDate(dateRange.getEndDate());
3048
+            dto.setUserIdList(userIdList);
2994 3049
             BigDecimal count = checkLargeScreenMapper.problemDistributionTotal(dto);
2995 3050
             SysCheckAnalysisReportCheckProblemDiscoveryItemDto checkProblemDiscoveryItemDto = new SysCheckAnalysisReportCheckProblemDiscoveryItemDto();
2996 3051
             checkProblemDiscoveryItemDto.setStartDate(dateRange.getStartDate());
@@ -3071,11 +3126,22 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
3071 3126
      * @return 问题分布统计
3072 3127
      */
3073 3128
     private SysCheckAnalysisReportCheckProblemDistributionDto getCheckProblemDistributionDto(SysAnalysisReportParamDto paramDto) {
3129
+        List<Long> userIdList = new ArrayList<>();
3130
+        if (ObjUtil.isNotNull(paramDto.getUserId())) {
3131
+            userIdList.add(paramDto.getUserId());
3132
+        } else {
3133
+            List<SysUser> sysUserList = sysUserService.selectUserByDeptId(paramDto.getDeptId());
3134
+            if (ObjUtil.isEmpty(sysUserList)) {
3135
+                return null;
3136
+            }
3137
+            userIdList.addAll(sysUserList.stream().map(SysUser::getUserId).collect(Collectors.toList()));
3138
+        }
3074 3139
         SysCheckAnalysisReportCheckProblemDistributionDto checkProblemDistributionDto = new SysCheckAnalysisReportCheckProblemDistributionDto();
3075 3140
         SysAnalysisReportDateRangeDto currentDateRangeDto = paramDto.getDateRangeList().stream().filter(dateRange -> StrUtil.equals(CompareTypeEnum.CURRENT.getCode(), dateRange.getTag())).findFirst().orElse(null);
3076 3141
         BaseLargeScreenQueryParamDto queryParamDto = new BaseLargeScreenQueryParamDto();
3077 3142
         queryParamDto.setStartDate(currentDateRangeDto.getStartDate());
3078 3143
         queryParamDto.setEndDate(currentDateRangeDto.getEndDate());
3144
+        queryParamDto.setUserIdList(userIdList);
3079 3145
         List<SysCheckAnalysisReportCheckProblemDistributionItemDto> checkProblemDistributionItemDtoList = checkLargeScreenMapper.problemDistributionStatistics(queryParamDto);
3080 3146
         checkProblemDistributionDto.setCheckProblemDistributionItemDtoList(checkProblemDistributionItemDtoList);
3081 3147
         if (CollUtil.isEmpty(checkProblemDistributionItemDtoList)) {
@@ -3108,59 +3174,189 @@ public class CheckLargeScreenServiceImpl implements ICheckLargeScreenService {
3108 3174
     private SysCheckAnalysisReportCheckProblemCorrectionDto getCheckProblemCorrectionDto(SysAnalysisReportParamDto paramDto) {
3109 3175
         SysCheckAnalysisReportCheckProblemCorrectionDto checkProblemCorrectionDto = new SysCheckAnalysisReportCheckProblemCorrectionDto();
3110 3176
         List<SysCheckAnalysisReportCheckProblemCorrectionItemDto> checkProblemCorrectionItemDtoList = new ArrayList<>();
3177
+        checkProblemCorrectionDto.setCheckProblemCorrectionItemDtoList(checkProblemCorrectionItemDtoList);
3111 3178
         SysAnalysisReportDateRangeDto currentDateRangeDto = paramDto.getDateRangeList().stream().filter(dateRange -> StrUtil.equals(CompareTypeEnum.CURRENT.getCode(), dateRange.getTag())).findFirst().orElse(null);
3112
-        BaseLargeScreenQueryParamDto queryParamDto = new BaseLargeScreenQueryParamDto();
3113
-        queryParamDto.setStartDate(currentDateRangeDto.getStartDate());
3114
-        queryParamDto.setEndDate(currentDateRangeDto.getEndDate());
3115
-        List<SysCheckAnalysisReportCheckProblemCorrectionItemDto> tempCheckProblemCorrectionItemDtoList = checkLargeScreenMapper.problemCorrectionStatistics(queryParamDto);
3116
-        if (CollUtil.isEmpty(tempCheckProblemCorrectionItemDtoList)) {
3179
+
3180
+        CheckLargeScreenCorrectionQueryParamDto tempQueryParam = new CheckLargeScreenCorrectionQueryParamDto();
3181
+        tempQueryParam.setStartDate(currentDateRangeDto.getStartDate());
3182
+        tempQueryParam.setEndDate(currentDateRangeDto.getEndDate());
3183
+        List<CheckLargeScreenCorrectionPortraitSqlDto> all = checkLargeScreenMapper.portrait(tempQueryParam);
3184
+        if (CollUtil.isEmpty(all)) {
3117 3185
             return null;
3118 3186
         }
3119
-        Map<Long, SysCheckAnalysisReportCheckProblemCorrectionItemDto> deptMap = tempCheckProblemCorrectionItemDtoList.stream().collect(Collectors.toMap(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getDeptId, item -> item, (oldValue, newValue) -> newValue));
3187
+        //补充检查级别为站级的整改单中的被检查班组数据
3188
+        List<Long> userIdList = all.stream().filter(item -> ObjectUtil.isNull(item.getCheckedTeamId())).map(CheckLargeScreenCorrectionPortraitSqlDto::getUserId).distinct().collect(Collectors.toList());
3189
+        if (CollUtil.isNotEmpty(userIdList)) {
3190
+            List<SysUser> sysUserList = sysUserService.selectByUserIdList(userIdList);
3191
+            Map<Long, Long> sysUserMap = sysUserList.stream().collect(Collectors.toMap(SysUser::getUserId, SysUser::getDeptId, (oldValue, newValue) -> newValue));
3192
+            List<Long> deptIdList = sysUserList.stream().map(SysUser::getDeptId).distinct().collect(Collectors.toList());
3193
+            List<SysDept> deptList = sysDeptService.selectDeptByIdList(deptIdList);
3194
+            Map<Long, String> deptMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName, (oldValue, newValue) -> newValue));
3195
+            all.forEach(item -> {
3196
+                if (ObjectUtil.isNull(item.getCheckedTeamId())) {
3197
+                    item.setCheckedTeamId(sysUserMap.getOrDefault(item.getUserId(), 0L));
3198
+                    item.setCheckedTeamName(deptMap.getOrDefault(item.getCheckedTeamId(), ""));
3199
+                }
3200
+            });
3201
+        }
3202
+        //补充被检查班科室数据
3203
+        List<Long> checkedTeamIdListTemp = all.stream().filter(item -> ObjectUtil.isNull(item.getCheckedDepartmentId())).map(CheckLargeScreenCorrectionPortraitSqlDto::getCheckedTeamId).distinct().collect(Collectors.toList());
3204
+        if (CollUtil.isNotEmpty(checkedTeamIdListTemp)) {
3205
+            List<SysDept> checkedTeamListTemp = sysDeptService.selectDeptByIdList(checkedTeamIdListTemp);
3206
+            if (CollUtil.isNotEmpty(checkedTeamListTemp)) {
3207
+                Map<Long, Long> deptIdMap = checkedTeamListTemp.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getParentId, (oldValue, newValue) -> newValue));
3208
+                List<Long> checkedDepartmentIdListTemp = checkedTeamListTemp.stream().map(SysDept::getParentId).collect(Collectors.toList());
3209
+                List<SysDept> checkedDepartmentListTemp = sysDeptService.selectDeptByIdList(checkedDepartmentIdListTemp);
3210
+                if (CollUtil.isNotEmpty(checkedDepartmentListTemp)) {
3211
+                    Map<Long, String> deptMap = checkedDepartmentListTemp.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName, (oldValue, newValue) -> newValue));
3212
+                    all.forEach(item -> {
3213
+                        if (ObjectUtil.isNull(item.getCheckedDepartmentId())) {
3214
+                            item.setCheckedDepartmentId(deptIdMap.getOrDefault(item.getCheckedTeamId(), 0L));
3215
+                            item.setCheckedDepartmentName(deptMap.getOrDefault(item.getCheckedDepartmentId(), ""));
3216
+                        }
3217
+                    });
3218
+                }
3219
+            }
3220
+        }
3120 3221
 
3121
-        SysCheckAnalysisReportCheckProblemCorrectionItemDto maxItemDto = tempCheckProblemCorrectionItemDtoList.stream()
3122
-                .filter(p -> p.getOnTimeCompletedCount() != null && p.getOnTimeCompletedCount().compareTo(BigDecimal.ZERO) > 0)
3123
-                .max(Comparator.comparing(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOnTimeCompletedCount))
3124
-                .orElse(null);
3125
-        if (ObjUtil.isNotNull(maxItemDto)) {
3126
-            String desc = maxItemDto.getDeptName() + "的按时整改率更高、整改更及时,是当时整改工作落实较好的科室";
3222
+        if (ObjUtil.isNotNull(paramDto.getUserId())) {
3223
+            List<CheckLargeScreenCorrectionPortraitSqlDto> targetList = all.stream().filter(item -> ObjUtil.equals(paramDto.getUserId(), item.getUserId())).collect(Collectors.toList());
3224
+            if (CollUtil.isEmpty(targetList)) {
3225
+                return null;
3226
+            }
3227
+            SysCheckAnalysisReportCheckProblemCorrectionItemDto individual = new SysCheckAnalysisReportCheckProblemCorrectionItemDto();
3228
+            SysUser sysUser = sysUserService.selectUserById(paramDto.getUserId());
3229
+            individual.setDeptId(sysUser.getUserId());
3230
+            individual.setDeptName(sysUser.getNickName());
3231
+            individual.setOnTimeCompletedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3232
+            individual.setOverTimeCompletedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3233
+            individual.setOnTimeUnfinishedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3234
+            individual.setOverTimeUnfinishedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3235
+            individual.setOtherCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OTHER.getCode(), item.getCorrectionType())).count()));
3236
+            String desc = "按期整改" + individual.getOnTimeCompletedCount().add(individual.getOnTimeUnfinishedCount()) + "个,超期整改" + individual.getOverTimeCompletedCount().add(individual.getOverTimeUnfinishedCount()) + "个";
3127 3237
             checkProblemCorrectionDto.setDesc(desc);
3128
-        }
3238
+            checkProblemCorrectionItemDtoList.add(individual);
3239
+        } else {
3240
+            SysDept sysDept = sysDeptService.selectDeptById(paramDto.getDeptId());
3241
+            List<SysUser> sysUserList = sysUserService.selectUserByDeptId(sysDept.getDeptId());
3242
+            if (CollUtil.isEmpty(sysUserList)) {
3243
+                return null;
3244
+            }
3245
+            List<Long> targetUserIdList = sysUserList.stream().map(SysUser::getUserId).collect(Collectors.toList());
3246
+            List<CheckLargeScreenCorrectionPortraitSqlDto> targetList = all.stream().filter(item -> targetUserIdList.contains(item.getUserId())).collect(Collectors.toList());
3247
+            if (CollUtil.isEmpty(targetList)) {
3248
+                return null;
3249
+            }
3250
+            if (StrUtil.equals(sysDept.getDeptType(), DeptTypeEnum.STATION.getCode())) {
3251
+                Map<String, Long> descMap = targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_COMPLETED.getCode(), item.getCorrectionType())).collect(Collectors.groupingBy(item -> item.getCheckedBrigadeId() + "###" + item.getCheckedBrigadeName(), Collectors.counting()));
3252
+                String key = descMap.entrySet().stream()
3253
+                        .max(Map.Entry.comparingByValue())
3254
+                        .map(Map.Entry::getKey)
3255
+                        .orElse(null);
3256
+                if (ObjUtil.isNotNull(key)) {
3257
+                    String desc = key.split("###")[1] + "的按时整改率更高、整改更及时,是当时整改工作落实较好的大队";
3258
+                    checkProblemCorrectionDto.setDesc(desc);
3259
+                }
3260
+
3261
+                Map<Long, List<CheckLargeScreenCorrectionPortraitSqlDto>> deptMap = targetList.stream().collect(Collectors.groupingBy(CheckLargeScreenCorrectionPortraitSqlDto::getCheckedBrigadeId));
3262
+                SysDept deptQuery = new SysDept();
3263
+                deptQuery.setParentId(sysDept.getDeptId());
3264
+                deptQuery.setDeptType(DeptTypeEnum.BRIGADE.getCode());
3265
+                List<SysDept> sysDeptList = sysDeptService.selectDeptInfoAll(deptQuery);
3266
+                sysDeptList.forEach(dept -> {
3267
+                    SysCheckAnalysisReportCheckProblemCorrectionItemDto itemDto = new SysCheckAnalysisReportCheckProblemCorrectionItemDto();
3268
+                    itemDto.setDeptId(dept.getDeptId());
3269
+                    itemDto.setDeptName(dept.getDeptName());
3270
+                    List<CheckLargeScreenCorrectionPortraitSqlDto> list = deptMap.get(dept.getDeptId());
3271
+                    if (CollUtil.isNotEmpty(list)) {
3272
+                        itemDto.setOnTimeCompletedCount(BigDecimal.valueOf(list.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3273
+                        itemDto.setOverTimeCompletedCount(BigDecimal.valueOf(list.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3274
+                        itemDto.setOnTimeUnfinishedCount(BigDecimal.valueOf(list.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3275
+                        itemDto.setOverTimeUnfinishedCount(BigDecimal.valueOf(list.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3276
+                        itemDto.setOtherCount(BigDecimal.valueOf(list.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OTHER.getCode(), item.getCorrectionType())).count()));
3277
+                    } else {
3278
+                        itemDto.setOnTimeCompletedCount(BigDecimal.ZERO);
3279
+                        itemDto.setOverTimeCompletedCount(BigDecimal.ZERO);
3280
+                        itemDto.setOnTimeUnfinishedCount(BigDecimal.ZERO);
3281
+                        itemDto.setOverTimeUnfinishedCount(BigDecimal.ZERO);
3282
+                        itemDto.setOtherCount(BigDecimal.ZERO);
3283
+                    }
3284
+                    checkProblemCorrectionItemDtoList.add(itemDto);
3285
+                });
3286
+
3287
+                SysCheckAnalysisReportCheckProblemCorrectionItemDto totalItem = new SysCheckAnalysisReportCheckProblemCorrectionItemDto();
3288
+                totalItem.setDeptId(null);
3289
+                totalItem.setDeptName("总数");
3290
+                totalItem.setOnTimeCompletedCount(checkProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOnTimeCompletedCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3291
+                totalItem.setOverTimeCompletedCount(checkProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOverTimeCompletedCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3292
+                totalItem.setOnTimeUnfinishedCount(checkProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOnTimeUnfinishedCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3293
+                totalItem.setOverTimeUnfinishedCount(checkProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOverTimeUnfinishedCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3294
+                totalItem.setOtherCount(checkProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOtherCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3295
+                checkProblemCorrectionItemDtoList.add(0, totalItem);
3296
+            } else if (StrUtil.equals(sysDept.getDeptType(), DeptTypeEnum.BRIGADE.getCode())) {
3297
+                Map<String, Long> descMap = targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_COMPLETED.getCode(), item.getCorrectionType())).collect(Collectors.groupingBy(item -> item.getCheckedDepartmentId() + "###" + item.getCheckedDepartmentName(), Collectors.counting()));
3298
+                String key = descMap.entrySet().stream()
3299
+                        .max(Map.Entry.comparingByValue())
3300
+                        .map(Map.Entry::getKey)
3301
+                        .orElse(null);
3302
+                if (ObjUtil.isNotNull(key)) {
3303
+                    String desc = key.split("###")[1] + "的按时整改率更高、整改更及时,是当时整改工作落实较好的主管";
3304
+                    checkProblemCorrectionDto.setDesc(desc);
3305
+                }
3129 3306
 
3130
-        List<SysDept> deptList = sysDeptService.selectAllDept(SecurityUtils.getLoginUser().getDeptId());
3131
-        Collections.reverse(deptList);
3132
-        SysDept station = deptList.stream().filter(x -> StrUtil.equals(DeptType.STATION.getCode(), x.getDeptType())).findFirst().orElse(null);
3133
-        SysDept deptQuery = new SysDept();
3134
-        deptQuery.setParentId(station.getDeptId());
3135
-        deptQuery.setDeptType(DeptType.DEPARTMENT.getCode());
3136
-        List<SysDept> sysDeptList = sysDeptService.selectDeptInfoAll(deptQuery);
3137
-        sysDeptList.forEach(dept -> {
3138
-            SysCheckAnalysisReportCheckProblemCorrectionItemDto itemDto = deptMap.get(dept.getDeptId());
3139
-            if (itemDto != null) {
3140
-                checkProblemCorrectionItemDtoList.add(itemDto);
3307
+                SysCheckAnalysisReportCheckProblemCorrectionItemDto totalItem = new SysCheckAnalysisReportCheckProblemCorrectionItemDto();
3308
+                totalItem.setDeptId(sysDept.getDeptId());
3309
+                totalItem.setDeptName(sysDept.getDeptName());
3310
+                totalItem.setOnTimeCompletedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3311
+                totalItem.setOverTimeCompletedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3312
+                totalItem.setOnTimeUnfinishedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3313
+                totalItem.setOverTimeUnfinishedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3314
+                totalItem.setOtherCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OTHER.getCode(), item.getCorrectionType())).count()));
3315
+                checkProblemCorrectionItemDtoList.add(totalItem);
3316
+            } else if (StrUtil.equals(sysDept.getDeptType(), DeptTypeEnum.MANAGER.getCode())) {
3317
+                Map<String, Long> descMap = targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_COMPLETED.getCode(), item.getCorrectionType())).collect(Collectors.groupingBy(item -> item.getCheckedTeamId() + "###" + item.getCheckedTeamName(), Collectors.counting()));
3318
+                String key = descMap.entrySet().stream()
3319
+                        .max(Map.Entry.comparingByValue())
3320
+                        .map(Map.Entry::getKey)
3321
+                        .orElse(null);
3322
+                if (ObjUtil.isNotNull(key)) {
3323
+                    String desc = key.split("###")[1] + "的按时整改率更高、整改更及时,是当时整改工作落实较好的班组";
3324
+                    checkProblemCorrectionDto.setDesc(desc);
3325
+                }
3326
+
3327
+                SysCheckAnalysisReportCheckProblemCorrectionItemDto totalItem = new SysCheckAnalysisReportCheckProblemCorrectionItemDto();
3328
+                totalItem.setDeptId(sysDept.getDeptId());
3329
+                totalItem.setDeptName(sysDept.getDeptName());
3330
+                totalItem.setOnTimeCompletedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3331
+                totalItem.setOverTimeCompletedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3332
+                totalItem.setOnTimeUnfinishedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3333
+                totalItem.setOverTimeUnfinishedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3334
+                totalItem.setOtherCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OTHER.getCode(), item.getCorrectionType())).count()));
3335
+                checkProblemCorrectionItemDtoList.add(totalItem);
3336
+            } else if (StrUtil.equals(sysDept.getDeptType(), DeptTypeEnum.TEAMS.getCode())) {
3337
+                Map<String, Long> descMap = targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_COMPLETED.getCode(), item.getCorrectionType())).collect(Collectors.groupingBy(item -> item.getUserId() + "###" + item.getUserName(), Collectors.counting()));
3338
+                String key = descMap.entrySet().stream()
3339
+                        .max(Map.Entry.comparingByValue())
3340
+                        .map(Map.Entry::getKey)
3341
+                        .orElse(null);
3342
+                if (ObjUtil.isNotNull(key)) {
3343
+                    String desc = key.split("###")[1] + "的按时整改率更高、整改更及时,是当时整改工作落实较好的成员";
3344
+                    checkProblemCorrectionDto.setDesc(desc);
3345
+                }
3346
+
3347
+                SysCheckAnalysisReportCheckProblemCorrectionItemDto totalItem = new SysCheckAnalysisReportCheckProblemCorrectionItemDto();
3348
+                totalItem.setDeptId(sysDept.getDeptId());
3349
+                totalItem.setDeptName(sysDept.getDeptName());
3350
+                totalItem.setOnTimeCompletedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3351
+                totalItem.setOverTimeCompletedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_COMPLETED.getCode(), item.getCorrectionType())).count()));
3352
+                totalItem.setOnTimeUnfinishedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.ON_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3353
+                totalItem.setOverTimeUnfinishedCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OVER_TIME_UNFINISHED.getCode(), item.getCorrectionType())).count()));
3354
+                totalItem.setOtherCount(BigDecimal.valueOf(targetList.stream().filter(item -> StrUtil.equals(CheckLargeScreenCorrectionTypeEnum.OTHER.getCode(), item.getCorrectionType())).count()));
3355
+                checkProblemCorrectionItemDtoList.add(totalItem);
3141 3356
             } else {
3142
-                SysCheckAnalysisReportCheckProblemCorrectionItemDto itemDtoZero = new SysCheckAnalysisReportCheckProblemCorrectionItemDto();
3143
-                itemDtoZero.setDeptId(dept.getDeptId());
3144
-                itemDtoZero.setDeptName(dept.getDeptName());
3145
-                itemDtoZero.setOnTimeCompletedCount(BigDecimal.ZERO);
3146
-                itemDtoZero.setOverTimeCompletedCount(BigDecimal.ZERO);
3147
-                itemDtoZero.setOnTimeUnfinishedCount(BigDecimal.ZERO);
3148
-                itemDtoZero.setOverTimeUnfinishedCount(BigDecimal.ZERO);
3149
-                itemDtoZero.setOtherCount(BigDecimal.ZERO);
3150
-                checkProblemCorrectionItemDtoList.add(itemDtoZero);
3357
+                throw new ServiceException("部门类型错误");
3151 3358
             }
3152
-        });
3153
-
3154
-        SysCheckAnalysisReportCheckProblemCorrectionItemDto totalItem = new SysCheckAnalysisReportCheckProblemCorrectionItemDto();
3155
-        totalItem.setDeptId(null);
3156
-        totalItem.setDeptName("总数");
3157
-        totalItem.setOnTimeCompletedCount(tempCheckProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOnTimeCompletedCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3158
-        totalItem.setOverTimeCompletedCount(tempCheckProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOverTimeCompletedCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3159
-        totalItem.setOnTimeUnfinishedCount(tempCheckProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOnTimeUnfinishedCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3160
-        totalItem.setOverTimeUnfinishedCount(tempCheckProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOverTimeUnfinishedCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3161
-        totalItem.setOtherCount(tempCheckProblemCorrectionItemDtoList.stream().map(SysCheckAnalysisReportCheckProblemCorrectionItemDto::getOtherCount).reduce(BigDecimal.ZERO, BigDecimal::add));
3162
-        checkProblemCorrectionItemDtoList.add(0, totalItem);
3163
-        checkProblemCorrectionDto.setCheckProblemCorrectionItemDtoList(checkProblemCorrectionItemDtoList);
3359
+        }
3164 3360
 
3165 3361
         return checkProblemCorrectionDto;
3166 3362
     }

+ 24 - 32
airport-check/src/main/resources/mapper/check/CheckLargeScreenMapper.xml

@@ -66,6 +66,12 @@
66 66
             and (ct.check_start_time >= #{startDate}
67 67
             and ct.check_start_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
68 68
         </if>
69
+        <if test="userIdList != null and userIdList.size() > 0">
70
+            and ct.create_id in
71
+            <foreach collection="userIdList" item="item" open="(" separator="," close=")">
72
+                #{item}
73
+            </foreach>
74
+        </if>
69 75
         order by ct.check_start_time desc
70 76
     </select>
71 77
 
@@ -932,62 +938,48 @@
932 938
     </select>
933 939
 
934 940
     <select id="problemDistributionTotal" resultType="java.math.BigDecimal">
935
-        select count(cpi.id) total
941
+        select count(cu.id) total
936 942
         from check_correction cc
937 943
         inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
944
+        inner join check_user cu on
945
+        (cu.source_id = cpi.id and cu.type = 'PROBLEM_RECTIFICATION_INSPECTION_ITEM_DETAILS')
938 946
         where 1 = 1
939 947
         <if test="startDate != null and endDate != null">
940 948
             and (cc.check_time >= #{startDate}
941 949
             and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
942 950
         </if>
951
+        <if test="userIdList != null and userIdList.size() > 0">
952
+            and cu.user_id in
953
+            <foreach collection="userIdList" item="item" open="(" separator="," close=")">
954
+                #{item}
955
+            </foreach>
956
+        </if>
943 957
     </select>
944 958
 
945 959
     <select id="problemDistributionStatistics"
946 960
             resultType="com.sundot.airport.common.core.domain.SysCheckAnalysisReportCheckProblemDistributionItemDto">
947 961
         select cpi.category_code_one code,
948 962
         cpi.category_name_one name,
949
-        count(cpi.id) total
963
+        count(cu.id) total
950 964
         from check_correction cc
951 965
         inner join check_project_item cpi on (cpi.source_id = cc.id and cpi.type = 'CHECK_CORRECTION')
966
+        inner join check_user cu on
967
+        (cu.source_id = cpi.id and cu.type = 'PROBLEM_RECTIFICATION_INSPECTION_ITEM_DETAILS')
952 968
         where 1 = 1
953 969
         <if test="startDate != null and endDate != null">
954 970
             and (cc.check_time >= #{startDate}
955 971
             and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
956 972
         </if>
973
+        <if test="userIdList != null and userIdList.size() > 0">
974
+            and cu.user_id in
975
+            <foreach collection="userIdList" item="item" open="(" separator="," close=")">
976
+                #{item}
977
+            </foreach>
978
+        </if>
957 979
         group by cpi.category_code_one, cpi.category_name_one
958 980
         order by total desc
959 981
     </select>
960 982
 
961
-    <select id="problemCorrectionStatistics"
962
-            resultType="com.sundot.airport.common.core.domain.SysCheckAnalysisReportCheckProblemCorrectionItemDto">
963
-        select temp.deptId deptId,
964
-        temp.deptName deptName,
965
-        ifnull(sum(case when temp.type = 'ON_TIME_COMPLETED' then 1 else 0 end), 0) onTimeCompletedCount,
966
-        ifnull(sum(case when temp.type = 'OVER_TIME_COMPLETED' then 1 else 0 end), 0) overTimeCompletedCount,
967
-        ifnull(sum(case when temp.type = 'ON_TIME_UNFINISHED' then 1 else 0 end), 0) onTimeUnfinishedCount,
968
-        ifnull(sum(case when temp.type = 'OVER_TIME_UNFINISHED' then 1 else 0 end), 0) overTimeUnfinishedCount,
969
-        ifnull(sum(case when temp.type = 'OTHER' then 1 else 0 end), 0) otherCount
970
-        from (select cc.checked_brigade_id deptId,
971
-        cc.checked_brigade_name deptName,
972
-        case
973
-        when cc.status = 'RECTIFIED' and cc.rectification_deadline >= cc.completion_time
974
-        then 'ON_TIME_COMPLETED'
975
-        when cc.status = 'RECTIFIED' and cc.rectification_deadline <![CDATA[ < ]]> cc.completion_time
976
-        then 'OVER_TIME_COMPLETED'
977
-        when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() <![CDATA[ <= ]]> cc.rectification_deadline
978
-        then 'ON_TIME_UNFINISHED'
979
-        when cc.status = 'UNDER_RECTIFICATION' and CURRENT_DATE() > cc.rectification_deadline
980
-        then 'OVER_TIME_UNFINISHED'
981
-        else 'OTHER' end type
982
-        from check_correction cc
983
-        where 1 = 1
984
-        <if test="startDate != null and endDate != null">
985
-            and (cc.check_time >= #{startDate}
986
-            and cc.check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
987
-        </if>) temp
988
-        group by temp.deptId, temp.deptName
989
-    </select>
990
-
991 983
     <select id="getUsageReportCheckTaskDto"
992 984
             resultType="com.sundot.airport.common.core.domain.SysUsageReportCheckTaskDto">
993 985
         select ct.task_code taskCode,

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

@@ -7,6 +7,7 @@ import org.springframework.format.annotation.DateTimeFormat;
7 7
 
8 8
 import java.io.Serializable;
9 9
 import java.util.Date;
10
+import java.util.List;
10 11
 
11 12
 /**
12 13
  * 大屏查询参数
@@ -115,4 +116,8 @@ public class BaseLargeScreenQueryParamDto implements Serializable {
115 116
 
116 117
     @ApiModelProperty("站id")
117 118
     private Long inspectStationId;
119
+
120
+    @ApiModelProperty("人员ID列表")
121
+    private List<Long> userIdList;
122
+
118 123
 }

+ 10 - 0
airport-common/src/main/java/com/sundot/airport/common/core/domain/SysAnalysisReportParamDto.java

@@ -38,4 +38,14 @@ public class SysAnalysisReportParamDto {
38 38
      */
39 39
     private List<SysAnalysisReportDateRangeDto> dateRangeList;
40 40
 
41
+    /**
42
+     * 用户ID
43
+     */
44
+    private Long userId;
45
+
46
+    /**
47
+     * 部门ID
48
+     */
49
+    private Long deptId;
50
+
41 51
 }