本文主要是介绍activiti7.0工作流,举个例子实现自定义任务监听和执行监听代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
public class MyListener implements TaskListener, ExecutionListener {// 实现任务监听TaskListener@Overridepublic void notify(DelegateTask delegateTask) {log.info("自定义任务监听器执行");String eventName = delegateTask.getEventName();switch (eventName){case EVENTNAME_CREATE:log.info("===create===");create(delegateTask);break;case EVENTNAME_ASSIGNMENT:log.info("===assignment===");assigment(delegateTask);break;case EVENTNAME_COMPLETE:log.info("===complete===");complete(delegateTask);break;case EVENTNAME_DELETE:log.info("===delete===");delete(delegateTask);break;default:break;}}public void create(DelegateTask delegateTask){}public void assigment(DelegateTask delegateTask){}// 任务监听完成事件public void complete(DelegateTask delegateTask){Integer operateFlag = (Integer)delegateTask.getVariableLocal("operateFlag");log.info("operateFlag:{}",operateFlag);Workflow workflow = new Workflow();workflow.setInstanceId(delegateTask.getProcessInstanceId());// 修改状态workflowMedia.setStatus(AuditStatus.Audit.getCode());SpringUtils.getBean(IWorkflowService.class).updateWorkflow(workflowMedia);}}public void delete(DelegateTask delegateTask){}// 实现执行监听ExecutionListener@Overridepublic void notify(DelegateExecution delegateExecution) {log.info("自定义执行监听器执行");String eventName = delegateExecution.getEventName();switch (eventName) {case EVENTNAME_START:log.info("===start===");start(delegateExecution);break;case EVENTNAME_END:log.info("===end===");end(delegateExecution);break;case EVENTNAME_TAKE:log.info("===take===");take(delegateExecution);break;default:break;}}private void start(DelegateExecution delegateExecution) {}private void end(DelegateExecution delegateExecution) {}private void take(DelegateExecution delegateExecution) {}}
这篇关于activiti7.0工作流,举个例子实现自定义任务监听和执行监听代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!