update 优化工作流流程监听增加节点信息
This commit is contained in:
parent
70aa14ecf8
commit
b50904c6ff
@ -27,10 +27,20 @@ public class ProcessCreateTaskEvent implements Serializable {
|
||||
private String flowCode;
|
||||
|
||||
/**
|
||||
* 审批节点编码
|
||||
* 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 流程节点编码
|
||||
*/
|
||||
private String nodeCode;
|
||||
|
||||
/**
|
||||
* 流程节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
|
@ -33,7 +33,22 @@ public class ProcessEvent implements Serializable {
|
||||
private String businessId;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 流程节点编码
|
||||
*/
|
||||
private String nodeCode;
|
||||
|
||||
/**
|
||||
* 流程节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 流程状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
|
@ -27,16 +27,27 @@ public class FlowProcessEventHandler {
|
||||
*
|
||||
* @param flowCode 流程定义编码
|
||||
* @param businessId 业务id
|
||||
* @param status 状态
|
||||
* @param nodeType 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
* @param nodeCode 流程节点编码
|
||||
* @param nodeName 流程节点名称
|
||||
* @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, String businessId, Integer nodeType, String nodeCode, String nodeName,
|
||||
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, businessId, status, nodeType, nodeCode, nodeName, submit, params);
|
||||
|
||||
ProcessEvent processEvent = new ProcessEvent();
|
||||
processEvent.setTenantId(tenantId);
|
||||
processEvent.setFlowCode(flowCode);
|
||||
processEvent.setBusinessId(businessId);
|
||||
processEvent.setNodeType(nodeType);
|
||||
processEvent.setNodeCode(nodeCode);
|
||||
processEvent.setNodeName(nodeName);
|
||||
processEvent.setStatus(status);
|
||||
processEvent.setParams(params);
|
||||
processEvent.setSubmit(submit);
|
||||
@ -47,17 +58,22 @@ public class FlowProcessEventHandler {
|
||||
* 执行创建任务监听
|
||||
*
|
||||
* @param flowCode 流程定义编码
|
||||
* @param nodeCode 审批节点编码
|
||||
* @param nodeType 节点类型(0开始节点 1中间节点 2结束节点 3互斥网关 4并行网关)
|
||||
* @param nodeCode 流程节点编码
|
||||
* @param nodeName 流程节点名称
|
||||
* @param taskId 任务id
|
||||
* @param businessId 业务id
|
||||
*/
|
||||
public void processCreateTaskHandler(String flowCode, String nodeCode, Long taskId, String businessId) {
|
||||
public void processCreateTaskHandler(String flowCode, Integer nodeType, String nodeCode, String nodeName, Long taskId, String businessId) {
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
log.info("发布流程任务事件, 租户ID: {}, 流程编码: {}, 节点编码: {}, 任务ID: {}, 业务ID: {}", tenantId, flowCode, nodeCode, taskId, businessId);
|
||||
log.info("发布流程任务事件, 租户ID: {}, 流程编码: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 任务ID: {}, 业务ID: {}",
|
||||
tenantId, flowCode, nodeType, nodeCode, nodeName, taskId, businessId);
|
||||
ProcessCreateTaskEvent processCreateTaskEvent = new ProcessCreateTaskEvent();
|
||||
processCreateTaskEvent.setTenantId(tenantId);
|
||||
processCreateTaskEvent.setFlowCode(flowCode);
|
||||
processCreateTaskEvent.setNodeType(nodeType);
|
||||
processCreateTaskEvent.setNodeCode(nodeCode);
|
||||
processCreateTaskEvent.setNodeName(nodeName);
|
||||
processCreateTaskEvent.setTaskId(taskId);
|
||||
processCreateTaskEvent.setBusinessId(businessId);
|
||||
SpringUtils.context().publishEvent(processCreateTaskEvent);
|
||||
|
@ -52,7 +52,8 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
Task task = listenerVariable.getTask();
|
||||
if (task != null && BusinessStatusEnum.WAITING.getStatus().equals(flowStatus)) {
|
||||
// 判断流程状态(发布审批中事件)
|
||||
flowProcessEventHandler.processCreateTaskHandler(definition.getFlowCode(), task.getNodeCode(), task.getId(), businessId);
|
||||
flowProcessEventHandler.processCreateTaskHandler(definition.getFlowCode(), task.getNodeType(),
|
||||
task.getNodeCode(), task.getNodeName(), task.getId(), businessId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,8 +84,6 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
public void finish(ListenerVariable listenerVariable) {
|
||||
Instance instance = listenerVariable.getInstance();
|
||||
Definition definition = listenerVariable.getDefinition();
|
||||
String businessId = instance.getBusinessId();
|
||||
String flowStatus = instance.getFlowStatus();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
FlowParams flowParams = listenerVariable.getFlowParams();
|
||||
if (ObjectUtil.isNotNull(flowParams)) {
|
||||
@ -96,20 +95,21 @@ 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.getBusinessId(), instance.getNodeType(),
|
||||
instance.getNodeCode(), instance.getNodeName(), 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;
|
||||
|
@ -162,7 +162,8 @@ 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.getBusinessId(), ins.getNodeType(),
|
||||
ins.getNodeCode(), ins.getNodeName(), ins.getFlowStatus(), null, true);
|
||||
}
|
||||
// 设置弹窗处理人
|
||||
Map<String, Object> assigneeMap = setPopAssigneeMap(completeTaskBo.getAssigneeMap(), ins.getVariableMap());
|
||||
|
Loading…
x
Reference in New Issue
Block a user