Commit 71e42cb0a1d350b37308ccccf3ac68c687a497c2
1 parent
fe3ca8de
【功能新增】审批节点的审批人与发起人相同时,对应的处理类型的配置
Showing
7 changed files
with
96 additions
and
39 deletions
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmBoundaryEventType.java
| @@ -4,7 +4,6 @@ import cn.hutool.core.util.ArrayUtil; | @@ -4,7 +4,6 @@ import cn.hutool.core.util.ArrayUtil; | ||
| 4 | import lombok.AllArgsConstructor; | 4 | import lombok.AllArgsConstructor; |
| 5 | import lombok.Getter; | 5 | import lombok.Getter; |
| 6 | 6 | ||
| 7 | -// TODO @jason:这个是不是可以去掉了哈? | ||
| 8 | /** | 7 | /** |
| 9 | * BPM 边界事件 (boundary event) 自定义类型枚举 | 8 | * BPM 边界事件 (boundary event) 自定义类型枚举 |
| 10 | * | 9 | * |
| @@ -14,8 +13,7 @@ import lombok.Getter; | @@ -14,8 +13,7 @@ import lombok.Getter; | ||
| 14 | @AllArgsConstructor | 13 | @AllArgsConstructor |
| 15 | public enum BpmBoundaryEventType { | 14 | public enum BpmBoundaryEventType { |
| 16 | 15 | ||
| 17 | - USER_TASK_TIMEOUT(1,"用户任务超时"), | ||
| 18 | - USER_TASK_REJECT_POST_PROCESS(2, "用户任务拒绝后处理"); | 16 | + USER_TASK_TIMEOUT(1,"用户任务超时"); |
| 19 | 17 | ||
| 20 | private final Integer type; | 18 | private final Integer type; |
| 21 | private final String name; | 19 | private final String name; |
| @@ -23,4 +21,5 @@ public enum BpmBoundaryEventType { | @@ -23,4 +21,5 @@ public enum BpmBoundaryEventType { | ||
| 23 | public static BpmBoundaryEventType typeOf(Integer type) { | 21 | public static BpmBoundaryEventType typeOf(Integer type) { |
| 24 | return ArrayUtil.firstMatch(eventType -> eventType.getType().equals(type), values()); | 22 | return ArrayUtil.firstMatch(eventType -> eventType.getType().equals(type), values()); |
| 25 | } | 23 | } |
| 24 | + | ||
| 26 | } | 25 | } |
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmUserTaskAssignStartUserHandlerTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.enums.definition; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | +import lombok.Getter; | ||
| 5 | +import lombok.RequiredArgsConstructor; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * BPM 用户任务的审批人与发起人相同时,处理类型枚举 | ||
| 9 | + * | ||
| 10 | + * @author 芋道源码 | ||
| 11 | + */ | ||
| 12 | +@RequiredArgsConstructor | ||
| 13 | +@Getter | ||
| 14 | +public enum BpmUserTaskAssignStartUserHandlerTypeEnum implements IntArrayValuable { | ||
| 15 | + | ||
| 16 | + START_USER_AUDIT(1), // 由发起人对自己审批 | ||
| 17 | + SKIP(2), // 自动跳过【参考飞书】:1)如果当前节点还有其他审批人,则交由其他审批人进行审批;2)如果当前节点没有其他审批人,则该节点自动通过 | ||
| 18 | + ASSIGN_DEPT_LEADER(3); // 转交给部门负责人审批 | ||
| 19 | + | ||
| 20 | + private final Integer type; | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public int[] array() { | ||
| 24 | + return new int[0]; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
| 1 | package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple; | 1 | package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | -import cn.iocoder.yudao.module.bpm.enums.definition.BpmApproveMethodEnum; | ||
| 5 | -import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType; | ||
| 6 | -import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskRejectHandlerType; | ||
| 7 | -import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutHandlerType; | 4 | +import cn.iocoder.yudao.module.bpm.enums.definition.*; |
| 8 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; | 5 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; |
| 9 | import com.fasterxml.jackson.annotation.JsonIgnore; | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 10 | import com.fasterxml.jackson.annotation.JsonInclude; | 7 | import com.fasterxml.jackson.annotation.JsonInclude; |
| @@ -84,6 +81,10 @@ public class BpmSimpleModelNodeVO { | @@ -84,6 +81,10 @@ public class BpmSimpleModelNodeVO { | ||
| 84 | */ | 81 | */ |
| 85 | private TimeoutHandler timeoutHandler; | 82 | private TimeoutHandler timeoutHandler; |
| 86 | 83 | ||
| 84 | + @Schema(description = "审批节点的审批人与发起人相同时,对应的处理类型", example = "1") | ||
| 85 | + @InEnum(BpmUserTaskAssignStartUserHandlerTypeEnum.class) | ||
| 86 | + private Integer assignStartUserHandlerType; | ||
| 87 | + | ||
| 87 | @Data | 88 | @Data |
| 88 | @Schema(description = "审批节点拒绝处理策略") | 89 | @Schema(description = "审批节点拒绝处理策略") |
| 89 | public static class RejectHandler { | 90 | public static class RejectHandler { |
| @@ -132,14 +133,7 @@ public class BpmSimpleModelNodeVO { | @@ -132,14 +133,7 @@ public class BpmSimpleModelNodeVO { | ||
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | // Map<String, Integer> formPermissions; 表单权限;仅发起、审批、抄送节点会使用 | 135 | // Map<String, Integer> formPermissions; 表单权限;仅发起、审批、抄送节点会使用 |
| 135 | - // Integer approveMethod; 审批方式;仅审批节点会使用 | ||
| 136 | - // TODO @jason 后面和前端一起调整一下;下面的 ①、②、③ 是优先级 | ||
| 137 | - // TODO @芋艿:① 审批人的选择; | ||
| 138 | // TODO @芋艿:⑥ 没有人的策略? | 136 | // TODO @芋艿:⑥ 没有人的策略? |
| 139 | - // TODO @芋艿:② 审批拒绝的策略? | ||
| 140 | - // TODO @芋艿:③ 配置的可操作列表?(操作权限) | ||
| 141 | - // TODO @芋艿:④ 表单的权限列表? | ||
| 142 | - // TODO @芋艿:⑨ 超时配置;要支持指定时间点、指定时间间隔; | ||
| 143 | // TODO @芋艿:条件;建议可以固化的一些选项;然后有个表达式兜底;要支持 | 137 | // TODO @芋艿:条件;建议可以固化的一些选项;然后有个表达式兜底;要支持 |
| 144 | 138 | ||
| 145 | } | 139 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java
| @@ -176,7 +176,6 @@ public interface BpmTaskConvert { | @@ -176,7 +176,6 @@ public interface BpmTaskConvert { | ||
| 176 | childTask.setParentTaskId(parentTask.getId()); | 176 | childTask.setParentTaskId(parentTask.getId()); |
| 177 | childTask.setProcessDefinitionId(parentTask.getProcessDefinitionId()); | 177 | childTask.setProcessDefinitionId(parentTask.getProcessDefinitionId()); |
| 178 | childTask.setProcessInstanceId(parentTask.getProcessInstanceId()); | 178 | childTask.setProcessInstanceId(parentTask.getProcessInstanceId()); |
| 179 | -// childTask.setExecutionId(parentTask.getExecutionId()); // TODO 芋艿:新加的,不太确定;尴尬,不加时,子任务不通过会失败(报错);加了,子任务审批通过会失败(报错) | ||
| 180 | childTask.setTaskDefinitionKey(parentTask.getTaskDefinitionKey()); | 179 | childTask.setTaskDefinitionKey(parentTask.getTaskDefinitionKey()); |
| 181 | childTask.setTaskDefinitionId(parentTask.getTaskDefinitionId()); | 180 | childTask.setTaskDefinitionId(parentTask.getTaskDefinitionId()); |
| 182 | childTask.setPriority(parentTask.getPriority()); | 181 | childTask.setPriority(parentTask.getPriority()); |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java
| @@ -29,12 +29,17 @@ public interface BpmnModelConstants { | @@ -29,12 +29,17 @@ public interface BpmnModelConstants { | ||
| 29 | String BOUNDARY_EVENT_TYPE = "boundaryEventType"; | 29 | String BOUNDARY_EVENT_TYPE = "boundaryEventType"; |
| 30 | 30 | ||
| 31 | // TODO @jason:这个命名,应该也要改哈 | 31 | // TODO @jason:这个命名,应该也要改哈 |
| 32 | + // TODO @jason:1)是不是上面的 timeoutAction 改成 timeoutHandler; | ||
| 32 | /** | 33 | /** |
| 33 | * BPMN ExtensionElement 的扩展属性,用于标记用户任务超时执行动作 | 34 | * BPMN ExtensionElement 的扩展属性,用于标记用户任务超时执行动作 |
| 34 | */ | 35 | */ |
| 35 | String USER_TASK_TIMEOUT_HANDLER_ACTION = "timeoutAction"; | 36 | String USER_TASK_TIMEOUT_HANDLER_ACTION = "timeoutAction"; |
| 36 | 37 | ||
| 37 | - // TODO @jason:1)是不是上面的 timeoutAction 改成 timeoutHandler;2)rejectHandlerType 改成 rejectHandler 哇? | 38 | + /** |
| 39 | + * BPMN ExtensionElement 的扩展属性,用于标记用户任务的审批人与发起人相同时,对应的处理类型 | ||
| 40 | + */ | ||
| 41 | + String USER_TASK_ASSIGN_START_USER_HANDLER_TYPE = "assignStartUserHandlerType"; | ||
| 42 | + | ||
| 38 | /** | 43 | /** |
| 39 | * BPMN ExtensionElement 的扩展属性,用于标记用户任务拒绝处理类型 | 44 | * BPMN ExtensionElement 的扩展属性,用于标记用户任务拒绝处理类型 |
| 40 | */ | 45 | */ |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
| @@ -10,6 +10,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | @@ -10,6 +10,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 10 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; | 10 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; |
| 11 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.RejectHandler; | 11 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.RejectHandler; |
| 12 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmApproveMethodEnum; | 12 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmApproveMethodEnum; |
| 13 | +import cn.iocoder.yudao.module.bpm.enums.definition.BpmBoundaryEventType; | ||
| 13 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModeConditionType; | 14 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModeConditionType; |
| 14 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType; | 15 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType; |
| 15 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; | 16 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; |
| @@ -25,7 +26,6 @@ import java.util.Objects; | @@ -25,7 +26,6 @@ import java.util.Objects; | ||
| 25 | 26 | ||
| 26 | import static cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.OperationButtonSetting; | 27 | import static cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.OperationButtonSetting; |
| 27 | import static cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.TimeoutHandler; | 28 | import static cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.TimeoutHandler; |
| 28 | -import static cn.iocoder.yudao.module.bpm.enums.definition.BpmBoundaryEventType.USER_TASK_TIMEOUT; | ||
| 29 | import static cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType.*; | 29 | import static cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType.*; |
| 30 | import static cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutHandlerType.REMINDER; | 30 | import static cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutHandlerType.REMINDER; |
| 31 | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.*; | 31 | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.*; |
| @@ -338,8 +338,9 @@ public class SimpleModelUtils { | @@ -338,8 +338,9 @@ public class SimpleModelUtils { | ||
| 338 | List<FlowElement> flowElements = new ArrayList<>(); | 338 | List<FlowElement> flowElements = new ArrayList<>(); |
| 339 | UserTask userTask = buildBpmnUserTask(node); | 339 | UserTask userTask = buildBpmnUserTask(node); |
| 340 | flowElements.add(userTask); | 340 | flowElements.add(userTask); |
| 341 | + | ||
| 342 | + // 添加用户任务的 Timer Boundary Event, 用于任务的审批超时处理 | ||
| 341 | if (node.getTimeoutHandler() != null && node.getTimeoutHandler().getEnable()) { | 343 | if (node.getTimeoutHandler() != null && node.getTimeoutHandler().getEnable()) { |
| 342 | - // 添加用户任务的 Timer Boundary Event, 用于任务的超时处理 | ||
| 343 | BoundaryEvent boundaryEvent = buildUserTaskTimerBoundaryEvent(userTask, node.getTimeoutHandler()); | 344 | BoundaryEvent boundaryEvent = buildUserTaskTimerBoundaryEvent(userTask, node.getTimeoutHandler()); |
| 344 | flowElements.add(boundaryEvent); | 345 | flowElements.add(boundaryEvent); |
| 345 | } | 346 | } |
| @@ -347,31 +348,31 @@ public class SimpleModelUtils { | @@ -347,31 +348,31 @@ public class SimpleModelUtils { | ||
| 347 | } | 348 | } |
| 348 | 349 | ||
| 349 | /** | 350 | /** |
| 350 | - * 添加 UserTask 用户审批的 BoundaryEvent 超时事件 | 351 | + * 添加 UserTask 用户的审批超时 BoundaryEvent 事件 |
| 351 | * | 352 | * |
| 352 | * @param userTask 审批任务 | 353 | * @param userTask 审批任务 |
| 353 | * @param timeoutHandler 超时处理器 | 354 | * @param timeoutHandler 超时处理器 |
| 354 | - * @return | 355 | + * @return BoundaryEvent 超时事件 |
| 355 | */ | 356 | */ |
| 356 | private static BoundaryEvent buildUserTaskTimerBoundaryEvent(UserTask userTask, TimeoutHandler timeoutHandler) { | 357 | private static BoundaryEvent buildUserTaskTimerBoundaryEvent(UserTask userTask, TimeoutHandler timeoutHandler) { |
| 357 | - // 定时器边界事件 | 358 | + // 1.1 定时器边界事件 |
| 358 | BoundaryEvent boundaryEvent = new BoundaryEvent(); | 359 | BoundaryEvent boundaryEvent = new BoundaryEvent(); |
| 359 | boundaryEvent.setId("Event-" + IdUtil.fastUUID()); | 360 | boundaryEvent.setId("Event-" + IdUtil.fastUUID()); |
| 360 | - // 设置关联的任务为不会被中断 | ||
| 361 | - boundaryEvent.setCancelActivity(false); | 361 | + boundaryEvent.setCancelActivity(false); // 设置关联的任务为不会被中断 |
| 362 | boundaryEvent.setAttachedToRef(userTask); | 362 | boundaryEvent.setAttachedToRef(userTask); |
| 363 | + // 1.2 定义超时时间、最大提醒次数 | ||
| 363 | TimerEventDefinition eventDefinition = new TimerEventDefinition(); | 364 | TimerEventDefinition eventDefinition = new TimerEventDefinition(); |
| 364 | eventDefinition.setTimeDuration(timeoutHandler.getTimeDuration()); | 365 | eventDefinition.setTimeDuration(timeoutHandler.getTimeDuration()); |
| 365 | if (Objects.equals(REMINDER.getAction(), timeoutHandler.getAction()) && | 366 | if (Objects.equals(REMINDER.getAction(), timeoutHandler.getAction()) && |
| 366 | timeoutHandler.getMaxRemindCount() != null && timeoutHandler.getMaxRemindCount() > 1) { | 367 | timeoutHandler.getMaxRemindCount() != null && timeoutHandler.getMaxRemindCount() > 1) { |
| 367 | - // 最大提醒次数 | ||
| 368 | - eventDefinition.setTimeCycle(String.format("R%d/%s", timeoutHandler.getMaxRemindCount(), timeoutHandler.getTimeDuration())); | 368 | + eventDefinition.setTimeCycle(String.format("R%d/%s", |
| 369 | + timeoutHandler.getMaxRemindCount(), timeoutHandler.getTimeDuration())); | ||
| 369 | } | 370 | } |
| 370 | boundaryEvent.addEventDefinition(eventDefinition); | 371 | boundaryEvent.addEventDefinition(eventDefinition); |
| 371 | 372 | ||
| 372 | - // 添加定时器边界事件类型 | ||
| 373 | - addExtensionElement(boundaryEvent, BOUNDARY_EVENT_TYPE, USER_TASK_TIMEOUT.getType().toString()); | ||
| 374 | - // 添加超时执行动作元素 | 373 | + // 2.1 添加定时器边界事件类型 |
| 374 | + addExtensionElement(boundaryEvent, BOUNDARY_EVENT_TYPE, BpmBoundaryEventType.USER_TASK_TIMEOUT.getType().toString()); | ||
| 375 | + // 2.2 添加超时执行动作元素 | ||
| 375 | addExtensionElement(boundaryEvent, USER_TASK_TIMEOUT_HANDLER_ACTION, StrUtil.toStringOrNull(timeoutHandler.getAction())); | 376 | addExtensionElement(boundaryEvent, USER_TASK_TIMEOUT_HANDLER_ACTION, StrUtil.toStringOrNull(timeoutHandler.getAction())); |
| 376 | return boundaryEvent; | 377 | return boundaryEvent; |
| 377 | } | 378 | } |
| @@ -455,8 +456,6 @@ public class SimpleModelUtils { | @@ -455,8 +456,6 @@ public class SimpleModelUtils { | ||
| 455 | userTask.setDueDate(node.getTimeoutHandler().getTimeDuration()); | 456 | userTask.setDueDate(node.getTimeoutHandler().getTimeDuration()); |
| 456 | } | 457 | } |
| 457 | 458 | ||
| 458 | - // TODO 芋艿 + jason:要不要基于服务任务,实现或签下的审批不通过?或者说,按比例审批 | ||
| 459 | - | ||
| 460 | // TODO @jason:addCandidateElements、processMultiInstanceLoopCharacteristics 建议一起搞哈? | 459 | // TODO @jason:addCandidateElements、processMultiInstanceLoopCharacteristics 建议一起搞哈? |
| 461 | // 添加候选人元素 | 460 | // 添加候选人元素 |
| 462 | addCandidateElements(node.getCandidateStrategy(), node.getCandidateParam(), userTask); | 461 | addCandidateElements(node.getCandidateStrategy(), node.getCandidateParam(), userTask); |
| @@ -468,10 +467,11 @@ public class SimpleModelUtils { | @@ -468,10 +467,11 @@ public class SimpleModelUtils { | ||
| 468 | processMultiInstanceLoopCharacteristics(node.getApproveMethod(), node.getApproveRatio(), userTask); | 467 | processMultiInstanceLoopCharacteristics(node.getApproveMethod(), node.getApproveRatio(), userTask); |
| 469 | // 添加任务被拒绝的处理元素 | 468 | // 添加任务被拒绝的处理元素 |
| 470 | addTaskRejectElements(node.getRejectHandler(), userTask); | 469 | addTaskRejectElements(node.getRejectHandler(), userTask); |
| 470 | + // 添加用户任务的审批人与发起人相同时的处理元素 | ||
| 471 | + addAssignStartUserHandlerType(node.getAssignStartUserHandlerType(), userTask); | ||
| 471 | return userTask; | 472 | return userTask; |
| 472 | } | 473 | } |
| 473 | 474 | ||
| 474 | - | ||
| 475 | private static void addTaskRejectElements(RejectHandler rejectHandler, UserTask userTask) { | 475 | private static void addTaskRejectElements(RejectHandler rejectHandler, UserTask userTask) { |
| 476 | if (rejectHandler == null) { | 476 | if (rejectHandler == null) { |
| 477 | return; | 477 | return; |
| @@ -480,6 +480,13 @@ public class SimpleModelUtils { | @@ -480,6 +480,13 @@ public class SimpleModelUtils { | ||
| 480 | addExtensionElement(userTask, USER_TASK_REJECT_RETURN_TASK_ID, rejectHandler.getReturnNodeId()); | 480 | addExtensionElement(userTask, USER_TASK_REJECT_RETURN_TASK_ID, rejectHandler.getReturnNodeId()); |
| 481 | } | 481 | } |
| 482 | 482 | ||
| 483 | + private static void addAssignStartUserHandlerType(Integer assignStartUserHandlerType, UserTask userTask) { | ||
| 484 | + if (assignStartUserHandlerType == null) { | ||
| 485 | + return; | ||
| 486 | + } | ||
| 487 | + addExtensionElement(userTask, USER_TASK_ASSIGN_START_USER_HANDLER_TYPE, assignStartUserHandlerType.toString()); | ||
| 488 | + } | ||
| 489 | + | ||
| 483 | private static void processMultiInstanceLoopCharacteristics(Integer approveMethod, Integer approveRatio, UserTask userTask) { | 490 | private static void processMultiInstanceLoopCharacteristics(Integer approveMethod, Integer approveRatio, UserTask userTask) { |
| 484 | BpmApproveMethodEnum bpmApproveMethodEnum = BpmApproveMethodEnum.valueOf(approveMethod); | 491 | BpmApproveMethodEnum bpmApproveMethodEnum = BpmApproveMethodEnum.valueOf(approveMethod); |
| 485 | if (bpmApproveMethodEnum == null || bpmApproveMethodEnum == BpmApproveMethodEnum.RANDOM) { | 492 | if (bpmApproveMethodEnum == null || bpmApproveMethodEnum == BpmApproveMethodEnum.RANDOM) { |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.service.task; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.service.task; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.*; | 4 | import cn.hutool.core.util.*; |
| 5 | +import cn.hutool.extra.spring.SpringUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.framework.common.util.date.DateUtils; | 7 | import cn.iocoder.yudao.framework.common.util.date.DateUtils; |
| 7 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | 8 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| @@ -79,7 +80,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -79,7 +80,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 79 | @Resource | 80 | @Resource |
| 80 | private BpmProcessInstanceCopyService processInstanceCopyService; | 81 | private BpmProcessInstanceCopyService processInstanceCopyService; |
| 81 | @Resource | 82 | @Resource |
| 82 | - private BpmModelService bpmModelService; | 83 | + private BpmModelService modelService; |
| 83 | @Resource | 84 | @Resource |
| 84 | private BpmMessageService messageService; | 85 | private BpmMessageService messageService; |
| 85 | 86 | ||
| @@ -228,7 +229,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -228,7 +229,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 228 | // 1.1 校验当前任务 task 存在 | 229 | // 1.1 校验当前任务 task 存在 |
| 229 | Task task = validateTaskExist(id); | 230 | Task task = validateTaskExist(id); |
| 230 | // 1.2 根据流程定义获取流程模型信息 | 231 | // 1.2 根据流程定义获取流程模型信息 |
| 231 | - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); | 232 | + BpmnModel bpmnModel = modelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); |
| 232 | FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); | 233 | FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); |
| 233 | if (source == null) { | 234 | if (source == null) { |
| 234 | throw exception(TASK_NOT_EXISTS); | 235 | throw exception(TASK_NOT_EXISTS); |
| @@ -498,7 +499,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -498,7 +499,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 498 | } | 499 | } |
| 499 | 500 | ||
| 500 | // 3. 根据不同的 RejectHandler 处理策略 | 501 | // 3. 根据不同的 RejectHandler 处理策略 |
| 501 | - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); | 502 | + BpmnModel bpmnModel = modelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId()); |
| 502 | FlowElement flowElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); | 503 | FlowElement flowElement = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); |
| 503 | // 3.1 情况一:驳回到指定的任务节点 | 504 | // 3.1 情况一:驳回到指定的任务节点 |
| 504 | BpmUserTaskRejectHandlerType userTaskRejectHandlerType = BpmnModelUtils.parseRejectHandlerType(flowElement); | 505 | BpmUserTaskRejectHandlerType userTaskRejectHandlerType = BpmnModelUtils.parseRejectHandlerType(flowElement); |
| @@ -562,7 +563,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -562,7 +563,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 562 | */ | 563 | */ |
| 563 | private FlowElement validateTargetTaskCanReturn(String sourceKey, String targetKey, String processDefinitionId) { | 564 | private FlowElement validateTargetTaskCanReturn(String sourceKey, String targetKey, String processDefinitionId) { |
| 564 | // 1.1 获取流程模型信息 | 565 | // 1.1 获取流程模型信息 |
| 565 | - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(processDefinitionId); | 566 | + BpmnModel bpmnModel = modelService.getBpmnModelByDefinitionId(processDefinitionId); |
| 566 | // 1.3 获取当前任务节点元素 | 567 | // 1.3 获取当前任务节点元素 |
| 567 | FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, sourceKey); | 568 | FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, sourceKey); |
| 568 | // 1.3 获取跳转的节点元素 | 569 | // 1.3 获取跳转的节点元素 |
| @@ -690,7 +691,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -690,7 +691,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 690 | }); | 691 | }); |
| 691 | 692 | ||
| 692 | // 2. 终止流程 | 693 | // 2. 终止流程 |
| 693 | - BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(taskList.get(0).getProcessDefinitionId()); | 694 | + BpmnModel bpmnModel = modelService.getBpmnModelByDefinitionId(taskList.get(0).getProcessDefinitionId()); |
| 694 | List<String> activityIds = CollUtil.newArrayList(convertSet(taskList, Task::getTaskDefinitionKey)); | 695 | List<String> activityIds = CollUtil.newArrayList(convertSet(taskList, Task::getTaskDefinitionKey)); |
| 695 | EndEvent endEvent = BpmnModelUtils.getEndEvent(bpmnModel); | 696 | EndEvent endEvent = BpmnModelUtils.getEndEvent(bpmnModel); |
| 696 | Assert.notNull(endEvent, "结束节点不能未空"); | 697 | Assert.notNull(endEvent, "结束节点不能未空"); |
| @@ -915,13 +916,29 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -915,13 +916,29 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 915 | @Override | 916 | @Override |
| 916 | public void afterCommit() { | 917 | public void afterCommit() { |
| 917 | if (StrUtil.isEmpty(task.getAssignee())) { | 918 | if (StrUtil.isEmpty(task.getAssignee())) { |
| 919 | + log.error("[processTaskAssigned][taskId({}) 没有分配到负责人]", task.getId()); | ||
| 918 | return; | 920 | return; |
| 919 | } | 921 | } |
| 920 | ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); | 922 | ProcessInstance processInstance = processInstanceService.getProcessInstance(task.getProcessInstanceId()); |
| 921 | - if (processInstance != null) { | ||
| 922 | - AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())); | ||
| 923 | - messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task)); | 923 | + if (processInstance == null) { |
| 924 | + log.error("[processTaskAssigned][taskId({}) 没有找到流程实例]", task.getId()); | ||
| 925 | + return; | ||
| 926 | + } | ||
| 927 | + BpmnModel bpmnModel = modelService.getBpmnModelByDefinitionId(processInstance.getProcessDefinitionId()); | ||
| 928 | + if (bpmnModel == null) { | ||
| 929 | + log.error("[processTaskAssigned][taskId({}) 没有找到流程模型]", task.getId()); | ||
| 930 | + return; | ||
| 931 | + } | ||
| 932 | + | ||
| 933 | + // 审批人与提交人为同一人时,根据策略进行处理 | ||
| 934 | + if (StrUtil.equals(task.getAssignee(), processInstance.getStartUserId())) { | ||
| 935 | + getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO() | ||
| 936 | + .setId(task.getId()).setReason("审批人与提交人为同一人时,自动通过")); | ||
| 937 | + return; | ||
| 924 | } | 938 | } |
| 939 | + | ||
| 940 | + AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())); | ||
| 941 | + messageService.sendMessageWhenTaskAssigned(BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task)); | ||
| 925 | } | 942 | } |
| 926 | 943 | ||
| 927 | }); | 944 | }); |
| @@ -966,4 +983,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -966,4 +983,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 966 | })); | 983 | })); |
| 967 | } | 984 | } |
| 968 | 985 | ||
| 986 | + /** | ||
| 987 | + * 获得自身的代理对象,解决 AOP 生效问题 | ||
| 988 | + * | ||
| 989 | + * @return 自己 | ||
| 990 | + */ | ||
| 991 | + private BpmTaskServiceImpl getSelf() { | ||
| 992 | + return SpringUtil.getBean(getClass()); | ||
| 993 | + } | ||
| 994 | + | ||
| 969 | } | 995 | } |