From 8443e3a27424c6d77930e32a9b6e8bbcb35c6fc1 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Sat, 19 Oct 2024 19:43:58 +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 --- .../java/com/hz/pm/api/external/MhApiClient.java | 4 + .../com/hz/pm/api/external/todo/MHTodoClient.java | 18 ++-- .../todo/enumerization/MHTodoTypeEnum.java | 74 +++++++++++--- .../hz/pm/api/meeting/manage/MeetingManage.java | 4 + .../projectdeclared/manage/ConstructionManage.java | 8 +- .../manage/FinalAcceptanceManage.java | 4 + .../projectdeclared/manage/OperationManage.java | 6 ++ .../manage/ProjectReviewManage.java | 5 + .../api/projectdeclared/manage/PurchaseManage.java | 31 ++++-- .../service/IPurchaseInstService.java | 6 ++ .../projectlib/manage/AmountApprovalManage.java | 15 ++- .../scheduler/listener/MhTodoHandedListener.java | 44 +++++++++ .../api/scheduler/listener/MhTodoSendListener.java | 88 +++++++++++++++++ .../listener/UserTaskCreateOrFinishListener.java | 106 +++++++++++++++++---- .../listener/event/MhTodoHandedEvent.java | 52 ++++++++++ .../scheduler/listener/event/MhTodoSendEvent.java | 58 +++++++++++ .../hz/pm/api/scheduler/task/MhTodoCloseTask.java | 53 +++++++++++ .../hz/pm/api/sys/model/entity/MhTodoRecord.java | 1 + 18 files changed, 519 insertions(+), 58 deletions(-) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoHandedListener.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoSendListener.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/event/MhTodoHandedEvent.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/event/MhTodoSendEvent.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/MhTodoCloseTask.java 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 14c8451..38d8244 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 @@ -132,6 +132,10 @@ public class MhApiClient { } public boolean sendZwddWorkNotice(MhZwddWorkNoticeDTO notice) { + log.info("发送浙政钉工作通知:{}", notice); + if (environmentUtil.isDevEnv()) { + return Boolean.TRUE; + } notice.setClientId(zwddWorkNoticeClientId); notice.setClientSecret(zwddWorkNoticeClientSecret); String retBody = HttpUtil.post(mhApiHost + ZWDD_MSG_URL, JSONUtil.toJsonStr(notice)); 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 ef2730b..bde246a 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 @@ -68,11 +68,6 @@ public class MHTodoClient { @Transactional(rollbackFor = Exception.class) public void addTodo(Object paramObj, UserFullInfoDTO receiver, MHTodoTypeEnum type, String bizId, String content) { - log.info("发送信产待办:【{}({})】类型:{} 内容:{}", receiver.getRealName(), receiver.getMhUserId(), type, content); - if (environmentUtil.isDevEnv()) { - return; - } - String url = mhApiHost + TODO_ADD; String paramObjs = JSON.toJSONString(paramObj); MhTodoRequestDTO todoReq = MhTodoRequestDTO.builder() .wkContent(content) @@ -80,7 +75,11 @@ public class MHTodoClient { .params(paramObjs) .wkUser(receiver.getMhUserId()) .build(); - log.info("添加新创待办:{}", todoReq); + log.info("发送信产待办:{}", todoReq); + if (environmentUtil.isDevEnv()) { + return; + } + String url = mhApiHost + TODO_ADD; String responseResult = HttpUtil.post(url, JSON.toJSONString(todoReq)); MhTodoRetDTO retData = JSON.parseObject(responseResult, TYPE_REF); if (retData.getCode() != 200 || StrUtil.isBlank(retData.getData())) { @@ -104,9 +103,9 @@ public class MHTodoClient { * * @param wkhandleId 待办ID */ - private void complete(String wkhandleId) { + public boolean complete(String wkhandleId) { if (environmentUtil.isDevEnv()) { - return; + return Boolean.TRUE; } String url = mhApiHost + TODO_COMPLETE; // 发送PUT请求 @@ -117,9 +116,10 @@ public class MHTodoClient { boolean state = Boolean.parseBoolean(retData.getData()); if (!state) { log.error("待办完成失败:{} {}", wkhandleId, retData); + return Boolean.FALSE; } } - + return Boolean.TRUE; } 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 5a8d8d7..d868a8d 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 @@ -16,19 +16,71 @@ import lombok.Getter; @SuppressWarnings("all") public enum MHTodoTypeEnum { - SELF_TEST_AUDIT("系统自测审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), - ADAPTION_AUDIT("开工文件审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), - TEST_VALID_AUDIT("监理核实验证审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), - COMPLIANCE_REVIEW_AUDIT("合规性审查审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), - PROJECT_REVIEW_AUDIT("项目评审审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), - PROJECT_STOPPED_AUDIT("项目终止审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), - PROJECT_CHANGE_AUDIT("项目变更审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), - FINAL_INSPECT_AUDIT("终验审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), - XCFHX_INSPECT_AUDIT("信创符合性审查审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&xinchuangId={xinchuangId}"), - DECLARED_RECORD_APPLY("立项备案申请", "mhProjectId=${mhProjectId}&status=${status}&projectCode=${projectCode}&projectId=${projectId}&userId=${userId}&userName=${userName}&path=${path}"), - DECLARED_RECORD_AUDIT("立项备案审批", "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"); + 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}"), + /** + * 流程审批待办 + */ + + SELF_TEST_AUDIT("系统自测审批", TEST_VALID_APPLY, null, null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), + ADAPTION_AUDIT("开工文件审批", SELF_TEST_APPLY, null, null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), + TEST_VALID_AUDIT("监理核实验证审批", WITHOUT_ORG_CONFIRM, null, null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), + COMPLIANCE_REVIEW_AUDIT("合规性审查审批", WITHOUT_BUILD_SCHEME, null, null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), + PROJECT_REVIEW_AUDIT("项目复核审批", null, null, null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), + PROJECT_STOPPED_AUDIT("项目终止审批", null, "您单位的【%s】已通过项目终止审核。", null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), + PROJECT_CHANGE_AUDIT("项目变更审批", null, "您单位的【%s】已通过项目变更审核。", null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), + FINAL_INSPECT_AUDIT("终验审批", null, "您单位的【%s】已通过终验审核。", null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"), + XCFHX_INSPECT_AUDIT("信创符合性审查审批", WITHOUT_BUILD_SCHEME, null, null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}&xinchuangId={xinchuangId}"), + DECLARED_RECORD_AUDIT("立项备案审批", WITHOUT_PURCHASE_NOTICE, null, null, null, + "instanceId=${instanceId}&projectId=${projectId}&nodeId=${nodeId}&taskId=${taskId}&bidId=${bizId}&userId=${userId}&userName=${userName}&path=${path}"); private final String val; + + + private final MHTodoTypeEnum nextStep; + + private final String zwddMsg; + + private final String todoMsg; + + /** + * 当前环节发页路径 + */ + private final String pagePath; + private final String referLinkParam; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java index 06a0419..9f36583 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/manage/MeetingManage.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; +import cn.hutool.extra.spring.SpringUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.Wrapper; @@ -22,6 +23,7 @@ import com.hz.pm.api.common.util.EnvironmentUtil; import com.hz.pm.api.expert.entity.ExpertUserFullInfo; import com.hz.pm.api.expert.service.IExpertUserFullInfoService; import com.hz.pm.api.external.MhApiClient; +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; import com.hz.pm.api.gov.service.IBelongOrgService; import com.hz.pm.api.meeting.builder.ExpertInviteBuilder; import com.hz.pm.api.meeting.builder.MeetingReviewProjectBuilder; @@ -48,6 +50,7 @@ import com.hz.pm.api.projectlib.helper.ProjectManageUtil; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; import com.hz.pm.api.projectlib.service.IProjectService; +import com.hz.pm.api.scheduler.listener.event.MhTodoSendEvent; import com.hz.pm.api.sys.model.dto.RegionDTO; import com.hz.pm.api.sys.model.entity.MsgCallRecord; import com.hz.pm.api.sys.model.enumeration.SubmitTypeEnum; @@ -1162,6 +1165,7 @@ public class MeetingManage { Project project = projectService.getById(mip.getProjectId()); if (req.getReviewResult() == 1) { projectStateMachineUtil.pass(project); + SpringUtil.publishEvent(MhTodoSendEvent.of(MHTodoTypeEnum.PROJECT_REVIEW_APPLY, project)); } else { projectStateMachineUtil.reject(project); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java index 21bb171..8e2f08b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ConstructionManage.java @@ -2,6 +2,7 @@ package com.hz.pm.api.projectdeclared.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.extra.spring.SpringUtil; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; @@ -19,6 +20,7 @@ import com.hz.pm.api.common.statemachine.util.XcfhxStateMachineUtil; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.ExcelExportStyle; import com.hz.pm.api.common.util.StrUtils; +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; import com.hz.pm.api.projectdeclared.helper.MhXchxFileHelper; import com.hz.pm.api.projectdeclared.model.dto.DeclaredProjectExportDTO; import com.hz.pm.api.projectdeclared.model.dto.PaymentPlanSupplementDTO; @@ -43,6 +45,8 @@ import com.hz.pm.api.projectlib.model.vo.TenderListInfoVO; import com.hz.pm.api.projectlib.service.IProjectAnnualPaymentPlanService; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; +import com.hz.pm.api.scheduler.listener.event.MhTodoHandedEvent; +import com.hz.pm.api.scheduler.listener.event.MhTodoSendEvent; import com.hz.pm.api.sys.manage.ProcessModelManage; import com.hz.pm.api.user.helper.MhUnitQueryAuthHelper; import com.hz.pm.api.user.helper.MhUnitQueryAuthHelper.UnitQueryState; @@ -590,11 +594,13 @@ public class ConstructionManage { .eq(Purchase::getBidType, BidTypeEnum.BUILD_APP.getCode()) .apply("LENGTH(NVL(preliminary_inspection_materials,'')) = 0") .last(BizConst.LIMIT_1); + Project project = projectService.getById(req.getProjectId()); if (purchaseService.count(purchaseQuery) == 0) { - Project project = projectService.getById(req.getProjectId()); projectStateMachineUtil.pass(project); projectService.updateById(project); } + SpringUtil.publishEvent(MhTodoSendEvent.of(MHTodoTypeEnum.FINAL_INSPECT_APPLY, project, purchase)); + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.WITHOUT_FIRST_ACCEPT_RECORD, req.getBidId())); } @Transactional(rollbackFor = Exception.class) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java index 22b5926..baa749f 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java @@ -2,6 +2,7 @@ package com.hz.pm.api.projectdeclared.manage; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.NumberUtil; +import cn.hutool.extra.spring.SpringUtil; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Assert; @@ -16,6 +17,7 @@ import com.hz.pm.api.common.util.BizDateUtil; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.ExcelExportStyle; +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; import com.hz.pm.api.projectdeclared.model.dto.DeclaredProjectExportDTO; import com.hz.pm.api.projectdeclared.model.entity.Contract; import com.hz.pm.api.projectdeclared.model.entity.Purchase; @@ -38,6 +40,7 @@ import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; import com.hz.pm.api.projectlib.model.vo.TenderListInfoVO; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; +import com.hz.pm.api.scheduler.listener.event.MhTodoHandedEvent; import com.hz.pm.api.sys.manage.ProcessModelManage; import com.hz.pm.api.user.helper.MhUnitQueryAuthHelper; import com.hz.pm.api.user.security.model.UserFullInfoDTO; @@ -356,6 +359,7 @@ public class FinalAcceptanceManage { } } //发送给第一个审批人消息 + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.FINAL_INSPECT_APPLY, req.getBidId())); return instanceId; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java index 3576397..c1e426b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/OperationManage.java @@ -1,9 +1,11 @@ package com.hz.pm.api.projectdeclared.manage; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; import com.hz.pm.api.projectdeclared.model.dto.OperationReq; import com.hz.pm.api.projectdeclared.model.entity.Operation; import com.hz.pm.api.projectdeclared.model.entity.Purchase; @@ -13,6 +15,8 @@ import com.hz.pm.api.projectdeclared.service.IPurchaseService; import com.hz.pm.api.projectlib.model.entity.Project; import com.hz.pm.api.projectlib.model.enumeration.status.TenderMainStatus; import com.hz.pm.api.projectlib.service.IProjectService; +import com.hz.pm.api.scheduler.listener.event.MhTodoHandedEvent; +import com.hz.pm.api.scheduler.listener.event.MhTodoSendEvent; import com.hz.pm.api.user.security.model.UserInfoDetails; import com.hz.pm.api.user.util.LoginUserUtil; import com.ningdatech.basic.exception.BizException; @@ -91,6 +95,8 @@ public class OperationManage { // 修改标段状态 tenderStateMachineUtil.pass(purchase); purchaseService.updateById(purchase); + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.WITHOUT_OPERATION_PLAN, purchase.getId())); + SpringUtil.publishEvent(MhTodoSendEvent.of(MHTodoTypeEnum.ADAPTION_APPLY, project, purchase)); return operation.getProjectCode(); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java index 50d755b..49bcda8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/ProjectReviewManage.java @@ -1,6 +1,7 @@ package com.hz.pm.api.projectdeclared.manage; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -16,6 +17,7 @@ import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.datascope.model.DataScopeDTO; import com.hz.pm.api.datascope.utils.DataScopeUtil; +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; import com.hz.pm.api.meeting.entity.domain.MeetingInnerProject; import com.hz.pm.api.meeting.entity.dto.ProjectReviewResultDTO; import com.hz.pm.api.meeting.service.IMeetingInnerProjectService; @@ -34,6 +36,7 @@ import com.hz.pm.api.projectlib.model.req.UploadConstructionPlanSealFileReq; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; +import com.hz.pm.api.scheduler.listener.event.MhTodoHandedEvent; import com.hz.pm.api.sys.manage.ProcessModelManage; import com.hz.pm.api.user.helper.MhUnitCache; import com.hz.pm.api.user.security.model.UserFullInfoDTO; @@ -116,6 +119,7 @@ public class ProjectReviewManage { projectInstService.save(projectInst); projectStateMachineUtil.pass(project); projectService.updateById(project); + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.PROJECT_REVIEW_APPLY, project.getId())); log.info("项目评审提交成功 【{}】", instanceId); } @@ -367,6 +371,7 @@ public class ProjectReviewManage { .set(Project::getUpdateBy, LoginUserUtil.getUserId()) .eq(Project::getId, req.getProjectId()); projectService.update(wrapper); + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.WITHOUT_BUILD_SCHEME, project.getId())); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java index 944ac64..dac2e1b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/PurchaseManage.java @@ -7,6 +7,7 @@ import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.spring.SpringUtil; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; import com.alibaba.excel.EasyExcel; @@ -27,6 +28,7 @@ import com.hz.pm.api.external.MhFileClient; import com.hz.pm.api.external.model.dto.MhPurchaseIntentionDTO; import com.hz.pm.api.external.model.dto.MhPurchaseNoticeDTO; import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum; +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; import com.hz.pm.api.projectdeclared.helper.MhXchxFileHelper; import com.hz.pm.api.projectdeclared.model.dto.DeclaredProjectExportDTO; import com.hz.pm.api.projectdeclared.model.dto.PurchaseSaveDTO; @@ -54,6 +56,8 @@ import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; +import com.hz.pm.api.scheduler.listener.event.MhTodoHandedEvent; +import com.hz.pm.api.scheduler.listener.event.MhTodoSendEvent; import com.hz.pm.api.sys.manage.ProcessModelManage; import com.hz.pm.api.user.helper.MhUnitCache; import com.hz.pm.api.user.helper.MhUnitQueryAuthHelper; @@ -458,6 +462,10 @@ public class PurchaseManage { projectGovSystemReplaceInfosService.updateBatchById(projectGovSystemReplaceInfos); projectStateMachineUtil.pass(project); projectService.updateById(project); + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.WITHOUT_PURCHASE_NOTICE, project.getId())); + for (Purchase purchase : purchases) { + SpringUtil.publishEvent(MhTodoSendEvent.of(MHTodoTypeEnum.WITHOUT_PURCHASE_CONTRACT, project, purchase)); + } // 发布采购公告 if (!notices.isEmpty()) { mhApiClient.publishPurchaseNotice(notices); @@ -565,6 +573,8 @@ public class PurchaseManage { project.setUpdateOn(now); project.setContractAmount(totalAmount); projectService.updateById(project); + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.WITHOUT_PURCHASE_CONTRACT, purchase.getId())); + SpringUtil.publishEvent(MhTodoSendEvent.of(MHTodoTypeEnum.WITHOUT_OPERATION_PLAN, project, purchase)); } public AdaptionProgressStatVO adaptionProgressStatistics(PurchaseAdaptionListReq req) { @@ -756,9 +766,9 @@ public class PurchaseManage { ProjectProcessType instType = ProjectProcessType.TEST_VALID; WflowModels model = processModelManage.getWflowModelsNoNull(instType, user.getMhUnitId()); LocalDateTime now = LocalDateTime.now(); + Long projectId = purchases.get(0).getProjectId(); + Project project = projectService.getNewProject(projectId); for (Purchase purchase : purchases) { - Long projectId = purchase.getProjectId(); - Project project = projectService.getNewProject(projectId); ProcessStartParamsVo instParam = new ProcessStartParamsVo(); instParam.setUser(declaredProjectManage.buildUser(user)); instParam.setProcessUsers(Collections.emptyMap()); @@ -786,6 +796,7 @@ public class PurchaseManage { operationService.saveOrUpdate(operation); saveProjectPurchaseInstCode(purchase.getId(), instanceId, project.getId(), instType); } + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.TEST_VALID_APPLY, purchases.get(0).getId())); } private void saveProjectPurchaseInstCode(Long bidId, @@ -821,9 +832,10 @@ public class PurchaseManage { WflowModels model = processModelManage.getWflowModelsNoNull(instType, user.getMhUnitId()); LocalDateTime now = LocalDateTime.now(); + Long projectId = purchases.get(0).getProjectId(); + Project project = projectService.getNewProject(projectId); for (Purchase purchase : purchases) { - Long projectId = purchase.getProjectId(); - Project project = projectService.getNewProject(projectId); + ProcessStartParamsVo instParam = new ProcessStartParamsVo(); instParam.setUser(declaredProjectManage.buildUser(user)); instParam.setProcessUsers(Collections.emptyMap()); @@ -851,6 +863,7 @@ public class PurchaseManage { operationService.saveOrUpdate(operation); saveProjectPurchaseInstCode(purchase.getId(), instanceId, project.getId(), instType); } + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.SELF_TEST_APPLY, purchases.get(0).getId())); } @Transactional(rollbackFor = Exception.class) @@ -865,11 +878,10 @@ public class PurchaseManage { UserInfoDetails user = LoginUserUtil.loginUserDetail(); ProjectProcessType instType = ProjectProcessType.ADAPTION; WflowModels model = processModelManage.getWflowModelsNoNull(instType, user.getMhUnitId()); - + Long projectId = purchases.get(0).getProjectId(); + Project project = projectService.getNewProject(projectId); LocalDateTime now = LocalDateTime.now(); for (Purchase purchase : purchases) { - Long projectId = purchase.getProjectId(); - Project project = projectService.getNewProject(projectId); ProcessStartParamsVo instParam = new ProcessStartParamsVo(); instParam.setUser(declaredProjectManage.buildUser(user)); instParam.setProcessUsers(Collections.emptyMap()); @@ -897,6 +909,7 @@ public class PurchaseManage { operationService.saveOrUpdate(operation); saveProjectPurchaseInstCode(purchase.getId(), instanceId, project.getId(), instType); } + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.ADAPTION_APPLY, purchases.get(0).getId())); } public PageVo pageXcfhxApply(XcfhxListReq req) { @@ -1018,11 +1031,13 @@ public class PurchaseManage { } return TenderMainStatus.TO_BE_SUBMIT_FIRST_INSPECTED_INFO.eq(w.getStatus()); }); + Project project = projectService.getNewestNoNull(purchase.getProjectId()); if (changeProjectStatus) { - Project project = projectService.getNewestNoNull(purchase.getProjectId()); projectStateMachineUtil.pass(project); projectService.updateById(project); } + SpringUtil.publishEvent(MhTodoHandedEvent.of(MHTodoTypeEnum.WITHOUT_ORG_CONFIRM, req.getBidId())); + SpringUtil.publishEvent(MhTodoSendEvent.of(MHTodoTypeEnum.WITHOUT_FIRST_ACCEPT_RECORD, project, purchase)); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseInstService.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseInstService.java index 26f95a7..4fee82d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseInstService.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/service/IPurchaseInstService.java @@ -35,6 +35,12 @@ public interface IPurchaseInstService extends IService { return list(query); } + default PurchaseInst getByInstCode(String instCode) { + Wrapper query = Wrappers.lambdaQuery(PurchaseInst.class) + .eq(PurchaseInst::getInstCode, instCode); + return getOne(query); + } + default List listByProjectId(Long projectId) { Wrapper query = Wrappers.lambdaQuery(PurchaseInst.class) .eq(PurchaseInst::getProjectId, projectId); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java index aa249cb..baf4487 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -16,6 +17,7 @@ import com.hz.pm.api.common.util.DecimalUtil; import com.hz.pm.api.datascope.model.DataScopeDTO; import com.hz.pm.api.datascope.utils.DataScopeUtil; import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum; +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; import com.hz.pm.api.projectlib.entity.ProjectApprovalAmount; import com.hz.pm.api.projectlib.helper.ProjectManageUtil; import com.hz.pm.api.projectlib.model.dto.ProjectApprovalAmountDTO; @@ -27,6 +29,7 @@ import com.hz.pm.api.projectlib.model.vo.AmountApprovalProgressStatisticsVO; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; import com.hz.pm.api.projectlib.service.IProjectApprovalAmountService; import com.hz.pm.api.projectlib.service.IProjectService; +import com.hz.pm.api.scheduler.listener.event.MhTodoSendEvent; import com.hz.pm.api.user.helper.MhUnitCache; import com.hz.pm.api.user.security.model.UserFullInfoDTO; import com.hz.pm.api.user.util.LoginUserUtil; @@ -217,6 +220,9 @@ public class AmountApprovalManage { projectApprovalAmount.setProjectCode(project.getProjectCode()); projectApprovalAmount.setCarryOverAmount(req.getCarryOverAmount()); projectApprovalAmountService.save(projectApprovalAmount); + if (!approved) { + SpringUtil.publishEvent(MhTodoSendEvent.of(MHTodoTypeEnum.DECLARED_RECORD_APPLY, project)); + } } private Integer getLastApprovalYear(Project project) { @@ -250,14 +256,7 @@ public class AmountApprovalManage { public List listApprovalAmounts(String projectCode) { List approvalAmounts = projectApprovalAmountService.listAsc(projectCode); - List retData = BeanUtil.copyToList(approvalAmounts, ProjectApprovalAmountDTO.class); - for (int i = 0; i < retData.size() - 1; i++) { - ProjectApprovalAmountDTO curr = retData.get(i); - ProjectApprovalAmountDTO next = retData.get(i + 1); - curr.setCarryOverAmount(next.getCarryOverAmount()); - next.setCarryOverAmount(null); - } - return retData; + return BeanUtil.copyToList(approvalAmounts, ProjectApprovalAmountDTO.class); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoHandedListener.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoHandedListener.java new file mode 100644 index 0000000..c2f006e --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoHandedListener.java @@ -0,0 +1,44 @@ +package com.hz.pm.api.scheduler.listener; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hz.pm.api.scheduler.listener.event.MhTodoHandedEvent; +import com.hz.pm.api.sys.model.entity.MhTodoRecord; +import com.hz.pm.api.sys.model.entity.MhTodoRecord.TodoStatusEnum; +import com.hz.pm.api.sys.service.IMhTodoRecordService; +import com.ningdatech.basic.util.CollUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +/** + *

+ * MhTodoHandedListener + *

+ * + * @author WendyYang + * @since 14:11 2024/10/19 + */ +@Component +@RequiredArgsConstructor +public class MhTodoHandedListener { + + private final IMhTodoRecordService mhTodoRecordService; + + @EventListener(MhTodoHandedEvent.class) + public void handleEvent(MhTodoHandedEvent event) { + LambdaUpdateWrapper wrapper = Wrappers.lambdaUpdate(MhTodoRecord.class) + .set(MhTodoRecord::getStatus, TodoStatusEnum.HANDING.getCode()) + .eq(MhTodoRecord::getStatus, TodoStatusEnum.PENDING.getCode()) + .eq(MhTodoRecord::getType, event.getMhTodoType()); + if (CollUtil.isNotEmpty(event.getBizIds())) { + wrapper.in(MhTodoRecord::getBizId, CollUtils.convert(event.getBizIds(), String::valueOf)); + } else { + wrapper.eq(MhTodoRecord::getBizId, event.getBizId().toString()); + } + mhTodoRecordService.update(wrapper); + } + +} 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 new file mode 100644 index 0000000..4a86bc7 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/MhTodoSendListener.java @@ -0,0 +1,88 @@ +package com.hz.pm.api.scheduler.listener; + +import cn.hutool.core.util.ObjUtil; +import cn.hutool.core.util.StrUtil; +import com.hz.pm.api.common.helper.UserInfoHelper; +import com.hz.pm.api.external.MhApiClient; +import com.hz.pm.api.external.model.dto.MhZwddWorkNoticeDTO; +import com.hz.pm.api.external.todo.MHTodoClient; +import com.hz.pm.api.external.todo.dto.MhTodoExtraParamDTO; +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; +import com.hz.pm.api.projectdeclared.model.entity.Purchase; +import com.hz.pm.api.projectdeclared.model.entity.Xinchuang; +import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.scheduler.listener.event.MhTodoSendEvent; +import com.hz.pm.api.user.security.model.UserFullInfoDTO; +import lombok.RequiredArgsConstructor; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +/** + *

+ * MhTodoSendListener + *

+ * + * @author WendyYang + * @since 14:47 2024/10/19 + */ +@Component +@RequiredArgsConstructor +public class MhTodoSendListener { + + private final MhApiClient mhApiClient; + private final MHTodoClient mhTodoClient; + private final UserInfoHelper userInfoHelper; + + @Async + @EventListener(classes = MhTodoSendEvent.class) + public void handleEvent(MhTodoSendEvent event) { + MHTodoTypeEnum todoType = event.getMhTodoType(); + MHTodoTypeEnum nextStep = ObjUtil.defaultIfNull(todoType.getNextStep(), todoType); + Purchase purchase = event.getPurchase(); + Project project = event.getProject(); + Xinchuang xinchuang = event.getXinchuang(); + boolean isBidTodo = purchase != null; + String tmpName; + Long createBy; + Long bizId; + if (isBidTodo) { + tmpName = purchase.getBidName(); + createBy = Long.valueOf(purchase.getCreateBy()); + bizId = purchase.getId(); + } else if (project != null) { + tmpName = project.getProjectName(); + createBy = project.getCreateBy(); + bizId = project.getId(); + } else if (xinchuang != null) { + tmpName = xinchuang.getProjectName(); + createBy = Long.parseLong(xinchuang.getCreateBy()); + bizId = xinchuang.getId(); + } else { + return; + } + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(createBy); + if (user == null || user.getMhUserId() == null) { + return; + } + if (StrUtil.isNotBlank(nextStep.getZwddMsg())) { + String zwddMsg = String.format(nextStep.getZwddMsg(), tmpName); + MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() + .content(zwddMsg) + .title(nextStep.getVal()) + .targetUser(user.getMhUserId()) + .build(); + mhApiClient.sendZwddWorkNotice(notice); + } + if (StrUtil.isNotBlank(nextStep.getTodoMsg())) { + String todoMsg = String.format(nextStep.getTodoMsg(), tmpName); + MhTodoExtraParamDTO paramObj = MhTodoExtraParamDTO.builder() + .path(nextStep.getPagePath()) + .userName(user.getRealName()) + .userId(createBy) + .build(); + mhTodoClient.addTodo(paramObj, user, nextStep, bizId.toString(), todoMsg); + } + } + +} 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 63d657f..4023f65 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 @@ -1,5 +1,6 @@ package com.hz.pm.api.scheduler.listener; +import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.hz.pm.api.common.enumeration.ProjectProcessType; @@ -10,10 +11,12 @@ import com.hz.pm.api.external.model.dto.MhZwddWorkNoticeDTO; import com.hz.pm.api.external.todo.MHTodoClient; import com.hz.pm.api.external.todo.dto.MhTodoExtraParamDTO; import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; +import com.hz.pm.api.projectdeclared.model.entity.Purchase; import com.hz.pm.api.projectdeclared.model.entity.PurchaseInst; import com.hz.pm.api.projectdeclared.model.entity.Xinchuang; import com.hz.pm.api.projectdeclared.model.entity.XinchuangInst; import com.hz.pm.api.projectdeclared.service.IPurchaseInstService; +import com.hz.pm.api.projectdeclared.service.IPurchaseService; import com.hz.pm.api.projectdeclared.service.IXinchuangInstService; import com.hz.pm.api.projectdeclared.service.IXinchuangService; import com.hz.pm.api.projectlib.model.entity.Project; @@ -57,6 +60,7 @@ import static com.hz.pm.api.common.util.ThreadPoolUtil.SCHEDULER; public class UserTaskCreateOrFinishListener { private final HistoryService historyService; + private final IPurchaseService purchaseService; private final IProjectService projectService; private final IProjectInstService projectInstService; private final ProcessModelHistorysService processModelHistorysService; @@ -216,29 +220,32 @@ public class UserTaskCreateOrFinishListener { } else { mhTodoClient.completeTodo(todoType, task.getId()); } - if (!event.getAction().equals(ProcessHandlerEnum.PASS) - && !event.getAction().equals(ProcessHandlerEnum.SEAL_PASS)) { - String projectName; - Long createBy; - ProjectInst projectInst = projectInstService.getByInstCode(event.getInstCode()); - if (projectInst != null) { - Project project = projectService.getNewestNoNull(projectInst.getProjectId()); - projectName = project.getProjectName(); - createBy = project.getCreateBy(); - } else { - XinchuangInst xinchuangInst = xinchuangInstService.getByInstCode(event.getInstCode()); - if (xinchuangInst == null) { - return; - } - Xinchuang xinchuang = xinchuangService.getById(xinchuangInst.getXinchuangId()); - projectName = xinchuang.getProjectName(); - createBy = Long.parseLong(xinchuang.getCreateBy()); - } - UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(createBy); - if (userFullInfo == null || StrUtil.isBlank(userFullInfo.getMhUserId())) { + String projectName; + Long projectId; + Long createBy; + ProjectInst projectInst = projectInstService.getByInstCode(event.getInstCode()); + if (projectInst != null) { + Project project = projectService.getNewestNoNull(projectInst.getProjectId()); + projectId = project.getId(); + projectName = project.getProjectName(); + createBy = project.getCreateBy(); + } else { + XinchuangInst xinchuangInst = xinchuangInstService.getByInstCode(event.getInstCode()); + if (xinchuangInst == null) { return; } - String zzdContent = String.format("您单位的【%s】的%s已被驳回,请按时完成提交!", + Xinchuang xinchuang = xinchuangService.getById(xinchuangInst.getXinchuangId()); + projectName = xinchuang.getProjectName(); + projectId = xinchuang.getId(); + createBy = Long.parseLong(xinchuang.getCreateBy()); + } + UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(createBy); + if (userFullInfo == null || StrUtil.isBlank(userFullInfo.getMhUserId())) { + return; + } + if (event.getAction().equals(ProcessHandlerEnum.REJECT) + && !event.getAction().equals(ProcessHandlerEnum.SEAL_PASS)) { + String zzdContent = String.format("您单位的【%s】的%s已被驳回,请及时处理!", projectName, getProcessTypeName(procType)); MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() .content(zzdContent) @@ -246,6 +253,43 @@ public class UserTaskCreateOrFinishListener { .targetUser(userFullInfo.getMhUserId()) .build(); mhApiClient.sendZwddWorkNotice(notice); + } else if (event.getAction().equals(ProcessHandlerEnum.PASS)) { + Purchase purchase = null; + boolean isBidAudit = isBidAudit(procType); + if (isBidAudit) { + purchase = getPurchase(event.getInstCode()); + if (purchase == null) { + log.warn("未找到采购信息,无法发送信产待办:{}", event.getInstCode()); + return; + } + } + String bidName = purchase == null ? null : purchase.getBidName(); + MHTodoTypeEnum nextStep = ObjUtil.defaultIfNull(todoType.getNextStep(), todoType); + String tmpName = isBidAudit ? bidName : projectName; + if (StrUtil.isNotBlank(nextStep.getZwddMsg())) { + String zwddMsg = String.format(nextStep.getZwddMsg(), tmpName); + MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder() + .content(zwddMsg) + .title(nextStep.getVal()) + .targetUser(userFullInfo.getMhUserId()) + .build(); + mhApiClient.sendZwddWorkNotice(notice); + } + if (StrUtil.isNotBlank(nextStep.getTodoMsg())) { + String todoMsg = String.format(nextStep.getTodoMsg(), tmpName); + MhTodoExtraParamDTO paramObj = MhTodoExtraParamDTO.builder() + .path(nextStep.getPagePath()) + .userName(userFullInfo.getRealName()) + .userId(createBy) + .build(); + String bizId; + if (isBidAudit) { + bizId = purchase.getId().toString(); + } else { + bizId = projectId.toString(); + } + mhTodoClient.addTodo(paramObj, userFullInfo, nextStep, bizId, todoMsg); + } } break; default: @@ -253,6 +297,14 @@ public class UserTaskCreateOrFinishListener { } } + private Purchase getPurchase(String instCode) { + PurchaseInst purchaseInst = purchaseInstService.getByInstCode(instCode); + if (purchaseInst != null) { + return purchaseService.getById(purchaseInst.getBidId()); + } + return null; + } + private MHTodoTypeEnum getMhTodoTypeEnum(ProjectProcessType procType) { MHTodoTypeEnum todoType; switch (procType) { @@ -292,4 +344,16 @@ public class UserTaskCreateOrFinishListener { return todoType; } + private boolean isBidAudit(ProjectProcessType processType) { + switch (processType) { + case TEST_VALID: + case ADAPTION: + case ACCEPTANCE_DECLARATION_APPROVAL_PROCESS: + case SELF_TEST: + return Boolean.TRUE; + default: + } + return false; + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/event/MhTodoHandedEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/event/MhTodoHandedEvent.java new file mode 100644 index 0000000..78da092 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/event/MhTodoHandedEvent.java @@ -0,0 +1,52 @@ +package com.hz.pm.api.scheduler.listener.event; + +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; +import lombok.Getter; +import lombok.Setter; +import org.springframework.context.ApplicationEvent; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.List; + +/** + *

+ * MhTodoHandedEvent + *

+ * + * @author WendyYang + * @since 14:33 2024/10/19 + */ +@Getter +@Setter +public class MhTodoHandedEvent extends ApplicationEvent { + + public MhTodoHandedEvent(Object source) { + super(source); + } + + public static MhTodoHandedEvent of(MHTodoTypeEnum mhTodoType, Long bizId) { + return of(mhTodoType, String.valueOf(bizId)); + } + + private static MhTodoHandedEvent of(MHTodoTypeEnum mhTodoType, String bizId) { + MhTodoHandedEvent event = new MhTodoHandedEvent(LocalDateTime.now()); + event.setMhTodoType(mhTodoType); + event.setBizId(bizId); + return event; + } + + public static MhTodoHandedEvent of(MHTodoTypeEnum mhTodoType, List bizIds) { + MhTodoHandedEvent event = new MhTodoHandedEvent(LocalDateTime.now()); + event.setMhTodoType(mhTodoType); + event.setBizIds(bizIds); + return event; + } + + private MHTodoTypeEnum mhTodoType; + + private String bizId; + + private List bizIds; + +} \ No newline at end of file diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/event/MhTodoSendEvent.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/event/MhTodoSendEvent.java new file mode 100644 index 0000000..f7e00b4 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/event/MhTodoSendEvent.java @@ -0,0 +1,58 @@ +package com.hz.pm.api.scheduler.listener.event; + +import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; +import com.hz.pm.api.projectdeclared.model.entity.Purchase; +import com.hz.pm.api.projectdeclared.model.entity.Xinchuang; +import com.hz.pm.api.projectlib.model.entity.Project; +import lombok.Getter; +import lombok.Setter; +import org.springframework.context.ApplicationEvent; + +import java.time.LocalDateTime; + +/** + *

+ * MhTodoSendEvent + *

+ * + * @author WendyYang + * @since 14:48 2024/10/19 + */ +@Getter +@Setter +public class MhTodoSendEvent extends ApplicationEvent { + + public MhTodoSendEvent(Object source) { + super(source); + } + + + public static MhTodoSendEvent of(MHTodoTypeEnum mhTodoType, Project project){ + MhTodoSendEvent event = new MhTodoSendEvent(LocalDateTime.now()); + event.setProject(project); + event.setMhTodoType(mhTodoType); + return event; + } + + public static MhTodoSendEvent of(MHTodoTypeEnum mhTodoType, Project project,Purchase purchase){ + MhTodoSendEvent event = of(mhTodoType, project); + event.setPurchase(purchase); + return event; + } + + public static MhTodoSendEvent of(MHTodoTypeEnum mhTodoType, Xinchuang xinchuang) { + MhTodoSendEvent event = new MhTodoSendEvent(LocalDateTime.now()); + event.setXinchuang(xinchuang); + event.setMhTodoType(mhTodoType); + return event; + } + + private MHTodoTypeEnum mhTodoType; + + private Project project; + + private Purchase purchase; + + private Xinchuang xinchuang; + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/MhTodoCloseTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/MhTodoCloseTask.java new file mode 100644 index 0000000..69543d7 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/MhTodoCloseTask.java @@ -0,0 +1,53 @@ +package com.hz.pm.api.scheduler.task; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hz.pm.api.external.todo.MHTodoClient; +import com.hz.pm.api.sys.model.entity.MhTodoRecord; +import com.hz.pm.api.sys.service.IMhTodoRecordService; +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Profile; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static com.hz.pm.api.sys.model.entity.MhTodoRecord.TodoStatusEnum.HANDED; +import static com.hz.pm.api.sys.model.entity.MhTodoRecord.TodoStatusEnum.HANDING; + +/** + *

+ * MhTodoCloseTask + *

+ * + * @author WendyYang + * @since 13:49 2024/10/19 + */ +@Component +@Profile("prod") +@RequiredArgsConstructor +public class MhTodoCloseTask { + + private final IMhTodoRecordService mhTodoRecordService; + private final MHTodoClient mhTodoClient; + + @Scheduled(fixedRate = 2, timeUnit = TimeUnit.MINUTES) + public void closeMhTodo() { + Wrapper query = Wrappers.lambdaQuery(MhTodoRecord.class) + .eq(MhTodoRecord::getStatus, HANDING.getCode()); + List mhTodoList = mhTodoRecordService.list(query); + if (mhTodoList.isEmpty()) { + return; + } + for (MhTodoRecord mhTodo : mhTodoList) { + if (mhTodoClient.complete(mhTodo.getMhTodoId())) { + Wrapper update = Wrappers.lambdaUpdate(MhTodoRecord.class) + .set(MhTodoRecord::getStatus, HANDED.getCode()) + .eq(MhTodoRecord::getId, mhTodo.getId()); + mhTodoRecordService.update(update); + } + } + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/entity/MhTodoRecord.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/entity/MhTodoRecord.java index 9c22398..449b316 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/entity/MhTodoRecord.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/model/entity/MhTodoRecord.java @@ -64,6 +64,7 @@ public class MhTodoRecord implements Serializable { public enum TodoStatusEnum { PENDING(1, "待处理"), + HANDING(4, "处理中"), HANDED(2, "已处理"), DELETED(3, "已删除");