Commit 989c4e4b88bc32e0eddab2d5c4fc969f51133b51

Authored by YunaiV
1 parent b766f8d8

fix:【BPM 工作流】bpmn subProcess 存在 userTask NPE 的问题

yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/BpmTaskCandidateInvoker.java
@@ -18,10 +18,7 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi; @@ -18,10 +18,7 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
18 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; 18 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
19 import com.google.common.annotations.VisibleForTesting; 19 import com.google.common.annotations.VisibleForTesting;
20 import lombok.extern.slf4j.Slf4j; 20 import lombok.extern.slf4j.Slf4j;
21 -import org.flowable.bpmn.model.BpmnModel;  
22 -import org.flowable.bpmn.model.CallActivity;  
23 -import org.flowable.bpmn.model.FlowElement;  
24 -import org.flowable.bpmn.model.UserTask; 21 +import org.flowable.bpmn.model.*;
25 import org.flowable.engine.delegate.DelegateExecution; 22 import org.flowable.engine.delegate.DelegateExecution;
26 import org.flowable.engine.runtime.ProcessInstance; 23 import org.flowable.engine.runtime.ProcessInstance;
27 24
@@ -132,7 +129,7 @@ public class BpmTaskCandidateInvoker { @@ -132,7 +129,7 @@ public class BpmTaskCandidateInvoker {
132 Long startUserId, String processDefinitionId, Map<String, Object> processVariables) { 129 Long startUserId, String processDefinitionId, Map<String, Object> processVariables) {
133 // 如果是 CallActivity 子流程,不进行计算候选人 130 // 如果是 CallActivity 子流程,不进行计算候选人
134 FlowElement flowElement = BpmnModelUtils.getFlowElementById(bpmnModel, activityId); 131 FlowElement flowElement = BpmnModelUtils.getFlowElementById(bpmnModel, activityId);
135 - if (flowElement instanceof CallActivity) { 132 + if (flowElement instanceof CallActivity || flowElement instanceof SubProcess) {
136 return new HashSet<>(); 133 return new HashSet<>();
137 } 134 }
138 // 审批类型非人工审核时,不进行计算候选人。原因是:后续会自动通过、不通过 135 // 审批类型非人工审核时,不进行计算候选人。原因是:后续会自动通过、不通过
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java
@@ -478,7 +478,11 @@ public class BpmnModelUtils { @@ -478,7 +478,11 @@ public class BpmnModelUtils {
478 */ 478 */
479 public static FlowElement getFlowElementById(BpmnModel model, String flowElementId) { 479 public static FlowElement getFlowElementById(BpmnModel model, String flowElementId) {
480 Process process = model.getMainProcess(); 480 Process process = model.getMainProcess();
481 - return process.getFlowElement(flowElementId); 481 + FlowElement flowElement = process.getFlowElement(flowElementId);
  482 + if (flowElement != null) {
  483 + return flowElement;
  484 + }
  485 + return model.getFlowElement(flowElementId);
482 } 486 }
483 487
484 /** 488 /**
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
@@ -1379,7 +1379,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -1379,7 +1379,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
1379 PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class)); 1379 PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class));
1380 if (userTaskElement.getId().equals(START_USER_NODE_ID) 1380 if (userTaskElement.getId().equals(START_USER_NODE_ID)
1381 && (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核 1381 && (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核
1382 - || Boolean.TRUE.equals(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核 1382 + || BooleanUtil.isTrue(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核
1383 && ObjUtil.notEqual(returnTaskFlag, Boolean.TRUE)) { 1383 && ObjUtil.notEqual(returnTaskFlag, Boolean.TRUE)) {
1384 getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO().setId(task.getId()) 1384 getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO().setId(task.getId())
1385 .setReason(BpmReasonEnum.ASSIGN_START_USER_APPROVE_WHEN_SKIP_START_USER_NODE.getReason())); 1385 .setReason(BpmReasonEnum.ASSIGN_START_USER_APPROVE_WHEN_SKIP_START_USER_NODE.getReason()));