xuhy
2025-07-03 ca7e5eec896bb022ccb7e177ca3641e79f5f8554
ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
@@ -55,12 +55,13 @@
    private ISysUserService sysUserService;
    @Autowired
    private TTaskCleanService taskCleanService;
    @Autowired
    private TTemplateCountService templateCountService;
    // 每一个小时执行一次
//    @Scheduled(cron = "0 0 0 * * ?")
    @Scheduled(fixedRate = 1500000000)
    public void dayOfCreateInspection() {
        try {
@@ -170,10 +171,10 @@
            List<String> proIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
            // 拿到抽取的项目部下的所有保洁员
            List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
                    .in(TProjectDept::getId, proIds));
//            List<TProjectDept> tProjectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)
//                    .in(TProjectDept::getId, proIds));
            // 获取片区id
            List<String> areaIds = tProjectDeptList.stream().map(TProjectDept::getId).collect(Collectors.toList());
            List<String> areaIds = projectDepts.stream().map(TProjectDept::getId).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(areaIds)){
                return;
            }
@@ -183,7 +184,7 @@
                    .in(TCleaner::getProjectId, areaIds));
            int cleanerSums = num1 * Integer.parseInt(count + "");
            // 获取每天需要抽取的保洁员数,向上取整
            if (cleanerSums <cycle){
            if (cleanerSums < cycle){
                cleanerSums = cycle;
            }
            int dayCleanerCount = cleanerSums / cycle;
@@ -229,8 +230,6 @@
            List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class)
                    .in(TLocation::getLocationCleaner, cleanersIds));
            // 查询点位类型
//            List<TLocationType> locationTypes = locationTypeService.list(Wrappers.lambdaQuery(TLocationType.class)
//                    .orderByDesc(TLocationType::getCreateTime));
            JSONArray jsonArray = JSONObject.parseArray(num4);
            List<TLocation> tLocationList = new ArrayList<>();
            for (Object o : jsonArray) {
@@ -286,12 +285,20 @@
                task.setLocationId(tLocation.getId());
                task.setImplementTime(LocalDateTime.now().plusDays(1));
                task.setTaskType(1);
                task.setTemplateId(detail.getId());
                task.setTemplateId(detail.getTemplateId());
                String nameAndCode = CodeGenerateUtils.generateVolumeSn();
                task.setTaskName(nameAndCode);
                task.setTaskCode(nameAndCode);
                tasks.add(task);
            }
            // 添加应生成任务数量
            TTemplateCount templateCount = new TTemplateCount();
            templateCount.setTemplateId(detail.getId());
            templateCount.setTaskCount(tLocationList.size()* cycle);
            templateCount.setUserId(sysUser.getUserId());
            templateCountService.save(templateCount);
            taskCleanService.saveBatch(tasks);
            template.setTaskCount(tasks.size());
            templateService.updateById(template);