From 1832125d57e3299157f7135c65715d556768cce7 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Mon, 21 Oct 2024 11:42:51 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E5=85=A8=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=8F=90=E9=86=92=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/model/dingtalk/AbstractDingTalkMsg.java | 21 ++++++ .../model/dingtalk/DingTalkMarkdownMsgDTO.java | 41 +++++++++++ .../hz/pm/api/common/util/DingTalkMsgClient.java | 48 +++++++++++++ .../java/com/hz/pm/api/external/MhApiClient.java | 2 + .../external/model/dto/MhZwddWorkNoticeDTO.java | 1 + .../com/hz/pm/api/external/todo/MHTodoClient.java | 2 + .../todo/enumerization/MHTodoTypeEnum.java | 82 +++++++++++++++------- .../api/scheduler/listener/MhTodoSendListener.java | 1 + .../listener/UserTaskCreateOrFinishListener.java | 3 + .../scheduler/task/DeclaredRecordReminderTask.java | 1 + hz-pm-api/src/main/resources/application-prod.yml | 2 +- 11 files changed, 179 insertions(+), 25 deletions(-) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/common/model/dingtalk/AbstractDingTalkMsg.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/common/model/dingtalk/DingTalkMarkdownMsgDTO.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/common/util/DingTalkMsgClient.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/dingtalk/AbstractDingTalkMsg.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/dingtalk/AbstractDingTalkMsg.java new file mode 100644 index 0000000..6426281 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/dingtalk/AbstractDingTalkMsg.java @@ -0,0 +1,21 @@ +package com.hz.pm.api.common.model.dingtalk; + +import lombok.Data; + +/** + *

+ * AbstractDingTalkMsg + *

+ * + * @author WendyYang + * @since 19:31 2023/3/14 + */ +@Data +public abstract class AbstractDingTalkMsg { + + /** + * msgtype:消息类型 + */ + private String msgtype; + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/model/dingtalk/DingTalkMarkdownMsgDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/dingtalk/DingTalkMarkdownMsgDTO.java new file mode 100644 index 0000000..adba2e7 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/model/dingtalk/DingTalkMarkdownMsgDTO.java @@ -0,0 +1,41 @@ +package com.hz.pm.api.common.model.dingtalk; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + *

+ * DingTalkMarkdownPo + *

+ * + * @author WendyYang + * @since 13:01 2022/11/7 + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class DingTalkMarkdownMsgDTO extends AbstractDingTalkMsg { + + /** + * markdown + */ + private MarkdownDTO markdown; + + /** + * MarkdownDTO + */ + @Data + @NoArgsConstructor + public static class MarkdownDTO { + /** + * title + */ + private String title; + /** + * text + */ + private String text; + } + +} \ No newline at end of file diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/DingTalkMsgClient.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/DingTalkMsgClient.java new file mode 100644 index 0000000..9e402b8 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/DingTalkMsgClient.java @@ -0,0 +1,48 @@ +package com.hz.pm.api.common.util; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import com.hz.pm.api.common.model.dingtalk.DingTalkMarkdownMsgDTO; +import com.hz.pm.api.common.model.dingtalk.DingTalkMarkdownMsgDTO.MarkdownDTO; +import lombok.extern.slf4j.Slf4j; + +/** + *

+ * DIngTalkMsgClient + *

+ * + * @author WendyYang + * @since 09:38 2024/10/21 + */ +@Slf4j +public class DingTalkMsgClient { + + private DingTalkMsgClient() { + } + + private static final String WEB_HOOK = "https://oapi.dingtalk.com/robot/send?access_token=176a8522d9662b231f873f68725e973762d600245ce5fd5ece8ced1be7a6111c"; + + public static void send(String receiver, String content, Object extraParam) { + HttpRequest request = HttpUtil.createPost(WEB_HOOK); + DingTalkMarkdownMsgDTO msg = new DingTalkMarkdownMsgDTO(); + MarkdownDTO markdown = new MarkdownDTO(); + markdown.setTitle("模拟待办发送"); + StringBuilder msgObj = new StringBuilder() + .append("#### 接收人\n") + .append(receiver) + .append("\n#### 待办或提醒内容") + .append("\n").append(content) + .append("\n#### 拓展参数") + .append(JSONUtil.toJsonStr(extraParam)); + markdown.setText(JSONUtil.toJsonStr(msgObj)); + msg.setMarkdown(markdown); + msg.setMsgtype("markdown"); + request.body(JSONUtil.toJsonStr(msg)); + try (HttpResponse response = request.executeAsync()) { + log.info("模拟待办发送:{}", response); + } + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java index 38d8244..28f023c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/MhApiClient.java @@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.hz.pm.api.common.util.DingTalkMsgClient; import com.hz.pm.api.common.util.EnvironmentUtil; import com.hz.pm.api.external.model.dto.*; import com.hz.pm.api.external.model.enumeration.MhDictType; @@ -134,6 +135,7 @@ public class MhApiClient { public boolean sendZwddWorkNotice(MhZwddWorkNoticeDTO notice) { log.info("发送浙政钉工作通知:{}", notice); if (environmentUtil.isDevEnv()) { + DingTalkMsgClient.send(notice.getTargetUserName(), notice.getContent(), null); return Boolean.TRUE; } notice.setClientId(zwddWorkNoticeClientId); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhZwddWorkNoticeDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhZwddWorkNoticeDTO.java index f3d495f..8c105f0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhZwddWorkNoticeDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/model/dto/MhZwddWorkNoticeDTO.java @@ -38,5 +38,6 @@ public class MhZwddWorkNoticeDTO { */ private String targetUser; + private transient String targetUserName; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java index bde246a..e7dc26a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java @@ -10,6 +10,7 @@ import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hz.pm.api.common.util.DingTalkMsgClient; import com.hz.pm.api.common.util.EnvironmentUtil; import com.hz.pm.api.external.todo.dto.MhTodoRequestDTO; import com.hz.pm.api.external.todo.dto.MhTodoRetDTO; @@ -77,6 +78,7 @@ public class MHTodoClient { .build(); log.info("发送信产待办:{}", todoReq); if (environmentUtil.isDevEnv()) { + DingTalkMsgClient.send(receiver.getUsername(), content,paramObjs); return; } String url = mhApiHost + TODO_ADD; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/enumerization/MHTodoTypeEnum.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/enumerization/MHTodoTypeEnum.java index d868a8d..800459b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/enumerization/MHTodoTypeEnum.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/enumerization/MHTodoTypeEnum.java @@ -18,30 +18,64 @@ public enum MHTodoTypeEnum { SELF_TEST_APPLY("系统自测", null, "您单位的【%s】开工文件备案已通过,可在过程管理-适配改造中进行提交系统自测信息的操作。", - "【%s】系统自测信息需要您处理,请及时处理", null, null), - TEST_VALID_APPLY("监理核实验证", null, "您单位的【%s】系统自测备案已通过,可在过程管理-适配改造中进行填写监理核实验证信息的操作。", - "【%s】监理核实验证需要您处理,请及时处理", null, null), - FINAL_INSPECT_APPLY("终验申请", null, "您单位的【%s】已完成初验备案,可在过程管理-终验申请中进行终验申请的操作。", - "【%s】终验申请需要您处理,请及时处理", null, null), - ADAPTION_APPLY("上传开工文件", null, "您单位的【%s】已完成实施计划填写,可在过程管理-适配改造中进行上传开工文件的操作。", - "【%s】上传开工文件需要您处理,请及时处理", null, null), - PROJECT_REVIEW_APPLY("项目复核", null, "您单位的【%s】的专家评审已通过,可在过程管理-项目评审-项目复核中进行提交复核的操作。", - "【%s】项目复核需要您处理,请及时处理", null, null), - WITHOUT_BUILD_SCHEME("上传建设方案盖章件", null, "您单位的【%s】的合规性审査已通过,可在过程管理-项目评审-专家评审中进行上传建设方案盖章件的操作。", - "【%s】上传建设方案盖章件需要您处理,请及时处理", null, null), - WITHOUT_PURCHASE_NOTICE("发布采购公告", null, "您单位的【%s】立项备案已通过,可在过程管理-招标采购中进行发布采购公告的操作。", - "【%s】发布采购公告需要您处理,请及时处理", null, null), - WITHOUT_PURCHASE_CONTRACT("采购&合同信息备案", null, "您单位的【%s】已完成发布采购公告,可在过程管理-招标采购中进行采购&合同信息备案的操作。", - "【%s】采购&合同信息备案需要您处理,请及时处理", null, null), - WITHOUT_OPERATION_PLAN("实施计划填写", null, "您单位的【%s】已完成采购&合同信息备案,可在过程管理-适配改造中进行填写实施计划的操作。", - "【%s】实施计划需要您处理,请及时处理", null, null), - WITHOUT_FIRST_ACCEPT_RECORD("初验备案", null, "您单位的【%s】已完成适配改造,可在过程管理-初验申请中进行初验备案的操作。", - "【%s】初验备案需要您处理,请及时处理", null, null), - WITHOUT_ORG_CONFIRM("单位确认", null, "您单位的【%s】监理核实验证备案已通过,可在过程管理-适配改造中进行单位确认的操作。", - "【%s】单位确认需要您处理,请及时处理", null, null), - DECLARED_RECORD_APPLY("立项备案申请", null, "您单位的【%s】已下达资金,可在过程管理-项目立项中进行立项备案的操作。", - "【%s】立项备案需要您处理,请及时处理", null, - "mhProjectId=${mhProjectId}&status=${status}&projectCode=${projectCode}&projectId=${projectId}&userId=${userId}&userName=${userName}&path=${path}"), + "【%s】系统自测信息需要您处理,请及时处理", + "/declareManage/projectManages/adaptiveTransformation", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=1100"), + TEST_VALID_APPLY("监理核实验证", null, + "您单位的【%s】系统自测备案已通过,可在过程管理-适配改造中进行填写监理核实验证信息的操作。", + "【%s】监理核实验证需要您处理,请及时处理", + "/declareManage/projectManages/adaptiveTransformation", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=3100"), + FINAL_INSPECT_APPLY("终验申请", null, + "您单位的【%s】已完成初验备案,可在过程管理-终验申请中进行终验申请的操作。", + "【%s】终验申请需要您处理,请及时处理", + "/declareManage/projectManages/finalInspectionDeclare", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=401"), + ADAPTION_APPLY("上传开工文件", null, + "您单位的【%s】已完成实施计划填写,可在过程管理-适配改造中进行上传开工文件的操作。", + "【%s】上传开工文件需要您处理,请及时处理", + "/declareManage/projectManages/adaptiveTransformation", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=2100"), + PROJECT_REVIEW_APPLY("项目复核", null, + "您单位的【%s】的专家评审已通过,可在过程管理-项目评审-项目复核中进行提交复核的操作。", + "【%s】项目复核需要您处理,请及时处理", + "/declareManage/projectManages/projectRecheck", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=10040"), + WITHOUT_BUILD_SCHEME("上传建设方案盖章件", null, + "您单位的【%s】的合规性审査已通过,可在过程管理-项目评审-专家评审中进行上传建设方案盖章件的操作。", + "【%s】上传建设方案盖章件需要您处理,请及时处理", + "/declareManage/projectManages/expertReview", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=10050"), + WITHOUT_PURCHASE_NOTICE("发布采购公告", null, + "您单位的【%s】立项备案已通过,可在过程管理-招标采购中进行发布采购公告的操作。", + "【%s】发布采购公告需要您处理,请及时处理", + "/declareManage/projectManages/purchaseResults", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=20001"), + WITHOUT_PURCHASE_CONTRACT("采购&合同信息备案", null, + "您单位的【%s】已完成发布采购公告,可在过程管理-招标采购中进行采购&合同信息备案的操作。", + "【%s】采购&合同信息备案需要您处理,请及时处理", + "/declareManage/projectManages/purchaseResults", + "/instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=101"), + WITHOUT_OPERATION_PLAN("实施计划填写", null, + "您单位的【%s】已完成采购&合同信息备案,可在过程管理-适配改造中进行填写实施计划的操作。", + "【%s】实施计划需要您处理,请及时处理", + "/declareManage/projectManages/adaptiveTransformation", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=103"), + WITHOUT_FIRST_ACCEPT_RECORD("初验备案", null, + "您单位的【%s】已完成适配改造,可在过程管理-初验申请中进行初验备案的操作。", + "【%s】初验备案需要您处理,请及时处理", + "/declareManage/projectManages/initialInspectionRecord", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=201"), + WITHOUT_ORG_CONFIRM("单位确认", null, + "您单位的【%s】监理核实验证备案已通过,可在过程管理-适配改造中进行单位确认的操作。", + "【%s】单位确认需要您处理,请及时处理", + "/declareManage/projectManages/adaptiveTransformation", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=104"), + DECLARED_RECORD_APPLY("立项备案申请", null, + "您单位的【%s】已下达资金,可在过程管理-项目立项中进行立项备案的操作。", + "【%s】立项备案需要您处理,请及时处理", + "/declareManage/projectManages/projectFiling", + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&activeName=10022"), /** * 流程审批待办 */ diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoSendListener.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoSendListener.java index 4a86bc7..363764d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoSendListener.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoSendListener.java @@ -70,6 +70,7 @@ public class MhTodoSendListener { MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() .content(zwddMsg) .title(nextStep.getVal()) + .targetUserName(user.getRealName()) .targetUser(user.getMhUserId()) .build(); mhApiClient.sendZwddWorkNotice(notice); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/UserTaskCreateOrFinishListener.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/UserTaskCreateOrFinishListener.java index 4023f65..7f183bc 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/UserTaskCreateOrFinishListener.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/UserTaskCreateOrFinishListener.java @@ -176,6 +176,7 @@ public class UserTaskCreateOrFinishListener { MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() .content(zzdContent) .title(todoType.getVal()) + .targetUserName(assignee.getRealName()) .targetUser(assignee.getMhUserId()) .build(); mhApiClient.sendZwddWorkNotice(notice); @@ -250,6 +251,7 @@ public class UserTaskCreateOrFinishListener { MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() .content(zzdContent) .title(todoType.getVal()) + .targetUserName(userFullInfo.getRealName()) .targetUser(userFullInfo.getMhUserId()) .build(); mhApiClient.sendZwddWorkNotice(notice); @@ -271,6 +273,7 @@ public class UserTaskCreateOrFinishListener { MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() .content(zwddMsg) .title(nextStep.getVal()) + .targetUserName(userFullInfo.getRealName()) .targetUser(userFullInfo.getMhUserId()) .build(); mhApiClient.sendZwddWorkNotice(notice); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordReminderTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordReminderTask.java index 28666a0..8ebb062 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordReminderTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/DeclaredRecordReminderTask.java @@ -132,6 +132,7 @@ public class DeclaredRecordReminderTask extends AbstractReminderTask { MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() .title(DECLARED_RECORD_APPLY.getVal()) .content(content) + .targetUserName(user.getRealName()) .targetUser(user.getMhUserId()) .build(); mhApiClient.sendZwddWorkNotice(notice); diff --git a/hz-pm-api/src/main/resources/application-prod.yml b/hz-pm-api/src/main/resources/application-prod.yml index 4192861..7da5099 100644 --- a/hz-pm-api/src/main/resources/application-prod.yml +++ b/hz-pm-api/src/main/resources/application-prod.yml @@ -219,7 +219,7 @@ agent-login: # 提醒任务 reminder-task: declared-record: - open: true + open: false cron: 0 30 8 * * ? # 电话服务调用地址 mobile-call: