事件监听文档见 apidoc 的 com.seeyon.ctp.event.Event。 因为使用页面发起的流程第三方系统无法获取协同 ID,所以事件监听主要适用于使用代码发起的模板协同。 目前支持以下的事件监听:
事件名称 | 事件类 | 备注 |
---|---|---|
流程发起事件 | com.seeyon.apps.collaboration.event.CollaborationStartEvent | 发起协同、直接发送、转发、移动应用发送、平台接口发起协同均触发此事件 |
流程处理事件 | com.seeyon.apps.collaboration.event.CollaborationProcessEvent | |
流程结束事件 | com.seeyon.apps.collaboration.event.CollaborationFinishEvent | |
流程撤销事件 | com.seeyon.apps.collaboration.event.CollaborationCancelEvent | |
流程回退事件 | com.seeyon.apps.collaboration.event.CollaborationStepBackEvent | |
流程终止事件 | com.seeyon.apps.collaboration.event.CollaborationStopEvent |
示例:
@ListenEvent(event = CollaborationProcessEvent.class, async = true) public void onProcess(CollaborationProcessEvent event) { System.out.println("处理"); try { System.out.println("我的affairId:" + event.getAffairId()); System.out.println("模板编号:" + event.getTemplateCode()); System.out.println("已完成?" + event.isFinished()); System.out.println("已终止?" + event.isTerminated()); if (event.isTemplate("F0001") && event.isVouched()) { System.out.println("F0001模板核定通过"); } // 与3.5的CollaborationFormApprovalEvent作用相同 if (event.isTemplate("F0001") && event.isFormAudited()) { System.out.println("F0001模板表单审核通过"); } } catch (BusinessException e) { System.err.println(e.getLocalizedMessage()); } } @ListenEvent(event = CollaborationStartEvent.class, async = true) public void onStart(CollaborationStartEvent event) throws BusinessException { System.out.println("发起,我开动了"); System.out.println("我的affairId:" + event.getAffairId()); System.out.println("PC、手机或是接口发起的?" + event.getFrom()); } @ListenEvent(event = CollaborationStopEvent.class, async = true) public void onStop(CollaborationStopEvent event) { System.out.println("终止"); try { System.out.println("谁终止了我:" + event.getUserId()); System.out.println("模板编号:" + event.getTemplateCode()); } catch (BusinessException e) { System.err.println(e.getLocalizedMessage()); } } @ListenEvent(event = CollaborationStepBackEvent.class, async = true) public void onStepBack(CollaborationStepBackEvent event) { System.out.println("回退"); try { System.out.println("模板编号:" + event.getTemplateCode()); } catch (BusinessException e) { System.err.println(e.getLocalizedMessage()); } } @ListenEvent(event = CollaborationFinishEvent.class, async = true) public void onFinish(CollaborationFinishEvent event) { System.out.println("完成,我先到达终点:)"); try { System.out.println("我的affairId:" + event.getAffairId()); System.out.println("模板编号:" + event.getTemplateCode()); } catch (BusinessException e) { System.err.println(e.getLocalizedMessage()); } } @ListenEvent(event = CollaborationCancelEvent.class, async = true) public void onCancel(CollaborationCancelEvent event) { System.out.println("被撤销了...:("); try { System.out.println("我记得你,是你撤销的:" + event.getUserId()); System.out.println("为什么撤销?" + event.getMessage()); System.out.println("模板编号:" + event.getTemplateCode()); } catch (BusinessException e) { System.err.println(e.getLocalizedMessage()); } }