【代码评审】BPM:会签逻辑的实现

This commit is contained in:
YunaiV 2024-06-12 20:23:16 +08:00
parent 479d664a63
commit b0fe72d735
4 changed files with 6 additions and 0 deletions

View File

@ -49,6 +49,7 @@ public class BpmSimpleModelNodeVO {
*/
@JsonIgnore
private String attachNodeId;
// Map<String, Integer> formPermissions; 表单权限仅发起审批抄送节点会使用
// Integer approveMethod; 审批方式仅审批节点会使用
// TODO @jason 后面和前端一起调整一下

View File

@ -30,6 +30,8 @@ public class MultiInstanceServiceTaskDelegate implements JavaDelegate {
// 获取会签任务是否被拒绝
Boolean userTaskRejected = execution.getVariable(String.format("%s_reject", attachUserTaskId), Boolean.class);
// 如果会签任务被拒绝, 终止流程
// TODO @jason重要需要测试下如果基于 createChangeActivityStateBuilder()changeState 到结束节点实现审批不通过
// 注意需要考虑 bpmn 的高亮问题不过这个未来可能会废弃掉
if (BooleanUtil.isTrue(userTaskRejected)) {
processInstanceService.updateProcessInstanceReject(execution.getProcessInstanceId(),
BpmCommentTypeEnum.REJECT.formatComment("会签任务拒绝人数满足条件"));

View File

@ -42,6 +42,7 @@ public class CompleteByRejectCountExpression {
Integer approveMethod = NumberUtils.parseInt(BpmnModelUtils.parseExtensionElement(flowElement, USER_TASK_APPROVE_METHOD));
Assert.notNull(approveMethod, "审批方式不能空");
// 计算拒绝的人数
// TODO @jasonCollUtil.filter().size();貌似可以更简洁
Integer rejectCount = CollectionUtils.getSumValue(execution.getExecutions(),
item -> Objects.equals(BpmTaskStatusEnum.REJECT.getStatus(), item.getVariableLocal(BpmConstants.TASK_VARIABLE_STATUS, Integer.class)) ? 1 : 0,
Integer::sum, 0);
@ -81,4 +82,5 @@ public class CompleteByRejectCountExpression {
log.error("[completionCondition] 按拒绝人数计算会签的完成条件的审批方式[{}],配置有误", approveMethod);
throw exception(GlobalErrorCodeConstants.ERROR_CONFIGURATION);
}
}

View File

@ -353,6 +353,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
return;
} else if (userTaskRejectHandlerType == BpmUserTaskRejectHandlerType.FINISH_PROCESS_BY_REJECT_NUMBER) {
// 3.3 按拒绝人数终止流程
// TODO @jason建议抛出系统异常类似 throw new IllegalStateException()
if (!flowElement.hasMultiInstanceLoopCharacteristics()) {
log.error("[rejectTask] 用户任务拒绝处理类型配置错误, 按拒绝人数终止流程只能用于会签任务");
throw exception(GlobalErrorCodeConstants.ERROR_CONFIGURATION);