BPM: 实现业务流程结果监听器

This commit is contained in:
puhui999
2024-02-01 00:45:29 +08:00
parent acb8d3f23b
commit 624b35988e
10 changed files with 147 additions and 8 deletions

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.bpm.framework.bpm.listener;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.bpm.api.listener.BpmResultListenerApi;
import cn.iocoder.yudao.module.bpm.api.listener.dto.BpmResultListenerRespDTO;
import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent;
import jakarta.annotation.Resource;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 业务流程结果监听器实现类
*
* @author HUIHUI
*/
@Component
public class BpmServiceResultListener implements ApplicationListener<BpmProcessInstanceResultEvent> {
@Resource
private List<BpmResultListenerApi> bpmResultListenerApis;
@Override
public final void onApplicationEvent(BpmProcessInstanceResultEvent event) {
bpmResultListenerApis.forEach(bpmResultListenerApi -> {
if (!StrUtil.equals(event.getProcessDefinitionKey(), bpmResultListenerApi.getProcessDefinitionKey())) {
return;
}
bpmResultListenerApi.onEvent(BeanUtils.toBean(event, BpmResultListenerRespDTO.class));
});
}
}