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 | 267 | FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey()); |
| 268 | 268 | List<FlowNode> nextFlowNodes = BpmnModelUtils.getNextFlowNodes(flowElement, bpmnModel, processVariables); |
| 269 | 269 | |
| 270 | - // TODO @小北:还是可以优化下哈;“4. 组装节点信息” 只拼接出 candidateUserIds;之后,再第二次循环,查询用户和部门信息,进行拼接 | |
| 271 | 270 | // 2. 收集所有节点的候选用户 ID |
| 272 | 271 | Set<Long> allCandidateUsers = new HashSet<>(); |
| 273 | 272 | for (FlowNode node : nextFlowNodes) { |
| ... | ... | @@ -287,13 +286,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 287 | 286 | loginUserId, historicProcessInstance.getProcessDefinitionId(), processVariables); |
| 288 | 287 | |
| 289 | 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 | 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 | 297 | // 4.3 构建节点信息 |
| 299 | 298 | return new ActivityNode() | ... | ... |