无关风月
1 天以前 2fee40486f9473398be3c293e8311d45bd53adc9
Merge remote-tracking branch 'origin/master'

# Conflicts:
# ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
10个文件已修改
1363 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java 218 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/WorkbenchesController.java 323 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java 729 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-test.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTaskCleanServiceImpl.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/system/AnalysisUnqualifiedCleaningVO.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/system/ProgressListVO.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/system/TLocationTaskListVO.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/system/TaskSituationVO.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TTaskMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/DataStatisticsController.java
@@ -65,6 +65,8 @@
    private TAppealService appealService;
    @Resource
    private TDictDataService dictDataService;
    @Resource
    private TEarlyWarningService earlyWarningService;
    @ApiOperation(value = "查询片区")
    @GetMapping(value = "/queryProject")
@@ -169,6 +171,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -184,8 +187,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -231,8 +233,7 @@
            if(CollectionUtils.isEmpty(query.getProjectId())){
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -243,6 +244,9 @@
            if(!CollectionUtils.isEmpty(query.getProjectId())){
                query.setProjectId(query.getProjectId().stream().distinct().collect(Collectors.toList()));
                wrapper.in(TTask::getProjectId, query.getProjectId());
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
                        .in(TTask::getProjectId, query.getProjectId())
                        .between(TTask::getImplementTime, startTime, endTime));
            }
            List<TTask> list = taskCleanService.list(wrapper);
@@ -293,6 +297,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -303,8 +308,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())) {
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if (!CollectionUtils.isEmpty(tProjectDeptList)) {
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
@@ -350,8 +354,7 @@
            if(CollectionUtils.isEmpty(query.getProjectId())) {
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if (!CollectionUtils.isEmpty(tProjectDeptList)) {
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
@@ -418,6 +421,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -432,8 +436,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -457,25 +460,20 @@
            }
            list = list.stream().distinct().collect(Collectors.toList());
            map.put("timeoutWarn", list.stream().filter(task -> task.getStatus() == 2).count());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                map.put("unqualifiedWarn", 0);
                return R.ok(map);
            }
            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
                    .in(TTaskDetail::getTaskId, taskIds)
                    .orderByDesc(TTaskDetail::getCreateTime));
            int unqualifiedWarn = 0;
            for (TTask task : list) {
                TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
                if(Objects.nonNull(tTaskDetail)){
                    if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 2){
            List<TEarlyWarning> earlyWarnings = earlyWarningService.list(Wrappers.lambdaQuery(TEarlyWarning.class));
            if(CollectionUtils.isEmpty(earlyWarnings)){
                map.put("unqualifiedWarn", unqualifiedWarn);
            }else {
                // 将earlyWarnings列表的taskId用逗号拼接
                String taskIds = earlyWarnings.stream().map(TEarlyWarning::getTaskId).collect(Collectors.joining(","));
                for (TTask task : list) {
                    if(taskIds.contains(task.getId())){
                        unqualifiedWarn++;
                    }
                }
                map.put("unqualifiedWarn", unqualifiedWarn);
            }
            map.put("unqualifiedWarn", unqualifiedWarn);
        }else {
            // 超级管理员
            // 查询点位类型
@@ -489,12 +487,12 @@
                }
            }
            // 超级管理员 查询所有的任务列表
            List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
            List<TTask> taskList = new ArrayList<>();
            if(CollectionUtils.isEmpty(query.getProjectId())){
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -517,25 +515,20 @@
            }
            list = list.stream().distinct().collect(Collectors.toList());
            map.put("timeoutWarn", list.stream().filter(task -> task.getStatus() == 2).count());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                map.put("unqualifiedWarn", 0);
                return R.ok(map);
            }
            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
                    .in(TTaskDetail::getTaskId, taskIds)
                    .orderByDesc(TTaskDetail::getCreateTime));
            int unqualifiedWarn = 0;
            for (TTask task : list) {
                TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
                if(Objects.nonNull(tTaskDetail)){
                    if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 2){
            List<TEarlyWarning> earlyWarnings = earlyWarningService.list(Wrappers.lambdaQuery(TEarlyWarning.class));
            if(CollectionUtils.isEmpty(earlyWarnings)){
                map.put("unqualifiedWarn", unqualifiedWarn);
            }else {
                // 将earlyWarnings列表的taskId用逗号拼接
                String taskIds = earlyWarnings.stream().map(TEarlyWarning::getTaskId).collect(Collectors.joining(","));
                for (TTask task : list) {
                    if(taskIds.contains(task.getId())){
                        unqualifiedWarn++;
                    }
                }
                map.put("unqualifiedWarn", unqualifiedWarn);
            }
            map.put("unqualifiedWarn", unqualifiedWarn);
        }
        return R.ok(map);
    }
@@ -570,6 +563,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -584,8 +578,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -609,7 +602,8 @@
            }
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                    && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                return R.ok();
            }
@@ -662,12 +656,12 @@
                }
            }
            // 超级管理员 查询所有的任务列表
            List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
            List<TTask> taskList = new ArrayList<>();
            if(CollectionUtils.isEmpty(query.getProjectId())){
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -690,7 +684,8 @@
            }
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                    && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                return R.ok();
            }
@@ -792,6 +787,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -807,8 +803,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -851,15 +846,27 @@
            }
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                    && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                return R.ok();
            }
            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
                    .in(TTaskDetail::getTaskId, taskIds)
                    .eq(TTaskDetail::getClearStatus, 1)
                    .eq(TTaskDetail::getHandleType,1)
                    .orderByDesc(TTaskDetail::getCreateTime));
            // 使用 stream 去重,保留每个 taskId 最新的一条
            taskDetails = new ArrayList<>(taskDetails.stream()
                    .collect(Collectors.groupingBy(
                            TTaskDetail::getTaskId,
                            Collectors.collectingAndThen(
                                    Collectors.toList(),
                                    list1 -> list1.get(0)
                            )
                    ))
                    .values());
            if(query.getRankType() == 1){
                // 用户排名
@@ -868,8 +875,10 @@
                    dataStatisticsRankVO.setName(sysUser.getNickName());
                    List<String> taskIdList = tasks.stream().filter(task -> task.getPatrolInspector().equals(String.valueOf(sysUser.getUserId()))).map(TTask::getId).collect(Collectors.toList());
                    dataStatisticsRankVO.setTaskCount(taskIdList.size());
                    long count = taskDetails.stream().filter(taskDetail -> taskIdList.contains(taskDetail.getTaskId())).count();
                    long count = taskDetails.stream().filter(taskDetail -> taskIdList.contains(taskDetail.getTaskId())
                            && taskDetail.getClearStatus() == 1).count();
                    dataStatisticsRankVO.setQualifiedCount(count);
                    result.add(dataStatisticsRankVO);
                }
            }else {
                // 查询项目部
@@ -878,6 +887,9 @@
                    projectDepts = new ArrayList<>();
                    // 当前项目部
                    TProjectDept projectDept = projectDeptService.getById(deptId);
                    if(Objects.nonNull(projectDept) && !"0".equals(projectDept.getParentId())){
                        projectDept = projectDeptService.getById(projectDept.getParentId());
                    }
                    projectDepts.add(projectDept);
                }else {
                    if (CollectionUtils.isEmpty(query.getProjectId())){
@@ -906,7 +918,7 @@
                    dataStatisticsRankVO.setName(projectDept.getProjectName());
                    List<String> taskIdList;
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        List<String> projectIds = tProjectDeptList.stream().filter(e -> e.getParentId().equals(projectDept.getId())).map(TProjectDept::getId).collect(Collectors.toList());
                        taskIdList = tasks.stream().filter(task -> projectIds.contains(task.getProjectId())).map(TTask::getId).collect(Collectors.toList());
                    } else {
                        taskIdList = new ArrayList<>();
@@ -916,8 +928,10 @@
                        dataStatisticsRankVO.setQualifiedCount(0L);
                        continue;
                    }
                    long count = taskDetails.stream().filter(taskDetail -> taskIdList.contains(taskDetail.getTaskId())).count();
                    long count = taskDetails.stream().filter(taskDetail -> taskIdList.contains(taskDetail.getTaskId())
                            && taskDetail.getClearStatus() == 1).count();
                    dataStatisticsRankVO.setQualifiedCount(count);
                    result.add(dataStatisticsRankVO);
                }
            }
        }else {
@@ -985,15 +999,27 @@
            }
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
            && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                return R.ok();
            }
            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
                    .in(TTaskDetail::getTaskId, taskIds)
                    .eq(TTaskDetail::getClearStatus, 1)
                    .eq(TTaskDetail::getHandleType,1)
                    .orderByDesc(TTaskDetail::getCreateTime));
            // 使用 stream 去重,保留每个 taskId 最新的一条
            taskDetails = new ArrayList<>(taskDetails.stream()
                    .collect(Collectors.groupingBy(
                            TTaskDetail::getTaskId,
                            Collectors.collectingAndThen(
                                    Collectors.toList(),
                                    list1 -> list1.get(0)
                            )
                    ))
                    .values());
            if(query.getRankType() == 1){
                // 用户排名
@@ -1002,8 +1028,10 @@
                    dataStatisticsRankVO.setName(sysUser.getNickName());
                    List<String> taskIdList = tasks.stream().filter(task -> task.getPatrolInspector().equals(String.valueOf(sysUser.getUserId()))).map(TTask::getId).collect(Collectors.toList());
                    dataStatisticsRankVO.setTaskCount(taskIdList.size());
                    long count = taskDetails.stream().filter(taskDetail -> taskIdList.contains(taskDetail.getTaskId())).count();
                    long count = taskDetails.stream().filter(taskDetail -> taskIdList.contains(taskDetail.getTaskId())
                                && taskDetail.getClearStatus() == 1).count();
                    dataStatisticsRankVO.setQualifiedCount(count);
                    result.add(dataStatisticsRankVO);
                }
            }else {
                // 超级管理员 查询所有项目部
@@ -1033,7 +1061,7 @@
                    dataStatisticsRankVO.setName(projectDept.getProjectName());
                    List<String> taskIdList;
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        List<String> projectIds = tProjectDeptList.stream().filter(e -> e.getParentId().equals(projectDept.getId())).map(TProjectDept::getId).collect(Collectors.toList());
                        taskIdList = tasks.stream().filter(task -> projectIds.contains(task.getProjectId())).map(TTask::getId).collect(Collectors.toList());
                    } else {
                        taskIdList = new ArrayList<>();
@@ -1043,12 +1071,21 @@
                        dataStatisticsRankVO.setQualifiedCount(0L);
                        continue;
                    }
                    long count = taskDetails.stream().filter(taskDetail -> taskIdList.contains(taskDetail.getTaskId())).count();
                    long count = taskDetails.stream().filter(taskDetail -> taskIdList.contains(taskDetail.getTaskId())
                            && taskDetail.getClearStatus() == 1).count();
                    dataStatisticsRankVO.setQualifiedCount(count);
                    result.add(dataStatisticsRankVO);
                }
            }
        }
        // 先根据任务总数排序,再根据合格数进行排序
        result.sort((o1, o2) -> {
            if (o1.getTaskCount().equals(o2.getTaskCount())) {
                return o2.getQualifiedCount().compareTo(o1.getQualifiedCount());
            }else{
                return o2.getTaskCount().compareTo(o1.getTaskCount());
            }
        });
        return R.ok(result);
    }
