Commit 672a5ef538c2374a142e919ebd40ed3fcb4a2eaf

Authored by lizhixian
1 parent 1e2b5625

review: 代码审查

yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
@@ -564,6 +564,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -564,6 +564,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
564 FlowElement flowElement = bpmnModel.getFlowElement(taskDefinitionKey); 564 FlowElement flowElement = bpmnModel.getFlowElement(taskDefinitionKey);
565 // 2. 获取下一个将要执行的节点集合 565 // 2. 获取下一个将要执行的节点集合
566 List<FlowNode> nextFlowNodes = getNextFlowNodes(flowElement, bpmnModel, variables); 566 List<FlowNode> nextFlowNodes = getNextFlowNodes(flowElement, bpmnModel, variables);
  567 + Map<String, List<Long>> processVariables = new HashMap<>();
567 // 3. 循环下一个将要执行的节点集合 568 // 3. 循环下一个将要执行的节点集合
568 for (FlowNode nextFlowNode : nextFlowNodes) { 569 for (FlowNode nextFlowNode : nextFlowNodes) {
569 // 3.1 获取下一个将要执行节点中的审批人策略 570 // 3.1 获取下一个将要执行节点中的审批人策略
@@ -574,35 +575,35 @@ public class BpmTaskServiceImpl implements BpmTaskService { @@ -574,35 +575,35 @@ public class BpmTaskServiceImpl implements BpmTaskService {
574 } 575 }
575 // 3.3 获取节点中的审批人 576 // 3.3 获取节点中的审批人
576 List<Long> assignees = nextAssignees.get(nextFlowNode.getId()); 577 List<Long> assignees = nextAssignees.get(nextFlowNode.getId());
577 - // 3.3 如果节点中的审批人策略为 发起人自选 578 + // 3.4 流程变量
  579 + // 3.5 如果节点中的审批人策略为 发起人自选
578 if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy())) { 580 if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy())) {
579 - Map<String, List<Long>> hisProcessVariables = FlowableUtils.getStartUserSelectAssignees(processInstance.getProcessVariables());  
580 - List<Long> startUserSelectAssignee = hisProcessVariables.get(nextFlowNode.getId()); 581 + processVariables = FlowableUtils.getStartUserSelectAssignees(processInstance.getProcessVariables());
  582 + if(processVariables == null){
  583 + processVariables = new HashMap<>();
  584 + }
  585 + List<Long> startUserSelectAssignee = processVariables.get(nextFlowNode.getId());
581 // 如果当前节点已经存在审批人,则不允许覆盖 586 // 如果当前节点已经存在审批人,则不允许覆盖
582 if (CollUtil.isNotEmpty(startUserSelectAssignee)) { 587 if (CollUtil.isNotEmpty(startUserSelectAssignee)) {
583 continue; 588 continue;
584 } 589 }
585 - // 判断节点的审批人是否配置,节点存在,但未配置审批人 590 + // 如果节点存在,但未配置审批人
586 if (CollUtil.isEmpty(assignees)){ 591 if (CollUtil.isEmpty(assignees)){
587 throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName()); 592 throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName());
588 } 593 }
589 // 校验通过的全部节点和审批人 594 // 校验通过的全部节点和审批人
590 - hisProcessVariables.put(nextFlowNode.getId(), assignees);  
591 - variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES, hisProcessVariables); 595 + processVariables.put(nextFlowNode.getId(), assignees);
  596 + variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_SELECT_ASSIGNEES, processVariables);
592 } 597 }
593 - // 3.4 如果节点中的审批人策略为 审批人,在审批时选择下一个节点的审批人,并且该节点的审批人为空 598 + // 3.6 如果节点中的审批人策略为 审批人,在审批时选择下一个节点的审批人,并且该节点的审批人为空
594 if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.APPROVE_USER_SELECT.getStrategy())){ 599 if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.APPROVE_USER_SELECT.getStrategy())){
595 - // 判断节点的审批人是否配置,节点存在,但未配置审批人 600 + // 如果节点存在,但未配置审批人
596 if (CollUtil.isEmpty(assignees)) { 601 if (CollUtil.isEmpty(assignees)) {
597 throw exception(PROCESS_INSTANCE_APPROVE_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName()); 602 throw exception(PROCESS_INSTANCE_APPROVE_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName());
598 } 603 }
599 - Map<String, List<Long>> hisProcessVariables = FlowableUtils.getApproveUserSelectAssignees(processInstance.getProcessVariables());  
600 - if (hisProcessVariables == null) {  
601 - hisProcessVariables = new HashMap<>();  
602 - // 校验通过的全部节点和审批人  
603 - hisProcessVariables.put(nextFlowNode.getId(), assignees);  
604 - }  
605 - variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES, hisProcessVariables); 604 + // 校验通过的全部节点和审批人
  605 + processVariables.put(nextFlowNode.getId(), assignees);
  606 + variables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES, processVariables);
606 } 607 }
607 } 608 }
608 return variables; 609 return variables;