流程管理监听事件

1、新建监听事件类 KmExampleListener 并且继承 IEventListener 重写接口方法 handleEvent

2、在spring.xml文件中注入监听事件类

<bean id="kmExampleListener "
  class="com.landray.kmss.km.review.listener.kmExampleListener ">
  <property name="sysOrgElementService" ref="sysOrgElementService"></property>
</bean>

 

3、在plugin.xml文件中配置监听事件

<extension
  point="com.landray.kmss.lbpm.engine.event">
  <item
    name="listener">
    <param
      name="unid"
      value="kmExampleListener " />
    <param
      name="messageKey"
      value="测试监听事件" />
    <param
      name="eventTypes"
      value="endedNodeEvent" />
    <param
      name="listener"
      value="kmExampleListener " />
    <param
      name="enforce"
      value="false" />
    </item>
</extension>

4、编写监听事件逻辑

    
    private ISysOrgElementService sysOrgElementService;
    
    public ISysOrgElementService getSysOrgElementService() {
        return sysOrgElementService;
    }

    public void setSysOrgElementService(ISysOrgElementService sysOrgElementService) {
        this.sysOrgElementService = sysOrgElementService;
    }


    @Override
    public void handleEvent(EventExecutionContext context, String arg1) throws Exception {
        // TODO Auto-generated method stub
        IBaseModel model = context.getMainModel();
        
        if(!(model instanceof KmReviewMain)){
            return;
        }
        KmReviewMain kmReviewMain = (KmReviewMain) model;//获取流程实例

        String fdId = kmReviewMain.getFdId();//流程ID

        Map<String, Object> modelData = kmReviewMain.getExtendDataModelInfo().getModelData();
        
        //审批状态
        String confirmstate = modelData.get("fd_confirmstates") == null ? "": (String) modelData.get("fd_confirmstates");

        //申请人 地址簿对象
        Map<String, String> operators = (Map<String, String>) modelData.get("fd_operators");
        String operators_id = operators.get("id");
        String operators_name = operators.get("name");
        //获取组织架构对象
        SysOrgElement operators_element = (SysOrgElement) sysOrgElementService.findByPrimaryKey(operators_id);
        // 明细表
        List<Map<String, Object>> fd_attchMents = (List<Map<String, Object>>) modelData.get("fd_attchMents");

        for (int i = 0; i < fd_attchMents.size(); i++) {

            Map<String, Object> dMap = fd_attchMents.get(i);

            // 批准金额
            Double wa_cofm_money = (Double) dMap.get("fd_wa_cofm_money");

            // 审批状态
            String confirmstate_att = dMap.get("fd_confirmstate_att") == null? "" : (String) dMap.get("fd_confirmstate_att");
            
        }
    }

 

posted @ 2023-08-30 10:51  dzx坏孩子  阅读(48)  评论(0编辑  收藏  举报