Commit 29a902f37ee7eede247527555c2d33b37a571763

Authored by lizhixian
1 parent 4b89f689

review: 代码审查

yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java
... ... @@ -778,9 +778,16 @@ public class BpmnModelUtils {
778 778 if (currentElement instanceof ExclusiveGateway) {
779 779 // 查找满足条件的 SequenceFlow 路径
780 780 Gateway gateway = (Gateway) currentElement;
781   - SequenceFlow matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
782   - flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
783   - && (evalConditionExpress(variables, flow.getConditionExpression())));
  781 + SequenceFlow matchSequenceFlow;
  782 + // 流程首次发起时,variables值一定为空,会导致条件表达式解析错误导致预测节点缺失
  783 + if (null == variables) {
  784 + matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
  785 + flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()));
  786 + } else {
  787 + matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
  788 + flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
  789 + && (evalConditionExpress(variables, flow.getConditionExpression())));
  790 + }
784 791 if (matchSequenceFlow == null) {
785 792 matchSequenceFlow = CollUtil.findOne(gateway.getOutgoingFlows(),
786 793 flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));
... ... @@ -800,9 +807,15 @@ public class BpmnModelUtils {
800 807 if (currentElement instanceof InclusiveGateway) {
801 808 // 查找满足条件的 SequenceFlow 路径
802 809 Gateway gateway = (Gateway) currentElement;
803   - Collection<SequenceFlow> matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
804   - flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
805   - && evalConditionExpress(variables, flow.getConditionExpression()));
  810 + Collection<SequenceFlow> matchSequenceFlows;
  811 + if (null == variables){
  812 + matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
  813 + flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId()));
  814 + }else {
  815 + matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
  816 + flow -> ObjUtil.notEqual(gateway.getDefaultFlow(), flow.getId())
  817 + && evalConditionExpress(variables, flow.getConditionExpression()));
  818 + }
806 819 if (CollUtil.isEmpty(matchSequenceFlows)) {
807 820 matchSequenceFlows = CollUtil.filterNew(gateway.getOutgoingFlows(),
808 821 flow -> ObjUtil.equal(gateway.getDefaultFlow(), flow.getId()));
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
... ... @@ -808,9 +808,15 @@ public class SimpleModelUtils {
808 808 // 情况:CONDITION_BRANCH_NODE 排它,只有一个满足条件的。如果没有,就走默认的
809 809 if (nodeType == BpmSimpleModelNodeTypeEnum.CONDITION_BRANCH_NODE) {
810 810 // 查找满足条件的 BpmSimpleModelNodeVO 节点
811   - BpmSimpleModelNodeVO matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
812   - conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
813   - && evalConditionExpress(variables, conditionNode.getConditionSetting()));
  811 + BpmSimpleModelNodeVO matchConditionNode;
  812 + if(null == variables) {
  813 + matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
  814 + conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
  815 + }else {
  816 + matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
  817 + conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
  818 + && evalConditionExpress(variables, conditionNode.getConditionSetting()));
  819 + }
814 820 if (matchConditionNode == null) {
815 821 matchConditionNode = CollUtil.findOne(currentNode.getConditionNodes(),
816 822 conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
... ... @@ -823,9 +829,15 @@ public class SimpleModelUtils {
823 829 // 情况:INCLUSIVE_BRANCH_NODE 包容,多个满足条件的。如果没有,就走默认的
824 830 if (nodeType == BpmSimpleModelNodeTypeEnum.INCLUSIVE_BRANCH_NODE) {
825 831 // 查找满足条件的 BpmSimpleModelNodeVO 节点
826   - Collection<BpmSimpleModelNodeVO> matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
827   - conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
828   - && evalConditionExpress(variables, conditionNode.getConditionSetting()));
  832 + Collection<BpmSimpleModelNodeVO> matchConditionNodes;
  833 + if (null == variables) {
  834 + matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
  835 + conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
  836 + }else {
  837 + matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
  838 + conditionNode -> !BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow())
  839 + && evalConditionExpress(variables, conditionNode.getConditionSetting()));
  840 + }
829 841 if (CollUtil.isEmpty(matchConditionNodes)) {
830 842 matchConditionNodes = CollUtil.filterNew(currentNode.getConditionNodes(),
831 843 conditionNode -> BooleanUtil.isTrue(conditionNode.getConditionSetting().getDefaultFlow()));
... ...
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
... ... @@ -208,11 +208,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
208 208 // TODO @jason:有一个极端情况,如果一个用户有 2 个 task A 和 B,A 已经通过,B 需要审核。这个时,通过 A 进来,todo 拿到
209 209 // B,会不会表单权限不一致哈。
210 210 BpmTaskRespVO todoTask = taskService.getFirstTodoTask(loginUserId, reqVO.getProcessInstanceId());
211   - // 3.2 流程首次发起时,variables值一定为空,会导致条件表达式解析错误导致预测节点缺失
212   - if (null == processVariables) {
213   - processVariables = new HashMap<>();
214   - }
215   - // 3.3 预测未运行节点的审批信息
  211 + // 3.2 预测未运行节点的审批信息
216 212 List<ActivityNode> simulateActivityNodes = getSimulateApproveNodeList(startUserId, bpmnModel,
217 213 processDefinitionInfo,
218 214 processVariables, activities);
... ...