Commit 5e277e020f946e7c7886d70196797356f023e052
1 parent
296e6ab3
fix: 解决流程预测审批节点错误问题
Showing
2 changed files
with
12 additions
and
6 deletions
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/task/dto/BpmProcessInstanceCreateReqDTO.java
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| ... | ... | @@ -608,7 +608,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 608 | 608 | .getProcessDefinition(createReqVO.getProcessDefinitionId()); |
| 609 | 609 | // 发起流程 |
| 610 | 610 | return createProcessInstance0(userId, definition, createReqVO.getVariables(), null, |
| 611 | - createReqVO.getStartUserSelectAssignees()); | |
| 611 | + createReqVO.getStartUserSelectAssignees(), createReqVO.getNodeIds()); | |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | @Override |
| ... | ... | @@ -620,13 +620,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 620 | 620 | // 发起流程 |
| 621 | 621 | return createProcessInstance0(userId, definition, createReqDTO.getVariables(), |
| 622 | 622 | createReqDTO.getBusinessKey(), |
| 623 | - createReqDTO.getStartUserSelectAssignees()); | |
| 623 | + createReqDTO.getStartUserSelectAssignees(),createReqDTO.getNodeIds()); | |
| 624 | 624 | }); |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | private String createProcessInstance0(Long userId, ProcessDefinition definition, |
| 628 | 628 | Map<String, Object> variables, String businessKey, |
| 629 | - Map<String, List<Long>> startUserSelectAssignees) { | |
| 629 | + Map<String, List<Long>> startUserSelectAssignees, List<String> nodeIds) { | |
| 630 | 630 | // 1.1 校验流程定义 |
| 631 | 631 | if (definition == null) { |
| 632 | 632 | throw exception(PROCESS_DEFINITION_NOT_EXISTS); |
| ... | ... | @@ -644,7 +644,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 644 | 644 | throw exception(PROCESS_INSTANCE_START_USER_CAN_START); |
| 645 | 645 | } |
| 646 | 646 | // 1.3 校验发起人自选审批人 |
| 647 | - validateStartUserSelectAssignees(definition, startUserSelectAssignees); | |
| 647 | + validateStartUserSelectAssignees(definition, startUserSelectAssignees, nodeIds); | |
| 648 | 648 | |
| 649 | 649 | // 2. 创建流程实例 |
| 650 | 650 | if (variables == null) { |
| ... | ... | @@ -690,16 +690,17 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | private void validateStartUserSelectAssignees(ProcessDefinition definition, |
| 693 | - Map<String, List<Long>> startUserSelectAssignees) { | |
| 693 | + Map<String, List<Long>> startUserSelectAssignees, List<String> nodeIds) { | |
| 694 | 694 | // 1. 获得发起人自选审批人的 UserTask/ServiceTask 列表 |
| 695 | 695 | BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(definition.getId()); |
| 696 | 696 | List<Task> tasks = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectTaskList(bpmnModel); |
| 697 | 697 | if (CollUtil.isEmpty(tasks)) { |
| 698 | 698 | return; |
| 699 | 699 | } |
| 700 | + // 2.流程发起时要先获取当前流程的预测走向节点,发起是 | |
| 700 | 701 | |
| 701 | 702 | // 2. 校验发起人自选审批人的审批人和抄送人是否都配置了 |
| 702 | - tasks.forEach(task -> { | |
| 703 | + tasks.stream().filter(task -> nodeIds == null || nodeIds.contains(task.getId())).forEach(task -> { | |
| 703 | 704 | List<Long> assignees = startUserSelectAssignees != null ? startUserSelectAssignees.get(task.getId()) : null; |
| 704 | 705 | if (CollUtil.isEmpty(assignees)) { |
| 705 | 706 | throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, task.getName()); | ... | ... |