From 1459457aa34889375e2ed00e3b08f7a63653a86f Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Wed, 26 Feb 2025 16:38:17 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InspectionsLogController.java | 4 +- .../admin/taskinfo/TaskInfoController.java | 8 ++ .../EnterpriseInspectionsServiceImpl.java | 2 +- .../service/taskinfo/TaskInfoService.java | 5 ++ .../service/taskinfo/TaskInfoServiceImpl.java | 73 ++++++++++++++++++- 5 files changed, 87 insertions(+), 5 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java index 593d584..a3fb588 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java @@ -51,7 +51,7 @@ public class InspectionsLogController { @Operation(summary = "创建打卡") public CommonResult createInspectionsLog(@Valid @RequestBody InspectionsLogSaveReqVO createReqVO) { inspectionsLogService.createInspectionsLog(createReqVO); - return success("打卡成功"); + return success("签到成功"); } @PutMapping("/confirmSignIn") @@ -59,7 +59,7 @@ public class InspectionsLogController { public CommonResult confirmSignIn(@Valid @RequestBody InspectionsLogSaveReqVO createReqVO) { log.info("createReqVO:{}", createReqVO); inspectionsLogService.confirmSignIn(createReqVO); - return success("打卡成功"); + return success("签到成功"); } @GetMapping("/signInList") 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 b558b99..d2c95f1 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,6 +84,14 @@ public class TaskInfoController { return success(taskInfoService.createTaskInfo(createReqVO)); } + @PutMapping("/taskExec") + @Operation(summary = "创建任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。") + @PreAuthorize("@ss.hasPermission('system:task-info:create')") + public CommonResult taskExec(@Valid @RequestBody TaskInfoSaveReqVO updateReqVO) { + taskInfoService.taskExec(updateReqVO); + return success("执行成功"); + } + @PutMapping("/update") @Operation(summary = "更新任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。") @PreAuthorize("@ss.hasPermission('system:task-info:update')") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java index e16f018..afba306 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java @@ -194,7 +194,7 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe } //按照部门查询 - if (pageReqVO.getDepartmentId() != null) { + if (pageReqVO.getDepartmentId() != null && pageReqVO.getUserId() == null) { final List adminUserDOS = adminUserMapper.selectList(new QueryWrapper().eq("dept_id", pageReqVO.getDepartmentId())); if (adminUserDOS != null || adminUserDOS.size() > 0) { final List collect = adminUserDOS.stream().map(item -> item.getId()).collect(Collectors.toList()); 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 f10ecd3..cf8d055 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 @@ -63,4 +63,9 @@ public interface TaskInfoService { PageResult getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO); PageResult appPageByEnterpriseId(TaskInfoPageReqVO pageReqVO); + + /* + 任务执行 + */ + void taskExec(TaskInfoSaveReqVO updateReqVO); } 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 66c5308..7c1079c 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 @@ -2,9 +2,14 @@ package cn.iocoder.yudao.module.system.service.taskinfo; import cn.hutool.core.date.DateUtil; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.common.util.date.DateUtils; 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.api.notify.NotifyMessageSendApi; +import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; +import cn.iocoder.yudao.module.system.api.social.SocialClientApi; +import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.RoleNameAndSelectTypeVO; import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.EnterpriseInspectionsPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.tasktag.vo.TaskTagPageReqVO; @@ -75,6 +80,12 @@ public class TaskInfoServiceImpl implements TaskInfoService { @Resource private TagLibraryService tagLibraryService; + @Resource + SocialClientApi socialClientApi; + + @Resource + NotifyMessageSendApi notifyMessageSendApi; + @Override @Transactional public Long createTaskInfo(TaskInfoSaveReqVO createReqVO) { @@ -296,9 +307,67 @@ public class TaskInfoServiceImpl implements TaskInfoService { }); } - - // 查询列表 + // 查询列表 return new PageResult<>(taskInfoDOIPage.getRecords(), taskInfoDOIPage.getTotal()); } + @Override + @Transactional + public void taskExec(TaskInfoSaveReqVO updateReqVO) { + Long taskId = updateReqVO.getId(); + final TaskInfoDO taskInfoDO = taskInfoMapper.selectById(taskId); + if (taskInfoDO == null) { + throw exception(TASK_INFO_NOT_EXISTS); + } + taskInfoDO.setStatus(2); + taskInfoMapper.updateById(taskInfoDO); + + //执法任务更改状态 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EnterpriseInspectionsDO::getTaskId, taskInfoDO.getId()); + List enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper); + if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size() > 0) { + List list = new ArrayList<>(); + for (EnterpriseInspectionsDO enterpriseInspectionsDO : enterpriseInspectionsDOList) { + //小程序订阅 + try { + //发送消息); + SocialWxaSubscribeMessageSendReqDTO reqDTO = new SocialWxaSubscribeMessageSendReqDTO(); + reqDTO.setUserType(1); + reqDTO.setTemplateTitle("环保任务通知"); + reqDTO.setPage("sub/task/detail?id="+taskInfoDO.getId()); + reqDTO.setUserId(enterpriseInspectionsDO.getUserId()); + Map message = new HashMap<>(); + message.put("thing2", taskInfoDO.getTitle()); + message.put("time3", DateUtil.format(taskInfoDO.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + message.put("thing4", taskInfoDO.getDescription()); + message.put("time5", DateUtil.format(taskInfoDO.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + reqDTO.setMessages(message); + socialClientApi.sendWxaSubscribeMessage(reqDTO); + + } + catch (Exception e){ + log.error("任务发送通知错误:",e.toString()); + } + + //站内信发送通知 + NotifySendSingleToUserReqDTO notifyMessage = new NotifySendSingleToUserReqDTO(); + notifyMessage.setUserId(Long.valueOf(enterpriseInspectionsDO.getUserId())); + notifyMessage.setTemplateCode("task_messages"); + Map templateParams = new HashMap<>(); + templateParams.put("title", taskInfoDO.getTitle()); + templateParams.put("startTime", DateUtil.format(taskInfoDO.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + templateParams.put("endTime", DateUtil.format(taskInfoDO.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY) ); + templateParams.put("url", "sub/task/detail?taskId="+ enterpriseInspectionsDO.getTaskId()); + + notifyMessage.setTemplateParams(templateParams); + notifyMessageSendApi.sendSingleMessageToMember(notifyMessage); + + enterpriseInspectionsDO.setStatus(2); + list.add(enterpriseInspectionsDO); + } + enterpriseInspectionsMapper.updateBatch(list); + } + } + }