From 47ed39879d87696ddabecdf5aa851b540b22becf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Mon, 26 May 2025 14:09:08 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=BC=98=E5=8C=96=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/WorkflowGlobalListener.java | 55 ++++++++++++------- .../service/impl/FlwTaskServiceImpl.java | 2 - 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/listener/WorkflowGlobalListener.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/listener/WorkflowGlobalListener.java index cae4daaaa..ec9712d80 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/listener/WorkflowGlobalListener.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/listener/WorkflowGlobalListener.java @@ -7,12 +7,14 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.enums.BusinessStatusEnum; import org.dromara.common.core.utils.StringUtils; +import org.dromara.warm.flow.core.FlowEngine; import org.dromara.warm.flow.core.dto.FlowParams; import org.dromara.warm.flow.core.entity.Definition; import org.dromara.warm.flow.core.entity.Instance; import org.dromara.warm.flow.core.entity.Task; import org.dromara.warm.flow.core.listener.GlobalListener; import org.dromara.warm.flow.core.listener.ListenerVariable; +import org.dromara.warm.flow.core.service.InsService; import org.dromara.warm.flow.orm.entity.FlowTask; import org.dromara.workflow.common.ConditionalOnEnable; import org.dromara.workflow.common.constant.FlowConstant; @@ -43,6 +45,7 @@ public class WorkflowGlobalListener implements GlobalListener { private final IFlwInstanceService instanceService; private final FlowProcessEventHandler flowProcessEventHandler; private final IFlwCommonService flwCommonService; + private final InsService insService; /** * 创建监听器,任务创建时执行 @@ -60,12 +63,6 @@ public class WorkflowGlobalListener implements GlobalListener { // 判断流程状态(发布审批中事件) flowProcessEventHandler.processCreateTaskHandler(definition.getFlowCode(), instance, task.getId()); } - Boolean submit = MapUtil.getBool(variable, FlowConstant.SUBMIT); - if (submit != null && submit) { - flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, instance.getFlowStatus(), variable, true); - } - variable.remove(FlowConstant.SUBMIT); - flowParams.variable(variable); } /** @@ -110,6 +107,13 @@ public class WorkflowGlobalListener implements GlobalListener { flowTask.setPermissionList(List.of(instance.getCreateBy())); } } + // 申请人提交事件 + Boolean submit = MapUtil.getBool(variable, FlowConstant.SUBMIT); + if (submit != null && submit) { + flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, instance.getFlowStatus(), variable, true); + } + variable.remove(FlowConstant.SUBMIT); + flowParams.variable(variable); } /** @@ -136,24 +140,35 @@ public class WorkflowGlobalListener implements GlobalListener { if (StringUtils.isNotBlank(status)) { flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, status, params, false); } - Map variable = listenerVariable.getVariable(); + + if (ObjectUtil.isNull(flowParams)) { + return; + } + Map variable = flowParams.getVariable(); // 只有办理或者退回的时候才执行消息通知和抄送 if (TaskStatusEnum.PASS.getStatus().equals(flowParams.getHisStatus()) || TaskStatusEnum.BACK.getStatus().equals(flowParams.getHisStatus())) { Task task = listenerVariable.getTask(); - List flowCopyList = (List) variable.get(FlowConstant.FLOW_COPY_LIST); - List messageType = (List) variable.get(FlowConstant.MESSAGE_TYPE); - String notice = (String) variable.get(FlowConstant.MESSAGE_NOTICE); - - // 添加抄送人 - flwTaskService.setCopy(task, flowCopyList); - variable.remove(FlowConstant.FLOW_COPY_LIST); - - // 消息通知 - if (CollUtil.isNotEmpty(messageType)) { - flwCommonService.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice); - variable.remove(FlowConstant.MESSAGE_TYPE); - variable.remove(FlowConstant.MESSAGE_NOTICE); + if (variable != null) { + if (variable.containsKey(FlowConstant.FLOW_COPY_LIST)) { + List flowCopyList = (List) variable.get(FlowConstant.FLOW_COPY_LIST); + // 添加抄送人 + flwTaskService.setCopy(task, flowCopyList); + } + if (variable.containsKey(FlowConstant.MESSAGE_TYPE)) { + List messageType = (List) variable.get(FlowConstant.MESSAGE_TYPE); + String notice = (String) variable.get(FlowConstant.MESSAGE_NOTICE); + // 消息通知 + if (CollUtil.isNotEmpty(messageType)) { + flwCommonService.sendMessage(definition.getFlowName(), instance.getId(), messageType, notice); + } + } + Map variableMap = instance.getVariableMap(); + variableMap.remove(FlowConstant.FLOW_COPY_LIST); + variableMap.remove(FlowConstant.MESSAGE_TYPE); + variableMap.remove(FlowConstant.MESSAGE_NOTICE); + instance.setVariable(FlowEngine.jsonConvert.objToStr(variableMap)); + insService.updateById(instance); } } } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/FlwTaskServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/FlwTaskServiceImpl.java index 83a64b692..1d35c41cf 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/FlwTaskServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/FlwTaskServiceImpl.java @@ -397,8 +397,6 @@ public class FlwTaskServiceImpl implements IFlwTaskService { String applyNodeCode = flwCommonService.applyNodeCode(definitionId); Map variable = new HashMap<>(); - // 设置抄送人 - variable.put("flowCopyList", bo.getMessageType()); // 消息类型 variable.put("messageType", messageType); // 消息通知