From 53d014edd19f57125c355abe71ec5b478500e610 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 05 八月 2025 09:57:40 +0800 Subject: [PATCH] 保洁巡检所有代码 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java | 39 +++++++++++++++++++++++++++++++-------- 1 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java index 34324ab..2ed9857 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java @@ -10,6 +10,7 @@ import com.ruoyi.system.mapper.TCleanerMapper; import com.ruoyi.system.model.*; import com.ruoyi.system.service.*; +import com.ruoyi.system.utils.TemplateMessageSendUtil; import com.ruoyi.web.controller.tool.EmailUtils; import com.ruoyi.web.controller.tool.MsgUtils; import javafx.concurrent.Task; @@ -70,14 +71,10 @@ private TLeaveService leaveService; @Resource private TNoticeService noticeService; - - - // 每一个小时执行一次 -// @Scheduled(cron = "0 0 0 * * ?") -// @Scheduled(fixedRate = 1500000000) + // 每天晚上22点执行 + @Scheduled(cron = "0 0 22 * * ?") public void dayOfCreateInspection() { try { - // 查询任务模板 List<TTemplate> list = templateService.list(); if (CollectionUtils.isEmpty(list)) { @@ -96,6 +93,8 @@ private TNoticeSetService noticeSetService; @Resource private MsgUtils msgUtils; + @Resource + private TemplateMessageSendUtil templateMessageSendUtil; @Resource private TDictDataService dictDataService; @Scheduled(cron = "0 0 20 * * ?") @@ -118,7 +117,6 @@ List<TNotice> noticeList = new ArrayList<>(); List<TNotice> addNotice = new ArrayList<>(); taskCleanList.forEach(task -> { - task.setStatus(2); TEarlyWarning earlyWarning = new TEarlyWarning(); earlyWarning.setWarningType(1); earlyWarning.setTaskId(task.getId()); @@ -150,16 +148,41 @@ msgUtils.sendMsg2(sysUser.getPhonenumber(),count+""); break; case 2: - if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent())){ + if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent()) + &&StringUtils.hasLength(sysUser.getEmail())){ EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"今日剩余"+count+"个任务未完成,请尽快处理"); } break; case 3: + if (StringUtils.hasLength(sysUser.getOpenId())){ + Date date = new Date(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String format = simpleDateFormat.format(date); + templateMessageSendUtil.wxTemplateDayWorkRequest(sysUser.getOpenId(), + count+"",format); + } break; } } } noticeService.saveBatch(addNotice); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Scheduled(cron = "0 0 8 * * ?") + public void dayMinusOfEarlyWarning() { + try { + // 查询前一天为执行的所有任务,改成已超时状态 + 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) { -- Gitblit v1.7.1