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("待办内容不匹配短信,不予发送!");
}
}
}
验证#
涉及到流程的模块均会触发此代码进行监听,代码中手动写死了仅处理公文模块,且流程节点需要配置短信通知方式才会被触发。