banner
biuaxia

biuaxia

"万物皆有裂痕,那是光进来的地方。"
github
bilibili
tg_channel

藍凌全局攔截流程節點

title: 藍凌全局攔截流程節點
date: 2021-09-06 15:16:00
comment: false
toc: true
category:

  • Landray
    tags:
  • Landray
  • 全局
  • 攔截
  • 流程
  • 節點
  • 監聽

spring.xml#

spring.xml 完整內容為:

<?xml version="1.0" encoding="UTF-8"?>  
<beans  
        xmlns="http://www.springframework.org/schema/beans"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">  

    <bean  
            id="beanName"  
            class="packageName"/>  

</beans>  

plugin.xml#

plugin.xml 完整內容為:

<?xml version="1.0" encoding="UTF-8"?>  
<plugin  
	xmlns="http://www.example.org/plugin-config"  
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
	xsi:schemaLocation="http://www.example.org/plugin-config ../../plugin.xsd ">  

    <!--短信審批人節點事件-->  
	<extension  
			point="com.landray.kmss.lbpm.engine.event">  
		<item name="listener">  
			<param name="unid" value="kmImissiveSmsMainListener"/>  
			<param name="messageKey" value=""/>  
			<param name="eventTypes" value="manualNodeHanlderGetterEvent"/>  
			<param name="listener" value="kmImissiveSmsMainListener"/>  
			<param name="enforce" value="true"/>  
		</item>  
	</extension>  

</plugin>  

反向建立對應的 Bean 即可。

Listener#

完整代碼如下:

package com.landray.kmss.jtt.sms.listener;  

import cn.hutool.core.collection.CollUtil;  
import cn.hutool.core.convert.Convert;  
import cn.hutool.core.util.ArrayUtil;  
import cn.hutool.core.util.StrUtil;  
import cn.hutool.json.JSONUtil;  
import com.landray.kmss.common.model.IBaseModel;  
import com.landray.kmss.km.imissive.model.KmImissiveMain;  
import com.landray.kmss.sys.lbpm.engine.builder.ManualNodeDefinition;  
import com.landray.kmss.sys.lbpm.engine.builder.ProcessDefinition;  
import com.landray.kmss.sys.lbpm.engine.manager.event.EventExecutionContext;  
import com.landray.kmss.sys.lbpm.engine.manager.event.IEventListener;  
import com.landray.kmss.sys.lbpmservice.node.support.ManualNodeHanlderGetterEvent;  
import com.landray.kmss.sys.organization.interfaces.ISysOrgCoreService;  
import com.landray.kmss.sys.organization.model.SysOrgPerson;  
import com.landray.kmss.sys.right.interfaces.ExtendAuthModel;  
import com.landray.kmss.util.SpringBeanUtil;  
import com.landray.kmss.util.UserUtil;  
import org.apache.commons.logging.Log;  
import org.apache.commons.logging.LogFactory;  

import java.util.ArrayList;  
import java.util.List;  

public class GlobalSmsListener implements IEventListener {  

    private static final Log log = LogFactory.getLog(GlobalSmsListener.class);  

    @Override  
    public void handleEvent(EventExecutionContext execution, String s) throws Exception {  
        ManualNodeHanlderGetterEvent manualNodeHanlderGetterEvent = (ManualNodeHanlderGetterEvent) execution.getEvent();  
        ManualNodeDefinition manualNodeDefinition = manualNodeHanlderGetterEvent.getManualNodeDefinition();  

        log.info("HandlerIds類型: " + JSONUtil.toJsonStr(manualNodeDefinition.getHandlerSelectType()));  

        ProcessDefinition processDefinition = manualNodeDefinition.getProcessDefinition();  

        // Model資訊  
        IBaseModel mainModel = execution.getMainModel();  
        String notifyType = processDefinition.getNotifyType();  

        boolean classResult = mainModel instanceof KmImissiveMain;  
        if (!classResult) {  
            return;  
        }  

        ExtendAuthModel kmImissiveMain = Convert.convert(ExtendAuthModel.class, mainModel);  

        String docSubject = kmImissiveMain.getDocSubject();  
        log.info("預置信息-docSubject:" + docSubject);  

        final String mobileStr = "mobile";  
        log.info("短信匹配-提示類型:" + notifyType);  
        log.info("短信匹配:" + StrUtil.containsAny(notifyType, mobileStr));  

        if (StrUtil.containsAny(notifyType, mobileStr)) {  
            String handlerIds = manualNodeDefinition.getHandlerIds();  
            log.info("handlerIds匹配:" + JSONUtil.toJsonStr(handlerIds));  
            List<String> userIdList = StrUtil.splitTrim(handlerIds, ';');  

            ISysOrgCoreService sysOrgCoreService =  
                    (ISysOrgCoreService) SpringBeanUtil.getBean("sysOrgCoreService");  
            String[] userIdArray = ArrayUtil.toArray(userIdList, String.class);  
            log.info("userIdArray匹配:" + JSONUtil.toJsonStr(userIdArray));  
            try {  
                List byPrimaryKeys = sysOrgCoreService.findByPrimaryKeys(userIdArray);  
                // 嘗試解析崗位為具體人員  
                List expandToPerson = sysOrgCoreService.expandToPerson(byPrimaryKeys);  
                // 嘗試解析通用崗位  
                List parseSysOrgRole = sysOrgCoreService.parseSysOrgRole(byPrimaryKeys,  
                        sysOrgCoreService.findByPrimaryKey(  
                                UserUtil.getUser().getFdId()));  

                // 加入集合  
                List result = new ArrayList(2 * (expandToPerson.size() + parseSysOrgRole.size()));  
                result.addAll(expandToPerson);  
                result.addAll(parseSysOrgRole);  

                if (CollUtil.isNotEmpty(result)) {  
                    for (Object itemObj : result) {  
                        try {  
                            SysOrgPerson user = Convert.convert(SysOrgPerson.class, itemObj);  
                            String fdName = user.getFdName();  
                            String fdMobileNo = user.getFdMobileNo();  
                            if (StrUtil.isBlank(fdMobileNo)) {  
                                log.error("接收人 [" + fdName + "] 手機號為空,不予發送!");  
                                continue;  
                            }  
                        } catch (Exception e) {  
                            log.error("發送信息失敗,可能由於接收對象不正確導致。");  
                            log.error(itemObj.toString());  
                            return;  
                        }  
                    }  
                }  
            } catch (Exception e) {  
                log.error(e.getMessage());  
            }  
        } else {  
            log.debug("待辦內容不匹配短信,不予發送!");  
        }  
    }  

}  

驗證#

涉及到流程的模塊均會觸發此代碼進行監聽,代碼中手動寫死了僅處理公文模塊,且流程節點需要配置短信通知方式才會被觸發。

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。