Browse Source

review: 代码审查

smallNorthLee 6 tháng trước cách đây
mục cha
commit
248127a941

+ 5 - 16
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java

@@ -778,16 +778,9 @@ public class BpmnModelUtils {
         if (currentElement instanceof ExclusiveGateway) {
             // 查找满足条件的 SequenceFlow 路径
             Gateway gateway = (Gateway) currentElement;
-            SequenceFlow matchSequenceFlow;
-            // 流程首次发起时,variables值一定为空,会导致条件表达式解析错误导致预测节点缺失
-            if (null == variables) {
-                matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
-                        flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()));
-            } else {
-                matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
+            SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
                         flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
                                 && (evalConditionExpress(variables, flow.getConditionExpression())));
-            }
             if (matchSequenceFlow == null) {
                 matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
                         flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));
@@ -807,16 +800,9 @@ public class BpmnModelUtils {
         if (currentElement instanceof InclusiveGateway) {
             // 查找满足条件的 SequenceFlow 路径
             Gateway gateway = (Gateway) currentElement;
-            Collection<SequenceFlow> matchSequenceFlows;
-            // 流程首次发起时,variables值一定为空,会导致条件表达式解析错误导致预测节点缺失
-            if (null == variables){
-                matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
-                        flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()));
-            }else {
-                matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
+            Collection<SequenceFlow> matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
                         flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
                                 && evalConditionExpress(variables, flow.getConditionExpression()));
-            }
             if (CollUtil.isEmpty(matchSequenceFlows)) {
                 matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
                         flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));
@@ -851,6 +837,9 @@ public class BpmnModelUtils {
         if (express == null) {
             return Boolean.FALSE;
         }
+        if (variables == null) {
+            return Boolean.FALSE;
+        }
         try {
             Object result = FlowableUtils.getExpressionValue(variables, express);
             return Boolean.TRUE.equals(result);

+ 2 - 16
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java

@@ -808,16 +808,9 @@ public class SimpleModelUtils {
         // 情况:CONDITION_BRANCH_NODE 排它,只有一个满足条件的。如果没有,就走默认的
         if (nodeType == BpmSimpleModelNodeTypeEnum.CONDITION_BRANCH_NODE) {
             // 查找满足条件的 BpmSimpleModelNodeVO 节点
-            BpmSimpleModelNodeVO matchConditionNode;
-            // 流程首次发起时,variables值一定为空,会导致条件表达式解析错误导致预测节点缺失
-            if(null == variables) {
-                matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
-                        conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
-            }else {
-                matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
+            BpmSimpleModelNodeVO matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
                         conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
                                 && evalConditionExpress(variables, conditionNode.getConditionSetting()));
-            }
             if (matchConditionNode == null) {
                 matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
                         conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
@@ -830,16 +823,9 @@ public class SimpleModelUtils {
         // 情况:INCLUSIVE_BRANCH_NODE 包容,多个满足条件的。如果没有,就走默认的
         if (nodeType == BpmSimpleModelNodeTypeEnum.INCLUSIVE_BRANCH_NODE) {
             // 查找满足条件的 BpmSimpleModelNodeVO 节点
-            Collection<BpmSimpleModelNodeVO> matchConditionNodes;
-            // 流程首次发起时,variables值一定为空,会导致条件表达式解析错误导致预测节点缺失
-            if (null == variables) {
-                matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
-                        conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
-            }else {
-                matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
+            Collection<BpmSimpleModelNodeVO> matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
                         conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
                                 && evalConditionExpress(variables, conditionNode.getConditionSetting()));
-            }
             if (CollUtil.isEmpty(matchConditionNodes)) {
                 matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
                         conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));