Commit afb3e5f1 by 罗绍泽

流程实例完善

parent 35198140
......@@ -14,6 +14,8 @@ procinstanceModule.prototype.insertInfo = function(){};
procinstanceModule.prototype.insertInfoToNext = function(){};
//修改流程实例
procinstanceModule.prototype.updateInfo = function(){};
//修改流程实例,并执行下一步
procinstanceModule.prototype.updateInfoToNext = function(){};
//删除流程实例
procinstanceModule.prototype.deleteInfo = function(){};
......
......@@ -215,12 +215,13 @@ function editRow(index) {
//加载修改子页面成功后的回调
function updateUrlOnloadCallback(is_row){
console.log(is_row);
fillTable2(is_row.BUSINESS_ID,is_row.TASK_ID);
}
//保存
function updateData(is_entity){
alert('明天实现');
var v_result = procinstanceModule.act.updateInfo(is_entity);
$('#list').datagrid('reload');
return v_result;
}
function fillTable2(businessId,taskId){
......@@ -240,7 +241,9 @@ function fillTable2(businessId,taskId){
}
//下一步按钮执行事件
function updateDataToNext(is_entity){
alert('明天实现');
var v_result = procinstanceModule.act.updateInfoToNext(is_entity);
$('#list').datagrid('reload');
return v_result;
}
/****/
......@@ -320,8 +323,8 @@ function deleteBatchRow(){
* 备注:需更改
**/
function refreshRow(){
$('#list').datagrid('load',{});
$("#studentTab_searchForm")[0].reset();
$('#FIELD_PROCDEFINITION_UUID').combobox('setValue','');
searchRow();
}
/****/
......
......@@ -11,11 +11,9 @@
流程: <input class="easyui-textbox" id="FIELD_PROCDEFINITION_UUID" name="FIELD_PROCDEFINITION_UUID" style="width:200px"/>&nbsp;&nbsp;
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ext-advsearch',plain:true" onclick="javascript:advsearchRow()">高级查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="javascript:addRow()">新增</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear',plain:true" onclick="javascript:deleteBatchRow()">删除</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ext-file',plain:true" onclick="javascript:uploadcommonBatchRow()">附件</a>
</div>
<div id="detail" style="overflow:auto;"></div>
<script type="text/javascript" src="${ctx}/jwapp/pages/standard/js/jwStandardModule.js" charset="utf-8"></script>
......
......@@ -3,6 +3,5 @@
<input type="hidden" name="FIELD_OPETYPE" id="OPETYPE" value="${is_row.OPETYPE}" />
<input type="hidden" name="FIELD_UUID" id="UUID" value="${is_row.UUID}" />
<input type="hidden" name="FIELD_TABLE_ID_SYSTEM" id="TABLE_ID_SYSTEM"/>
<input type="hidden" name="FIELD_TASK_ID_SYSTEM" id="TASK_ID_SYSTEM"/>
<div id="table_content"></div>
</form>
\ No newline at end of file
......@@ -124,14 +124,14 @@ function getOptionMenu(data,index){
var procinstanceImgBtn="<span class=\"icon-edit\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"showProcinstanceImg('"
+ index + "')\">进度</a>";
returnData.push(editBtn);
returnData.push(delBtn);
//returnData.push(delBtn);
returnData.push(procinstanceImgBtn);
return returnData.join(" | ");
}
//返回菜单集的菜单个数(需更改)
function getOptionMenuCount(){
var is_menu_count = 3;
var is_menu_count = 2;
return is_menu_count;
}
......@@ -257,8 +257,8 @@ function deleteBatchRow(){
* 备注:需更改
**/
function refreshRow(){
$('#list').datagrid('load',{});
$("#studentTab_searchForm")[0].reset();
$('#FIELD_PROCDEFINITION_UUID').combobox('setValue','');
searchRow();
}
/****/
......
......@@ -11,11 +11,7 @@
流程: <input class="easyui-textbox" id="FIELD_PROCDEFINITION_UUID" name="FIELD_PROCDEFINITION_UUID" style="width:200px"/>&nbsp;&nbsp;
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ext-advsearch',plain:true" onclick="javascript:advsearchRow()">高级查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="javascript:addRow()">新增</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-clear',plain:true" onclick="javascript:deleteBatchRow()">删除</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ext-file',plain:true" onclick="javascript:uploadcommonBatchRow()">附件</a>
</div>
<div id="detail" style="overflow:auto;"></div>
<script type="text/javascript" src="${ctx}/jwapp/pages/standard/js/jwStandardModule.js" charset="utf-8"></script>
......
......@@ -33,7 +33,15 @@ public interface ProcinstanceBusiness {
* @param entity
* @throws BusinessException
*/
void update_proc_instance(Map<String, Object> entity) throws BusinessException;
Map<String, Object> update_proc_instance(Map<String, Object> entity) throws BusinessException;
/**
* 更新
*
* @param entity
* @throws BusinessException
*/
Map<String, Object> update_proc_instance_next(Map<String, Object> entity) throws BusinessException;
/**
* 删除记录
......
......@@ -99,7 +99,10 @@ public class ProcdefinitionBusinessImpl implements ProcdefinitionBusiness {
if (entity.get("UPDATE_TIME") == null) {
entity.put("UPDATE_TIME", new Date());
}
entity.put("DEPLOYMENT_KEY", UUID.randomUUID().toString());
//生成部署id,将时间戳转36进制,为了保证不重复,这里加了synchronized防止并发
synchronized (this){
entity.put("DEPLOYMENT_KEY", Long.toString(new Date().getTime(), 36));
}
// 动态传值插入
List<String> infoListKey = new ArrayList<String>();
......
......@@ -25,6 +25,11 @@ import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.NativeModelQuery;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.XPath;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -247,7 +252,33 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes),"GBK").deploy();
String bpmText=new String(bpmnBytes);
try {
//自动添加任务监听
Document doc = DocumentHelper.parseText(bpmText);
Element rootEle = doc.getRootElement();
String nsUri = rootEle.getNamespaceURI();
Map nsMap = new HashMap();
nsMap.put("rootNs", nsUri);
XPath mesXpath = doc.createXPath("/rootNs:definitions/rootNs:process/rootNs:userTask");
mesXpath.setNamespaceURIs(nsMap);
List listNodes=mesXpath.selectNodes(doc);
if(listNodes.size()>0){
for(Object node:listNodes){
Element node_e =(Element) node;
Element extensionElements=node_e.addElement("extensionElements");
Element taskListener=extensionElements.addElement("activiti:taskListener");
taskListener.addAttribute("event", "create");
taskListener.addAttribute("class", "com.gaowj.activiti.listener.AssignmentTaskListener");
}
}
bpmText=doc.asXML();
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, bpmText,"GBK").deploy();
// 将部署id存入流程定义表
Map<String, Object> entity = new HashMap<String, Object>();
entity.put("UUID", procId);
......
......@@ -23,6 +23,7 @@ import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.image.impl.DefaultProcessDiagramGenerator;
import org.apache.ibatis.session.RowBounds;
......@@ -37,7 +38,6 @@ public class ProcinstanceBusinessImpl implements ProcinstanceBusiness {
private procinstanceDAO procinstanceDAO;
private procdefinitionDAO procdefinitionDAO;
private formtableDAO formtableDAO;
......@@ -224,10 +224,131 @@ public class ProcinstanceBusinessImpl implements ProcinstanceBusiness {
}
@Override
public void update_proc_instance(Map<String, Object> entity) throws BusinessException {
// TODO Auto-generated method stub
public Map<String, Object> update_proc_instance(Map<String, Object> entity) throws BusinessException {
// 业务表主键id
String uuid = entity.get("UUID").toString();
Map<String, Object> query = new HashMap<String, Object>();
query.put("BUSINESS_ID", uuid);
//获取流程实例表对象
Map<String, Object> procInstance=procinstanceDAO.list_proc_instance_all(query).get(0);
if(procInstance.get("INSTANCE_ID")!=null&&!"".equals(procInstance.get("INSTANCE_ID"))){
//表示流程实例已启动,根据实例id,判断当前登陆人是否为该记录的当前任务人
long taskCount=taskService.createTaskQuery().processInstanceId(procInstance.get("INSTANCE_ID").toString()).taskCandidateUser(SessionUtil.getCode()).count();
if(taskCount==0){
//如果该人员对该流程实例的任务数量为0,表示该人员目前无权限对该记录进行修改操作
return new HashMap<String, Object>(){{
put("ERROR", "-1");
}};
}
}
//流程定义id
String procDefinitionId=procInstance.get("PROC_DEFINITION_ID").toString();
//查询表名
Map<String, Object> query2=new HashMap<String, Object>();
query2.put("UUID", procDefinitionId);
String tableName=procdefinitionDAO.list_procde_finition(query2).get(0).get("TABLE_NAME").toString();
//更新业务数据
update_custom_business(tableName,entity);
return entity;
}
@Override
public Map<String, Object> update_proc_instance_next(Map<String, Object> entity) throws BusinessException {
// 业务表主键id
String uuid = entity.get("UUID").toString();
Map<String, Object> query = new HashMap<String, Object>();
query.put("BUSINESS_ID", uuid);
//获取流程实例表对象
Map<String, Object> procInstance=procinstanceDAO.list_proc_instance_all(query).get(0);
//流程定义id
String procDefinitionId=procInstance.get("PROC_DEFINITION_ID").toString();
if(procInstance.get("INSTANCE_ID")!=null&&!"".equals(procInstance.get("INSTANCE_ID"))){
//表示流程实例已启动,根据实例id,判断当前登陆人是否为该记录的当前任务人
long taskCount=taskService.createTaskQuery().processInstanceId(procInstance.get("INSTANCE_ID").toString()).taskCandidateUser(SessionUtil.getCode()).count();
if(taskCount==0){
//如果该人员对该流程实例的任务数量为0,表示该人员目前无权限对该记录进行修改操作
return new HashMap<String, Object>(){{
put("ERROR", "-1");
}};
}else{
//如果是当前环节处理人,则完成当前任务
Task task=taskService.createTaskQuery().processInstanceId(procInstance.get("INSTANCE_ID").toString()).taskCandidateUser(SessionUtil.getCode()).list().get(0);
taskService.complete(task.getId());
}
}else{
//如果没有实例id,则通过流程定义id启动流程
Map<String,Object> query_proc_definition=new HashMap<String, Object>();
query_proc_definition.put("UUID", procDefinitionId);
String deploymentKey=procdefinitionDAO.list_procde_finition(query_proc_definition).get(0).get("DEPLOYMENT_KEY").toString();
ProcessInstance processInstance=runtimeService.startProcessInstanceByKey(deploymentKey);
//将实例id保存到实例表
Map<String,Object> procInstanceUpdate=new HashMap<String, Object>();
procInstanceUpdate.put("UUID", procInstance.get("UUID"));
procInstanceUpdate.put("INSTANCE_ID", processInstance.getId());
update_proc_instance_data(procInstanceUpdate);
}
//查询表名
Map<String, Object> query2=new HashMap<String, Object>();
query2.put("UUID", procDefinitionId);
String tableName=procdefinitionDAO.list_procde_finition(query2).get(0).get("TABLE_NAME").toString();
//更新业务数据
update_custom_business(tableName,entity);
return entity;
}
private void update_proc_instance_data(Map<String, Object> entity) {
Map<String, Object> entity2 = new HashMap<String, Object>();
entity2.put("UUID", entity.get("UUID"));
if (entity.keySet() != null) {
List<Map<String,Object>> info=new ArrayList<Map<String,Object>>();
entity2.put("info", info);
Set<String> key = entity.keySet();
for(String str:key){
if("UUID".equals(str)){
continue;
}
Map<String,Object> colum=new HashMap<String, Object>();
colum.put("key", str);
colum.put("value", entity.get(str));
info.add(colum);
}
}
procinstanceDAO.update_proc_instance(entity2);
}
private String update_custom_business(String tableName,Map<String, Object> entity) {
entity.remove("TABLE_ID_SYSTEM");
entity.put("UPDATE_ID", SessionUtil.getCode());
entity.put("UPDATE_TIME", new Date());
// 动态传值插入
List<Map<String,Object>> infoList = new ArrayList<Map<String,Object>>();
//List<String> infoListKey = new ArrayList<String>();
if (entity.keySet() != null) {
Set<String> key = entity.keySet();
// 将map集合中的key和value 取出来分别放到list集合里
for (String str : key) {
//UUID不需要加进去
if("UUID".equals(str)){
continue;
}
Map<String,Object> kv=new HashMap<String, Object>();
kv.put("value",entity.get(str));
kv.put("key",str);
infoList.add(kv);
}
entity.put("infoList", infoList);
}
//设置表名
entity.put("tableName", tableName);
entity.put("uuid", entity.get("UUID"));
procdefinitionDAO.update_custom_business(entity);
return entity.get("UUID").toString();
}
@Override
public void delete_proc_instance(List<String> list) throws BusinessException {
......
......@@ -88,5 +88,77 @@ public class actAction extends BasicAction {
}
return "json";
}
/**
* 更新
*
* @param entity
* @throws BusinessException
*/
public String updateInfo() throws BusinessException {
ProcinstanceBusiness business = BusinessManager.getBusiness(ProcinstanceBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject();
try {
entity = QueryParamUtil.StringToDate(entity);
//去除不要更新的字段
entity.remove("OPETYPE");
//更新
Map<String,Object> procinstance=business.update_proc_instance(entity);
if("-1".equals(procinstance.get("ERROR"))){
jsonObject.putAll(Status.getStatusErrorMessage("你不属于当前流程环节处理人,无权限处理该业务。"));
return "json";
}
// 操作日志
//sysbusiness.insert_logBusiness(具体方法,操作内容,操作描述,操作记录ID,操作记录中文描述,分类)
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("insertInfo", "" + procinstance,
"更新流程实例数据", (String) entity.get("UUID"), (String) entity.get("CONTENT"), "procinstance");
//
//
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
e.printStackTrace();
}
return "json";
}
/**
* 更新
*
* @param entity
* @throws BusinessException
*/
public String updateInfoToNext() throws BusinessException {
ProcinstanceBusiness business = BusinessManager.getBusiness(ProcinstanceBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject();
try {
entity = QueryParamUtil.StringToDate(entity);
//去除不要更新的字段
entity.remove("OPETYPE");
//更新
Map<String,Object> procinstance=business.update_proc_instance_next(entity);
if("-1".equals(procinstance.get("ERROR"))){
jsonObject.putAll(Status.getStatusErrorMessage("你不属于当前流程环节处理人,无权限处理该业务。"));
return "json";
}
// 操作日志
//sysbusiness.insert_logBusiness(具体方法,操作内容,操作描述,操作记录ID,操作记录中文描述,分类)
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("insertInfo", "" + procinstance,
"更新流程实例数据", (String) entity.get("UUID"), (String) entity.get("CONTENT"), "procinstance");
//
//
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
e.printStackTrace();
}
return "json";
}
}
......@@ -81,8 +81,6 @@ public class dataAction extends BasicAction{
try {
query = QueryParamUtil.StringToDate(query);
Map<String, Object> info = business.data_info(query.get("BUSINESS_ID").toString());
System.out.println(info.get("BUSINESS_DATA"));
System.out.println(info.get("FORM_MODEL"));
jsonObject = new JSONObject();
jsonObject.put("BUSINESS_DATA", QueryParamUtil.DateTimeToString((Map<String, Object>) info.get("BUSINESS_DATA")));
jsonObject.put("FORM_MODEL", QueryParamUtil.DateTimeToString((Map<String, Object>) info.get("FORM_MODEL")));
......
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