@@ -1092,27 +1129,36 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
                    }
                    query.setProjectId(projectIds);
                }
                // 巡检员数
                Integer totalEmployeeNum = sysUserService.selectUserCount(query.getProjectId(),deptType);
                map.put("totalEmployeeNum", totalEmployeeNum);
            }else {
                // 公司人员
                // 查询自己的任务列表
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
                        .eq(TTask::getPatrolInspector, userId));
                        .eq(TTask::getPatrolInspector, userId)
                        .between(TTask::getImplementTime, startTime, endTime));
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
                    }
                }else {
                }
                // 巡检员数
                Integer totalEmployeeNum = sysUserService.selectUserCount(query.getProjectId(),1);
                map.put("totalEmployeeNum", totalEmployeeNum+1);
            }
            // 查询片区
@@ -1134,6 +1180,7 @@
                list.addAll(taskList);
            }
            list = list.stream().distinct().collect(Collectors.toList());
        }else {
            // 超级管理员
            // 查询点位类型
@@ -1148,12 +1195,13 @@
                map.put("totalLocationNum", locationList.size());
            }
            // 超级管理员 查询所有的任务列表
            List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
            List<TTask> taskList = new ArrayList<>();
            if(CollectionUtils.isEmpty(query.getProjectId())){
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
                        .between(TTask::getImplementTime, startTime, endTime));
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -1167,6 +1215,9 @@
                List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
                        .in(TLocation::getProjectId, query.getProjectId()));
                map.put("totalLocationNum", locationList.size());
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
                        .in(TTask::getProjectId, query.getProjectId())
                        .between(TTask::getImplementTime, startTime, endTime));
            }
            list = taskCleanService.list(wrapper);
@@ -1178,6 +1229,17 @@
                list.addAll(taskList);
            }
            list = list.stream().distinct().collect(Collectors.toList());
            // 巡检员数
            if(CollectionUtils.isEmpty(query.getProjectId())){
                Integer totalEmployeeNum = sysUserService.selectUserCount(query.getProjectId(),deptType);
                Integer totalEmployeeNum1 = sysUserService.selectUserCount(query.getProjectId(),1);
                map.put("totalEmployeeNum", totalEmployeeNum+totalEmployeeNum1);
            }else {
                Integer totalEmployeeNum = sysUserService.selectUserCount(query.getProjectId(),1);
                map.put("totalEmployeeNum", totalEmployeeNum);
            }
        }
        // 查询任务相关数据
