diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/annotation/FlowListenerAnnotation.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/annotation/FlowListenerAnnotation.java index ad90df179..5ea262d17 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/annotation/FlowListenerAnnotation.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/annotation/FlowListenerAnnotation.java @@ -16,12 +16,12 @@ import java.lang.annotation.*; public @interface FlowListenerAnnotation { /** - * 流程定义 + * 流程定义key */ String processDefinitionKey(); /** - * 节点定义 + * 节点id */ String taskDefId() default ""; } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/config/GlobalFlowableListener.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/config/GlobalFlowableListener.java index c483eab63..444799b90 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/config/GlobalFlowableListener.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/config/GlobalFlowableListener.java @@ -107,8 +107,8 @@ public class GlobalFlowableListener implements FlowableEventListener { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(entity.getProcessDefinitionId()).singleResult(); String processDefinitionKey = processDefinition.getKey(); String taskDefinitionKey = entity.getTaskDefinitionKey(); - String beanName = processDefinitionKey + "_" + taskDefinitionKey; - FlowTaskEventHandler handler = flowEventStrategy.getTaskHandler(beanName); + String key = processDefinitionKey + "_" + taskDefinitionKey; + FlowTaskEventHandler handler = flowEventStrategy.getTaskHandler(key); if (handler != null) { handler.handleTask(entity); } diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/strategy/FlowEventStrategy.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/strategy/FlowEventStrategy.java index 3b00a4843..9da577633 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/strategy/FlowEventStrategy.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/flowable/strategy/FlowEventStrategy.java @@ -23,7 +23,7 @@ public class FlowEventStrategy implements BeanPostProcessor { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof FlowTaskEventHandler || bean instanceof FlowProcessEventHandler) { + if (bean instanceof FlowTaskEventHandler) { FlowListenerAnnotation annotation = bean.getClass().getAnnotation(FlowListenerAnnotation.class); if (null != annotation) { if (StringUtils.isNotBlank(annotation.processDefinitionKey()) && StringUtils.isNotBlank(annotation.taskDefId())) { @@ -32,6 +32,11 @@ public class FlowEventStrategy implements BeanPostProcessor { flowTaskEventHandlers.put(id, (FlowTaskEventHandler) bean); } } + } + } + if (bean instanceof FlowProcessEventHandler) { + FlowListenerAnnotation annotation = bean.getClass().getAnnotation(FlowListenerAnnotation.class); + if (null != annotation) { if (StringUtils.isNotBlank(annotation.processDefinitionKey()) && StringUtils.isBlank(annotation.taskDefId())) { if (!flowProcessEventHandlers.containsKey(annotation.processDefinitionKey())) { flowProcessEventHandlers.put(annotation.processDefinitionKey(), (FlowProcessEventHandler) bean); @@ -45,24 +50,24 @@ public class FlowEventStrategy implements BeanPostProcessor { /** * 获取可执行bean * - * @param beanName beanName + * @param key key */ - public FlowTaskEventHandler getTaskHandler(String beanName) { - if (!flowTaskEventHandlers.containsKey(beanName)) { + public FlowTaskEventHandler getTaskHandler(String key) { + if (!flowTaskEventHandlers.containsKey(key)) { return null; } - return flowTaskEventHandlers.get(beanName); + return flowTaskEventHandlers.get(key); } /** * 获取可执行bean * - * @param beanName beanName + * @param key key */ - public FlowProcessEventHandler getProcessHandler(String beanName) { - if (!flowProcessEventHandlers.containsKey(beanName)) { + public FlowProcessEventHandler getProcessHandler(String key) { + if (!flowProcessEventHandlers.containsKey(key)) { return null; } - return flowProcessEventHandlers.get(beanName); + return flowProcessEventHandlers.get(key); } }