| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | // 每一个小时执行一次 |
| | | // @Scheduled(cron = "0 0 0 * * ?") |
| | | @Scheduled(fixedRate = 1500000000) |
| | | // @Scheduled(fixedRate = 1500000000) |
| | | public void dayOfCreateInspection() { |
| | | try { |
| | | |
| | |
| | | // 创建任务 |
| | | 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(); |
| | |
| | | continue; |
| | | } |
| | | |
| | | |
| | | |
| | | SysUser sysUser = sysUsers.get(0); |
| | | int taskCount = 0; |
| | | for (SysUser sysUser : sysUsers) { |
| | | List<TProjectDept> projectDeptLists = new ArrayList<>(); |
| | | if(sysUser.getDeptType() == 1){ |
| | | TProjectDept projectDept = projectDeptService.getById(sysUser.getDeptId()); |
| | |
| | | // 抽取保洁员 |
| | | List<TCleaner> tCleaners = randomSelection(cleaners, dayCleanerCount); |
| | | if(CollectionUtils.isEmpty(tCleaners)){ |
| | | log.error("没有可抽取的保洁员"); |
| | | log.error("没有可抽取的保洁员,模板id为:{}",detail.getId()); |
| | | continue; |
| | | } |
| | | if(tCleaners.size() < dayCleanerCount){ |
| | |
| | | templateCountService.save(templateCount); |
| | | |
| | | taskCleanService.saveBatch(tasks); |
| | | template.setTaskCount(tasks.size()); |
| | | taskCount = taskCount + tasks.size(); |
| | | } |
| | | template.setTaskCount(taskCount); |
| | | templateService.updateById(template); |
| | | templateDetailService.updateById(detail); |
| | | } |