gaoluyang
8 天以前 d5452f48951a5540d2df44c55e494e75560b3866
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cn.iocoder.yudao.module.bpm.api.event;
 
import cn.hutool.core.util.StrUtil;
import org.springframework.context.ApplicationListener;
 
/**
 * {@link BpmProcessInstanceStatusEvent} 的监听器
 *
 * @author 超级管理员
 */
public abstract class BpmProcessInstanceStatusEventListener
        implements ApplicationListener<BpmProcessInstanceStatusEvent> {
 
    @Override
    public final void onApplicationEvent(BpmProcessInstanceStatusEvent event) {
        // 优先按流程定义 Key 匹配;同时兼容同一业务分类下的历史自定义 Key(此时按分类匹配)
        if (!StrUtil.equals(event.getProcessDefinitionKey(), getProcessDefinitionKey())
                && !StrUtil.equals(event.getProcessDefinitionCategory(), getProcessDefinitionKey())) {
            return;
        }
        onEvent(event);
    }
 
    /**
     * @return 返回监听的流程定义 Key
     */
    protected abstract String getProcessDefinitionKey();
 
    /**
     * 处理事件
     *
     * @param event 事件
     */
    protected abstract void onEvent(BpmProcessInstanceStatusEvent event);
 
}