Browse Source

feat:审批通过时,查询下一个执行节点,校验流程执行正确与否

smallNorthLee 5 months ago
parent
commit
d41cce94cd

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

@@ -856,6 +856,10 @@ public class BpmnModelUtils {
             if (targetElement == null) {
             if (targetElement == null) {
                 continue;
                 continue;
             }
             }
+            // 如果是结束节点,直接返回
+            if (targetElement instanceof EndEvent) {
+                break;
+            }
             // 情况一:处理不同类型的网关
             // 情况一:处理不同类型的网关
             if (targetElement instanceof Gateway) {
             if (targetElement instanceof Gateway) {
                 Gateway gateway = (Gateway) targetElement;
                 Gateway gateway = (Gateway) targetElement;

+ 4 - 1
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java

@@ -595,8 +595,11 @@ public class BpmTaskServiceImpl implements BpmTaskService {
         if (CollUtil.isNotEmpty(allNextAssignees)) {
         if (CollUtil.isNotEmpty(allNextAssignees)) {
             // 获取实例中的全部节点数据,避免后续节点的审批人被覆盖
             // 获取实例中的全部节点数据,避免后续节点的审批人被覆盖
             hisProcessVariables.putAll(allNextAssignees);
             hisProcessVariables.putAll(allNextAssignees);
+            // 设置流程变量,审批人自选
             newVariables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES, hisProcessVariables);
             newVariables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES, hisProcessVariables);
-            runtimeService.setVariables(processInstance.getProcessInstanceId(), variables);
+            // 设置流程变量,发起人自选,后续的节点或者回退后再或者驳回重新发起的场景可能存在发起人自选或者审批人自选,所以中两个变量值要保持一致,否则会查询不到审批人
+            newVariables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES, hisProcessVariables);
+            runtimeService.setVariables(processInstance.getProcessInstanceId(), newVariables);
         }
         }
         return newVariables;
         return newVariables;
     }
     }