@@ -1186,16 +1248,10 @@
        // 片区数量
        map.put("totalProjectNum", query.getProjectId().size());
        // 巡检员数
        Integer totalEmployeeNum = sysUserService.selectUserCount(query.getProjectId(),deptType);
        if (deptType != 1) {
            totalEmployeeNum = totalEmployeeNum + 1;
        }
        map.put("totalEmployeeNum", totalEmployeeNum);
        // 合格率
        // 匹配任务详情查看合格数量
        List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
        List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
        if(CollectionUtils.isEmpty(tasks)){
            map.put("qualifiedRate",BigDecimal.ZERO);
            return R.ok(map);
@@ -1252,6 +1308,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -1263,8 +1320,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -1276,8 +1332,7 @@
            if(CollectionUtils.isEmpty(query.getProjectId())){
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -1326,11 +1381,12 @@
        locationStatisticsVO.setTotalInspection(list.size());
        // 完成数
        long completeInspection = list.stream().filter(task -> task.getStatus() == 6).count();
        long completeInspection = list.stream().filter(task -> task.getStatus() == 6 || task.getStatus() == 5).count();
        locationStatisticsVO.setCompleteInspection(completeInspection);
        // 合格率
        List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
        List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
        if(CollectionUtils.isEmpty(tasks)){
            locationStatisticsVO.setPassRate(new BigDecimal(0));
            return R.ok(locationStatisticsVO);
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/WorkbenchesController.java
@@ -65,7 +65,8 @@
    private TCleanerService cleanerService;
    @Resource
    private TLeaveService leaveService;
    @Resource
    private TEarlyWarningService earlyWarningService;
    @ApiOperation(value = "查询部门 项目部列表 不分页")
    @GetMapping(value = "/listDepts")
    public R<List<DeptNoLimitVO>> listDepts() {
@@ -196,6 +197,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -210,8 +212,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -252,12 +253,12 @@
                map.put("totalLocationNum", locationList.size());
            }
            // 超级管理员 查询所有的任务列表
            List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
            List<TTask> taskList = new ArrayList<>();
            if(CollectionUtils.isEmpty(query.getProjectId())){
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -342,6 +343,16 @@
        wrapper.between(TTask::getImplementTime, query.getStartTime(), query.getEndTime());
        // 过滤每天的任务
        LocalDateTime start = DateUtils.stringToLocalDateTime(query.getStartTime());
        LocalDateTime end = DateUtils.stringToLocalDateTime(query.getEndTime());
        long daysBetween = ChronoUnit.DAYS.between(start, end);
        List<TaskSituationDayVO> taskSituationDayVOList = new ArrayList<>();
        LocalDateTime localDateTime = DateUtils.stringToLocalDateTime(query.getStartTime());
        String format = null;
        List<TTask> list;
        if (userId != 1L) {
            // 查询点位类型
@@ -365,6 +376,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -380,8 +392,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -397,7 +408,23 @@
            list = taskCleanService.list(wrapper);
            if(CollectionUtils.isEmpty(list)){
                return R.ok();
                for (long i = 0; i <= daysBetween; i++) {
                    TaskSituationDayVO taskSituationDayVO = new TaskSituationDayVO();
                    if(i == 0){
                        format = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                    }else {
                        format = DateUtils.stringToLocalDate(format).plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                    }
                    taskSituationDayVO.setTaskTime(format);
                    // 任务数
                    taskSituationDayVO.setTaskNum(0);
                    // 完成数
                    taskSituationDayVO.setCompletedNum(0);
                    taskSituationDayVO.setCompleteRate(BigDecimal.ZERO);
                    taskSituationDayVOList.add(taskSituationDayVO);
                }
                taskSituationVO.setTaskSituationDayVO(taskSituationDayVOList);
                return R.ok(taskSituationVO);
            }
            if(!CollectionUtils.isEmpty(taskList)){
@@ -417,13 +444,13 @@
                }
            }
            // 超级管理员 查询所有的任务列表
            List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
                    .between(TTask::getImplementTime, query.getStartTime(), query.getEndTime()));
            List<TTask> taskList = new ArrayList<>();
            if(CollectionUtils.isEmpty(query.getProjectId())){
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
                        .between(TTask::getImplementTime, query.getStartTime(), query.getEndTime()));
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -438,7 +465,23 @@
            list = taskCleanService.list(wrapper);
            if(CollectionUtils.isEmpty(list)){
                return R.ok();
                for (long i = 0; i <= daysBetween; i++) {
                    TaskSituationDayVO taskSituationDayVO = new TaskSituationDayVO();
                    if(i == 0){
                        format = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                    }else {
                        format = DateUtils.stringToLocalDate(format).plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                    }
                    taskSituationDayVO.setTaskTime(format);
                    // 任务数
                    taskSituationDayVO.setTaskNum(0);
                    // 完成数
                    taskSituationDayVO.setCompletedNum(0);
                    taskSituationDayVO.setCompleteRate(BigDecimal.ZERO);
                    taskSituationDayVOList.add(taskSituationDayVO);
                }
                taskSituationVO.setTaskSituationDayVO(taskSituationDayVOList);
                return R.ok(taskSituationVO);
            }
            if(!CollectionUtils.isEmpty(taskList)){
@@ -448,11 +491,12 @@
        }
        // 任务总数
        taskSituationVO.setTotalTaskNum(list.size());
        List<TTask> result = list.stream().filter(task -> task.getStatus() == 6).collect(Collectors.toList());
        List<TTask> result = list.stream().filter(task -> task.getStatus() == 6 || task.getStatus() == 5).collect(Collectors.toList());
        // 已完成任务数
        taskSituationVO.setCompletedTaskNum(result.size());
        // 匹配任务详情查看合格数量
        List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
        List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
        if(CollectionUtils.isEmpty(tasks)){
            taskSituationVO.setPassRate(BigDecimal.ZERO);
            return R.ok(taskSituationVO);
@@ -471,17 +515,6 @@
            }
        }
        taskSituationVO.setPassRate(new BigDecimal(qualifiedWarn).divide(new BigDecimal(tasks.size()), 2, RoundingMode.HALF_DOWN));
        // 过滤每天的任务
        LocalDateTime start = DateUtils.stringToLocalDateTime(query.getStartTime());
        LocalDateTime end = DateUtils.stringToLocalDateTime(query.getEndTime());
        long daysBetween = ChronoUnit.DAYS.between(start, end);
        List<TaskSituationDayVO> taskSituationDayVOList = new ArrayList<>();
        LocalDateTime localDateTime = DateUtils.stringToLocalDateTime(query.getStartTime());
        String format = null;
        for (long i = 0; i <= daysBetween; i++) {
            TaskSituationDayVO taskSituationDayVO = new TaskSituationDayVO();
            if(i == 0){
@@ -495,7 +528,7 @@
            // 任务数
            taskSituationDayVO.setTaskNum(tTasks.size());
            // 完成数
            taskSituationDayVO.setCompletedNum(tTasks.stream().filter(task -> task.getStatus() == 6).collect(Collectors.toList()).size());
            taskSituationDayVO.setCompletedNum(tTasks.stream().filter(task -> task.getStatus() == 6 || task.getStatus() == 5).collect(Collectors.toList()).size());
            int qualifiedWarnChild = 0;
            for (TTask task : tTasks) {
                TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
@@ -529,7 +562,7 @@
        LambdaQueryWrapper<TTask> wrapper = new LambdaQueryWrapper<>();
        String startTime = LocalDate.now() + " 00:00:00";
        String endTime = LocalDate.now() + " 23:59:59";
        wrapper.between(TTask::getImplementTime, startTime, endTime);
//        wrapper.between(TTask::getImplementTime, startTime, endTime);
        if (userId != 1L) {
            // 查询点位类型
            if(StringUtils.isNotEmpty(query.getLocationTypeId())){
@@ -552,6 +585,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -562,13 +596,14 @@
                // 公司人员
                // 查询自己的任务列表
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
                        .eq(TTask::getPatrolInspector, userId)
                        .between(TTask::getImplementTime, startTime, endTime));
                        .eq(TTask::getPatrolInspector, userId));
//                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
//                        .eq(TTask::getPatrolInspector, userId)
//                        .between(TTask::getImplementTime, startTime, endTime));
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -584,43 +619,62 @@
            List<TTask> list = taskCleanService.list(wrapper);
            if(CollectionUtils.isEmpty(list)){
                return R.ok();
                return R.ok(new ArrayList<>());
            }
            if(!CollectionUtils.isEmpty(taskList)){
                list.addAll(taskList);
            }
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> result = list.stream().filter(task -> task.getStatus() == 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                for (TTask task : result) {
                    TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
                    if(Objects.nonNull(tLocation)) {
                        task.setLocationName(tLocation.getLocationName());
                    }
                }
                return R.ok(result);
            // 查询预警数据
            List<TEarlyWarning> earlyWarnings = earlyWarningService.list(Wrappers.lambdaQuery(TEarlyWarning.class)
                    .between(TEarlyWarning::getCreateTime, startTime, endTime));
            if(CollectionUtils.isEmpty(earlyWarnings)){
                return R.ok(new ArrayList<>());
            }
            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
                    .in(TTaskDetail::getTaskId, taskIds)
                    .orderByDesc(TTaskDetail::getCreateTime));
            for (TTask task : list) {
                TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
                if(Objects.nonNull(tTaskDetail)){
                    if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 2){
                        result.add(task);
                    }
            String taskIds = earlyWarnings.stream().map(TEarlyWarning::getTaskId).collect(Collectors.joining(","));
            Iterator<TTask> iterator = list.iterator();
            while (iterator.hasNext()) {
                TTask task = iterator.next();
                if(!taskIds.contains(task.getId())){
                    iterator.remove();
                }
            }
            for (TTask task : result) {
                TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
                if(Objects.nonNull(tLocation)) {
                    task.setLocationName(tLocation.getLocationName());
                }
            }
            return R.ok(result);
//            List<TTask> result = list.stream().filter(task -> task.getStatus() == 2).collect(Collectors.toList());
//            List<TTask> tasks = list.stream().filter(task -> task.getStatus() == 1 || task.getStatus() == 2).collect(Collectors.toList());
//            if(CollectionUtils.isEmpty(tasks)){
//                for (TTask task : result) {
//                    TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
//                    if(Objects.nonNull(tLocation)) {
//                        task.setLocationName(tLocation.getLocationName());
//                    }
//                }
//                return R.ok(result);
//            }
//            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
//            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
//                    .in(TTaskDetail::getTaskId, taskIds)
//                    .orderByDesc(TTaskDetail::getCreateTime));
//            for (TTask task : list) {
//                TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
//                if(Objects.nonNull(tTaskDetail)){
//                    if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 2){
//                        result.add(task);
//                    }
//                }
//            }
//            for (TTask task : result) {
//                TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
//                if(Objects.nonNull(tLocation)) {
//                    task.setLocationName(tLocation.getLocationName());
//                }
//            }
            return R.ok(list);
        }else {
            // 超级管理员
            // 查询点位类型
@@ -639,8 +693,7 @@
            if(CollectionUtils.isEmpty(query.getProjectId())){
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -655,43 +708,62 @@
            List<TTask> list = taskCleanService.list(wrapper);
            if(CollectionUtils.isEmpty(list)){
                return R.ok();
                return R.ok(new ArrayList<>());
            }
            if(!CollectionUtils.isEmpty(taskList)){
                list.addAll(taskList);
            }
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> result = list.stream().filter(task -> task.getStatus() == 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                for (TTask task : result) {
                    TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
                    if(Objects.nonNull(tLocation)) {
                        task.setLocationName(tLocation.getLocationName());
                    }
                }
                return R.ok(result);
            // 查询预警数据
            List<TEarlyWarning> earlyWarnings = earlyWarningService.list(Wrappers.lambdaQuery(TEarlyWarning.class)
                    .between(TEarlyWarning::getCreateTime, startTime, endTime));
            if(CollectionUtils.isEmpty(earlyWarnings)){
                return R.ok(new ArrayList<>());
            }
            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
                    .in(TTaskDetail::getTaskId, taskIds)
                    .orderByDesc(TTaskDetail::getCreateTime));
            for (TTask task : list) {
                TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
                if(Objects.nonNull(tTaskDetail)){
                    if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 2){
                        result.add(task);
                    }
            String taskIds = earlyWarnings.stream().map(TEarlyWarning::getTaskId).collect(Collectors.joining(","));
            Iterator<TTask> iterator = list.iterator();
            while (iterator.hasNext()) {
                TTask task = iterator.next();
                if(!taskIds.contains(task.getId())){
                    iterator.remove();
                }
            }
            for (TTask task : result) {
                TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
                if(Objects.nonNull(tLocation)) {
                    task.setLocationName(tLocation.getLocationName());
                }
            }
            return R.ok(result);
//            List<TTask> result = list.stream().filter(task -> task.getStatus() == 2).collect(Collectors.toList());
//            List<TTask> tasks = list.stream().filter(task -> task.getStatus() == 1 || task.getStatus() == 2).collect(Collectors.toList());
//            if(CollectionUtils.isEmpty(tasks)){
//                for (TTask task : result) {
//                    TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
//                    if(Objects.nonNull(tLocation)) {
//                        task.setLocationName(tLocation.getLocationName());
//                    }
//                }
//                return R.ok(result);
//            }
//            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
//            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
//                    .in(TTaskDetail::getTaskId, taskIds)
//                    .orderByDesc(TTaskDetail::getCreateTime));
//            for (TTask task : list) {
//                TTaskDetail tTaskDetail = taskDetails.stream().filter(taskDetail -> taskDetail.getTaskId().equals(task.getId())).findFirst().orElse(null);
//                if(Objects.nonNull(tTaskDetail)){
//                    if(Objects.nonNull(tTaskDetail.getClearStatus()) && tTaskDetail.getClearStatus() == 2){
//                        result.add(task);
//                    }
//                }
//            }
//            for (TTask task : result) {
//                TLocation tLocation = locations.stream().filter(location -> location.getId().equals(task.getLocationId())).findFirst().orElse(null);
//                if(Objects.nonNull(tLocation)) {
//                    task.setLocationName(tLocation.getLocationName());
//                }
//            }
            return R.ok(list);
        }
    }
@@ -728,6 +800,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -742,8 +815,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -787,12 +859,12 @@
                }
            }
            // 超级管理员 查询所有的任务列表
            List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
            List<TTask> taskList = new ArrayList<>();
            if(CollectionUtils.isEmpty(query.getProjectId())){
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -855,6 +927,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -869,8 +942,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -893,7 +965,8 @@
                list.addAll(taskList);
            }
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                    && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                map.put("unqualifiedWarn", 0);
                map.put("qualifiedWarn", 0);
@@ -902,7 +975,19 @@
            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
                    .in(TTaskDetail::getTaskId, taskIds)
                    .eq(TTaskDetail::getHandleType, 1)
                    .orderByDesc(TTaskDetail::getCreateTime));
            taskDetails = new ArrayList<>(taskDetails.stream()
                    .collect(Collectors.groupingBy(
                            TTaskDetail::getTaskId,
                            Collectors.collectingAndThen(
                                    Collectors.toList(),
                                    list1 -> list1.get(0)
                            )
                    ))
                    .values());
            int unqualifiedWarn = 0;
            int qualifiedWarn = 0;
            for (TTask task : list) {
@@ -934,12 +1019,12 @@
                }
            }
            // 超级管理员 查询所有的任务列表
            List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
            List<TTask> taskList = new ArrayList<>();
            if(CollectionUtils.isEmpty(query.getProjectId())){
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -961,7 +1046,8 @@
                list.addAll(taskList);
            }
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                    && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                map.put("unqualifiedWarn", 0);
                map.put("qualifiedWarn", 0);
@@ -971,6 +1057,15 @@
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
                    .in(TTaskDetail::getTaskId, taskIds)
                    .orderByDesc(TTaskDetail::getCreateTime));
            taskDetails = new ArrayList<>(taskDetails.stream()
                    .collect(Collectors.groupingBy(
                            TTaskDetail::getTaskId,
                            Collectors.collectingAndThen(
                                    Collectors.toList(),
                                    list1 -> list1.get(0)
                            )
                    ))
                    .values());
            int unqualifiedWarn = 0;
            int qualifiedWarn = 0;
            for (TTask task : list) {
@@ -1023,6 +1118,7 @@
                                .eq(TProjectDept::getStatus, 1)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                        List<String> ids = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        projectIds.add(projectDept.getId());
                        projectIds.addAll(ids);
                    }else {
                        projectIds.add(deptId);
@@ -1037,8 +1133,7 @@
                if(CollectionUtils.isEmpty(query.getProjectId())){
                    // 查询所有项目部的任务列表
                    List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .eq(TProjectDept::getStatus, 1)
                            .ne(TProjectDept::getParentId, 0));
                            .eq(TProjectDept::getStatus, 1));
                    if(!CollectionUtils.isEmpty(tProjectDeptList)){
                        List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                        query.setProjectId(projectIds);
@@ -1061,9 +1156,10 @@
                list.addAll(taskList);
            }
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                    && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                return R.ok();
                return R.ok(analysisUnqualifiedCleaningVO);
            }
            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
