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
| @@ -41,4 +41,9 @@ public class BpmProcessInstanceCreateReqDTO { | @@ -41,4 +41,9 @@ public class BpmProcessInstanceCreateReqDTO { | ||
| 41 | */ | 41 | */ |
| 42 | private Map<String, List<Long>> startUserSelectAssignees; | 42 | private Map<String, List<Long>> startUserSelectAssignees; |
| 43 | 43 | ||
| 44 | + /** | ||
| 45 | + * 活动节点列表 createProcessInstance弃用时可移除 | ||
| 46 | + */ | ||
| 47 | + private List<String> nodeIds; | ||
| 48 | + | ||
| 44 | } | 49 | } |
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,7 +608,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 608 | .getProcessDefinition(createReqVO.getProcessDefinitionId()); | 608 | .getProcessDefinition(createReqVO.getProcessDefinitionId()); |
| 609 | // 发起流程 | 609 | // 发起流程 |
| 610 | return createProcessInstance0(userId, definition, createReqVO.getVariables(), null, | 610 | return createProcessInstance0(userId, definition, createReqVO.getVariables(), null, |
| 611 | - createReqVO.getStartUserSelectAssignees()); | 611 | + createReqVO.getStartUserSelectAssignees(), createReqVO.getNodeIds()); |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | @Override | 614 | @Override |
| @@ -620,13 +620,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -620,13 +620,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 620 | // 发起流程 | 620 | // 发起流程 |
| 621 | return createProcessInstance0(userId, definition, createReqDTO.getVariables(), | 621 | return createProcessInstance0(userId, definition, createReqDTO.getVariables(), |
| 622 | createReqDTO.getBusinessKey(), | 622 | createReqDTO.getBusinessKey(), |
| 623 | - createReqDTO.getStartUserSelectAssignees()); | 623 | + createReqDTO.getStartUserSelectAssignees(),createReqDTO.getNodeIds()); |
| 624 | }); | 624 | }); |
| 625 | } | 625 | } |
| 626 | 626 | ||
| 627 | private String createProcessInstance0(Long userId, ProcessDefinition definition, | 627 | private String createProcessInstance0(Long userId, ProcessDefinition definition, |
| 628 | Map<String, Object> variables, String businessKey, | 628 | Map<String, Object> variables, String businessKey, |
| 629 | - Map<String, List<Long>> startUserSelectAssignees) { | 629 | + Map<String, List<Long>> startUserSelectAssignees, List<String> nodeIds) { |
| 630 | // 1.1 校验流程定义 | 630 | // 1.1 校验流程定义 |
| 631 | if (definition == null) { | 631 | if (definition == null) { |
| 632 | throw exception(PROCESS_DEFINITION_NOT_EXISTS); | 632 | throw exception(PROCESS_DEFINITION_NOT_EXISTS); |
| @@ -644,7 +644,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -644,7 +644,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 644 | throw exception(PROCESS_INSTANCE_START_USER_CAN_START); | 644 | throw exception(PROCESS_INSTANCE_START_USER_CAN_START); |
| 645 | } | 645 | } |
| 646 | // 1.3 校验发起人自选审批人 | 646 | // 1.3 校验发起人自选审批人 |
| 647 | - validateStartUserSelectAssignees(definition, startUserSelectAssignees); | 647 | + validateStartUserSelectAssignees(definition, startUserSelectAssignees, nodeIds); |
| 648 | 648 | ||
| 649 | // 2. 创建流程实例 | 649 | // 2. 创建流程实例 |
| 650 | if (variables == null) { | 650 | if (variables == null) { |
| @@ -690,16 +690,17 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -690,16 +690,17 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 690 | } | 690 | } |
| 691 | 691 | ||
| 692 | private void validateStartUserSelectAssignees(ProcessDefinition definition, | 692 | private void validateStartUserSelectAssignees(ProcessDefinition definition, |
| 693 | - Map<String, List<Long>> startUserSelectAssignees) { | 693 | + Map<String, List<Long>> startUserSelectAssignees, List<String> nodeIds) { |
| 694 | // 1. 获得发起人自选审批人的 UserTask/ServiceTask 列表 | 694 | // 1. 获得发起人自选审批人的 UserTask/ServiceTask 列表 |
| 695 | BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(definition.getId()); | 695 | BpmnModel bpmnModel = processDefinitionService.getProcessDefinitionBpmnModel(definition.getId()); |
| 696 | List<Task> tasks = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectTaskList(bpmnModel); | 696 | List<Task> tasks = BpmTaskCandidateStartUserSelectStrategy.getStartUserSelectTaskList(bpmnModel); |
| 697 | if (CollUtil.isEmpty(tasks)) { | 697 | if (CollUtil.isEmpty(tasks)) { |
| 698 | return; | 698 | return; |
| 699 | } | 699 | } |
| 700 | + // 2.流程发起时要先获取当前流程的预测走向节点,发起是 | ||
| 700 | 701 | ||
| 701 | // 2. 校验发起人自选审批人的审批人和抄送人是否都配置了 | 702 | // 2. 校验发起人自选审批人的审批人和抄送人是否都配置了 |
| 702 | - tasks.forEach(task -> { | 703 | + tasks.stream().filter(task -> nodeIds == null || nodeIds.contains(task.getId())).forEach(task -> { |
| 703 | List<Long> assignees = startUserSelectAssignees != null ? startUserSelectAssignees.get(task.getId()) : null; | 704 | List<Long> assignees = startUserSelectAssignees != null ? startUserSelectAssignees.get(task.getId()) : null; |
| 704 | if (CollUtil.isEmpty(assignees)) { | 705 | if (CollUtil.isEmpty(assignees)) { |
| 705 | throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, task.getName()); | 706 | throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, task.getName()); |