Commit 9512dcf812f22a582ff731572e5173d50d90631b
1 parent
e380bc34
【代码优化】工作流:延迟器的支持
Showing
4 changed files
with
17 additions
and
5 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
| ... | ... | @@ -218,6 +218,7 @@ public class BpmSimpleModelNodeVO { |
| 218 | 218 | |
| 219 | 219 | @Schema(description = "延迟时间类型", example = "1") |
| 220 | 220 | @NotNull(message = "延迟时间类型不能为空") |
| 221 | + @InEnum(BpmDelayTimerType.class) | |
| 221 | 222 | private Integer delayType; |
| 222 | 223 | |
| 223 | 224 | @Schema(description = "延迟时间表达式", example = "PT1H,2025-01-01T00:00:00") |
| ... | ... | @@ -225,5 +226,4 @@ public class BpmSimpleModelNodeVO { |
| 225 | 226 | private String delayTime; |
| 226 | 227 | } |
| 227 | 228 | |
| 228 | - // TODO @芋艿:条件;建议可以固化的一些选项;然后有个表达式兜底;要支持 | |
| 229 | 229 | } | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java
| ... | ... | @@ -100,15 +100,14 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener { |
| 100 | 100 | BpmBoundaryEventType bpmTimerBoundaryEventType = BpmBoundaryEventType.typeOf(NumberUtils.parseInt(boundaryEventType)); |
| 101 | 101 | |
| 102 | 102 | // 2. 处理超时 |
| 103 | - // 2.1 用户任务超时处理 | |
| 104 | 103 | if (ObjectUtil.equal(bpmTimerBoundaryEventType, BpmBoundaryEventType.USER_TASK_TIMEOUT)) { |
| 104 | + // 2.1 用户任务超时处理 | |
| 105 | 105 | String timeoutHandlerType = BpmnModelUtils.parseBoundaryEventExtensionElement(boundaryEvent, |
| 106 | 106 | BpmnModelConstants.USER_TASK_TIMEOUT_HANDLER_TYPE); |
| 107 | 107 | String taskKey = boundaryEvent.getAttachedToRefId(); |
| 108 | 108 | taskService.processTaskTimeout(event.getProcessInstanceId(), taskKey, NumberUtils.parseInt(timeoutHandlerType)); |
| 109 | - } | |
| 110 | - // 2.2 触发器超时处理 | |
| 111 | - if (ObjectUtil.equal(bpmTimerBoundaryEventType, BpmBoundaryEventType.DELAY_TIMER_TIMEOUT)) { | |
| 109 | + // 2.2 触发器超时处理 | |
| 110 | + } else if (ObjectUtil.equal(bpmTimerBoundaryEventType, BpmBoundaryEventType.DELAY_TIMER_TIMEOUT)) { | |
| 112 | 111 | String taskKey = boundaryEvent.getAttachedToRefId(); |
| 113 | 112 | taskService.processDelayTimerTimeout(event.getProcessInstanceId(), taskKey); |
| 114 | 113 | } | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java
| ... | ... | @@ -5,6 +5,7 @@ import cn.hutool.extra.spring.SpringUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; |
| 6 | 6 | import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; |
| 7 | 7 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants; |
| 8 | +import lombok.SneakyThrows; | |
| 8 | 9 | import org.flowable.common.engine.api.delegate.Expression; |
| 9 | 10 | import org.flowable.common.engine.api.variable.VariableContainer; |
| 10 | 11 | import org.flowable.common.engine.impl.el.ExpressionManager; |
| ... | ... | @@ -67,6 +68,17 @@ public class FlowableUtils { |
| 67 | 68 | } |
| 68 | 69 | } |
| 69 | 70 | |
| 71 | + @SneakyThrows | |
| 72 | + public static <V> V execute(String tenantIdStr, Callable<V> callable) { | |
| 73 | + if (ObjectUtil.isEmpty(tenantIdStr) | |
| 74 | + || Objects.equals(tenantIdStr, ProcessEngineConfiguration.NO_TENANT_ID)) { | |
| 75 | + return callable.call(); | |
| 76 | + } else { | |
| 77 | + Long tenantId = Long.valueOf(tenantIdStr); | |
| 78 | + return TenantUtils.execute(tenantId, callable); | |
| 79 | + } | |
| 80 | + } | |
| 81 | + | |
| 70 | 82 | // ========== Execution 相关的工具方法 ========== |
| 71 | 83 | |
| 72 | 84 | /** | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java