From da7707ead3db27fbc7acd87eb0e0d00d14737d9a Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 26 Jun 2023 17:06:52 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=A3=80=E4=BF=AE=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/message/MessageConstants.java | 5 ++ .../service/impl/AccessPlanV4ServiceImpl.java | 55 ++++++++++++++++++++-- .../service/impl/AccessTaskV4ServiceImpl.java | 53 ++++++++++++++++++++- 3 files changed, 108 insertions(+), 5 deletions(-) diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java index 9960a32..abe695b 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java @@ -52,10 +52,15 @@ public class MessageConstants { DUTY("duty","值班消息"), SAFE("safe","安全消息"), ACCESS("access","检修消息"), + BUSINESS("business","事务消息"), TICKETMESSAGE("ticket-message","工作票消息"), OPERATIONTICKETMESSAGE("operation-ticket-message","操作票消息"), ROUTINEMAINTENANCE("operation-maintenance-message","日常维护消息"), OPERATIONDEFECTMESSAGE("operation-defect-message","消缺消息"), + + OVERHAUL_PLAN("overhaul-plan","检修计划"), + + OVERHAUL_TASK("overhaul-task","检修任务"), ; @Getter private String key; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java index 269b491..a7a13e0 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java @@ -3,6 +3,9 @@ package com.hnac.hzims.operational.access.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.BusinessMessageDTO; +import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.access.dto.*; import com.hnac.hzims.operational.access.entity.OperAccessContentEntity; @@ -22,6 +25,9 @@ import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.TaskUtil; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -46,8 +52,14 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ private final AccessTaskV4Service accessTaskV4Service; + private final ISysClient sysClient; + private final IFlowClient flowClient; + private final IUserClient userClient; + + private final IMessageClient messageClient; + /** * 开启检修计划流程 * @param entity @@ -178,12 +190,21 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ entity.setTaskName("流程结束"); entity.setNextStepOperator("流程结束,无需人员处理"); entity.setActEndTime(new Date()); + return this.planService.updateById(entity); + // 审核不通过 + } else if(ObjectUtil.isNotEmpty(variables.get("examine")) && !(Boolean) variables.get("examine")){ + String content = "您有一条检修计划待调整!检修计划名称:".concat(entity.getName()) + .concat(",当前环节:") + .concat(processWorkFlowResponse.getTaskName()); + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); + return this.planService.updateById(entity); } - this.planService.updateById(entity); this.saveAccessMaterial(entity); this.saveAccessContent(entity); - // 开启检修任务 - this.startTaskProcess(entity); + String content = "您有一条检修计划待审批!检修计划名称:".concat(entity.getName()) + .concat(",当前环节:") + .concat(processWorkFlowResponse.getTaskName()); + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); return true; } @@ -220,4 +241,32 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ accessTaskV4Service.startProcessV4(task); } } + + /** + * 推送业务流程消息 + * @param entity + * @param userId + * @param content + */ + private void sendMessage(AccessPlanV4DTO entity, String userId, String content) { + BusinessMessageDTO message = new BusinessMessageDTO(); + // 计划Id + message.setTaskId(entity.getId()); + message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OVERHAUL_PLAN.getKey()); + // 主题 + message.setSubject(MessageConstants.BusinessClassifyEnum.OVERHAUL_PLAN.getDescription()); + message.setDeptId(entity.getCreateDept()); + R result = sysClient.getDeptName(entity.getCreateDept()); + if (result.isSuccess()) { + message.setDeptName(result.getData()); + } + // 内容 + message.setContent(content); + message.setTenantId("200000"); + User admin = userClient.userByAccount("200000", "admin").getData(); + message.setCreateUser(admin.getId()); + message.setUserIds(userId); + messageClient.sendAppAndWsMsgByUsers(message); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java index 31351e4..89cef1c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java @@ -4,7 +4,11 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.BusinessMessageDTO; +import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.dto.AccessPlanV4DTO; import com.hnac.hzims.operational.access.dto.AccessTaskV4DTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskDetailDTO; import com.hnac.hzims.operational.access.entity.OperAccessMaterialEntity; @@ -25,6 +29,9 @@ import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.TaskUtil; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -47,8 +54,14 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { private final IOperAccessTaskDetailService detailService; + private final ISysClient sysClient; + private final IFlowClient flowClient; + private final IUserClient userClient; + + private final IMessageClient messageClient; + /** * 开启检修任务流程 * @param entity @@ -161,16 +174,52 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service { if(ObjectUtil.isNotEmpty(variables.get("examine")) && (Boolean) variables.get("examine")){ entity.setTaskName("流程结束"); entity.setNextStepOperator("流程结束,无需人员处理"); - entity.setActEndTime(new Date()); // 更新任务数据 this.taskService.updateById(entity); - }else if(ObjectUtil.isNotEmpty(variables.get("examine")) && !(Boolean) variables.get("examine")){ + }else if(ObjectUtil.isEmpty(variables.get("examine")) && !(Boolean) variables.get("examine")){ + String content = "您有一条检修任务待处理!检修任务名称:".concat(entity.getName()) + .concat(",当前环节:") + .concat(processWorkFlowResponse.getTaskName()); + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); return this.taskService.updateById(entity); } // 保存检修材料 this.saveMaterial(entity); // 保存检修详情 this.saveDetails(entity); + // 发送消息 + String content = "您有一条检修任务待审批!检修任务名称:".concat(entity.getName()) + .concat(",当前环节:") + .concat(processWorkFlowResponse.getTaskName()); + this.sendMessage(entity,processWorkFlowResponse.getUserId(),content); return true; } + + /** + * 推送业务流程消息 + * @param entity + * @param userId + * @param content + */ + private void sendMessage(AccessTaskV4DTO entity, String userId, String content) { + BusinessMessageDTO message = new BusinessMessageDTO(); + // 计划Id + message.setTaskId(entity.getId()); + message.setBusinessClassify(MessageConstants.BusinessClassifyEnum.BUSINESS.getKey()); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OVERHAUL_TASK.getKey()); + // 主题 + message.setSubject(MessageConstants.BusinessClassifyEnum.OVERHAUL_TASK.getDescription()); + message.setDeptId(entity.getCreateDept()); + R result = sysClient.getDeptName(entity.getCreateDept()); + if (result.isSuccess()) { + message.setDeptName(result.getData()); + } + // 内容 + message.setContent(content); + message.setTenantId("200000"); + User admin = userClient.userByAccount("200000", "admin").getData(); + message.setCreateUser(admin.getId()); + message.setUserIds(userId); + messageClient.sendAppAndWsMsgByUsers(message); + } } \ No newline at end of file