宅急送 项目第十二天 项目总结

重点:
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

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
二、完善其余功能节点 -- 流程 1、 将 提供其余节点页面 复制 pages/zhongzhuan 入库(点击左侧菜单入库) ----- Action (查询入库任务列表)---- instore_list.jsp ---- 办理任务 ---- instore_complete.jsp(提交form) --- Action (办理任务流转到下一个节点) 修改function 数据表 入库 task_findInStoreTask.action 出库 task_findOutStoreTask.action 签收 task_findReceiveInfoTask.action 2、 查询任务列表 TaskAction // 业务方法 ----- 查询入库环节 的个人任务 public String findInStoreTask(){ // 登陆用户 User user = (User) getSession().getAttribute("user"); List<ZhongZhuanInfo> zhongZhuanInfoList = myTaskService.findTransferTask(user,"入库"); // 值栈 ActionContext.getContext().put("zhongZhuanInfoList", zhongZhuanInfoList); return "findInStoreTaskSUCCESS"; } // 业务方法 ----- 查询出库环节 的个人任务 public String findOutStoreTask(){ // 登陆用户 User user = (User) getSession().getAttribute("user"); List<ZhongZhuanInfo> zhongZhuanInfoList = myTaskService.findTransferTask(user,"出库"); // 值栈 ActionContext.getContext().put("zhongZhuanInfoList", zhongZhuanInfoList); return "findOutStoreTaskSUCCESS"; } // 业务方法 ----- 查询签收环节 的个人任务 public String findReceiveInfoTask(){ // 登陆用户 User user = (User) getSession().getAttribute("user"); List<ZhongZhuanInfo> zhongZhuanInfoList = myTaskService.findTransferTask(user,"配送签收"); // 值栈 ActionContext.getContext().put("zhongZhuanInfoList", zhongZhuanInfoList); return "findReceiveInfoTaskSUCCESS"; } 3、 配置struts.xml结果页面 <result name="findInStoreTaskSUCCESS">/WEB-INF/pages/zhongzhuan/instore_list.jsp</result> <result name="findOutStoreTaskSUCCESS">/WEB-INF/pages/zhongzhuan/outstore_list.jsp</result> <result name="findReceiveInfoTaskSUCCESS">/WEB-INF/pages/zhongzhuan/receiveinfo_list.jsp</result> 4、 Action办理对应节点任务 // 业务方法 ---- 办理入库任务 public String instorecomplete(){ InStore inStore = new InStore(); inStore.setInfo(info); inStore.setUpdateTime(new Date()); // 调用业务层 myTaskService.completeInStore(taskId, inStore); return "instorecompleteSUCCESS"; } // 业务方法 ---- 办理出库任务 public String outstorecomplete(){ OutStore outStore = new OutStore(); outStore.setInfo(info); outStore.setUpdateTime(new Date()); // 调用业务层 myTaskService.completeOutStore(taskId, outStore); return "outstorecompleteSUCCESS"; } // 业务方法 ---- 办理签收任务 public String receiveinfocomplete(){ ReceiveGoodsInfo receiveGoodsInfo = new ReceiveGoodsInfo(); receiveGoodsInfo.setInfo(info); receiveGoodsInfo.setUpdateTime(new Date()); // 调用业务层 myTaskService.completeReceiveGoodsInfo(taskId, receiveGoodsInfo); return "receiveinfocompleteSUCCESS"; } 5、 struts.xml 跳转回任务列表 <result name="instorecompleteSUCCESS" type="redirectAction">task_findInStoreTask</result> <result name="outstorecompleteSUCCESS" type="redirectAction">task_findOutStoreTask</result> <result name="receiveinfocompleteSUCCESS" type="redirectAction">task_findReceiveInfoTask</result> 在JBPM在流程结束时,发生异常 org.springframework.dao.DataIntegrityViolationException: could not delete: [org.jbpm.pvm.internal.model.ExecutionImpl#50001]; SQL [delete from JBPM4_EXECUTION where DBID_=? and DBVERSION_=?]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.pvm.internal.model.ExecutionImpl#50001] 解决: hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect ======================================================================================================================== 三、 流程实例 查看管理 1、 查询实例功能 查询系统正在运行实例 ExecutionService.createProcessInstanceQuery() 查询系统已经完成的实例 HistoryService.createHistoryProcessInstanceQuery() json/admin/json { id:1005, pId:100, name:"查看正在运行的任务", t:"",page:"page_workflow_processinstance.action"} 改为 { id:1005, pId:100, name:"查看正在运行的任务", t:"",page:"processinstance_list.action"} 2、 每个运行流程实例,关联流程变量 ZhongZhuanInfo 包含所有流程信息 根据流程实例id 查询ZhongZhuanInfo数据 (ZhongZhuanInfo) processEngine.getExecutionService().getVariable(pid, "zhongZhuanInfo"); 服务器返回 中转信息 result = zhongZhuanInfo.toString(); <result name="showInfoSUCCESS" type="json"> <param name="root">result</param> </result> 在页面抓取中转信息,回显 $.post("${pageContext.request.cotnextPath}/processinstance_showInfo.action", {"pid": pid}, function(data){ $.messager.alert("流程实例信息", data, "info"); }); 3、 实例运行的流程图查看 需要在流程图上面 标记每个 流程运行到哪个任务节点 第一步: 为每条实例记录,添加查看流程图函数 <a href="#" class="easyui-linkbutton" onclick="showPng('<s:property value="#processInstance.id"/>');">查看流程图</a> function showPng(pid){ alert("查看" + pid + "对应流程图"); } 第二步: 流程图查看Action 可以复用 ---- processdefinition_showpng.action?deploymentId= & resourceName= RepositoryService.getResourceAsStream(java.lang.String deploymentId, java.lang.String resourceName) * resourceName 可以通过 deploymentId 动态获得 RepositoryService repositoryService = processEngine.getRepositoryService(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).uniqueResult(); resourceName = processDefinition.getImageResourceName(); 第三步: 点击查看流程图, 获得活动节点坐标 通过 window.showModalDialog() 查看流程图页面 (弹出窗口,显示页面 url地址不能修改 ) function showPng(pid){ //alert("查看" + pid + "对应流程图"); window.showModalDialog("${pageContext.request.contextPath}/processinstance_findactivityinfo.action?pid="+pid); } 查看某一个具体活动节点坐标 String processDefinitionId = "test-1"; // 流程定义的id String activityName = "start1"; // 活动的名称 ActivityCoordinates c = processEngine.getRepositoryService() .getActivityCoordinates(processDefinitionId, activityName); 查看当前流程实例活动所有节点名称 ProcessInstance的 java.util.Set<java.lang.String> findActiveActivityNames() @Override public List<ActivityCoordinates> findActivityCoordinates(String pid) { // 1、 根据流程实例id 获得所有活动节点名称 ProcessInstance processInstance = processEngine.getExecutionService().createProcessInstanceQuery().processInstanceId(pid).uniqueResult(); Set<String> activityNames = processInstance.findActiveActivityNames(); // 2、一个活动节点 --- 对应一个坐标对象 List<ActivityCoordinates> activityCoordinates = new ArrayList<ActivityCoordinates>(); for(String activityName: activityNames){ // 获得每一个活动节点名称 String processDefinitionId = processInstance.getProcessDefinitionId();//流程定义id ActivityCoordinates activityCoordinate = processEngine.getRepositoryService().getActivityCoordinates(processDefinitionId, activityName); activityCoordinates.add(activityCoordinate); } return activityCoordinates; } ============ 为了在下一个页面 可以显示流程图, 根据实例id 查询 发布id @Override public String findDeploymentIdByProcessInstanceId(String pid) { ProcessInstance processInstance = processEngine.getExecutionService().createProcessInstanceQuery().processInstanceId(pid).uniqueResult(); ProcessDefinition processDefinition = processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionId(processInstance.getProcessDefinitionId()).uniqueResult(); return processDefinition.getDeploymentId(); } <img src="${pageContext.request.contextPath }/processdefinition_showpng.action?deploymentId=<s:property value="#deploymentId"/>" style="position: absolute;top: 0;left: 0"/> <s:iterator value="#activityCoordinates" var="activityCoordinate"> <div style="width: <s:property value="#activityCoordinate.width"/>px; height: <s:property value="#activityCoordinate.height"/>px; left: <s:property value="#activityCoordinate.x"/>px; top: <s:property value="#activityCoordinate.y"/>px; position: absolute; border-color: red; border-style: solid; border-width: 1px;"> </s:iterator>
宅急送物流管理系统是一个基于浏览器的B/S架构系统,用于进行各种数据信息的管理功能。它包括前后台系统,实现了线上操作和各项功能,如用户管理、登录注册、权限管理等,同时还能对各类宅急送物流管理系统相关的实体进行管理。 在实现宅急送物流管理系统的课程设计中,需要先收集其他宅急送物流管理系统产品进行分析,然后深入进行web系统的数据库设计,并基于MVC模式进行代码编写。页面搭建方面可以使用Layui进行快速开发,最终完成宅急送物流管理系统各个模块的开发。 随着改革开放和经济发展,我国物流行业快速发展,但在某些地区,物流业的发展还不能适应人们的需求。随着经济的快速发展和信息化的普及,在线物流投递和查询变得越来越重要。为了提高宅急送物流的管理水平,开发了JSP宅急送物流管理系统。该系统包括前端和后端两大板块,功能模块涵盖了系统用户管理、订单管理、车辆管理、企业公告、新闻资讯管理、品牌促销管理、配送网点管理、线路设置、运费设置、系统管理等。其中,用户注册、订单下定和订单查询模块是最重要的功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [基于web的宅急送物流管理系统(完整源码+论文全套+教学视频)](https://blog.csdn.net/weixin_39978749/article/details/117236793)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [JSP宅急送物流管理系统](https://blog.csdn.net/QQ55318293/article/details/128171857)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值