From 3a41ebfaccacd052a049d70356c899ab66035bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E9=A3=9E=E5=AE=87?= <2684146481@qq.com> Date: Tue, 6 Jun 2023 11:31:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=A5=A8=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/message/MessageConstants.java | 1 + .../service/impl/TicketProcessServiceImpl.java | 59 ++++++++++++++++++++-- 2 files changed, 56 insertions(+), 4 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 e6a42b3..7b7fbdb 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 @@ -53,6 +53,7 @@ public class MessageConstants { DUTY("duty","值班消息"), SAFE("safe","安全消息"), ACCESS("access","检修消息"), + TICKETMESSAGE("ticket-message","工作票消息"), ; @Getter private String key; diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java index 15ce51e..15202c8 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java @@ -11,6 +11,9 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.MessagePushRecordDto; +import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient; import com.hnac.hzims.operational.feign.IAccessTaskClient; @@ -54,6 +57,7 @@ import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; +import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; @@ -147,6 +151,13 @@ public class TicketProcessServiceImpl implements TicketProcessService { private final ProcessDictService processDictService; + + private final IMessageClient messageClient; + + + private final ISysClient sysClient; + + /** * 启动开票流程 * @@ -306,15 +317,16 @@ public class TicketProcessServiceImpl implements TicketProcessService { //工作结束 WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish(); try { - log.info("工作结束==============>"+ (workTicket.getFlowStatus().intValue())); if (ObjectUtils.isNotEmpty(workTicketFinish)) { WorkTicketFinish ticketFinish = workTicketFinishService.selectByTicketId(workTicketInfo.getId()); log.info("获取工作结束:{}", workTicketFinish); if (ObjectUtils.isEmpty(workTicketFinish.getId()) || ObjectUtils.isEmpty(ticketFinish)) { + log.info("获取工作结束保存成功"); workTicketFinish.setTicketId(workTicketInfo.getId()); workTicketFinishService.save(workTicketFinish); } else { + log.info("获取工作结束更新成功"); workTicketDelay.setInitialTime(LocalDateTime.now()); workTicketFinishService.updateByTicketId(workTicketFinish); } @@ -384,6 +396,47 @@ public class TicketProcessServiceImpl implements TicketProcessService { } catch (Exception e) { e.printStackTrace(); } + + + + //推送消息 + MessagePushRecordDto message = new MessagePushRecordDto(); + message.setBusinessClassify("business"); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey()); + message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription()); + message.setTaskId(workTicketInfo.getId()); + message.setTenantId("200000"); + message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH)); + message.setPushType(MessageConstants.IMMEDIATELY); + //您有一张工作票待审批,工作内容:*****,审批环节:*****; + String countent = + "您有一张工作票待审批,工作内容:".concat(workTicketInfo.getWorkContent()) + .concat(",审批环节:") + .concat(response.getTaskName()); + message.setContent(countent); + message.setDeptId(workTicketInfo.getCreateDept()); + R deptName = sysClient.getDeptName(workTicketInfo.getCreateDept()); + if (deptName.isSuccess()) { + message.setDeptName(deptName.getData()); + } + String userIds = response.getUserId(); + if (StringUtils.isBlank(userIds)){ + log.error("推送的消息不能为空哦,{}",userIds); + return; + } + String[] split = userIds.split(","); + for (String userId : split) { + message.setPusher(userId); + User user = UserCache.getUser(NumberUtils.toLong(userId)); + if (ObjectUtils.isNotEmpty(user)) { + message.setPusherName(user.getName()); + } + message.setAccount(userId); + + message.setCreateUser(NumberUtils.toLong(userId)); + messageClient.sendMessage(message); + } + } @@ -432,7 +485,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { String taskId = response.getTaskId(); if (StringUtils.isEmpty(taskId)) { workTicket.setFlowDescription("结束"); - workTicket.setFlowTaskId(" "); + // workTicket.setFlowTaskId(" "); workTicket.setFlowTaskName("结束"); workTicket.setNextStepOperator(" "); workTicket.setStepOperator(" "); @@ -1165,8 +1218,6 @@ public class TicketProcessServiceImpl implements TicketProcessService { dataConversion.put(key, BooleanUtils.toBoolean(newValue) ? "☑" : "□"); } } - - }