1.在相应的模块创建一个Ibpl文件夹,并创建监听类,此处以会议预约例(此后所有代码都是基于会议-会议预约功能开发):
在com.landray.kmss.km.imeeting.lbpm下创建KmImeetingMeetingBookLbpmProcessFinishListener类,继承自IEventListener类,并重写handleEvent(EventExecutionContext execution, String parameter)方法,代码如下:
public void handleEvent(EventExecutionContext execution, String parameter) throws Exception {
}
在WebContent\WEB-INF\KmssConfig\gh\planning\spring.xml下面注册创建好的bean。
1.WebContent\WEB-INF\KmssConfig\gh\planning\plugin.xml下添加配置
2.参数:
point:配置的参数为流程事件。
model:需要监听的实体类。
unid:监听类的id,不可重复,一般可以用类名。
messageKey:监听事件显示名称,在ApplicationResources.properties内配置的,
此处(py.LiuChengJieShuShi=流程结束)。
eventTypes:lbpmProcessFinishEvent为流程结束事件。
listener:此为实现了IEventListener接口的实现类,此处为1.1新创建
KmImeetingMeetingBookLbpmProcessFinishListener。
-
1.当plugin.xml下配置model的对象流程结束之后,自动进入该实现类的handleEvent方法。
2.具体在流程结束之后需要执行的操作可以在实现类的handleEvent()方法中编写具体实现。
3.此为强制监听,无论是否配置,都会执行监听,区别于非强制监听。
在com.landray.kmss.km.imeeting.model下新增BaseConfig类,继承于BaseAppConfig。
package com.landray.kmss.km.imeeting.model;
import com.landray.kmss.sys.appconfig.model.BaseAppConfig;
/**
* 基本配置信息
*/
public class BaseConfig extends BaseAppConfig {
public BaseConfig() throws Exception {
super();
}
public String getJSPUrl() {
return "/km/imeeting/common/base_config.jsp";
}
@Override
public String getValue(String name) {
return super.getValue(name);
}
/**
* 获取实例
*
* @return
*/
public static BaseConfig get() {
try {
return new BaseConfig();
} catch (Exception e) {
return null;
}
}
/**
* 获取配置项
*
* @param key
* 表单name值
* @return
*/
public static String get(String key) {
try {
return get().getValue(key);
} catch (Exception e) {
return "";
}
}
}
此处为后台配置的显示页面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/resource/jsp/edit_top.jsp"%>
"
onclick="Com_Submit(document.sysAppConfigForm, 'update');">
基础设置
会议预约通知人员
<%@ include file="/resource/jsp/edit_down.jsp"%>
在\WebContent\km\imeeting\tree.jsp中添加如下配置:
<%-- 会议室预约 --%>
n10 = n6.AppendURLChild(" "," ");
/*基础设置*/
n10 = n6.AppendURLChild (
'会议预约通知人员',
' ')
后台==》会议管理后台==》会议预约==》会议预约通知人员
该配置类可以在任意模块下,快速新建一个后台配置类,一般用于后续添加配置项操作。
此处为1中创建的监听类,在流程结束后,向2中配置的人员发送待阅通知。
ISysNotifyMainCoreService类的send(ISysNotifyModel var1, NotifyContext var2, HashMap var3) 方法实现了具体的发送通知功能。
private ISysNotifyMainCoreService sysNotifyMainCoreService;
public ISysNotifyMainCoreService getSysNotifyMainCoreService() {
if (sysNotifyMainCoreService == null) {
sysNotifyMainCoreService = (ISysNotifyMainCoreService) SpringBeanUtil.getBean("sysNotifyMainCoreService");
}
此处为将2中配置的全部人员添加到数组targets0中,并设置为接收人。
BaseConfig baseConfig = new BaseConfig();
String value = baseConfig.getValue("base.costApplyHysq.inform.fdPersonIds");
String[] personIds = value.split(";");
List targets0 = new ArrayList();
ISysOrgPersonService sysOrgPersonService=(ISysOrgPersonService) SpringBeanUtil.getBean("sysOrgPersonService");
List byPrimaryKeys = sysOrgPersonService.findByPrimaryKeys(personIds);
targets0.addAll(byPrimaryKeys);
notifyContext0.setNotifyTarget(targets0);
1.发送类型设置:1代办 2待阅
2.发送标题:显示内容
3.key:必须保证key的唯一,一定不要与其他通知事件重复。
4.链接:设置点击通知之后的跳转地址
//1
notifyContext0.setFlag("2");
//2
notifyContext0.setSubject(ResourceUtil.getString("cost.apply.hysq.finish.notify.subject", "cost-apply"));
notifyContext0.setNotifyType("todo");
//3
notifyContext0.setKey(ResourceUtil.getString("cost.apply.hysq.finish.notify.key", "cost-apply"));
//4
notifyContext0.setLink("/cost/apply/cost_apply_hysq/costApplyHysq.do?method=view&fdId=" + costApplyHysq.getFdId());
拼接好数据后,调用ISysNotifyMainCoreService的send方法即可,发送内容,发送人,点击跳转链接在3.2已配置完成。
getSysNotifyMainCoreService().send(costApplyHysq, notifyContext0, null);
上述1,2,3功能都可单独使用。
例如:
(1)可以A文档完成后修改B文档状态可以在1中直接修改;
(2)需要新增配置选项显示在前端做选择,可以直接用2实现;(3)提交文档发送通知,可以在具体方法的save中实现发送通知功能即可;