mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-10-14 06:00:23 +00:00
update 优化工作流流程监听增加节点信息
This commit is contained in:
@@ -30,10 +30,20 @@ public class ProcessCreateTaskEvent extends RemoteApplicationEvent {
|
||||
private String flowCode;
|
||||
|
||||
/**
|
||||
* 审批节点编码
|
||||
* 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 流程节点编码
|
||||
*/
|
||||
private String nodeCode;
|
||||
|
||||
/**
|
||||
* 流程节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
|
@@ -36,7 +36,22 @@ public class ProcessEvent extends RemoteApplicationEvent {
|
||||
private String businessId;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 流程节点编码
|
||||
*/
|
||||
private String nodeCode;
|
||||
|
||||
/**
|
||||
* 流程节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 流程状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package org.dromara.workflow.handler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.warm.flow.core.entity.Instance;
|
||||
import org.dromara.workflow.api.event.ProcessCreateTaskEvent;
|
||||
import org.dromara.workflow.api.event.ProcessDeleteEvent;
|
||||
import org.dromara.workflow.api.event.ProcessEvent;
|
||||
@@ -25,18 +26,23 @@ public class FlowProcessEventHandler {
|
||||
/**
|
||||
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
|
||||
*
|
||||
* @param flowCode 流程定义编码
|
||||
* @param businessId 业务id
|
||||
* @param status 状态
|
||||
* @param submit 当为true时为申请人节点办理
|
||||
* @param flowCode 流程定义编码
|
||||
* @param instance 实例数据
|
||||
* @param status 流程状态
|
||||
* @param params 办理参数
|
||||
* @param submit 当为true时为申请人节点办理
|
||||
*/
|
||||
public void processHandler(String flowCode, String businessId, String status, Map<String, Object> params, boolean submit) {
|
||||
public void processHandler(String flowCode, Instance instance, String status, Map<String, Object> params, boolean submit) {
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
log.info("发布流程事件,租户ID: {}, 流程状态: {}, 流程编码: {}, 业务ID: {}, 是否申请人节点办理: {}", tenantId, status, flowCode, businessId, submit);
|
||||
log.info("【流程事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}, 流程状态: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 是否申请人节点: {}, 参数: {}",
|
||||
tenantId, flowCode, instance.getBusinessId(), status, instance.getNodeType(), instance.getNodeCode(), instance.getNodeName(), submit, params);
|
||||
ProcessEvent processEvent = new ProcessEvent();
|
||||
processEvent.setTenantId(tenantId);
|
||||
processEvent.setFlowCode(flowCode);
|
||||
processEvent.setBusinessId(businessId);
|
||||
processEvent.setBusinessId(instance.getBusinessId());
|
||||
processEvent.setNodeType(instance.getNodeType());
|
||||
processEvent.setNodeCode(instance.getNodeCode());
|
||||
processEvent.setNodeName(instance.getNodeName());
|
||||
processEvent.setStatus(status);
|
||||
processEvent.setParams(params);
|
||||
processEvent.setSubmit(submit);
|
||||
@@ -46,20 +52,22 @@ public class FlowProcessEventHandler {
|
||||
/**
|
||||
* 执行创建任务监听
|
||||
*
|
||||
* @param flowCode 流程定义编码
|
||||
* @param nodeCode 审批节点编码
|
||||
* @param taskId 任务id
|
||||
* @param businessId 业务id
|
||||
* @param flowCode 流程定义编码
|
||||
* @param instance 实例数据
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
public void processCreateTaskHandler(String flowCode, String nodeCode, Long taskId, String businessId) {
|
||||
public void processCreateTaskHandler(String flowCode, Instance instance, Long taskId) {
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
log.info("发布流程任务事件, 租户ID: {}, 流程编码: {}, 节点编码: {}, 任务ID: {}, 业务ID: {}", tenantId, flowCode, nodeCode, taskId, businessId);
|
||||
log.info("【流程任务事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 任务ID: {}",
|
||||
tenantId, flowCode, instance.getBusinessId(), instance.getNodeType(), instance.getNodeCode(), instance.getNodeName(), taskId);
|
||||
ProcessCreateTaskEvent processCreateTaskEvent = new ProcessCreateTaskEvent();
|
||||
processCreateTaskEvent.setTenantId(tenantId);
|
||||
processCreateTaskEvent.setFlowCode(flowCode);
|
||||
processCreateTaskEvent.setNodeCode(nodeCode);
|
||||
processCreateTaskEvent.setBusinessId(instance.getBusinessId());
|
||||
processCreateTaskEvent.setNodeType(instance.getNodeType());
|
||||
processCreateTaskEvent.setNodeCode(instance.getNodeCode());
|
||||
processCreateTaskEvent.setNodeName(instance.getNodeName());
|
||||
processCreateTaskEvent.setTaskId(taskId);
|
||||
processCreateTaskEvent.setBusinessId(businessId);
|
||||
SpringUtils.context().publishEvent(processCreateTaskEvent);
|
||||
}
|
||||
|
||||
@@ -71,7 +79,7 @@ public class FlowProcessEventHandler {
|
||||
*/
|
||||
public void processDeleteHandler(String flowCode, String businessId) {
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
log.info("发布删除流程事件, 租户ID: {}, 流程编码: {}, 业务ID: {}", tenantId, flowCode, businessId);
|
||||
log.info("【流程删除事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}", tenantId, flowCode, businessId);
|
||||
ProcessDeleteEvent processDeleteEvent = new ProcessDeleteEvent();
|
||||
processDeleteEvent.setTenantId(tenantId);
|
||||
processDeleteEvent.setFlowCode(flowCode);
|
||||
|
@@ -47,12 +47,10 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
public void create(ListenerVariable listenerVariable) {
|
||||
Instance instance = listenerVariable.getInstance();
|
||||
Definition definition = listenerVariable.getDefinition();
|
||||
String businessId = instance.getBusinessId();
|
||||
String flowStatus = instance.getFlowStatus();
|
||||
Task task = listenerVariable.getTask();
|
||||
if (task != null && BusinessStatusEnum.WAITING.getStatus().equals(flowStatus)) {
|
||||
if (task != null && BusinessStatusEnum.WAITING.getStatus().equals(instance.getFlowStatus())) {
|
||||
// 判断流程状态(发布审批中事件)
|
||||
flowProcessEventHandler.processCreateTaskHandler(definition.getFlowCode(), task.getNodeCode(), task.getId(), businessId);
|
||||
flowProcessEventHandler.processCreateTaskHandler(definition.getFlowCode(), instance, task.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,20 +94,20 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
params.put("message", flowParams.getMessage());
|
||||
}
|
||||
// 判断流程状态(发布:撤销,退回,作废,终止,已完成事件)
|
||||
String status = determineFlowStatus(instance, flowStatus);
|
||||
String status = determineFlowStatus(instance);
|
||||
if (StringUtils.isNotBlank(status)) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), businessId, status, params, false);
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), instance, status, params, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程实例和当前流程状态确定最终状态
|
||||
* 根据流程实例确定最终状态
|
||||
*
|
||||
* @param instance 流程实例
|
||||
* @param flowStatus 流程实例当前状态
|
||||
* @param instance 流程实例
|
||||
* @return 流程最终状态
|
||||
*/
|
||||
private String determineFlowStatus(Instance instance, String flowStatus) {
|
||||
private String determineFlowStatus(Instance instance) {
|
||||
String flowStatus = instance.getFlowStatus();
|
||||
if (StringUtils.isNotBlank(flowStatus) && BusinessStatusEnum.initialState(flowStatus)) {
|
||||
log.info("流程实例当前状态: {}", flowStatus);
|
||||
return flowStatus;
|
||||
|
@@ -165,7 +165,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
|
||||
Definition definition = defService.getById(flowTask.getDefinitionId());
|
||||
// 检查流程状态是否为草稿、已撤销或已退回状态,若是则执行流程提交监听
|
||||
if (BusinessStatusEnum.isDraftOrCancelOrBack(ins.getFlowStatus())) {
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), ins.getBusinessId(), ins.getFlowStatus(), null, true);
|
||||
flowProcessEventHandler.processHandler(definition.getFlowCode(), ins, ins.getFlowStatus(), null, true);
|
||||
}
|
||||
// 设置弹窗处理人
|
||||
Map<String, Object> assigneeMap = setPopAssigneeMap(completeTaskBo.getAssigneeMap(), ins.getVariableMap());
|
||||
|
Reference in New Issue
Block a user