fix: 修复流程分支节点预测问题

This commit is contained in:
lizhixian 2025-02-17 10:28:11 +08:00
parent 3d20ce1a9b
commit 1023afda40
1 changed files with 26 additions and 20 deletions

View File

@ -32,7 +32,7 @@ import static org.flowable.bpmn.constants.BpmnXMLConstants.FLOWABLE_EXTENSIONS_P
/** /**
* BPMN Model 操作工具类目前分成三部分 * BPMN Model 操作工具类目前分成三部分
* * <p>
* 1. BPMN 修改 + 解析元素相关的方法 * 1. BPMN 修改 + 解析元素相关的方法
* 2. BPMN 简单查找相关的方法 * 2. BPMN 简单查找相关的方法
* 3. BPMN 复杂遍历相关的方法 * 3. BPMN 复杂遍历相关的方法
@ -150,9 +150,9 @@ public class BpmnModelUtils {
/** /**
* 解析审批类型 * 解析审批类型
* *
* @see BpmUserTaskApproveTypeEnum
* @param userTask 任务节点 * @param userTask 任务节点
* @return 审批类型 * @return 审批类型
* @see BpmUserTaskApproveTypeEnum
*/ */
public static Integer parseApproveType(FlowElement userTask) { public static Integer parseApproveType(FlowElement userTask) {
return NumberUtils.parseInt(parseExtensionElement(userTask, BpmnModelConstants.USER_TASK_APPROVE_TYPE)); return NumberUtils.parseInt(parseExtensionElement(userTask, BpmnModelConstants.USER_TASK_APPROVE_TYPE));
@ -196,9 +196,9 @@ public class BpmnModelUtils {
/** /**
* 给节点添加用户任务的审批人与发起人相同时处理类型枚举 * 给节点添加用户任务的审批人与发起人相同时处理类型枚举
* *
* @see BpmUserTaskAssignStartUserHandlerTypeEnum
* @param assignStartUserHandlerType 发起人处理类型 * @param assignStartUserHandlerType 发起人处理类型
* @param userTask 任务节点 * @param userTask 任务节点
* @see BpmUserTaskAssignStartUserHandlerTypeEnum
*/ */
public static void addAssignStartUserHandlerType(Integer assignStartUserHandlerType, UserTask userTask) { public static void addAssignStartUserHandlerType(Integer assignStartUserHandlerType, UserTask userTask) {
if (assignStartUserHandlerType == null) { if (assignStartUserHandlerType == null) {
@ -210,9 +210,9 @@ public class BpmnModelUtils {
/** /**
* 给节点添加用户任务的审批人为空时处理类型枚举 * 给节点添加用户任务的审批人为空时处理类型枚举
* *
* @see BpmUserTaskAssignEmptyHandlerTypeEnum
* @param emptyHandler 空处理 * @param emptyHandler 空处理
* @param userTask 任务节点 * @param userTask 任务节点
* @see BpmUserTaskAssignEmptyHandlerTypeEnum
*/ */
public static void addAssignEmptyHandlerType(BpmSimpleModelNodeVO.AssignEmptyHandler emptyHandler, UserTask userTask) { public static void addAssignEmptyHandlerType(BpmSimpleModelNodeVO.AssignEmptyHandler emptyHandler, UserTask userTask) {
if (emptyHandler == null) { if (emptyHandler == null) {
@ -778,10 +778,16 @@ public class BpmnModelUtils {
if (currentElement instanceof ExclusiveGateway) { if (currentElement instanceof ExclusiveGateway) {
// 查找满足条件的 SequenceFlow 路径 // 查找满足条件的 SequenceFlow 路径
Gateway gateway = (Gateway) currentElement; Gateway gateway = (Gateway) currentElement;
SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(), SequenceFlow matchSequenceFlow;
//流程首次发起时variables值一定为空会导致条件表达式解析错误导致预测节点缺失
if (null == variables) {
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()));
} else {
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()) flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
//流程第一次发起时variables条件值一定为空发生异常会导致后续分支节点无法预测 && (evalConditionExpress(variables, flow.getConditionExpression())));
|| (null != variables && evalConditionExpress(variables, flow.getConditionExpression()))); }
if (matchSequenceFlow == null) { if (matchSequenceFlow == null) {
matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(), matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId())); flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));