From bff2e3da13bc9d1c35682ac4d4bb86638bd82109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=B9=8F?= Date: Mon, 17 Feb 2025 15:09:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/EnterpriseInspectionsPageReqVO.java | 3 + .../admin/taskinfo/TaskInfoController.java | 2 +- .../admin/taskinfo/vo/TaskInfoRespVO.java | 5 ++ .../admin/taskinfo/vo/TaskInfoSaveReqVO.java | 7 +++ .../EnterpriseInspectionsMapper.java | 1 + .../system/job/TaskSendStartMessageJob.java | 62 +++++++++++++++++++ .../service/taskinfo/TaskInfoService.java | 2 + .../service/taskinfo/TaskInfoServiceImpl.java | 40 ++++++++++-- 8 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java index 2b56c17..3243812 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsPageReqVO.java @@ -48,5 +48,8 @@ public class EnterpriseInspectionsPageReqVO extends PageParam { @Schema(description = "按部门查询的用户id集合") private List userIds; + @Schema(description = "任务ids") + private List taskIds; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java index 1e65152..59a5dc7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java @@ -84,7 +84,7 @@ public class TaskInfoController { return success(taskInfoService.createTaskInfo(createReqVO)); } - @PutMapping("/update") + @PostMapping("/update") @Operation(summary = "更新任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。") @PreAuthorize("@ss.hasPermission('system:task-info:update')") public CommonResult updateTaskInfo(@Valid @RequestBody TaskInfoSaveReqVO updateReqVO) { diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java index b67f19d..431f9cf 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java @@ -103,6 +103,11 @@ public class TaskInfoRespVO { @ExcelProperty("企业集合") private List enterpriseIdes; + + @Schema(description = "企业任务集合") + @ExcelProperty("企业任务集合") + private List enterpriseIdeTasks; + @Schema(description = "标签集合") @ExcelProperty("标签集合") private List taskTagIdes; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java index 7d28ab0..87b4c7b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java @@ -3,14 +3,19 @@ package cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; +import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.time.LocalDateTime; import java.util.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + @Schema(description = "管理后台 - 任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。新增/修改 Request VO") @Data +@ToString(callSuper = true) public class TaskInfoSaveReqVO { @Schema(description = "任务ID,主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4541") @@ -42,9 +47,11 @@ public class TaskInfoSaveReqVO { private String status; @Schema(description = "任务计划开始时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime startDate; @Schema(description = "任务计划结束时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime endDate; @Schema(description = "父任务id", example = "30399") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java index bd341ac..54edde2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java @@ -45,6 +45,7 @@ public interface EnterpriseInspectionsMapper extends BaseMapperX beforeTaskInfoList = taskInfoService.getBeforeTaskInfoList(); + beforeTaskInfoList.forEach(beforeTaskInfo -> { + beforeTaskInfo.getEnterpriseIdeTasks().forEach(x ->{ + if(x.getUserId()!= null){ + try { + //发送消息); + SocialWxaSubscribeMessageSendReqDTO reqDTO = new SocialWxaSubscribeMessageSendReqDTO(); + reqDTO.setUserType(1); + reqDTO.setTemplateTitle("环保任务通知"); + reqDTO.setPage("pages/index"); + reqDTO.setUserId(x.getUserId()); + Map message = new HashMap<>(); + message.put("thing2", beforeTaskInfo.getTitle()); + message.put("time3", DateUtil.format(beforeTaskInfo.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + message.put("thing4", beforeTaskInfo.getDescription()); + message.put("time5", DateUtil.format(beforeTaskInfo.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + reqDTO.setMessages(message); + socialClientApi.sendWxaSubscribeMessage(reqDTO); + } + catch (Exception e){ + log.error("任务发送通知错误:",e.toString()); + } + + } + + + }); + }); + return "发送消息任务数量:"+ beforeTaskInfoList.size(); + } +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java index 15c7e3c..64a44b1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java @@ -55,6 +55,8 @@ public interface TaskInfoService { // List getTaskInfoList(TaskInfoPageReqVO pageReqVO); + List getBeforeTaskInfoList(); + //定时执行任务 void sendTask(Long taskId); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java index f986d0f..b886298 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java @@ -1,10 +1,11 @@ package cn.iocoder.yudao.module.system.service.taskinfo; -import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.infra.api.job.JobApi; -import cn.iocoder.yudao.module.system.controller.admin.tasktag.vo.TaskTagPageReqVO; +import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.EnterpriseInspectionsPageReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; @@ -31,9 +32,7 @@ import java.util.stream.Collectors; import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.common.pojo.JobSaveReqVO; import cn.iocoder.yudao.module.system.dal.mysql.taskinfo.TaskInfoMapper; @@ -180,6 +179,39 @@ public class TaskInfoServiceImpl implements TaskInfoService { return taskInfoMapper.selectPage(pageReqVO); } + @Override + public List getBeforeTaskInfoList() { + //查询所有新建的任务 + LambdaQueryWrapperX queryWrapperX=new LambdaQueryWrapperX(); + //待进行的任务 + queryWrapperX.eqIfPresent(TaskInfoDO::getStatus,1); + //当天到任务 + queryWrapperX.eqIfPresent(TaskInfoDO::getStartDate,DateUtil.format(new Date(), "yyyy-MM-dd")); + + List taskInfoDOS = taskInfoMapper.selectList(queryWrapperX); + + Map taskMap = CollectionUtils.convertMap(taskInfoDOS, TaskInfoDO::getId); + + EnterpriseInspectionsPageReqVO enterpriseInspectionsPageReqVO=new EnterpriseInspectionsPageReqVO(); + enterpriseInspectionsPageReqVO.setTaskIds(taskMap.keySet().parallelStream().collect(Collectors.toList())); + + List enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(enterpriseInspectionsPageReqVO); + + Map> enterpriseInspectionsMap = CollectionUtils.convertMultiMap(enterpriseInspectionsDOList, EnterpriseInspectionsDO::getTaskId); + + List taskInfoRespVOS = new LinkedList<>(); + taskMap.forEach((k,v)->{ + TaskInfoRespVO taskInfoRespVO=BeanUtils.toBean(v,TaskInfoRespVO.class); + taskInfoRespVO.setEnterpriseIdeTasks(enterpriseInspectionsMap.get(k)); + taskInfoRespVOS.add(taskInfoRespVO); + }); + + return taskInfoRespVOS; + } + + + + @Override public void sendTask(Long taskId) { From 22a8584faeb01090bcdf3c7d1bf02d6a335dc52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=B9=8F?= Date: Mon, 17 Feb 2025 15:41:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/taskinfo/TaskInfoController.java | 2 +- .../admin/taskinfo/vo/TaskInfoSaveReqVO.java | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java index 18bf658..c4e6c7e 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java @@ -84,7 +84,7 @@ public class TaskInfoController { return success(taskInfoService.createTaskInfo(createReqVO)); } - @PostMapping("/update") + @PutMapping("/update") @Operation(summary = "更新任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。") @PreAuthorize("@ss.hasPermission('system:task-info:update')") public CommonResult updateTaskInfo(@Valid @RequestBody TaskInfoSaveReqVO updateReqVO) { diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java index 87b4c7b..ecef9b3 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java @@ -1,12 +1,20 @@ package cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; @@ -47,12 +55,16 @@ public class TaskInfoSaveReqVO { private String status; @Schema(description = "任务计划开始时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime startDate; + @JsonSerialize(using = LocalDateSerializer.class) // 序列化(响应) + @JsonDeserialize(using = LocalDateDeserializer.class) // 反序列化(请求) + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate startDate; @Schema(description = "任务计划结束时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime endDate; + @JsonSerialize(using = LocalDateSerializer.class) // 序列化(响应) + @JsonDeserialize(using = LocalDateDeserializer.class) // 反序列化(请求) + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate endDate; @Schema(description = "父任务id", example = "30399") private Long parentId;