# demo38 **Repository Path**: FlowableDemo/demo38 ## Basic Information - **Project Name**: demo38 - **Description**: 在demo37,流程实例结束的时,处理业务数据 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-01-20 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ------ 环境: [jkd8+]() [mysql5.6+]() ## 一、[添加多个节点详见demo37](https://gitee.com/FlowableDemo/demo37) ## 二、添加事件监听器 - 实现FlowableEventListener接口 ``` /** * 事件监听:流程实例执行完处理业务数据 * */ public class CustomFlowableEventListener implements FlowableEventListener { private ProcessEngineConfigurationImpl processEngineConfigurationImpl; @Override public void onEvent(FlowableEvent event) { FlowableEngineEventType flowableEventType = (FlowableEngineEventType) event.getType(); System.out.println("事件类型: " + flowableEventType); switch (flowableEventType) { case PROCESS_COMPLETED: FlowableEntityEventImpl flowableEntityEventImpl = (FlowableEntityEventImpl) event; SqlSessionFactory sqlSessionFactory = processEngineConfigurationImpl.getSqlSessionFactory(); SqlSession sqlSession = sqlSessionFactory.openSession(); CreationMapper cm = sqlSession.getMapper(CreationMapper.class); cm.updateState(flowableEntityEventImpl.getProcessInstanceId()); sqlSession.commit(); sqlSession.close(); break; default: break; } } @Override public boolean isFailOnException() { return false; } @Override public boolean isFireOnTransactionLifecycleEvent() { return false; } @Override public String getOnTransaction() { return null; } public ProcessEngineConfigurationImpl getProcessEngineConfigurationImpl() { return processEngineConfigurationImpl; } public void setProcessEngineConfigurationImpl(ProcessEngineConfigurationImpl processEngineConfigurationImpl) { this.processEngineConfigurationImpl = processEngineConfigurationImpl; } } ``` - 在配置文件flowable-context.xml中配置监听器 ``` ``` ## 三、实践测试 - 运行complete,依次完成任务,当实例执行完,ACT_CREATION表中的STATE_被值为1