Commit 629bf284959cafbdb8f8e454759faa250b6219bb

Authored by lizhixian
1 parent f70a5047

fix:修复审批接口,校验任务规则为发起人自选时,先从历史变量中查询审批人。

yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
@@ -613,16 +613,17 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -613,16 +613,17 @@ public class BpmTaskServiceImpl implements BpmTaskService {
613 Integer candidateStrategy = parseCandidateStrategy(nextFlowNode); 613 Integer candidateStrategy = parseCandidateStrategy(nextFlowNode);
614 // 2.1 情况一:如果节点中的审批人策略为 发起人自选 614 // 2.1 情况一:如果节点中的审批人策略为 发起人自选
615 if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy())) { 615 if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy())) {
616 - // 如果节点存在,但未配置审批人  
617 - List<Long> assignees = nextAssignees != null ? nextAssignees.get(nextFlowNode.getId()) : null;  
618 - if (CollUtil.isEmpty(assignees)) {  
619 - throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName());  
620 - } 616 + // 先从历史中获取审批人,在发起人会把所有的审批人保存到历史中,这里从历史中获取
621 processVariables = FlowableUtils.getStartUserSelectAssignees(processInstance.getProcessVariables()); 617 processVariables = FlowableUtils.getStartUserSelectAssignees(processInstance.getProcessVariables());
622 // 特殊:如果当前节点已经存在审批人,则不允许覆盖 618 // 特殊:如果当前节点已经存在审批人,则不允许覆盖
623 if (processVariables != null && CollUtil.isNotEmpty(processVariables.get(nextFlowNode.getId()))) { 619 if (processVariables != null && CollUtil.isNotEmpty(processVariables.get(nextFlowNode.getId()))) {
624 continue; 620 continue;
625 } 621 }
  622 + // 如果节点存在,但未配置审批人
  623 + List<Long> assignees = nextAssignees != null ? nextAssignees.get(nextFlowNode.getId()) : null;
  624 + if (CollUtil.isEmpty(assignees)) {
  625 + throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName());
  626 + }
626 // 设置 PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES 627 // 设置 PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES
627 if (processVariables == null) { 628 if (processVariables == null) {
628 processVariables = new HashMap<>(); 629 processVariables = new HashMap<>();
@@ -632,12 +633,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -632,12 +633,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
632 } 633 }
633 // 2.2 情况二:如果节点中的审批人策略为 审批人,在审批时选择下一个节点的审批人,并且该节点的审批人为空 634 // 2.2 情况二:如果节点中的审批人策略为 审批人,在审批时选择下一个节点的审批人,并且该节点的审批人为空
634 if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.APPROVE_USER_SELECT.getStrategy())) { 635 if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.APPROVE_USER_SELECT.getStrategy())) {
  636 + // 获取审批人自选的历史变量
  637 + processVariables = FlowableUtils.getApproveUserSelectAssignees(processInstance.getProcessVariables());
635 // 如果节点存在,但未配置审批人 638 // 如果节点存在,但未配置审批人
636 List<Long> assignees = nextAssignees != null ? nextAssignees.get(nextFlowNode.getId()) : null; 639 List<Long> assignees = nextAssignees != null ? nextAssignees.get(nextFlowNode.getId()) : null;
637 if (CollUtil.isEmpty(assignees)) { 640 if (CollUtil.isEmpty(assignees)) {
638 throw exception(PROCESS_INSTANCE_APPROVE_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName()); 641 throw exception(PROCESS_INSTANCE_APPROVE_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName());
639 } 642 }
640 - processVariables = FlowableUtils.getApproveUserSelectAssignees(processInstance.getProcessVariables());  
641 if (processVariables == null) { 643 if (processVariables == null) {
642 processVariables = new HashMap<>(); 644 processVariables = new HashMap<>();
643 } 645 }