【代码优化】工作流:延迟器的支持

This commit is contained in:
YunaiV 2025-01-03 19:53:06 +08:00
parent e380bc34f3
commit 9512dcf812
4 changed files with 17 additions and 5 deletions

View File

@ -218,6 +218,7 @@ public class BpmSimpleModelNodeVO {
@Schema(description = "延迟时间类型", example = "1")
@NotNull(message = "延迟时间类型不能为空")
@InEnum(BpmDelayTimerType.class)
private Integer delayType;
@Schema(description = "延迟时间表达式", example = "PT1H,2025-01-01T00:00:00")
@ -225,5 +226,4 @@ public class BpmSimpleModelNodeVO {
private String delayTime;
}
// TODO @芋艿条件建议可以固化的一些选项然后有个表达式兜底要支持
}

View File

@ -100,15 +100,14 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener {
BpmBoundaryEventType bpmTimerBoundaryEventType = BpmBoundaryEventType.typeOf(NumberUtils.parseInt(boundaryEventType));
// 2. 处理超时
// 2.1 用户任务超时处理
if (ObjectUtil.equal(bpmTimerBoundaryEventType, BpmBoundaryEventType.USER_TASK_TIMEOUT)) {
// 2.1 用户任务超时处理
String timeoutHandlerType = BpmnModelUtils.parseBoundaryEventExtensionElement(boundaryEvent,
BpmnModelConstants.USER_TASK_TIMEOUT_HANDLER_TYPE);
String taskKey = boundaryEvent.getAttachedToRefId();
taskService.processTaskTimeout(event.getProcessInstanceId(), taskKey, NumberUtils.parseInt(timeoutHandlerType));
}
// 2.2 触发器超时处理
if (ObjectUtil.equal(bpmTimerBoundaryEventType, BpmBoundaryEventType.DELAY_TIMER_TIMEOUT)) {
// 2.2 触发器超时处理
} else if (ObjectUtil.equal(bpmTimerBoundaryEventType, BpmBoundaryEventType.DELAY_TIMER_TIMEOUT)) {
String taskKey = boundaryEvent.getAttachedToRefId();
taskService.processDelayTimerTimeout(event.getProcessInstanceId(), taskKey);
}

View File

@ -5,6 +5,7 @@ import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants;
import lombok.SneakyThrows;
import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.common.engine.api.variable.VariableContainer;
import org.flowable.common.engine.impl.el.ExpressionManager;
@ -67,6 +68,17 @@ public class FlowableUtils {
}
}
@SneakyThrows
public static <V> V execute(String tenantIdStr, Callable<V> callable) {
if (ObjectUtil.isEmpty(tenantIdStr)
|| Objects.equals(tenantIdStr, ProcessEngineConfiguration.NO_TENANT_ID)) {
return callable.call();
} else {
Long tenantId = Long.valueOf(tenantIdStr);
return TenantUtils.execute(tenantId, callable);
}
}
// ========== Execution 相关的工具方法 ==========
/**

View File

@ -282,4 +282,5 @@ public interface BpmTaskService {
* @param taskDefineKey 任务 Key
*/
void processDelayTimerTimeout(String processInstanceId, String taskDefineKey);
}