Commit 5e15a100cb660aa4c10bc364518a6380173b0dde
1 parent
fedb9242
review: 代码审查
Showing
2 changed files
with
10 additions
and
20 deletions
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java
| ... | ... | @@ -40,6 +40,7 @@ public interface ErrorCodeConstants { |
| 40 | 40 | ErrorCode PROCESS_INSTANCE_START_USER_CAN_START = new ErrorCode(1_009_004_005, "发起流程失败,你没有权限发起该流程"); |
| 41 | 41 | ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_ALLOW = new ErrorCode(1_009_004_005, "流程取消失败,该流程不允许取消"); |
| 42 | 42 | ErrorCode PROCESS_INSTANCE_HTTP_TRIGGER_CALL_ERROR = new ErrorCode(1_009_004_006, "流程 Http 触发器请求调用失败"); |
| 43 | + ErrorCode PROCESS_INSTANCE_APPROVE_USER_SELECT_ASSIGNEES_NOT_CONFIG = new ErrorCode(1_009_004_007, "任务({})的下一个节点审批人未配置"); | |
| 43 | 44 | |
| 44 | 45 | // ========== 流程任务 1-009-005-000 ========== |
| 45 | 46 | ErrorCode TASK_OPERATE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1_009_005_001, "操作失败,原因:该任务的审批人不是你"); | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| ... | ... | @@ -530,9 +530,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 530 | 530 | if (CollUtil.isNotEmpty(reqVO.getVariables())) { |
| 531 | 531 | Map<String, Object> variables = FlowableUtils.filterTaskFormVariable(reqVO.getVariables()); |
| 532 | 532 | // 校验传递的参数中是否为下一个将要执行的任务节点 |
| 533 | - validateNextAssignees(task.getTaskDefinitionKey(), reqVO.getVariables(), bpmnModel, reqVO.getNextAssignees(), instance); | |
| 533 | + validateAndSetNextAssignees(task.getTaskDefinitionKey(), reqVO.getVariables(), bpmnModel, reqVO.getNextAssignees(), instance); | |
| 534 | 534 | // 如果有下一个审批人,则设置到流程变量中 |
| 535 | - // TODO @小北:validateNextAssignees 升级成 validateAndSetNextAssignees,然后里面吧下面这一小段逻辑,抽进去如何? | |
| 536 | 535 | if (CollUtil.isNotEmpty(reqVO.getNextAssignees())) { |
| 537 | 536 | // 获取实例中的全部节点数据,避免后续节点的审批人被覆盖 |
| 538 | 537 | // TODO @小北:这里有个需要讨论的点,微信哈; |
| ... | ... | @@ -567,38 +566,28 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 567 | 566 | * @param nextAssignees 下一个节点审批人集合(参数) |
| 568 | 567 | * @param processInstance 流程实例 |
| 569 | 568 | */ |
| 570 | - private void validateNextAssignees(String taskDefinitionKey, Map<String, Object> variables, BpmnModel bpmnModel, | |
| 569 | + private void validateAndSetNextAssignees(String taskDefinitionKey, Map<String, Object> variables, BpmnModel bpmnModel, | |
| 571 | 570 | Map<String, List<Long>> nextAssignees, ProcessInstance processInstance) { |
| 572 | 571 | // 1. 获取当前任务节点的信息 |
| 573 | 572 | FlowElement flowElement = bpmnModel.getFlowElement(taskDefinitionKey); |
| 574 | 573 | // 2. 获取下一个将要执行的节点集合 |
| 575 | 574 | List<FlowNode> nextFlowNodes = getNextFlowNodes(flowElement, bpmnModel, variables); |
| 576 | - | |
| 577 | 575 | // 3. 循环下一个将要执行的节点集合 |
| 578 | 576 | for (FlowNode nextFlowNode : nextFlowNodes) { |
| 579 | - // 3.1 获取下一个将要执行节点的属性(是否为自选审批人等) | |
| 580 | - // TODO @小北:public static Integer parseCandidateStrategy(FlowElement userTask) 使用这个工具方法哈。 | |
| 581 | - Map<String, List<ExtensionElement>> extensionElements = nextFlowNode.getExtensionElements(); | |
| 582 | - List<ExtensionElement> elements = extensionElements.get(BpmnModelConstants.USER_TASK_CANDIDATE_STRATEGY); | |
| 583 | - if (CollUtil.isEmpty(elements)) { | |
| 584 | - continue; | |
| 585 | - } | |
| 586 | - // 3.2 获取节点中的审批人策略 | |
| 587 | - Integer candidateStrategy = Integer.valueOf(elements.get(0).getElementText()); | |
| 588 | - // 3.3 获取流程实例中的发起人自选审批人 | |
| 577 | + // 3.1 获取下一个将要执行节点中的审批人策略 | |
| 578 | + Integer candidateStrategy = parseCandidateStrategy(nextFlowNode); | |
| 579 | + // 3.2 获取流程实例中的发起人自选审批人 | |
| 589 | 580 | Map<String, List<Long>> startUserSelectAssignees = FlowableUtils.getStartUserSelectAssignees(processInstance.getProcessVariables()); |
| 590 | 581 | List<Long> startUserSelectAssignee = startUserSelectAssignees.get(nextFlowNode.getId()); |
| 591 | - // 3.4 如果节点中的审批人策略为 发起人自选,并且该节点的审批人为空 | |
| 582 | + // 3.3 如果节点中的审批人策略为 发起人自选,并且该节点的审批人为空 | |
| 592 | 583 | if (ObjUtil.equals(candidateStrategy, BpmTaskCandidateStrategyEnum.START_USER_SELECT.getStrategy()) && CollUtil.isEmpty(startUserSelectAssignee)) { |
| 593 | - // 先判断前端传递的参数节点节点是否为将要执行的节点 | |
| 594 | - // TODO @小北:!nextAssignees.containsKey(nextFlowNode.getId())、和 CollUtil.isEmpty(nextAssignees.get(nextFlowNode.getId()))) 是不是等价的? | |
| 584 | + // 判断节点是否为执行节点 | |
| 595 | 585 | if (!nextAssignees.containsKey(nextFlowNode.getId())) { |
| 596 | 586 | throw exception(TASK_TARGET_NODE_NOT_EXISTS, nextFlowNode.getName()); |
| 597 | 587 | } |
| 598 | - // 如果前端传递的节点为空,则抛出异常 | |
| 599 | - // TODO @小北:换一个错误码哈。 | |
| 588 | + // 判断节点的审批人是否配置 | |
| 600 | 589 | if (CollUtil.isEmpty(nextAssignees.get(nextFlowNode.getId()))) { |
| 601 | - throw exception(PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName()); | |
| 590 | + throw exception(PROCESS_INSTANCE_APPROVE_USER_SELECT_ASSIGNEES_NOT_CONFIG, nextFlowNode.getName()); | |
| 602 | 591 | } |
| 603 | 592 | } |
| 604 | 593 | // TODO @小北:加一个“审批人选择”的校验; | ... | ... |