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

This commit is contained in:
YunaiV
2025-07-22 21:57:01 +08:00
parent b766f8d820
commit 989c4e4b88
3 changed files with 8 additions and 7 deletions

View File

@ -18,10 +18,7 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.CallActivity;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.UserTask;
import org.flowable.bpmn.model.*;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.runtime.ProcessInstance;
@ -132,7 +129,7 @@ public class BpmTaskCandidateInvoker {
Long startUserId, String processDefinitionId, Map<String, Object> processVariables) {
// 如果是 CallActivity 子流程,不进行计算候选人
FlowElement flowElement = BpmnModelUtils.getFlowElementById(bpmnModel, activityId);
if (flowElement instanceof CallActivity) {
if (flowElement instanceof CallActivity || flowElement instanceof SubProcess) {
return new HashSet<>();
}
// 审批类型非人工审核时,不进行计算候选人。原因是:后续会自动通过、不通过

View File

@ -478,7 +478,11 @@ public class BpmnModelUtils {
*/
public static FlowElement getFlowElementById(BpmnModel model, String flowElementId) {
Process process = model.getMainProcess();
return process.getFlowElement(flowElementId);
FlowElement flowElement = process.getFlowElement(flowElementId);
if (flowElement != null) {
return flowElement;
}
return model.getFlowElement(flowElementId);
}
/**

View File

@ -1379,7 +1379,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE, String.class));
if (userTaskElement.getId().equals(START_USER_NODE_ID)
&& (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核
|| Boolean.TRUE.equals(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核
|| BooleanUtil.isTrue(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核
&& ObjUtil.notEqual(returnTaskFlag, Boolean.TRUE)) {
getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO().setId(task.getId())
.setReason(BpmReasonEnum.ASSIGN_START_USER_APPROVE_WHEN_SKIP_START_USER_NODE.getReason()));