Commit 952dcef5 by 罗绍泽

流程实例详情实现,考虑后期加一个环节可处理人列表,就是配置环节的时候的人员列表,但是activiti中暂时没有找到可以获取的方法

parent 539975bc
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
<property name="taskService" ref="taskService"></property> <property name="taskService" ref="taskService"></property>
<property name="historyService" ref="historyService"></property> <property name="historyService" ref="historyService"></property>
<property name="repositoryService" ref="repositoryService"></property> <property name="repositoryService" ref="repositoryService"></property>
<property name="systemBackDAO" ref="systemBackDAO"></property>
</bean> </bean>
<bean id="ProcdefinitionInitLinkBusiness" class="com.gaowj.business.procdefinitionInitlink.ProcdefinitionInitLinkBusinessImpl"> <bean id="ProcdefinitionInitLinkBusiness" class="com.gaowj.business.procdefinitionInitlink.ProcdefinitionInitLinkBusinessImpl">
......
...@@ -304,6 +304,12 @@ function openProcEditRow(editUrl,is_row,is_title,is_max,is_width,is_height,is_le ...@@ -304,6 +304,12 @@ function openProcEditRow(editUrl,is_row,is_title,is_max,is_width,is_height,is_le
saveBox('detail','list'); saveBox('detail','list');
} }
}, { }, {
text : '退回',
iconCls : 'icon-ext-44_08',
handler : function() {
lastBox('detail','list');
}
}, {
text : '下一步', text : '下一步',
iconCls : 'icon-ext-44_08', iconCls : 'icon-ext-44_08',
handler : function() { handler : function() {
...@@ -327,6 +333,24 @@ function openProcEditRow(editUrl,is_row,is_title,is_max,is_width,is_height,is_le ...@@ -327,6 +333,24 @@ function openProcEditRow(editUrl,is_row,is_title,is_max,is_width,is_height,is_le
} }
/****/ /****/
//弹出层流程编辑上一步(退回)按扭
function lastBox(Box_id,List_id) {
if(Box_id==null||Box_id==''||Box_id==undefined)
Box_id='detail';
if(List_id==null||List_id==''||List_id==undefined)
List_id='list';
var returnIsValid = $('#inputForm').form('validate');
if (returnIsValid) {
//$("#inputForm").submit();
var query = $("#inputForm").getFormVal();
var v_result = backProc(query);
if (v_result != null && v_result != undefined) {
closeBox(Box_id);
$.messager.alert('提示', v_result.VALUE);
}
}
}
//弹出层流程编辑下一步按扭 //弹出层流程编辑下一步按扭
function nextBox(Box_id,List_id) { function nextBox(Box_id,List_id) {
if(Box_id==null||Box_id==''||Box_id==undefined) if(Box_id==null||Box_id==''||Box_id==undefined)
......
...@@ -29,7 +29,7 @@ var ls_module_id='2'; ...@@ -29,7 +29,7 @@ var ls_module_id='2';
var ls_ywlx = 'YBYW'; var ls_ywlx = 'YBYW';
//定义grid列表 //定义grid列表
var ls_title="选择人员"; var ls_title=null;
var is_column = [ [ var is_column = [ [
{field : 'LINK_NAME',title : '环节名',width : 300,align : 'center'}, {field : 'LINK_NAME',title : '环节名',width : 300,align : 'center'},
{field : 'PROC_DEFIN_KEY',title : 'PROC_DEFIN_KEY',width : 300,align : 'center'} {field : 'PROC_DEFIN_KEY',title : 'PROC_DEFIN_KEY',width : 300,align : 'center'}
......
...@@ -412,7 +412,7 @@ function procdefinitionImg(index){ ...@@ -412,7 +412,7 @@ function procdefinitionImg(index){
width : 1000, width : 1000,
height : 500, height : 500,
title : '流程图', title : '流程图',
content:'<img src="procdefinitionData_showProcdefinitionImg?deploymentId='+is_row[0].DEPLOYMENT_ID+'" />' content:'<div style="height:100%;overflow:auto;"><img src="procdefinitionData_showProcdefinitionImg?deploymentId='+is_row[0].DEPLOYMENT_ID+'" /></div>'
}); });
} }
...@@ -430,5 +430,5 @@ function choosePeopleRow(index){ ...@@ -430,5 +430,5 @@ function choosePeopleRow(index){
success:function(data){ success:function(data){
} }
}); });
openViewIframRow("choosePeople","procdefinitionView_procdefiChoosePeopleTab?DEPLOYMENT_ID="+is_row[0].DEPLOYMENT_ID,is_row[0],"选人列表",true,0.95,0.95,0,0); openViewIframRow("choosePeople","procdefinitionView_procdefiChoosePeopleTab?DEPLOYMENT_ID="+is_row[0].DEPLOYMENT_ID,is_row[0],"环节配置",true,0.95,0.95,0,0);
} }
...@@ -541,6 +541,64 @@ function showProcinstanceImg(index) { ...@@ -541,6 +541,64 @@ function showProcinstanceImg(index) {
width : 1000, width : 1000,
height : 500, height : 500,
title : '流程图', title : '流程图',
content:'<img src="procinstanceData_showProcinstanceImg?instanceId='+is_row[0].INSTANCE_ID+'" />' href:'procinstanceView_procinstanceTabHistory?instanceId='+is_row[0].INSTANCE_ID,
onLoad:function(){
$('#historyTable').datagrid({
iconCls:$.getJwWindowPic(),
url:gaowj.WEB_APP_NAME+"/procinstanceData_procinstanceHistory",
queryParams : {
processInstanceId:$("#instanceIdHide").val()
},//查询参数
rownumbers : true,//显示索引号
singleSelect : false,//是否多选
fitColumns : false,//是否撑满
autoRowHeight : false,//设定高度
rowStyler :function(index,row){return rowstyler(index,row);},
pagination : true,//分页显示
pageSize : rows,//显示行数
pageList : listPageSize,//条数选择
striped : true, //是否隔行显示
remoteSort : false,//是否从服务器排序
frozenColumns : [[
{
field : 'ck',
checkbox : true
}
]],
columns : [ [ {
field : 'ACTIVITY_NAME',
title : '环节名称',
width : 200,
align : 'center',
}, {
field : 'ASSIGNEE',
title : '办理人',
width : 200,
align : 'center',
}, {
field : 'START_TIME',
title : '开始时间',
width : 250,
align : 'center',
}, {
field : 'END_TIME',
title : '结束时间',
width : 250,
align : 'center',
} ] ],
onLoadSuccess : function() {
if(is_opetipmenuwidth==null){
is_opetipmenuwidth = 60;
}
}
});
}
}); });
}
//流程退回
function backProc(is_entity){
var v_result = proctaskModule.act.back(is_entity);
$('#list').datagrid('reload');
return v_result;
} }
\ No newline at end of file
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<div style="overflow:auto;height:100%;">
<div style="overflow:auto;">
<img src="procinstanceData_showProcinstanceImg?instanceId=${instanceId}" />
</div>
<input type="hidden" id="instanceIdHide" value="${instanceId}" />
<div id="historyTable"></div>
</div>
...@@ -16,6 +16,8 @@ proctaskModule.prototype.updateInfo = function(){}; ...@@ -16,6 +16,8 @@ proctaskModule.prototype.updateInfo = function(){};
proctaskModule.prototype.updateInfoToNext = function(){}; proctaskModule.prototype.updateInfoToNext = function(){};
//删除流程实例 //删除流程实例
proctaskModule.prototype.deleteInfo = function(){}; proctaskModule.prototype.deleteInfo = function(){};
//退回流程实例
proctaskModule.prototype.back = function(){};
//创建一个数据操作对象,然后再后续使用 //创建一个数据操作对象,然后再后续使用
proctaskModule.act = new proctaskModule("json").delegate("proctaskAct"); proctaskModule.act = new proctaskModule("json").delegate("proctaskAct");
......
...@@ -438,6 +438,6 @@ function showProcinstanceImg(index) { ...@@ -438,6 +438,6 @@ function showProcinstanceImg(index) {
width : 1000, width : 1000,
height : 500, height : 500,
title : '流程图', title : '流程图',
content:'<img src="procinstanceData_showProcinstanceImg?instanceId='+is_row[0].INSTANCE_ID+'" />' content:'<div style="height:100%;overflow:auto;"><img src="procinstanceData_showProcinstanceImg?instanceId='+is_row[0].INSTANCE_ID+'" /></div>'
}); });
} }
\ No newline at end of file
...@@ -18,6 +18,12 @@ import com.gaowj.business.ProcinstanceBusiness; ...@@ -18,6 +18,12 @@ import com.gaowj.business.ProcinstanceBusiness;
import com.gaowj.business.comp.BusinessManager; import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.util.SessionUtil; import com.gaowj.business.util.SessionUtil;
/**
* 流程任务新建时,设置该任务在数据库存储的人员列表
*
* @author luosz
*
*/
public class AssignmentTaskListener implements TaskListener { public class AssignmentTaskListener implements TaskListener {
/** /**
...@@ -28,49 +34,28 @@ public class AssignmentTaskListener implements TaskListener { ...@@ -28,49 +34,28 @@ public class AssignmentTaskListener implements TaskListener {
@Override @Override
public void notify(DelegateTask task) { public void notify(DelegateTask task) {
ApplicationContext context = ContextLoaderListener.getCurrentWebApplicationContext(); ApplicationContext context = ContextLoaderListener.getCurrentWebApplicationContext();
HistoryService historyService=(HistoryService) context.getBean("historyService"); HistoryService historyService = (HistoryService) context.getBean("historyService");
// 获取流程历史中已执行节点,并按照节点在流程中执行先后顺序排序 // 获取流程历史中已执行节点,并按照节点在流程中执行先后顺序排序
List<HistoricActivityInstance> historicActivityInstanceList = historyService.createHistoricActivityInstanceQuery().processInstanceId(task.getProcessInstanceId()).orderByHistoricActivityInstanceId().asc().list(); List<HistoricActivityInstance> historicActivityInstanceList = historyService.createHistoricActivityInstanceQuery().processInstanceId(task.getProcessInstanceId()).orderByHistoricActivityInstanceId().asc().list();
System.out.println("历史环节数量:"+historicActivityInstanceList.size());
if (historicActivityInstanceList.size() == 0) {
if(historicActivityInstanceList.size()==0){ // 如果历史环节数量为0,则表示这个实例第一次启动,第一个环节默认为当前登陆人
//如果历史环节数量为0,则表示这个实例第一次启动,第一个环节默认为当前登陆人 // task.setAssignee(SessionUtil.getCode());
//task.setAssignee(SessionUtil.getCode()); List<String> listUserId = new ArrayList<String>();
List<String> listUserId=new ArrayList<String>();
listUserId.add(SessionUtil.getCode()); listUserId.add(SessionUtil.getCode());
task.addCandidateUsers(listUserId); task.addCandidateUsers(listUserId);
}else{ } else {
//读取环节人员配置信息,循环设置人员 // 读取环节人员配置信息,循环设置人员
ProcdefiChooseUserBusiness procdefiChooseUserBusiness=(ProcdefiChooseUserBusiness) context.getBean("ProcdefiChooseUserBusiness"); ProcdefiChooseUserBusiness procdefiChooseUserBusiness = (ProcdefiChooseUserBusiness) context.getBean("ProcdefiChooseUserBusiness");
Map<String, Object> query=new HashMap<String, Object>(); Map<String, Object> query = new HashMap<String, Object>();
query.put("LINK_KEY", task.getTaskDefinitionKey().toString()); query.put("LINK_KEY", task.getTaskDefinitionKey().toString());
List<Map<String, Object>> listUser=procdefiChooseUserBusiness.list_procdefi_chooseUser(query); List<Map<String, Object>> listUser = procdefiChooseUserBusiness.list_procdefi_chooseUser(query);
List<String> listUserId=new ArrayList<String>(); List<String> listUserId = new ArrayList<String>();
for(Map<String, Object> user:listUser){ for (Map<String, Object> user : listUser) {
listUserId.add(user.get("CODE").toString()); listUserId.add(user.get("CODE").toString());
} }
task.addCandidateUsers(listUserId); task.addCandidateUsers(listUserId);
} }
/*System.out.println(task.getAssignee());
System.out.println(task.getCategory());
System.out.println(task.getDescription());
System.out.println(task.getEventName());
System.out.println(task.getExecutionId());
System.out.println(task.getFormKey());
System.out.println(task.getId());
System.out.println(task.getName());
System.out.println(task.getOwner());
System.out.println(task.getPriority());
System.out.println(task.getProcessDefinitionId());
System.out.println(task.getProcessInstanceId());
System.out.println(task.getTaskDefinitionKey());
System.out.println(task.getTenantId());
System.out.println(task.getVariables().toString());*/
//
} }
} }
package com.gaowj.activiti.listener;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import com.gaowj.business.util.SessionUtil;
/**
* 任务完成时,设置实际的办理人为当前登录人
*
* @author luosz
*
*/
public class AssignmentTaskListenerComplete implements TaskListener {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void notify(DelegateTask task) {
task.setAssignee(SessionUtil.getCode());
}
}
...@@ -58,6 +58,16 @@ public interface ProcinstanceBusiness { ...@@ -58,6 +58,16 @@ public interface ProcinstanceBusiness {
* @throws BusinessException * @throws BusinessException
*/ */
Page<Map<String, Object>> list_proc_instance(int pageNo, int pageSize, Map<String, Object> query) throws BusinessException; Page<Map<String, Object>> list_proc_instance(int pageNo, int pageSize, Map<String, Object> query) throws BusinessException;
/**
* 获取历史任务列表
* @param pageNo
* @param pageSize
* @param query
* @return
* @throws BusinessException
*/
List<Map<String, Object>> list_proc_instance_history(String processInstanceId) throws BusinessException;
/** /**
* 获取所有记录 * 获取所有记录
......
...@@ -22,4 +22,6 @@ public interface ProctaskBusiness { ...@@ -22,4 +22,6 @@ public interface ProctaskBusiness {
Map<String, Object> update(Map<String, Object> entity) throws BusinessException; Map<String, Object> update(Map<String, Object> entity) throws BusinessException;
Map<String, Object> updateToNext(String taskId,Map<String, Object> entity) throws BusinessException; Map<String, Object> updateToNext(String taskId,Map<String, Object> entity) throws BusinessException;
Map<String, Object> back(Map<String, Object> entity) throws BusinessException;
} }
...@@ -270,6 +270,9 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus ...@@ -270,6 +270,9 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus
Element taskListener=extensionElements.addElement("activiti:taskListener"); Element taskListener=extensionElements.addElement("activiti:taskListener");
taskListener.addAttribute("event", "create"); taskListener.addAttribute("event", "create");
taskListener.addAttribute("class", "com.gaowj.activiti.listener.AssignmentTaskListener"); taskListener.addAttribute("class", "com.gaowj.activiti.listener.AssignmentTaskListener");
Element taskListenerComplete=extensionElements.addElement("activiti:taskListener");
taskListenerComplete.addAttribute("event", "complete");
taskListenerComplete.addAttribute("class", "com.gaowj.activiti.listener.AssignmentTaskListenerComplete");
} }
} }
bpmText=doc.asXML(); bpmText=doc.asXML();
......
...@@ -21,6 +21,7 @@ import org.activiti.engine.RuntimeService; ...@@ -21,6 +21,7 @@ import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService; import org.activiti.engine.TaskService;
import org.activiti.engine.history.HistoricActivityInstance; import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricProcessInstance; import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
...@@ -31,6 +32,7 @@ import com.gaowj.business.ProcinstanceBusiness; ...@@ -31,6 +32,7 @@ import com.gaowj.business.ProcinstanceBusiness;
import com.gaowj.business.exception.BusinessException; import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.formtable.formtableDAO; import com.gaowj.business.formtable.formtableDAO;
import com.gaowj.business.procdefinition.procdefinitionDAO; import com.gaowj.business.procdefinition.procdefinitionDAO;
import com.gaowj.business.system.SystemBackDAO;
import com.gaowj.business.util.Page; import com.gaowj.business.util.Page;
import com.gaowj.business.util.SessionUtil; import com.gaowj.business.util.SessionUtil;
...@@ -49,6 +51,8 @@ public class ProcinstanceBusinessImpl implements ProcinstanceBusiness { ...@@ -49,6 +51,8 @@ public class ProcinstanceBusinessImpl implements ProcinstanceBusiness {
private HistoryService historyService; private HistoryService historyService;
private RepositoryService repositoryService; private RepositoryService repositoryService;
private SystemBackDAO systemBackDAO;
public RuntimeService getRuntimeService() { public RuntimeService getRuntimeService() {
return runtimeService; return runtimeService;
...@@ -107,6 +111,14 @@ public class ProcinstanceBusinessImpl implements ProcinstanceBusiness { ...@@ -107,6 +111,14 @@ public class ProcinstanceBusinessImpl implements ProcinstanceBusiness {
this.repositoryService = repositoryService; this.repositoryService = repositoryService;
} }
public SystemBackDAO getSystemBackDAO() {
return systemBackDAO;
}
public void setSystemBackDAO(SystemBackDAO systemBackDAO) {
this.systemBackDAO = systemBackDAO;
}
@Override @Override
public Map<String, Object> insert_proc_instance(Map<String, Object> entity) throws BusinessException { public Map<String, Object> insert_proc_instance(Map<String, Object> entity) throws BusinessException {
//流程定义id //流程定义id
...@@ -443,36 +455,53 @@ public class ProcinstanceBusinessImpl implements ProcinstanceBusiness { ...@@ -443,36 +455,53 @@ public class ProcinstanceBusinessImpl implements ProcinstanceBusiness {
page.setItems(items); page.setItems(items);
return page; return page;
/*// 计算起始记录 }
int pageStart = (pageNo - 1) * pageSize;
ProcessInstanceQuery leaveDynamicQuery = runtimeService.createProcessInstanceQuery() @Override
.orderByProcessInstanceId().desc().active(); public List<Map<String, Object>> list_proc_instance_history(String processInstanceId) throws BusinessException{
if(query.get("PROCDEFINITION_UUID")!=null&&!"".equals(query.get("PROCDEFINITION_UUID"))){ List<HistoricActivityInstance> listHistoricActivityInstance = historyService // 历史相关Service
Map<String, Object> query2=new HashMap<String, Object>(); .createHistoricActivityInstanceQuery() // 创建历史活动实例查询
query2.put("UUID", query.get("PROCDEFINITION_UUID")); .processInstanceId(processInstanceId) // 执行流程实例id
String deploymentKey=procdefinitionDAO.list_procde_finition(query2).get(0).get("DEPLOYMENT_KEY").toString(); //.finished()
.orderByHistoricActivityInstanceStartTime().asc().list();
if(deploymentKey!=null&&!"".equals(deploymentKey)){
leaveDynamicQuery.processDefinitionKey(deploymentKey); List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
List<String> listAssignee=new ArrayList<String>();
for (HistoricActivityInstance hai : listHistoricActivityInstance) {
if(hai.getActivityName()==null){
continue;
} }
if(hai.getAssignee()==null&&hai.getEndTime()!=null){
//如果没有办理人,但是有结束时间,任务该环节是开始环节,默认剔除
continue;
}
if(hai.getAssignee()!=null){
listAssignee.add(hai.getAssignee());
}
Map<String,Object> entry=new HashMap<String, Object>();
entry.put("ACTIVITY_NAME", hai.getActivityName());
entry.put("ASSIGNEE", hai.getAssignee()==null?"":hai.getAssignee());
entry.put("START_TIME", hai.getStartTime());
entry.put("END_TIME", hai.getEndTime()==null?"":hai.getEndTime());
list.add(entry);
} }
List<ProcessInstance> list = leaveDynamicQuery.listPage(pageStart, pageSize);
List<Map<String, Object>> items=new ArrayList<Map<String,Object>>(); Map<String,Object> query=new HashMap<String, Object>();
for(ProcessInstance processInstance:list){ query.put("CODE_IN", listAssignee);
Map<String, Object> item=new HashMap<String, Object>(); List<Map<String, Object>> items = systemBackDAO.listLoginUserInfo(query);
items.add(item);
outer:
item.put("NAME", processInstance.getName()); for(Map<String, Object> m:list){
for(Map<String, Object> user:items){
if(m.get("ASSIGNEE")!=null&&!"".equals(m.get("ASSIGNEE"))){
if(m.get("ASSIGNEE").equals(user.get("CODE"))){
m.put("ASSIGNEE",user.get("EMNAME"));
continue outer;
}
}
}
} }
return list;
int count=(int) leaveDynamicQuery.count();
// 创建分页对象
Page<Map<String, Object>> page = new Page<Map<String, Object>>();
page.setStart(pageStart);
page.setLimit(pageSize);
page.setCount(count);
page.setItems(items);
return page;*/
} }
@Override @Override
......
...@@ -24,15 +24,15 @@ import com.gaowj.business.util.SessionUtil; ...@@ -24,15 +24,15 @@ import com.gaowj.business.util.SessionUtil;
public class ProctaskBusinessImpl implements ProctaskBusiness { public class ProctaskBusinessImpl implements ProctaskBusiness {
private TaskService taskService; private TaskService taskService;
private RuntimeService runtimeService; private RuntimeService runtimeService;
private procinstanceDAO procinstanceDAO; private procinstanceDAO procinstanceDAO;
private procdefinitionDAO procdefinitionDAO; private procdefinitionDAO procdefinitionDAO;
private formmodelsDAO formmodelsDAO; private formmodelsDAO formmodelsDAO;
private formtableDAO formtableDAO; private formtableDAO formtableDAO;
public RuntimeService getRuntimeService() { public RuntimeService getRuntimeService() {
...@@ -88,55 +88,60 @@ public class ProctaskBusinessImpl implements ProctaskBusiness { ...@@ -88,55 +88,60 @@ public class ProctaskBusinessImpl implements ProctaskBusiness {
Page<Map<String, Object>> page = new Page<Map<String, Object>>(); Page<Map<String, Object>> page = new Page<Map<String, Object>>();
// 计算起始记录 // 计算起始记录
int pageStart = (pageNo - 1) * pageSize; int pageStart = (pageNo - 1) * pageSize;
TaskQuery taskQuery=taskService.createTaskQuery().taskCandidateUser(SessionUtil.getCode()); TaskQuery taskQuery = taskService.createTaskQuery().taskCandidateUser(SessionUtil.getCode());
page.setStart(pageStart); page.setStart(pageStart);
page.setLimit(pageSize); page.setLimit(pageSize);
page.setCount((int)taskQuery.count()); page.setCount((int) taskQuery.count());
List<Task> list = taskQuery.orderByTaskCreateTime().desc().listPage(pageStart, pageSize); List<Task> list = taskQuery.orderByTaskCreateTime().desc().listPage(pageStart, pageSize);
List<Map<String,Object>> items=new ArrayList<Map<String,Object>>(); List<Map<String, Object>> items = new ArrayList<Map<String, Object>>();
List<String> listInstanceId=new ArrayList<String>(); List<String> listInstanceId = new ArrayList<String>();
for(Task task:list){ List<Map<String, Object>> listInstance = null;
Map<String,Object> map=new HashMap<String, Object>(); if (list.size() > 0) {
items.add(map); for (Task task : list) {
map.put("CREATE_TIME", task.getCreateTime()); Map<String, Object> map = new HashMap<String, Object>();
map.put("EXECUTION_ID", task.getExecutionId()); items.add(map);
map.put("TASK_ID", task.getId()); map.put("CREATE_TIME", task.getCreateTime());
listInstanceId.add(task.getExecutionId()); map.put("EXECUTION_ID", task.getExecutionId());
} map.put("PROCESS_INSTANCE_ID", task.getProcessInstanceId());
map.put("TASK_ID", task.getId());
Map<String, Object> query2=new HashMap<String, Object>(); //listInstanceId.add(task.getExecutionId());
query2.put("INSTANCE_ID_IN", listInstanceId); listInstanceId.add(task.getProcessInstanceId());
}
List<Map<String, Object>> listInstance=null;
if (query.get("PROCDEFINITION_UUID") != null && !"".equals(query.get("PROCDEFINITION_UUID"))) { Map<String, Object> query2 = new HashMap<String, Object>();
String procdefinitionUuid = query.get("PROCDEFINITION_UUID").toString(); query2.put("INSTANCE_ID_IN", listInstanceId);
query.remove("PROCDEFINITION_UUID");
//通过流程定义id获取表名 if (query.get("PROCDEFINITION_UUID") != null && !"".equals(query.get("PROCDEFINITION_UUID"))) {
Map<String, Object> query3=new HashMap<String, Object>(); String procdefinitionUuid = query.get("PROCDEFINITION_UUID").toString();
query3.put("UUID", procdefinitionUuid); query.remove("PROCDEFINITION_UUID");
String tableName=procdefinitionDAO.list_procde_finition(query3).get(0).get("TABLE_NAME").toString(); // 通过流程定义id获取表名
query2.put("tableName", tableName); Map<String, Object> query3 = new HashMap<String, Object>();
try { query3.put("UUID", procdefinitionUuid);
listInstance=procinstanceDAO.list_proc_instance(query2); String tableName = procdefinitionDAO.list_procde_finition(query3).get(0).get("TABLE_NAME").toString();
} catch (Exception e) { query2.put("tableName", tableName);
if(e.getMessage().indexOf("doesn't exist")!=-1){ try {
//如果有XX不存在字样,说明当前需要查询的表不存在,则直接设置为空list listInstance = procinstanceDAO.list_proc_instance(query2);
listInstance=new ArrayList<Map<String, Object>>(); } catch (Exception e) {
if (e.getMessage().indexOf("doesn't exist") != -1) {
// 如果有XX不存在字样,说明当前需要查询的表不存在,则直接设置为空list
listInstance = new ArrayList<Map<String, Object>>();
}
} }
} else {
listInstance = procinstanceDAO.list_proc_instance_all(query2);
} }
}
else{ outer: for (Map<String, Object> instance : listInstance) {
listInstance=procinstanceDAO.list_proc_instance_all(query2); for (Map<String, Object> map : items) {
} if (map.get("PROCESS_INSTANCE_ID").equals(instance.get("INSTANCE_ID"))) {
instance.putAll(map);
outer: continue outer;
for (Map<String, Object> instance : listInstance) { }
for (Map<String, Object> map : items){
if (map.get("EXECUTION_ID").equals(instance.get("INSTANCE_ID"))) {
instance.putAll(map);
continue outer;
} }
} }
} else {
//如果activit中没有任务,则new一个空的list
listInstance = new ArrayList<Map<String, Object>>();
} }
page.setItems(listInstance); page.setItems(listInstance);
return page; return page;
...@@ -144,23 +149,23 @@ public class ProctaskBusinessImpl implements ProctaskBusiness { ...@@ -144,23 +149,23 @@ public class ProctaskBusinessImpl implements ProctaskBusiness {
@Override @Override
public Map<String, Object> data_info(String businessId) throws BusinessException { public Map<String, Object> data_info(String businessId) throws BusinessException {
Map<String, Object> info=new HashMap<String, Object>(); Map<String, Object> info = new HashMap<String, Object>();
Map<String, Object> query=new HashMap<String, Object>(); Map<String, Object> query = new HashMap<String, Object>();
query.put("BUSINESS_ID", businessId); query.put("BUSINESS_ID", businessId);
List<Map<String, Object>> listProcinstance=procinstanceDAO.list_proc_instance_all(query); List<Map<String, Object>> listProcinstance = procinstanceDAO.list_proc_instance_all(query);
if(listProcinstance.size()>0){ if (listProcinstance.size() > 0) {
Map<String, Object> procinstance=listProcinstance.get(0); Map<String, Object> procinstance = listProcinstance.get(0);
//流程定义id // 流程定义id
String procDefinitionId=procinstance.get("PROC_DEFINITION_ID").toString(); String procDefinitionId = procinstance.get("PROC_DEFINITION_ID").toString();
//表单模板id // 表单模板id
String formModelId=procinstance.get("FORM_MODEL_ID").toString(); String formModelId = procinstance.get("FORM_MODEL_ID").toString();
//根据表单模板id获取模板 // 根据表单模板id获取模板
Map<String, Object> formModel=getFormModelById(formModelId); Map<String, Object> formModel = getFormModelById(formModelId);
//根据流程定义id获取存储业务数据的表 // 根据流程定义id获取存储业务数据的表
String tableName=getBusinessTableNameByProcDefinitionId(procDefinitionId); String tableName = getBusinessTableNameByProcDefinitionId(procDefinitionId);
//根据业务数据的表名和业务id,查询业务数据 // 根据业务数据的表名和业务id,查询业务数据
Map<String, Object> businessData=getBusinessDataByBusinessTableAndBusinessId(tableName, businessId); Map<String, Object> businessData = getBusinessDataByBusinessTableAndBusinessId(tableName, businessId);
//填充返回数据 // 填充返回数据
info.put("FORM_MODEL", formModel); info.put("FORM_MODEL", formModel);
info.put("BUSINESS_DATA", businessData); info.put("BUSINESS_DATA", businessData);
} }
...@@ -168,24 +173,25 @@ public class ProctaskBusinessImpl implements ProctaskBusiness { ...@@ -168,24 +173,25 @@ public class ProctaskBusinessImpl implements ProctaskBusiness {
} }
private Map<String, Object> getFormModelById(String uuid) { private Map<String, Object> getFormModelById(String uuid) {
Map<String, Object> query=new HashMap<String, Object>(); Map<String, Object> query = new HashMap<String, Object>();
query.put("UUID", uuid); query.put("UUID", uuid);
return formmodelsDAO.list_form_models(query).get(0); return formmodelsDAO.list_form_models(query).get(0);
} }
/** /**
* 根据流程定义id获取业务数据表的表名 * 根据流程定义id获取业务数据表的表名
*
* @param procDefinitionId * @param procDefinitionId
* @return * @return
*/ */
private String getBusinessTableNameByProcDefinitionId(String procDefinitionId){ private String getBusinessTableNameByProcDefinitionId(String procDefinitionId) {
Map<String, Object> query=new HashMap<String, Object>(); Map<String, Object> query = new HashMap<String, Object>();
query.put("UUID", procDefinitionId); query.put("UUID", procDefinitionId);
return procdefinitionDAO.list_procde_finition(query).get(0).get("TABLE_NAME").toString(); return procdefinitionDAO.list_procde_finition(query).get(0).get("TABLE_NAME").toString();
} }
private Map<String, Object> getBusinessDataByBusinessTableAndBusinessId(String tableName,String uuid) { private Map<String, Object> getBusinessDataByBusinessTableAndBusinessId(String tableName, String uuid) {
Map<String, Object> query=new HashMap<String, Object>(); Map<String, Object> query = new HashMap<String, Object>();
query.put("UUID", uuid); query.put("UUID", uuid);
query.put("tableName", tableName); query.put("tableName", tableName);
return procinstanceDAO.list_proc_instance(query).get(0); return procinstanceDAO.list_proc_instance(query).get(0);
...@@ -193,48 +199,61 @@ public class ProctaskBusinessImpl implements ProctaskBusiness { ...@@ -193,48 +199,61 @@ public class ProctaskBusinessImpl implements ProctaskBusiness {
@Override @Override
public Map<String, Object> update(Map<String, Object> entity) throws BusinessException { public Map<String, Object> update(Map<String, Object> entity) throws BusinessException {
//存储自定义表单的业务数据 // 存储自定义表单的业务数据
update_custom_business(entity.get("TABLE_ID_SYSTEM").toString(),entity); update_custom_business(entity.get("TABLE_ID_SYSTEM").toString(), entity);
return entity; return entity;
} }
@Override @Override
public Map<String, Object> updateToNext(String taskId,Map<String, Object> entity) throws BusinessException { public Map<String, Object> updateToNext(String taskId, Map<String, Object> entity) throws BusinessException {
//存储自定义表单的业务数据 // 存储自定义表单的业务数据
update_custom_business(entity.get("TABLE_ID_SYSTEM").toString(),entity); update_custom_business(entity.get("TABLE_ID_SYSTEM").toString(), entity);
//通过任务id获取流程id // 通过任务id获取流程id
String processInstanceId=taskService.createTaskQuery().taskId(taskId).singleResult().getProcessInstanceId(); String processInstanceId = taskService.createTaskQuery().taskId(taskId).singleResult().getProcessInstanceId();
//完成当前任务 // 完成当前任务
taskService.complete(taskId); taskService.complete(taskId);
//判断当前流程是否结束 // 判断当前流程是否结束
long count=runtimeService.createExecutionQuery().processInstanceId(processInstanceId).count(); long count = runtimeService.createExecutionQuery().processInstanceId(processInstanceId).count();
if(count==0){ if (count == 0) {
//表示流程已结束,修改实例表的complete字段为1 // 表示流程已结束,修改实例表的complete字段为1
Map<String, Object> query=new HashMap<String, Object>(); Map<String, Object> query = new HashMap<String, Object>();
query.put("BUSINESS_ID", entity.get("UUID")); query.put("BUSINESS_ID", entity.get("UUID"));
//先获取实例表的uuid // 先获取实例表的uuid
String procinstanceId=procinstanceDAO.list_proc_instance_all(query).get(0).get("UUID").toString(); String procinstanceId = procinstanceDAO.list_proc_instance_all(query).get(0).get("UUID").toString();
Map<String, Object> procinstance=new HashMap<String, Object>(); Map<String, Object> procinstance = new HashMap<String, Object>();
procinstance.put("UUID", procinstanceId); procinstance.put("UUID", procinstanceId);
procinstance.put("COMPLETE", 1); procinstance.put("COMPLETE", 1);
//通过实例表的uuid对实例表的状态进行更新 // 通过实例表的uuid对实例表的状态进行更新
update_proc_instance(procinstance); update_proc_instance(procinstance);
} }
return entity; return entity;
} }
@Override
public Map<String, Object> back(Map<String, Object> entity) throws BusinessException {
// 存储自定义表单的业务数据
update_custom_business(entity.get("TABLE_ID_SYSTEM").toString(), entity);
// 通过任务id获取流程id
String taskId = entity.get("TASK_ID_SYSTEM").toString();
// String processInstanceId =
// taskService.createTaskQuery().taskId(taskId).singleResult().getProcessInstanceId();
// 完成当前任务
taskService.complete(taskId);
return entity;
}
private void update_proc_instance(Map<String, Object> entity) { private void update_proc_instance(Map<String, Object> entity) {
Map<String, Object> entity2 = new HashMap<String, Object>(); Map<String, Object> entity2 = new HashMap<String, Object>();
entity2.put("UUID", entity.get("UUID")); entity2.put("UUID", entity.get("UUID"));
if (entity.keySet() != null) { if (entity.keySet() != null) {
List<Map<String,Object>> info=new ArrayList<Map<String,Object>>(); List<Map<String, Object>> info = new ArrayList<Map<String, Object>>();
entity2.put("info", info); entity2.put("info", info);
Set<String> key = entity.keySet(); Set<String> key = entity.keySet();
for(String str:key){ for (String str : key) {
if("UUID".equals(str)){ if ("UUID".equals(str)) {
continue; continue;
} }
Map<String,Object> colum=new HashMap<String, Object>(); Map<String, Object> colum = new HashMap<String, Object>();
colum.put("key", str); colum.put("key", str);
colum.put("value", entity.get(str)); colum.put("value", entity.get(str));
info.add(colum); info.add(colum);
...@@ -243,8 +262,8 @@ public class ProctaskBusinessImpl implements ProctaskBusiness { ...@@ -243,8 +262,8 @@ public class ProctaskBusinessImpl implements ProctaskBusiness {
procinstanceDAO.update_proc_instance(entity2); procinstanceDAO.update_proc_instance(entity2);
} }
private String update_custom_business(String tableId,Map<String, Object> entity) { private String update_custom_business(String tableId, Map<String, Object> entity) {
entity.remove("TABLE_ID_SYSTEM"); entity.remove("TABLE_ID_SYSTEM");
if (entity.get("UUID") == null) { if (entity.get("UUID") == null) {
entity.put("UUID", java.util.UUID.randomUUID().toString()); entity.put("UUID", java.util.UUID.randomUUID().toString());
...@@ -261,40 +280,37 @@ public class ProctaskBusinessImpl implements ProctaskBusiness { ...@@ -261,40 +280,37 @@ public class ProctaskBusinessImpl implements ProctaskBusiness {
if (entity.get("UPDATE_TIME") == null) { if (entity.get("UPDATE_TIME") == null) {
entity.put("UPDATE_TIME", new Date()); entity.put("UPDATE_TIME", new Date());
} }
Map<String, Object> query=new HashMap<String, Object>(); Map<String, Object> query = new HashMap<String, Object>();
query.put("UUID", tableId); query.put("UUID", tableId);
// 动态传值插入 // 动态传值插入
List<Map<String,Object>> infoList = new ArrayList<Map<String,Object>>(); List<Map<String, Object>> infoList = new ArrayList<Map<String, Object>>();
//List<String> infoListKey = new ArrayList<String>(); // List<String> infoListKey = new ArrayList<String>();
if (entity.keySet() != null) { if (entity.keySet() != null) {
Set<String> key = entity.keySet(); Set<String> key = entity.keySet();
// 将map集合中的key和value 取出来分别放到list集合里 // 将map集合中的key和value 取出来分别放到list集合里
for (String str : key) { for (String str : key) {
//UUID不需要加进去 // UUID不需要加进去
if("UUID".equals(str)){ if ("UUID".equals(str)) {
continue; continue;
} }
Map<String,Object> kv=new HashMap<String, Object>(); Map<String, Object> kv = new HashMap<String, Object>();
kv.put("value",entity.get(str)); kv.put("value", entity.get(str));
kv.put("key",str); kv.put("key", str);
infoList.add(kv); infoList.add(kv);
} }
entity.put("infoList", infoList); entity.put("infoList", infoList);
} }
/*List<Object> infoList = new ArrayList<Object>(); /*
if (entity.keySet() != null) { * List<Object> infoList = new ArrayList<Object>(); if (entity.keySet()
Set<String> key = entity.keySet(); * != null) { Set<String> key = entity.keySet(); // 将map集合中的key和value
// 将map集合中的key和value 取出来分别放到list集合里 * 取出来分别放到list集合里 for (String str : key) {
for (String str : key) { * infoList.add(entity.get(str)); infoListKey.add(str); }
infoList.add(entity.get(str)); * entity.put("infoListKey", infoListKey); entity.put("infoList",
infoListKey.add(str); * infoList); }
} */
entity.put("infoListKey", infoListKey); // 设置表名
entity.put("infoList", infoList); String tableName = formtableDAO.list_form_table(query).get(0).get("TABLE_NAME").toString();
}*/
//设置表名
String tableName=formtableDAO.list_form_table(query).get(0).get("TABLE_NAME").toString();
entity.put("tableName", tableName); entity.put("tableName", tableName);
entity.put("uuid", entity.get("UUID")); entity.put("uuid", entity.get("UUID"));
procdefinitionDAO.update_custom_business(entity); procdefinitionDAO.update_custom_business(entity);
......
...@@ -6,6 +6,7 @@ import java.net.URLEncoder; ...@@ -6,6 +6,7 @@ import java.net.URLEncoder;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.ParseException; import java.text.ParseException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import com.gaowj.business.ProcdefinitionBusiness; import com.gaowj.business.ProcdefinitionBusiness;
...@@ -103,4 +104,24 @@ public class dataAction extends BasicAction{ ...@@ -103,4 +104,24 @@ public class dataAction extends BasicAction{
} }
return name; return name;
} }
public String procinstanceHistory() throws BusinessException {
ProcinstanceBusiness business = BusinessManager.getBusiness(ProcinstanceBusiness.class);
try {
List<Map<String, Object>> listRows = business.list_proc_instance_history(RequestUtils.getString(request, "processInstanceId"));
Map<String, Object> data = new HashMap<String, Object>();
data.put("rowSet", QueryParamUtil.DateTimeToString(listRows));
data.put("pageNo", pageNo);
data.put("pageSize", pageSize);
data.put("pageCount", pageCount);
data.put("rows", data.get("rowSet"));
data.put("total", listRows.size());
jsonObject = new JSONObject();
jsonObject.putAll(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "json";
}
} }
...@@ -28,5 +28,10 @@ public class viewAction extends BasicAction { ...@@ -28,5 +28,10 @@ public class viewAction extends BasicAction {
request.setAttribute("is_row", query); request.setAttribute("is_row", query);
return "procinstanceTabDetailEdit"; return "procinstanceTabDetailEdit";
} }
public String procinstanceTabHistory() throws BusinessException{
request.setAttribute("instanceId", RequestUtils.getString(request, "instanceId"));
return "procinstanceTabHistory";
}
} }
...@@ -84,4 +84,19 @@ public class actAction extends BasicAction{ ...@@ -84,4 +84,19 @@ public class actAction extends BasicAction{
} }
return "json"; return "json";
} }
public String back() throws BusinessException {
ProctaskBusiness business = BusinessManager.getBusiness(ProctaskBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request, RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject();
try {
entity = QueryParamUtil.StringToDate(entity);
//business.list_proc_task(pageNo, pageSize, query)
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
e.printStackTrace();
}
return "json";
}
} }
...@@ -103,6 +103,14 @@ ...@@ -103,6 +103,14 @@
<if test="EMID != null and EMID != ''"> <if test="EMID != null and EMID != ''">
and u.emid like CONCAT('%',#{EMID},'%') and u.emid like CONCAT('%',#{EMID},'%')
</if> </if>
<if test="CODE_IN != null and CODE_IN != ''">
and u.code IN
<trim prefix="(" suffix=")" suffixOverrides=",">
<foreach collection="CODE_IN" item="value">
#{value},
</foreach>
</trim>
</if>
<if test="NAME != null and NAME != ''"> <if test="NAME != null and NAME != ''">
and u.emid in (select lu.emid from c_t_sys_loginuser lu where lu.emname like CONCAT('%',#{NAME},'%') or lu.emid like CONCAT('%',#{NAME},'%')) and u.emid in (select lu.emid from c_t_sys_loginuser lu where lu.emname like CONCAT('%',#{NAME},'%') or lu.emid like CONCAT('%',#{NAME},'%'))
</if> </if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment