重点:
1、 复习 JBPM 工作流开发流程
2、 完成 中转配送流程
3、 流程实例监控 模块
4、 异常处理
5、 二级缓存
1. JBPM开发流程回顾
1.1. 在项目整合工作流框架 (第九天)
导入jar包 (使用 maven坐标导入 )
配置文件 jbpm.cfg.xml 核心配置文件, 默认引入 hibernate 配置文件 jbpm.hibernate.cfg.xml , 如果整合Spring ,引入
<import resource="jbpm.tx.spring.cfg.xml" />
将hibernate 配置权力,交给Spring
引入hbm
<value>jbpm.repository.hbm.xml</value>
<value>jbpm.execution.hbm.xml</value>
<value>jbpm.history.hbm.xml</value>
<value>jbpm.task.hbm.xml</value>
<value>jbpm.identity.hbm.xml</value>
Spring 整合 JBPM ,需要通过 SpringHelper 工厂类,创建 ProcessEngine 流程引擎
<!-- 整合jbpm 配置 -->
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper">
<property name="jbpmCfg" value="jbpm.cfg.xml"></property>
</bean>
<bean id="processEngine" factory-bean="springHelper"
factory-method="createProcessEngine" />
注意问题 :
1、 MySQ整合,需要使用
org.hibernate.dialect.MySQL5InnoDBDialect 方言
2、 JBPM 依赖 juel jar包, 会和 tomcat发布/lib/el-api.jar 冲突, 解决将三个jar放入tomcat/lib,不要放入项目WEB-INF/lib
1.2. 流程定义管理 (与业务无关)
1.2.1. 可以通过模块,将业务流程部署到项目中 ,上传zip压缩包
1.2.2. 流程设计
在线设计器 和 线下设计器 ,通过设计 生成 jpdl.xml 和 png ,在线设计器直接部署,线下设计器,需要上传zip压缩包!
1.2.3. 流程定义查看
1.2.4. 流程图查看
1.3. 如何启动流程 ?
不同业务流程,启动时,方式不同
中转配送流程,通过 工作单审批 功能, 审批工作单,启动中转流程
通过 key 启动 ,默认启动相同 key 最高版本的流程
在流程实例,关联流程变量 ZhongZhuanInfo , 关联流程中 所有任务节点对应 数据
1.4. 任务节点,谁来办理
任务节点,使用 candidate-groups 组任务办理方式 (要根据业务使用 swimlanes)
将系统用户角色管理 和 JBPM用户和组关联 起来!
添加系统用户,添加JBPM的用户
添加系统角色,添加JBPM的用户组
为用户授予角色, 完成JBPM 用户 和 组关系建立
1.5. 任务办理
组任务查看 —- 拾取组任务查看 — 个人任务 — 个人任务 办理
1.5.1. 如何将页面中显示,流程实例变量信息
服务器查询任务列表 List<Task>
,但是Task接口没有获取流程变量方法,使用 TaskImpl 实现类 API ,显示流程业务数据 !
1.5.2. 在任务列表,显示所有流程对应任务,如果跳转到不同的页面办理?
通过 <task>
节点 form 属性,执行任务办理表单(页面), 通过 Task对象获得form页面, 点击办理时,跳转到不同页面办理
1.5.3. 办理任务时,服务器如何操作
将业务数据,关联PO对象,进行持久化
将业务数据,关联流程实例上
办理任务,流转自动流转
在办理中转环节任务时,使用自由流转技术(动态Transition), 通过当前节点,流向任何节点
面试题 : 如果流程已经写好了,需要在流程中 新增一个节点,如何做 ?
方案一: 修改 流程图,重新发布,版本+1 ,再次启动该流程 使用新流程定义 (问题, 原来流程 无法使用 新流程定义 )
方案二 : 修改已经发布的流程定义 ,数据保存 jbpm4_lob 表,是二进制blob ,先通过数据 读取blob,成为 InputStream , 使用 dom4j 加载到内存 ,使用dom4j 为流程添加新节点 ,将内存数据回显 lob表,流程被修改
2. 完成中转配送流程 剩余节点任务
入库、出库、配送签收 三个任务节点 办理
当办理入库任务,跳转 instore_complete.jsp
当办理出库任务,跳转 outstore_complete.jsp
当办理配送签收任务时,跳转 receiveinfo_complete.jsp
编写 三个任务节点 办理的业务代码
入库, TaskAction 提供 instorecomplete 方法
出库: TaskAction 提供 outstorecomplete 方法
配送签收 : TaskAction 提供 receiveinfocomplete 方法
在 BaseService 注入 inStoreDAO、outStoreDAO、receiveGoodsInfoDAO