资源说明:二、完善其余功能节点 -- 流程
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 zhongZhuanInfoList = myTaskService.findTransferTask(user,"入库");
// 值栈
ActionContext.getContext().put("zhongZhuanInfoList", zhongZhuanInfoList);
return "findInStoreTaskSUCCESS";
}
// 业务方法 ----- 查询出库环节 的个人任务
public String findOutStoreTask(){
// 登陆用户
User user = (User) getSession().getAttribute("user");
List zhongZhuanInfoList = myTaskService.findTransferTask(user,"出库");
// 值栈
ActionContext.getContext().put("zhongZhuanInfoList", zhongZhuanInfoList);
return "findOutStoreTaskSUCCESS";
}
// 业务方法 ----- 查询签收环节 的个人任务
public String findReceiveInfoTask(){
// 登陆用户
User user = (User) getSession().getAttribute("user");
List zhongZhuanInfoList = myTaskService.findTransferTask(user,"配送签收");
// 值栈
ActionContext.getContext().put("zhongZhuanInfoList", zhongZhuanInfoList);
return "findReceiveInfoTaskSUCCESS";
}
3、 配置struts.xml结果页面
/WEB-INF/pages/zhongzhuan/instore_list.jsp
/WEB-INF/pages/zhongzhuan/outstore_list.jsp
/WEB-INF/pages/zhongzhuan/receiveinfo_list.jsp
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 跳转回任务列表
task_findInStoreTask
task_findOutStoreTask
task_findReceiveInfoTask
在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
在页面抓取中转信息,回显
$.post("${pageContext.request.cotnextPath}/processinstance_showInfo.action", {"pid": pid}, function(data){
$.messager.alert("流程实例信息", data, "info");
});
3、 实例运行的流程图查看
需要在流程图上面 标记每个 流程运行到哪个任务节点
第一步: 为每条实例记录,添加查看流程图函数
');">查看流程图
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 findActiveActivityNames()
@Override
public List findActivityCoordinates(String pid) {
// 1、 根据流程实例id 获得所有活动节点名称
ProcessInstance processInstance = processEngine.getExecutionService().createProcessInstanceQuery().processInstanceId(pid).uniqueResult();
Set activityNames = processInstance.findActiveActivityNames();
// 2、一个活动节点 --- 对应一个坐标对象
List activityCoordinates = new ArrayList();
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();
}
" style="position: absolute;top: 0;left: 0"/>
px;
height: px;
left: px;
top: px;
position: absolute; border-color: red; border-style: solid; border-width: 1px;">
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。