Commit 9a83515c0547daf922c75459db0f07ce25e4bfb8
1 parent
23ed5b78
fix: 流程发起预测节点审批人是否配置在后端逻辑中实现
Showing
1 changed file
with
14 additions
and
9 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| @@ -30,6 +30,7 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmReasonEnum; | @@ -30,6 +30,7 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmReasonEnum; | ||
| 30 | import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; | 30 | import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; |
| 31 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; | 31 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker; |
| 32 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.dept.BpmTaskCandidateStartUserSelectStrategy; | 32 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.dept.BpmTaskCandidateStartUserSelectStrategy; |
| 33 | +import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; | ||
| 33 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; | 34 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; |
| 34 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants; | 35 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants; |
| 35 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.event.BpmProcessInstanceEventPublisher; | 36 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.event.BpmProcessInstanceEventPublisher; |
| @@ -648,7 +649,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -648,7 +649,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 648 | throw exception(PROCESS_INSTANCE_START_USER_CAN_START); | 649 | throw exception(PROCESS_INSTANCE_START_USER_CAN_START); |
| 649 | } | 650 | } |
| 650 | // 1.3 校验发起人自选审批人 | 651 | // 1.3 校验发起人自选审批人 |
| 651 | - validateStartUserSelectAssignees(definition, startUserSelectAssignees); | 652 | + validateStartUserSelectAssignees(userId, definition, startUserSelectAssignees, variables); |
| 652 | 653 | ||
| 653 | // 2. 创建流程实例 | 654 | // 2. 创建流程实例 |
| 654 | if (variables == null) { | 655 | if (variables == null) { |
| @@ -693,17 +694,21 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -693,17 +694,21 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 693 | return instance.getId(); | 694 | return instance.getId(); |
| 694 | } | 695 | } |
| 695 | 696 | ||
| 696 | - private void validateStartUserSelectAssignees(ProcessDefinition definition, | ||
| 697 | - Map<String, List<Long>> startUserSelectAssignees) { | ||
| 698 | - // 1. 获得发起人自选审批人的 UserTask/ServiceTask 列表 | ||
| 699 | - BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(definition.getId()); | ||
| 700 | - List<Task> tasks = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectTaskList(bpmnModel); | ||
| 701 | - if (CollUtil.isEmpty(tasks)) { | 697 | + private void validateStartUserSelectAssignees(Long userId, ProcessDefinition definition, |
| 698 | + Map<String, List<Long>> startUserSelectAssignees, Map<String,Object> variables) { | ||
| 699 | + // 1.获取预测的节点信息 | ||
| 700 | + BpmApprovalDetailReqVO detailReqVO = new BpmApprovalDetailReqVO(); | ||
| 701 | + detailReqVO.setProcessVariables(variables); | ||
| 702 | + detailReqVO.setProcessDefinitionId(definition.getId()); | ||
| 703 | + BpmApprovalDetailRespVO respVO = getApprovalDetail(userId, detailReqVO); | ||
| 704 | + List<ActivityNode> activityNodes = respVO.getActivityNodes(); | ||
| 705 | + if (CollUtil.isEmpty(activityNodes)){ | ||
| 702 | return; | 706 | return; |
| 703 | } | 707 | } |
| 704 | - | 708 | + //移除掉不是发起人自选审批人节点 |
| 709 | + activityNodes.removeIf(task -> null == task.getCandidateStrategy() || !task.getCandidateStrategy().equals(BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy())); | ||
| 705 | // 2. 流程发起时要先获取当前流程的预测走向节点,发起时只校验预测的节点发起人自选审批人的审批人和抄送人是否都配置了 | 710 | // 2. 流程发起时要先获取当前流程的预测走向节点,发起时只校验预测的节点发起人自选审批人的审批人和抄送人是否都配置了 |
| 706 | - tasks.forEach(task -> { | 711 | + activityNodes.forEach(task -> { |
| 707 | List<Long> assignees = startUserSelectAssignees != null ? startUserSelectAssignees.get(task.getId()) : null; | 712 | List<Long> assignees = startUserSelectAssignees != null ? startUserSelectAssignees.get(task.getId()) : null; |
| 708 | if (CollUtil.isEmpty(assignees)) { | 713 | if (CollUtil.isEmpty(assignees)) { |
| 709 | throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, task.getName()); | 714 | throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, task.getName()); |