Commit 41639d5dd7c9b8b272e615435fa7e2707998a478
1 parent
67e548d5
review: 重构组装下一个节点审批人方法
Showing
1 changed file
with
5 additions
and
6 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| @@ -267,7 +267,6 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -267,7 +267,6 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 267 | FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); | 267 | FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); |
| 268 | List<FlowNode> nextFlowNodes = BpmnModelUtils.getNextFlowNodes(flowElement, bpmnModel, processVariables); | 268 | List<FlowNode> nextFlowNodes = BpmnModelUtils.getNextFlowNodes(flowElement, bpmnModel, processVariables); |
| 269 | 269 | ||
| 270 | - // TODO @小北:还是可以优化下哈;“4. 组装节点信息” 只拼接出 candidateUserIds;之后,再第二次循环,查询用户和部门信息,进行拼接 | ||
| 271 | // 2. 收集所有节点的候选用户 ID | 270 | // 2. 收集所有节点的候选用户 ID |
| 272 | Set<Long> allCandidateUsers = new HashSet<>(); | 271 | Set<Long> allCandidateUsers = new HashSet<>(); |
| 273 | for (FlowNode node : nextFlowNodes) { | 272 | for (FlowNode node : nextFlowNodes) { |
| @@ -287,13 +286,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -287,13 +286,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 287 | loginUserId, historicProcessInstance.getProcessDefinitionId(), processVariables); | 286 | loginUserId, historicProcessInstance.getProcessDefinitionId(), processVariables); |
| 288 | 287 | ||
| 289 | // 4.2 组装候选用户信息 | 288 | // 4.2 组装候选用户信息 |
| 290 | - List<UserSimpleBaseVO> candidateUsers = new ArrayList<>(); | ||
| 291 | - for (Long userId : candidateUserIds) { | ||
| 292 | - UserSimpleBaseVO user = BpmProcessInstanceConvert.INSTANCE.buildUser(userId, userMap, deptMap); | 289 | + List<UserSimpleBaseVO> candidateUsers = convertList(candidateUserIds, userId -> { |
| 290 | + AdminUserRespDTO user = userMap.get(userId); | ||
| 293 | if (user != null) { | 291 | if (user != null) { |
| 294 | - candidateUsers.add(user); | 292 | + return BpmProcessInstanceConvert.INSTANCE.buildUser(userId, userMap, deptMap); |
| 295 | } | 293 | } |
| 296 | - } | 294 | + return null; |
| 295 | + }); | ||
| 297 | 296 | ||
| 298 | // 4.3 构建节点信息 | 297 | // 4.3 构建节点信息 |
| 299 | return new ActivityNode() | 298 | return new ActivityNode() |