Commit b0fe72d73513022e4ce7d9cfecc3813dd5e932a5
1 parent
479d664a
【代码评审】BPM:会签逻辑的实现
Showing
4 changed files
with
6 additions
and
0 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
| @@ -49,6 +49,7 @@ public class BpmSimpleModelNodeVO { | @@ -49,6 +49,7 @@ public class BpmSimpleModelNodeVO { | ||
| 49 | */ | 49 | */ |
| 50 | @JsonIgnore | 50 | @JsonIgnore |
| 51 | private String attachNodeId; | 51 | private String attachNodeId; |
| 52 | + | ||
| 52 | // Map<String, Integer> formPermissions; 表单权限;仅发起、审批、抄送节点会使用 | 53 | // Map<String, Integer> formPermissions; 表单权限;仅发起、审批、抄送节点会使用 |
| 53 | // Integer approveMethod; 审批方式;仅审批节点会使用 | 54 | // Integer approveMethod; 审批方式;仅审批节点会使用 |
| 54 | // TODO @jason 后面和前端一起调整一下 | 55 | // TODO @jason 后面和前端一起调整一下 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/custom/delegate/MultiInstanceServiceTaskDelegate.java
| @@ -30,6 +30,8 @@ public class MultiInstanceServiceTaskDelegate implements JavaDelegate { | @@ -30,6 +30,8 @@ public class MultiInstanceServiceTaskDelegate implements JavaDelegate { | ||
| 30 | // 获取会签任务是否被拒绝 | 30 | // 获取会签任务是否被拒绝 |
| 31 | Boolean userTaskRejected = execution.getVariable(String.format("%s_reject", attachUserTaskId), Boolean.class); | 31 | Boolean userTaskRejected = execution.getVariable(String.format("%s_reject", attachUserTaskId), Boolean.class); |
| 32 | // 如果会签任务被拒绝, 终止流程 | 32 | // 如果会签任务被拒绝, 终止流程 |
| 33 | + // TODO @jason:【重要】需要测试下,如果基于 createChangeActivityStateBuilder()、changeState 到结束节点,实现审批不通过; | ||
| 34 | + // 注意:需要考虑 bpmn 的高亮问题;(不过这个,未来可能会废弃掉!) | ||
| 33 | if (BooleanUtil.isTrue(userTaskRejected)) { | 35 | if (BooleanUtil.isTrue(userTaskRejected)) { |
| 34 | processInstanceService.updateProcessInstanceReject(execution.getProcessInstanceId(), | 36 | processInstanceService.updateProcessInstanceReject(execution.getProcessInstanceId(), |
| 35 | BpmCommentTypeEnum.REJECT.formatComment("会签任务拒绝人数满足条件")); | 37 | BpmCommentTypeEnum.REJECT.formatComment("会签任务拒绝人数满足条件")); |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/custom/expression/CompleteByRejectCountExpression.java
| @@ -42,6 +42,7 @@ public class CompleteByRejectCountExpression { | @@ -42,6 +42,7 @@ public class CompleteByRejectCountExpression { | ||
| 42 | Integer approveMethod = NumberUtils.parseInt(BpmnModelUtils.parseExtensionElement(flowElement, USER_TASK_APPROVE_METHOD)); | 42 | Integer approveMethod = NumberUtils.parseInt(BpmnModelUtils.parseExtensionElement(flowElement, USER_TASK_APPROVE_METHOD)); |
| 43 | Assert.notNull(approveMethod, "审批方式不能空"); | 43 | Assert.notNull(approveMethod, "审批方式不能空"); |
| 44 | // 计算拒绝的人数 | 44 | // 计算拒绝的人数 |
| 45 | + // TODO @jason:CollUtil.filter().size();貌似可以更简洁 | ||
| 45 | Integer rejectCount = CollectionUtils.getSumValue(execution.getExecutions(), | 46 | Integer rejectCount = CollectionUtils.getSumValue(execution.getExecutions(), |
| 46 | item -> Objects.equals(BpmTaskStatusEnum.REJECT.getStatus(), item.getVariableLocal(BpmConstants.TASK_VARIABLE_STATUS, Integer.class)) ? 1 : 0, | 47 | item -> Objects.equals(BpmTaskStatusEnum.REJECT.getStatus(), item.getVariableLocal(BpmConstants.TASK_VARIABLE_STATUS, Integer.class)) ? 1 : 0, |
| 47 | Integer::sum, 0); | 48 | Integer::sum, 0); |
| @@ -81,4 +82,5 @@ public class CompleteByRejectCountExpression { | @@ -81,4 +82,5 @@ public class CompleteByRejectCountExpression { | ||
| 81 | log.error("[completionCondition] 按拒绝人数计算会签的完成条件的审批方式[{}],配置有误", approveMethod); | 82 | log.error("[completionCondition] 按拒绝人数计算会签的完成条件的审批方式[{}],配置有误", approveMethod); |
| 82 | throw exception(GlobalErrorCodeConstants.ERROR_CONFIGURATION); | 83 | throw exception(GlobalErrorCodeConstants.ERROR_CONFIGURATION); |
| 83 | } | 84 | } |
| 85 | + | ||
| 84 | } | 86 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| @@ -353,6 +353,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -353,6 +353,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 353 | return; | 353 | return; |
| 354 | } else if (userTaskRejectHandlerType == BpmUserTaskRejectHandlerType.FINISH_PROCESS_BY_REJECT_NUMBER) { | 354 | } else if (userTaskRejectHandlerType == BpmUserTaskRejectHandlerType.FINISH_PROCESS_BY_REJECT_NUMBER) { |
| 355 | // 3.3 按拒绝人数终止流程 | 355 | // 3.3 按拒绝人数终止流程 |
| 356 | + // TODO @jason:建议抛出系统异常。类似 throw new IllegalStateException() | ||
| 356 | if (!flowElement.hasMultiInstanceLoopCharacteristics()) { | 357 | if (!flowElement.hasMultiInstanceLoopCharacteristics()) { |
| 357 | log.error("[rejectTask] 用户任务拒绝处理类型配置错误, 按拒绝人数终止流程只能用于会签任务"); | 358 | log.error("[rejectTask] 用户任务拒绝处理类型配置错误, 按拒绝人数终止流程只能用于会签任务"); |
| 358 | throw exception(GlobalErrorCodeConstants.ERROR_CONFIGURATION); | 359 | throw exception(GlobalErrorCodeConstants.ERROR_CONFIGURATION); |