@@ -1114,12 +1210,12 @@
                }
            }
            // 超级管理员 查询所有的任务列表
            List<TTask> taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
            List<TTask> taskList = new ArrayList<>();
            if(CollectionUtils.isEmpty(query.getProjectId())){
                taskList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class));
                // 查询所有项目部的任务列表
                List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                        .eq(TProjectDept::getStatus, 1)
                        .ne(TProjectDept::getParentId, 0));
                        .eq(TProjectDept::getStatus, 1));
                if(!CollectionUtils.isEmpty(tProjectDeptList)){
                    List<String> projectIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    query.setProjectId(projectIds);
@@ -1134,7 +1230,7 @@
            List<TTask> list = taskCleanService.list(wrapper);
            if(CollectionUtils.isEmpty(list)){
                return R.ok();
                return R.ok(analysisUnqualifiedCleaningVO);
            }
            if(!CollectionUtils.isEmpty(taskList)){
@@ -1143,9 +1239,10 @@
            list = list.stream().distinct().collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2).collect(Collectors.toList());
            List<TTask> tasks = list.stream().filter(task -> task.getStatus() != 1 && task.getStatus() != 2
                    && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(tasks)){
                return R.ok();
                return R.ok(analysisUnqualifiedCleaningVO);
            }
            List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList());
            List<TTaskDetail> taskDetails = tTaskDetailService.list(Wrappers.lambdaQuery(TTaskDetail.class)
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
@@ -1,363 +1,366 @@
//package com.ruoyi.web.controller.task;
//
//
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.ruoyi.common.core.domain.entity.SysUser;
//import com.ruoyi.common.core.redis.RedisCache;
//import com.ruoyi.common.utils.CodeGenerateUtils;
//import com.ruoyi.system.mapper.TCleanerMapper;
//import com.ruoyi.system.model.*;
//import com.ruoyi.system.service.*;
//import javafx.concurrent.Task;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.poi.ss.formula.functions.T;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.util.CollectionUtils;
//
//import java.math.BigDecimal;
//import java.text.SimpleDateFormat;
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * @author xiaochen
// * @date 2025/6/11 18:39
// */
//@Slf4j
//@Component
//public class TaskUtil {
//
//    // 项目部权重标识
//    private static final String PROJECT_DEPT_WEIGHT = ":PROJECT_DEPT_WEIGHT";
//    // 保洁员权重标识
//    private static final String CLEANER_WEIGHT = ":CLEANER_WEIGHT";
//    // 重复点位标识
//    private static final String REPEAT_LOCATION = ":REPEAT_LOCATION";
//
//    @Autowired
//    private RedisCache redisCache;
//    @Autowired
//    private TTemplateService templateService;
//    @Autowired
//    private TTemplateDetailService templateDetailService;
//    @Autowired
//    private TProjectDeptService projectDeptService;
//    @Autowired
//    private TCleanerService cleanerService;
//    @Autowired
//    private TLocationService locationService;
//    @Autowired
//    private TLocationTypeService locationTypeService;
//    @Autowired
//    private ISysUserService sysUserService;
//    @Autowired
//    private TTaskCleanService taskCleanService;
//    @Autowired
//    private TTemplateCountService templateCountService;
//
//
//    // 每一个小时执行一次
////    @Scheduled(cron = "0 0 0 * * ?")
////    @Scheduled(fixedRate = 1500000000)
//    public void dayOfCreateInspection() {
//        try {
//
//            // 查询任务模板
//            List<TTemplate> list = templateService.list();
//            if (CollectionUtils.isEmpty(list)) {
//                return;
//            }
//            list.forEach(template -> {
//                // 创建任务
//                createInspection(template);
//            });
//
//            // 查询前一天为执行的所有任务,改成已超时状态
//            List<TTask> taskCleanList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
//                    .like(TTask::getImplementTime, LocalDate.now().minusDays(1))
//                    .eq(TTask::getStatus, 1));
//            if (!CollectionUtils.isEmpty(taskCleanList)) {
//                taskCleanList.forEach(task -> {
//                    task.setStatus(2);
//                });
//                taskCleanService.updateBatchById(taskCleanList);
//            }
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//    public void createInspection(TTemplate template) {
//        // 查询所有的模板详情
//        List<TTemplateDetail> list = templateDetailService.list(Wrappers.lambdaQuery(TTemplateDetail.class)
//                .eq(TTemplateDetail::getTemplateId, template.getId()));
//        if (CollectionUtils.isEmpty(list)) {
//            return;
//        }
//        // 通过模板id查询员工巡检员
//        List<SysUser> sysUsers = sysUserService.selectUserByTempLateId(template.getId());
//        // 创建任务
//        for (TTemplateDetail detail : list) {
//            // 计算周期
//            int cycle = detail.getCycle();
//            switch (detail.getCycleType()){
//                case 2:
//                    cycle = cycle * 7;
//                    break;
//                case 3:
//                    cycle = cycle * 30;
//                    break;
//                case 4:
//                    cycle = cycle * 90;
//                    break;
//                case 5:
//                    cycle = cycle * 365;
//                    break;
//            }
//
//            // 拿到保洁抽查次数
//            int num1 = detail.getNum1();
//            // 拿到项目部数
//            int num2 = detail.getNum2();
//            // 拿到每日重复点位
//            int num3 = detail.getNum3();
//            // 获取点位类型的占比
//            String num4 = detail.getNum4();
//
//            // 未绑定员工
//            if(CollectionUtils.isEmpty(sysUsers)){
//                continue;
//            }
//
//            int taskCount = 0;
//            for (SysUser sysUser : sysUsers) {
//                List<TProjectDept> projectDeptLists = new ArrayList<>();
//                if(sysUser.getDeptType() == 1){
//                    TProjectDept projectDept = projectDeptService.getById(sysUser.getDeptId());
//                    if("0".equals(projectDept.getParentId())){
//                        projectDeptLists = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
//                                .eq(TProjectDept::getParentId, projectDept.getId()));
//                    }else {
//                        projectDeptLists.add(projectDept);
//                    }
//                }else {
//                    projectDeptLists = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
//                            .ne(TProjectDept::getParentId,0));
//                }
//                List<String> proDeptIds = projectDeptLists.stream().map(TProjectDept::getId).collect(Collectors.toList());
//
//                // 获取项目部在该模板详情中的权重
//                List<String> projectDeptIds = redisCache.getCacheList(detail.getId() + PROJECT_DEPT_WEIGHT);
//                // 获取项目部列表
//                List<TProjectDept> projectDeptList;
//                if(CollectionUtils.isEmpty(projectDeptIds)){
//                    projectDeptList = projectDeptLists;
//                }else {
//                    projectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
//                            .ne(TProjectDept::getParentId,0)
//                            .in(TProjectDept::getId, proDeptIds)
//                            .notIn(TProjectDept::getId, projectDeptIds));
//                    // 所过所有的项目部都被抽取了,则重新抽取,并且清空项目部权重
//                    if(CollectionUtils.isEmpty(projectDeptList)){
//                        projectDeptList = projectDeptLists;
//                        redisCache.deleteObject(detail.getId() + PROJECT_DEPT_WEIGHT);
//                    }
//                }
//                // 如果可抽取的项目部数不足,先抽取余下项目部后,再清空权重,重新抽取
//                List<TProjectDept> projectDepts = randomSelection(projectDeptList, num2);
//                if(projectDepts.size() < num2){
//                    List<String> proIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
//                    List<TProjectDept> projectDeptList1 = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
//                            .notIn(TProjectDept::getId, proIds)
//                            .ne(TProjectDept::getParentId,0));
//                    redisCache.deleteObject(detail.getId() + PROJECT_DEPT_WEIGHT);
//                    List<TProjectDept> projectDepts1 = randomSelection(projectDeptList1, num2 - projectDepts.size());
//                    List<String> proIds1 = projectDepts1.stream().map(TProjectDept::getId).collect(Collectors.toList());
//                    // 将已抽取的项目部id保存到redis中
//                    redisCache.setCacheList(detail.getId() + PROJECT_DEPT_WEIGHT, proIds1);
//                    projectDepts.addAll(projectDepts1);
//                }else {
//                    List<String> proIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
//                    // 将已抽取的项目部id保存到redis中
//                    redisCache.setCacheList(detail.getId() + PROJECT_DEPT_WEIGHT, proIds);
//                }
//                List<String> proIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
//
//                // 拿到抽取的项目部下的所有保洁员
////            List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
////                    .in(TProjectDept::getId, proIds));
//                // 获取片区id
//                List<String> areaIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
//                if(CollectionUtils.isEmpty(areaIds)){
//                    return;
//                }
//
//                // 计算每天需要抽取多少个保洁员
//                long count = cleanerService.count(Wrappers.lambdaQuery(TCleaner.class)
//                        .in(TCleaner::getProjectId, areaIds));
//                int cleanerSums = num1 * Integer.parseInt(count + "");
//                // 获取每天需要抽取的保洁员数,向上取整
//                if (cleanerSums < cycle){
//                    cleanerSums = cycle;
//                }
//                int dayCleanerCount = cleanerSums / cycle;
//
//                if((cycle == detail.getCurrentValue()) && cleanerSums % cycle != 0){
//                    dayCleanerCount++;
//                }
//
//                // 获取保洁员权重
//                List<String> cleanerIds = redisCache.getCacheList(detail.getId() + CLEANER_WEIGHT);
//                // 获取保洁员列表
//                List<TCleaner> cleaners;
//                if(CollectionUtils.isEmpty(cleanerIds)){
//                    cleaners = cleanerService.list(Wrappers.lambdaQuery(TCleaner.class)
//                            .in(TCleaner::getProjectId, areaIds));
//                }else {
//                    cleaners = cleanerService.list(Wrappers.lambdaQuery(TCleaner.class)
//                            .in(TCleaner::getProjectId, areaIds)
//                            .notIn(TCleaner::getId, cleanerIds));
//                    if(CollectionUtils.isEmpty(cleaners)){
//                        cleaners = cleanerService.list(Wrappers.lambdaQuery(TCleaner.class)
//                                .in(TCleaner::getProjectId, areaIds));
//                        redisCache.deleteObject(detail.getId() + CLEANER_WEIGHT);
//                    }
//                }
//
//                // 抽取保洁员
//                List<TCleaner> tCleaners = randomSelection(cleaners, dayCleanerCount);
//                if(CollectionUtils.isEmpty(tCleaners)){
//                    log.error("没有可抽取的保洁员,模板id为:{}",detail.getId());
//                    continue;
//                }
//                if(tCleaners.size() < dayCleanerCount){
//                    List<String> cleanIds = tCleaners.stream().map(TCleaner::getId).collect(Collectors.toList());
//                    List<TCleaner> cleaners1 = cleanerService.list(Wrappers.lambdaQuery(TCleaner.class)
//                            .in(TCleaner::getProjectId, areaIds)
//                            .notIn(TCleaner::getId, cleanIds));
//                    redisCache.deleteObject(detail.getId() + CLEANER_WEIGHT);
//                    List<TCleaner> tCleaners1 = randomSelection(cleaners1, dayCleanerCount - tCleaners.size());
//                    List<String> cleanIds1 = tCleaners1.stream().map(TCleaner::getId).collect(Collectors.toList());
//                    // 将已抽取的保洁员id保存到redis中
//                    cleanIds1.addAll(cleanIds);
//                    redisCache.setCacheList(detail.getId() + CLEANER_WEIGHT, cleanIds1);
//                    tCleaners.addAll(tCleaners1);
//                }else {
//                    List<String> cleanIds = tCleaners.stream().map(TCleaner::getId).collect(Collectors.toList());
//                    redisCache.setCacheList(detail.getId() + CLEANER_WEIGHT, cleanIds);
//                }
//
//                // 通过保洁员id查询点位
//                List<String> cleanersIds = tCleaners.stream().map(TCleaner::getId).collect(Collectors.toList());
//                List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
//                        .in(TLocation::getLocationCleaner, cleanersIds));
//                // 查询点位类型
//                JSONArray jsonArray = JSONObject.parseArray(num4);
//                List<TLocation> tLocationList = new ArrayList<>();
//                for (Object o : jsonArray) {
//                    JSONObject jsonObject = JSONObject.parseObject(o.toString());
//                    String id = jsonObject.getString("id");
//                    BigDecimal value = jsonObject.getBigDecimal("value");
//                    List<TLocation> locations = locationList.stream().filter(tLocation -> tLocation.getLocationType().equals(id)).collect(Collectors.toList());
//                    if(!CollectionUtils.isEmpty(locations)){
//                        BigDecimal bigDecimal = new BigDecimal(locations.size()).multiply(value.divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN)).setScale(0, BigDecimal.ROUND_UP);
//                        int locationCount = bigDecimal.intValue();
//                        if(locationCount > 0){
//                            List<TLocation> tLocations = randomSelection(locations, locationCount);
//                            tLocationList.addAll(tLocations);
//                        }
//                    }
//                }
//                tLocationList = tLocationList.stream().distinct().collect(Collectors.toList());
//                // 抽取重复点位
//                Integer currentValue = detail.getCurrentValue();
//                if(currentValue != cycle){
//                    // 周期天数加一
//                    detail.setCurrentValue(currentValue + 1);
//                    // 获取重复点位
//                    Set<TLocation> repeatLocation = redisCache.getCacheSet(detail.getId() + ":" + sysUser.getUserId() + REPEAT_LOCATION);
//                    if(!CollectionUtils.isEmpty(repeatLocation)){
//                        List<TLocation> locations = randomSelection(new ArrayList<>(tLocationList), num3);
//                        tLocationList.addAll(locations);
//                    }
//                    Set<TLocation> locationSet = new HashSet<>(tLocationList);
//                    redisCache.setCacheSet(detail.getId() + ":" + sysUser.getUserId() + REPEAT_LOCATION, locationSet);
//
//                }else {
//                    // 设置当前周期为0
//                    detail.setCurrentValue(0);
//                    // 将重复点位置空
//                    redisCache.deleteObject(detail.getId() + ":" + sysUser.getUserId() + REPEAT_LOCATION);
//                    // 将项目部权重置空
//                    redisCache.deleteObject(detail.getId() + PROJECT_DEPT_WEIGHT);
//                    // 将保洁员权重置空
//                    redisCache.deleteObject(detail.getId() + CLEANER_WEIGHT);
//                }
//
//                // 创建任务
//                List<TTask> tasks = new ArrayList<>();
//                for (TLocation tLocation : tLocationList) {
//                    TTask task = new TTask();
//                    // 获取保洁员
//                    tCleaners.stream().filter(tCleaner -> tCleaner.getId().equals(tLocation.getLocationCleaner())).findFirst().ifPresent(tCleaner -> {
//                        task.setProjectId(tCleaner.getProjectId());
//                        task.setCleanerId(tCleaner.getId());
//                    });
//                    // 获取巡检员
//                    task.setPatrolInspector(sysUser.getUserId().toString());
//                    task.setPatrolInspectorDept(sysUser.getDeptId());
//                    task.setUserId(sysUser.getUserId());
//                    task.setStatus(1);
//                    task.setLocationId(tLocation.getId());
//                    task.setImplementTime(LocalDateTime.now().plusDays(1));
//                    task.setTaskType(1);
//                    task.setTemplateId(detail.getTemplateId());
//                    String nameAndCode = CodeGenerateUtils.generateVolumeSn();
//                    task.setTaskName(nameAndCode);
//                    task.setTaskCode(nameAndCode);
//                    tasks.add(task);
//                }
//
//            // 添加应生成任务数量
//            TTemplateCount templateCount = new TTemplateCount();
//            templateCount.setTemplateId(detail.getTemplateId());
//            templateCount.setTaskCount(tLocationList.size()* cycle);
//            templateCount.setUserId(sysUser.getUserId());
//            templateCountService.save(templateCount);
//
//            taskCleanService.saveBatch(tasks);
//            taskCount = taskCount + tasks.size();
//            }
//            template.setTaskCount(taskCount);
//            templateService.updateById(template);
//            templateDetailService.updateById(detail);
//        }
//    }
//
//    /**
//     * 从集合中随机抽取数量
//     * @param list
//     * @param size
//     * @return
//     * @param <T>
//     */
//    private static <T> List<T> randomSelection(List<T> list, int size) {
//        List<T> selected = new ArrayList<>();
//        int length = list.size();
//        for (int i = 0; i < size; i++) {
//            Collections.shuffle(list);
//            // 如果需求的大小超过了集合的长度,则只能取到集合的全部元素
//            int subListSize = Math.min(size - selected.size(), length);
//            selected.addAll(list.subList(0, subListSize));
//        }
//        return selected;
//    }
//
//}
package com.ruoyi.web.controller.task;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.CodeGenerateUtils;
import com.ruoyi.system.mapper.TCleanerMapper;
import com.ruoyi.system.model.*;
import com.ruoyi.system.service.*;
import javafx.concurrent.Task;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
 * @author xiaochen
 * @date 2025/6/11 18:39
 */
@Slf4j
@Component
public class TaskUtil {
    // 项目部权重标识
    private static final String PROJECT_DEPT_WEIGHT = ":PROJECT_DEPT_WEIGHT";
    // 保洁员权重标识
    private static final String CLEANER_WEIGHT = ":CLEANER_WEIGHT";
    // 重复点位标识
    private static final String REPEAT_LOCATION = ":REPEAT_LOCATION";
    @Autowired
    private RedisCache redisCache;
    @Autowired
    private TTemplateService templateService;
    @Autowired
    private TTemplateDetailService templateDetailService;
    @Autowired
    private TProjectDeptService projectDeptService;
    @Autowired
    private TCleanerService cleanerService;
    @Autowired
    private TLocationService locationService;
    @Autowired
    private TLocationTypeService locationTypeService;
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private TTaskCleanService taskCleanService;
    @Autowired
    private TTemplateCountService templateCountService;
    // 每一个小时执行一次
//    @Scheduled(cron = "0 0 0 * * ?")
//    @Scheduled(fixedRate = 1500000000)
    public void dayOfCreateInspection() {
        try {
            // 查询任务模板
            List<TTemplate> list = templateService.list();
            if (CollectionUtils.isEmpty(list)) {
                return;
            }
            list.forEach(template -> {
                // 创建任务
                createInspection(template);
            });
            // 查询前一天为执行的所有任务,改成已超时状态
            List<TTask> taskCleanList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class)
                    .like(TTask::getImplementTime, LocalDate.now().minusDays(1))
                    .eq(TTask::getStatus, 1));
            if (!CollectionUtils.isEmpty(taskCleanList)) {
                taskCleanList.forEach(task -> {
                    task.setStatus(2);
                });
                taskCleanService.updateBatchById(taskCleanList);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void createInspection(TTemplate template) {
        // 查询所有的模板详情
        List<TTemplateDetail> list = templateDetailService.list(Wrappers.lambdaQuery(TTemplateDetail.class)
                .eq(TTemplateDetail::getTemplateId, template.getId()));
        if (CollectionUtils.isEmpty(list)) {
            return;
        }
        // 通过模板id查询员工巡检员
        List<SysUser> sysUsers = sysUserService.selectUserByTempLateId(template.getId());
        // 创建任务
        for (TTemplateDetail detail : list) {
            // 计算周期
            int cycle = detail.getCycle();
            switch (detail.getCycleType()){
                case 2:
                    cycle = cycle * 7;
                    break;
                case 3:
                    cycle = cycle * 30;
                    break;
                case 4:
                    cycle = cycle * 90;
                    break;
                case 5:
                    cycle = cycle * 365;
                    break;
            }
            // 拿到保洁抽查次数
            int num1 = detail.getNum1();
            // 拿到项目部数
            int num2 = detail.getNum2();
            // 拿到每日重复点位
            int num3 = detail.getNum3();
            // 获取点位类型的占比
            String num4 = detail.getNum4();
            // 未绑定员工
            if(CollectionUtils.isEmpty(sysUsers)){
                continue;
            }
            int taskCount = 0;
            for (SysUser sysUser : sysUsers) {
                List<TProjectDept> projectDeptLists = new ArrayList<>();
                if(sysUser.getDeptType() == 1){
                    TProjectDept projectDept = projectDeptService.getById(sysUser.getDeptId());
                    if("0".equals(projectDept.getParentId())){
                        projectDeptLists = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                                .eq(TProjectDept::getParentId, projectDept.getId()));
                    }else {
                        projectDeptLists.add(projectDept);
                    }
                }else {
                    projectDeptLists = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .ne(TProjectDept::getParentId,0));
                }
                List<String> proDeptIds = projectDeptLists.stream().map(TProjectDept::getId).collect(Collectors.toList());
                // 获取项目部在该模板详情中的权重
                List<String> projectDeptIds = redisCache.getCacheList(detail.getId() + PROJECT_DEPT_WEIGHT);
                // 获取项目部列表
                List<TProjectDept> projectDeptList;
                if(CollectionUtils.isEmpty(projectDeptIds)){
                    projectDeptList = projectDeptLists;
                }else {
                    projectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .ne(TProjectDept::getParentId,0)
                            .in(TProjectDept::getId, proDeptIds)
                            .notIn(TProjectDept::getId, projectDeptIds));
                    // 所过所有的项目部都被抽取了,则重新抽取,并且清空项目部权重
                    if(CollectionUtils.isEmpty(projectDeptList)){
                        projectDeptList = projectDeptLists;
                        redisCache.deleteObject(detail.getId() + PROJECT_DEPT_WEIGHT);
                    }
                }
                // 如果可抽取的项目部数不足,先抽取余下项目部后,再清空权重,重新抽取
                List<TProjectDept> projectDepts = randomSelection(projectDeptList, num2);
                if(projectDepts.size() < num2){
                    List<String> proIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    List<TProjectDept> projectDeptList1 = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                            .notIn(TProjectDept::getId, proIds)
                            .ne(TProjectDept::getParentId,0));
                    redisCache.deleteObject(detail.getId() + PROJECT_DEPT_WEIGHT);
                    List<TProjectDept> projectDepts1 = randomSelection(projectDeptList1, num2 - projectDepts.size());
                    List<String> proIds1 = projectDepts1.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    // 将已抽取的项目部id保存到redis中
                    redisCache.setCacheList(detail.getId() + PROJECT_DEPT_WEIGHT, proIds1);
                    projectDepts.addAll(projectDepts1);
                }else {
                    List<String> proIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
                    // 将已抽取的项目部id保存到redis中
                    redisCache.setCacheList(detail.getId() + PROJECT_DEPT_WEIGHT, proIds);
                }
                List<String> proIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
                // 拿到抽取的项目部下的所有保洁员
//            List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
//                    .in(TProjectDept::getId, proIds));
                // 获取片区id
                List<String> areaIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
                if(CollectionUtils.isEmpty(areaIds)){
                    return;
                }
                // 计算每天需要抽取多少个保洁员
                long count = cleanerService.count(Wrappers.lambdaQuery(TCleaner.class)
                        .in(TCleaner::getProjectId, areaIds));
                int cleanerSums = num1 * Integer.parseInt(count + "");
                // 获取每天需要抽取的保洁员数,向上取整
                if (cleanerSums < cycle){
                    cleanerSums = cycle;
                }
                int dayCleanerCount = cleanerSums / cycle;
                if((cycle == detail.getCurrentValue()) && cleanerSums % cycle != 0){
                    dayCleanerCount++;
                }
                // 获取保洁员权重
                List<String> cleanerIds = redisCache.getCacheList(detail.getId() + CLEANER_WEIGHT);
                // 获取保洁员列表
                List<TCleaner> cleaners;
                if(CollectionUtils.isEmpty(cleanerIds)){
                    cleaners = cleanerService.list(Wrappers.lambdaQuery(TCleaner.class)
                            .in(TCleaner::getProjectId, areaIds));
                }else {
                    cleaners = cleanerService.list(Wrappers.lambdaQuery(TCleaner.class)
                            .in(TCleaner::getProjectId, areaIds)
                            .notIn(TCleaner::getId, cleanerIds));
                    if(CollectionUtils.isEmpty(cleaners)){
                        cleaners = cleanerService.list(Wrappers.lambdaQuery(TCleaner.class)
                                .in(TCleaner::getProjectId, areaIds));
                        redisCache.deleteObject(detail.getId() + CLEANER_WEIGHT);
                    }
                }
                // 抽取保洁员
                List<TCleaner> tCleaners = randomSelection(cleaners, dayCleanerCount);
                if(CollectionUtils.isEmpty(tCleaners)){
                    log.error("没有可抽取的保洁员,模板id为:{}",detail.getId());
                    continue;
                }
                if(tCleaners.size() < dayCleanerCount){
                    List<String> cleanIds = tCleaners.stream().map(TCleaner::getId).collect(Collectors.toList());
                    List<TCleaner> cleaners1 = cleanerService.list(Wrappers.lambdaQuery(TCleaner.class)
                            .in(TCleaner::getProjectId, areaIds)
                            .notIn(TCleaner::getId, cleanIds));
                    redisCache.deleteObject(detail.getId() + CLEANER_WEIGHT);
                    List<TCleaner> tCleaners1 = randomSelection(cleaners1, dayCleanerCount - tCleaners.size());
                    List<String> cleanIds1 = tCleaners1.stream().map(TCleaner::getId).collect(Collectors.toList());
                    // 将已抽取的保洁员id保存到redis中
                    cleanIds1.addAll(cleanIds);
                    redisCache.setCacheList(detail.getId() + CLEANER_WEIGHT, cleanIds1);
                    tCleaners.addAll(tCleaners1);
                }else {
                    List<String> cleanIds = tCleaners.stream().map(TCleaner::getId).collect(Collectors.toList());
                    redisCache.setCacheList(detail.getId() + CLEANER_WEIGHT, cleanIds);
                }
                // 通过保洁员id查询点位
                List<String> cleanersIds = tCleaners.stream().map(TCleaner::getId).collect(Collectors.toList());
                List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
                        .in(TLocation::getLocationCleaner, cleanersIds));
                // 查询点位类型
                JSONArray jsonArray = JSONObject.parseArray(num4);
                List<TLocation> tLocationList = new ArrayList<>();
                for (Object o : jsonArray) {
                    JSONObject jsonObject = JSONObject.parseObject(o.toString());
                    String id = jsonObject.getString("id");
                    BigDecimal value = jsonObject.getBigDecimal("value");
                    List<TLocation> locations = locationList.stream().filter(tLocation -> tLocation.getLocationType().equals(id)).collect(Collectors.toList());
                    if(!CollectionUtils.isEmpty(locations)){
                        BigDecimal bigDecimal = new BigDecimal(locations.size()).multiply(value.divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN)).setScale(0, BigDecimal.ROUND_UP);
                        int locationCount = bigDecimal.intValue();
                        if(locationCount > 0){
                            List<TLocation> tLocations = randomSelection(locations, locationCount);
                            tLocationList.addAll(tLocations);
                        }
                    }
                }
                tLocationList = tLocationList.stream().distinct().collect(Collectors.toList());
                // 抽取重复点位
                Integer currentValue = detail.getCurrentValue();
                if(currentValue != cycle){
                    // 周期天数加一
                    detail.setCurrentValue(currentValue + 1);
                    // 获取重复点位
                    Set<TLocation> repeatLocation = redisCache.getCacheSet(detail.getId() + ":" + sysUser.getUserId() + REPEAT_LOCATION);
                    if(!CollectionUtils.isEmpty(repeatLocation)){
                        List<TLocation> locations = randomSelection(new ArrayList<>(tLocationList), num3);
                        tLocationList.addAll(locations);
                    }
                    Set<TLocation> locationSet = new HashSet<>(tLocationList);
                    redisCache.setCacheSet(detail.getId() + ":" + sysUser.getUserId() + REPEAT_LOCATION, locationSet);
                }else {
                    // 设置当前周期为0
                    detail.setCurrentValue(0);
                    // 将重复点位置空
                    redisCache.deleteObject(detail.getId() + ":" + sysUser.getUserId() + REPEAT_LOCATION);
                    // 将项目部权重置空
                    redisCache.deleteObject(detail.getId() + PROJECT_DEPT_WEIGHT);
                    // 将保洁员权重置空
                    redisCache.deleteObject(detail.getId() + CLEANER_WEIGHT);
                }
                // 创建任务
                List<TTask> tasks = new ArrayList<>();
                for (TLocation tLocation : tLocationList) {
                    TTask task = new TTask();
                    // 获取保洁员
                    tCleaners.stream().filter(tCleaner -> tCleaner.getId().equals(tLocation.getLocationCleaner())).findFirst().ifPresent(tCleaner -> {
                        task.setProjectId(tCleaner.getProjectId());
                        task.setCleanerId(tCleaner.getId());
                    });
                    // 获取巡检员
                    task.setPatrolInspector(sysUser.getUserId().toString());
                    task.setPatrolInspectorDept(sysUser.getDeptId());
                    task.setUserId(sysUser.getUserId());
                    task.setStatus(1);
                    task.setLocationId(tLocation.getId());
                    task.setImplementTime(LocalDateTime.now().plusDays(1));
                    task.setTaskType(1);
                    task.setTemplateId(detail.getTemplateId());
                    String nameAndCode = CodeGenerateUtils.generateVolumeSn();
                    task.setTaskName(nameAndCode);
                    task.setTaskCode(nameAndCode);
                    tasks.add(task);
                }
                // 添加应生成任务数量
                TTemplateCount templateCount = new TTemplateCount();
                templateCount.setTemplateId(detail.getTemplateId());
                // 查询所有的保洁员下面的点位
                List<String> cleanIds = cleaners.stream().map(TCleaner::getId).collect(Collectors.toList());
                List<TLocation> tLocations = locationService.list(Wrappers.lambdaQuery(TLocation.class)
                        .in(TLocation::getLocationCleaner, cleanIds));
                templateCount.setTaskCount(tLocations.size());
                templateCount.setUserId(sysUser.getUserId());
                templateCountService.save(templateCount);
                taskCleanService.saveBatch(tasks);
                taskCount = taskCount + tasks.size();
            }
            template.setTaskCount(taskCount);
            templateService.updateById(template);
            templateDetailService.updateById(detail);
        }
    }
    /**
     * 从集合中随机抽取数量
     * @param list
     * @param size
     * @return
     * @param <T>
     */
    private static <T> List<T> randomSelection(List<T> list, int size) {
        List<T> selected = new ArrayList<>();
        int length = list.size();
        for (int i = 0; i < size; i++) {
            Collections.shuffle(list);
            // 如果需求的大小超过了集合的长度,则只能取到集合的全部元素
            int subListSize = Math.min(size - selected.size(), length);
            selected.addAll(list.subList(0, subListSize));
        }
        return selected;
    }
}
ruoyi-admin/src/main/resources/application-test.yml
@@ -73,7 +73,7 @@
    # 端口,默认为6379
    port: 6379
    # 数据库索引
    database: 0
    database: 1
    # 密码
    password: 123456
    # 连接超时时间
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTaskCleanServiceImpl.java
@@ -20,6 +20,7 @@
import com.ruoyi.system.vo.system.TaskListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
@@ -163,16 +164,36 @@
        List<TDept> deptList = deptMapper.selectList(Wrappers.lambdaQuery(TDept.class));
        List<TProjectDept> projectDeptList = projectDeptMapper.selectList(Wrappers.lambdaQuery(TProjectDept.class));
        if(CollectionUtils.isEmpty(list)){
            return pageInfo;
        }
        List<String> taskIds = list.stream().map(TLocationTaskListVO::getId).collect(Collectors.toList());
        List<TTaskDetail> taskDetails = taskDetailMapper.selectList(Wrappers.lambdaQuery(TTaskDetail.class)
                .in(TTaskDetail::getTaskId,taskIds)
                .orderByDesc(BaseModel::getCreateTime));
        for (TLocationTaskListVO tLocationTaskListVO : list) {
            if(tLocationTaskListVO.getDeptType()==1){
                projectDeptList.stream().filter(e -> e.getId().equals(tLocationTaskListVO.getDeptId())).findFirst().ifPresent(e -> {
                    tLocationTaskListVO.setDeptName(e.getProjectName());
                    if("0".equals(e.getParentId())){
                        tLocationTaskListVO.setDeptName(e.getProjectName());
                    }else {
                        projectDeptList.stream().filter(ee -> ee.getId().equals(e.getParentId())).findFirst().ifPresent(ee -> {
                            tLocationTaskListVO.setDeptName(ee.getProjectName());
                        });
                    }
                });
            }else {
                deptList.stream().filter(e -> e.getId().equals(tLocationTaskListVO.getDeptId())).findFirst().ifPresent(e -> {
                    tLocationTaskListVO.setDeptName(e.getDeptName());
                });
            }
            taskDetails.stream().filter(e -> e.getTaskId().equals(tLocationTaskListVO.getId())).findFirst().ifPresent(e -> {
                tLocationTaskListVO.setClearStatus(e.getClearStatus());
            });
        }
        pageInfo.setRecords(list);
        return pageInfo;
ruoyi-system/src/main/java/com/ruoyi/system/vo/system/AnalysisUnqualifiedCleaningVO.java
@@ -5,6 +5,7 @@
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@@ -12,9 +13,9 @@
public class AnalysisUnqualifiedCleaningVO implements Serializable {
    @ApiModelProperty(value = "不合格任务总数")
    private Integer total;
    private Integer total=0;
    @ApiModelProperty(value = "不合格任务分类统计")
    private List<AnalysisUnqualifiedCleaningDetailVO> analysisUnqualifiedCleaningDetailVOS;
    private List<AnalysisUnqualifiedCleaningDetailVO> analysisUnqualifiedCleaningDetailVOS=new ArrayList<>();
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/system/ProgressListVO.java
@@ -1,17 +1,23 @@
package com.ruoyi.system.vo.system;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.system.model.TTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@ApiModel(value = "任务进度列表分页VO")
public class ProgressListVO  extends TTask {
public class ProgressListVO  implements Serializable {
    @Excel(name = "姓名", width = 20,orderNum = "1")
    @ApiModelProperty(value = "姓名")
@@ -44,4 +50,44 @@
    @ApiModelProperty(value = "计划请假天数")
    private Long num5;
    private String id;
    @ApiModelProperty(value = "项目部/片区id")
    private String projectId;
    @ApiModelProperty(value = "任务状态:1未执行、2超时、3待确认、4待整改、5整改完成、6已完成")
    private Integer status;
    @ApiModelProperty(value = "保洁员id")
    private String cleanerId;
    @ApiModelProperty(value = "点位id")
    private String locationId;
    @ApiModelProperty(value = "巡检员id 对应sys_user表")
    private String patrolInspector;
    @ApiModelProperty(value = "执行日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDateTime implementTime;
    @ApiModelProperty(value = "执行日期前端传递")
    private String implementTime1;
    @ApiModelProperty(value = "任务类型 1日常任务 2自建任务")
    private Integer taskType;
    @ApiModelProperty(value = "巡检员所属部门id")
    private String patrolInspectorDept;
    @ApiModelProperty(value = "任务名称")
    private String taskName;
    @ApiModelProperty(value = "任务编号")
    private String taskCode;
    @ApiModelProperty(value = "模板id 日常任务存储")
    private String templateId;
    @ApiModelProperty(value = "模板id 日常任务存储")
    private Long userId;
    @ApiModelProperty(value = "点位名称")
    private String locationName;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/system/TLocationTaskListVO.java
@@ -1,5 +1,6 @@
package com.ruoyi.system.vo.system;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.system.model.TTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -24,4 +25,7 @@
    @ApiModelProperty(value = "部门Id")
    private String deptId;
    @ApiModelProperty(value = "清洁情况 1合格2不合格")
    private Integer clearStatus;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/system/TaskSituationVO.java
@@ -6,6 +6,7 @@
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@Data
@@ -13,15 +14,15 @@
public class TaskSituationVO implements Serializable {
    @ApiModelProperty(value = "总计任务数")
    private Integer totalTaskNum;
    private Integer totalTaskNum=0;
    @ApiModelProperty(value = "已完成任务数")
    private Integer completedTaskNum;
    private Integer completedTaskNum=0;
    @ApiModelProperty(value = "合格率")
    private BigDecimal passRate;
    private BigDecimal passRate=BigDecimal.ZERO;
    @ApiModelProperty(value = "任务情况每日VO")
    private List<TaskSituationDayVO> taskSituationDayVO;
    private List<TaskSituationDayVO> taskSituationDayVO=new ArrayList<>();
}
ruoyi-system/src/main/resources/mapper/system/TTaskMapper.xml
@@ -222,7 +222,7 @@
        group by t1.user_id,t1.template_id
    </select>
    <select id="pointInspectionHeatDetailTaskList" resultType="com.ruoyi.system.vo.system.TLocationTaskListVO">
        select t1.*,t2.nick_name as nickName,t2.phonenumber AS phoneNumber,t2.deptName,t2.deptId
        select t1.*,t2.nick_name as nickName,t2.phonenumber AS phoneNumber,t2.deptName,t2.deptId,t2.deptType
        from t_task t1
        left join sys_user t2 on t1.user_id = t2.user_id
        <where>