Commit b299d9ca by 罗绍泽

activiti jar包升级(5.17-5.19)

parent 213a9961
...@@ -28,4 +28,5 @@ ...@@ -28,4 +28,5 @@
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" /> <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" /> <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="formService" factory-bean="processEngine" factory-method="getFormService" /> <bean id="formService" factory-bean="processEngine" factory-method="getFormService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
</beans> </beans>
...@@ -40,5 +40,16 @@ ...@@ -40,5 +40,16 @@
<property name="sqlSessionFactory" ref="sqlSessionFactory-process" /> <property name="sqlSessionFactory" ref="sqlSessionFactory-process" />
</bean> </bean>
</property> </property>
<property name="procdefinitionDAO">
<bean class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.gaowj.business.procdefinition.procdefinitionDAO" />
<property name="sqlSessionFactory" ref="sqlSessionFactory-process" />
</bean>
</property>
<property name="repositoryService" ref="repositoryService"></property>
<property name="managementService" ref="managementService"></property>
</bean> </bean>
</beans> </beans>
...@@ -58,7 +58,14 @@ var ls_title="流程定义"; ...@@ -58,7 +58,14 @@ var ls_title="流程定义";
var is_column = [ [ var is_column = [ [
{field : 'PROC_NAME',title : '流程名',width : 100,align : 'center'}, {field : 'PROC_NAME',title : '流程名',width : 100,align : 'center'},
{field : 'DEPLOYMENT_KEY',title : 'KEY',width : 80,align : 'center'}, {field : 'DEPLOYMENT_KEY',title : 'KEY',width : 80,align : 'center'},
{field : 'CONTENT',title : '关联表',width : 80,align : 'center'} {field : 'CONTENT',title : '关联表',width : 80,align : 'center'},
{field : 'DEPLOYMENT_ID',title : '部署id',width : 80,align : 'center',formatter:function(value,row,index){
if(value==null||value==''){
return '未部署';
}else{
return value;
}
}}
] ]; ] ];
//列表加载完成回调 //列表加载完成回调
function dataOnLoadSuccess(){ function dataOnLoadSuccess(){
......
...@@ -8,12 +8,14 @@ var procdefinitionmodelsModule = function(format) { ...@@ -8,12 +8,14 @@ var procdefinitionmodelsModule = function(format) {
//定义数据交互 //定义数据交互
procdefinitionmodelsModule.prototype = BusinessObject; procdefinitionmodelsModule.prototype = BusinessObject;
//插入流程定义 //插入模板
procdefinitionmodelsModule.prototype.insertProcdefinitionmodels = function(){}; procdefinitionmodelsModule.prototype.insertProcdefinitionmodels = function(){};
//修改流程定义 //修改模板
procdefinitionmodelsModule.prototype.updateProcdefinitionmodels = function(){}; procdefinitionmodelsModule.prototype.updateProcdefinitionmodels = function(){};
//删除流程定义 //删除模板
procdefinitionmodelsModule.prototype.deleteProcdefinitionmodels = function(){}; procdefinitionmodelsModule.prototype.deleteProcdefinitionmodels = function(){};
//部署模板到流程定义
procdefinitionmodelsModule.prototype.deploy = function(){};
//创建一个数据操作对象,然后再后续使用 //创建一个数据操作对象,然后再后续使用
procdefinitionmodelsModule.act = new procdefinitionmodelsModule("json").delegate("procdefinitionmodelsAct"); procdefinitionmodelsModule.act = new procdefinitionmodelsModule("json").delegate("procdefinitionmodelsAct");
......
...@@ -56,9 +56,9 @@ var ls_ywlx = 'YBYW'; ...@@ -56,9 +56,9 @@ var ls_ywlx = 'YBYW';
//定义grid列表 //定义grid列表
var ls_title=null; var ls_title=null;
var is_column = [ [ var is_column = [ [
{field : 'PROC_NAME',title : '流程名',width : 100,align : 'center'}, {field : 'NAME',title : '模板名称',width : 100,align : 'center'},
{field : 'DEPLOYMENT_KEY',title : 'KEY',width : 80,align : 'center'}, {field : 'DESCRIPTION',title : '描述',width : 80,align : 'center'},
{field : 'CONTENT',title : '关联表',width : 80,align : 'center'} {field : 'KEY',title : 'KEY',width : 80,align : 'center'}
] ]; ] ];
//列表加载完成回调 //列表加载完成回调
function dataOnLoadSuccess(){ function dataOnLoadSuccess(){
...@@ -74,7 +74,7 @@ function rowstyler(index,row){ ...@@ -74,7 +74,7 @@ function rowstyler(index,row){
} }
} }
//展示列表 //展示列表
datagrid("list", ls_title, gaowj.WEB_APP_NAME + "/procdefinitionmodelsData_list", queryData, is_column, 60, 80); datagrid("list", ls_title, gaowj.WEB_APP_NAME + "/procdefinitionmodelsData_list", Object.assign({},$("#procdefinitionmodelsTab_searchForm").getFormVal(),queryData), is_column, 60, 80);
/****/ /****/
...@@ -98,10 +98,10 @@ function formatMenu(value, data,index) { ...@@ -98,10 +98,10 @@ function formatMenu(value, data,index) {
//上浮横向菜单集里的具体菜单项(需更改) //上浮横向菜单集里的具体菜单项(需更改)
function getOptionMenu(data,index){ function getOptionMenu(data,index){
var returnData= "<span class=\"icon-edit\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"editRow('" var returnData= "<span class=\"icon-edit\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"design('"
+ index + "')\">编辑</a> | <span class=\"icon-clear\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"deleteRow('" + index + "')\">设计</a> | <span class=\"icon-ext-file\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"deploy('"
+ index + "')\">删除</a> | <span class=\"icon-ext-file\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"modelList('" + index + "')\">部署</a> | <span class=\"icon-clear\" style=\"padding-left:20px;*width:20px;\"></span><a href=\"javascript:void(0);\" onclick=\"deleteRow('"
+ index + "')\">模板</a>"; + index + "')\">删除</a>";
return returnData; return returnData;
} }
...@@ -252,7 +252,7 @@ function refreshRow(){ ...@@ -252,7 +252,7 @@ function refreshRow(){
* 备注:需更改 * 备注:需更改
**/ **/
function searchRow(){ function searchRow(){
var v_query = $("#procdefinitionTab_searchForm").getFormVal(); var v_query = $("#procdefinitionmodelsTab_searchForm").getFormVal();
$('#list').datagrid('load',v_query); $('#list').datagrid('load',v_query);
} }
/****/ /****/
...@@ -359,60 +359,25 @@ function uploadcommonBatchRow(){ ...@@ -359,60 +359,25 @@ function uploadcommonBatchRow(){
} }
/****/ /****/
function replaceByJson(text,json){ function design(index){
for(key in json){
text = text.replace('@{'+key+'}',json[key]);
}
return text;
}
function modelList(index){
$('#list').datagrid('selectRow',index); $('#list').datagrid('selectRow',index);
var is_row = $('#list').datagrid('getSelections'); var is_row = $('#list').datagrid('getSelections');
$('#list').datagrid('clearSelections'); $('#list').datagrid('clearSelections');
openViewIframRow("detail","procdefinitionView_modelList",is_row[0],"流程模板列表",true,0.65,0.95,0,0); window.open('http://localhost:92/process-editor/modeler.jsp?modelId=' + is_row[0].ID);
} }
function modelList_datagrid(is_view,is_title,is_url,is_query,is_column,is_opetipmenuwidth,optionWidth){ function deploy(index){
if(optionWidth==null || optionWidth==''){ $.messager.confirm('警告', '您确定需要部署该模板吗?', function(r) {
optionWidth = 80; if (r) {
} $('#list').datagrid('selectRow',index);
$('#'+is_view).datagrid({ var is_row = $('#list').datagrid('getSelections');
title:is_title, $('#list').datagrid('clearSelections');
iconCls:$.getJwWindowPic(), var v_result=procdefinitionmodelsModule.act.deploy({
url:is_url, FIELD_PROCID:$("#PROCID").val(),
queryParams : is_query,//查询参数 FIELD_MODELID:is_row[0].ID
rownumbers : true,//显示索引号 });
singleSelect : false,//是否多选 $.messager.alert('提示',v_result.VALUE);
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
},
{
field : 'option',
title : '操作',
width : optionWidth,
align : 'center',
formatter : formatMenu
}
]],
columns : is_column,
//toolbar : '#modelTabTb',
onLoadSuccess : function() {
if(is_opetipmenuwidth==null){
is_opetipmenuwidth = 60;
}
createOptionMenuTooltip(is_opetipmenuwidth);
dataOnLoadSuccess();
} }
}); });
} }
\ No newline at end of file
...@@ -12,43 +12,57 @@ import com.gaowj.business.util.Page; ...@@ -12,43 +12,57 @@ import com.gaowj.business.util.Page;
public interface ProcdefinitionmodelsBusiness { public interface ProcdefinitionmodelsBusiness {
/** /**
* 插入 * 插入
*
* @param entity * @param entity
* @throws BusinessException * @throws BusinessException
*/ */
Map<String,Object> insert_procde_finition_models(Map<String,Object> entity) throws BusinessException ; Map<String, Object> insert_procde_finition_models(Map<String, Object> entity) throws BusinessException;
/** /**
* 更新 * 更新
*
* @param entity * @param entity
* @throws BusinessException * @throws BusinessException
*/ */
void update_procde_finition_models(Map<String,Object> entity) throws BusinessException ; void update_procde_finition_models(Map<String, Object> entity) throws BusinessException;
/** /**
* 删除记录 * 删除记录
*
* @param entity * @param entity
* @throws BusinessException * @throws BusinessException
*/ */
void delete_procde_finition_models(List<String> list)throws BusinessException; void delete_procde_finition_models(List<String> list) throws BusinessException;
/** /**
* 分页获取记录 * 分页获取记录
*
* @param entity * @param entity
* @throws BusinessException * @throws BusinessException
*/ */
Page<Map<String, Object>> list_procde_finition_models(int pageNo, int pageSize, Map<String, Object> query)throws BusinessException ; Page<Map<String, Object>> list_procde_finition_models(int pageNo, int pageSize, Map<String, Object> query) throws BusinessException;
/** /**
* 获取所有记录 * 获取所有记录
*
* @param entity * @param entity
* @throws BusinessException * @throws BusinessException
*/ */
List<Map<String,Object>> list_procde_finition_models(Map<String, Object> query) throws BusinessException ; List<Map<String, Object>> list_procde_finition_models(Map<String, Object> query) throws BusinessException;
/** /**
* 获取所有记录数 * 获取所有记录数
*
* @param entity * @param entity
* @throws BusinessException * @throws BusinessException
*/ */
int listCount_procde_finition_models(Map<String, Object> query) throws BusinessException ; int listCount_procde_finition_models(Map<String, Object> query) throws BusinessException;
/**
* 模板部署
*
* @param query
* @throws BusinessException
*/
void deploy(Map<String, Object> query) throws BusinessException;
} }
package com.gaowj.business.procdefinitionmodels; package com.gaowj.business.procdefinitionmodels;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -7,11 +9,23 @@ import java.util.List; ...@@ -7,11 +9,23 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.editor.constants.ModelDataJsonConstants;
import org.activiti.editor.language.json.converter.BpmnJsonConverter;
import org.activiti.engine.ManagementService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.NativeModelQuery;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.RowBounds;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.gaowj.business.ProcdefinitionmodelsBusiness; import com.gaowj.business.ProcdefinitionmodelsBusiness;
import com.gaowj.business.exception.BusinessException; import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.procdefinition.procdefinitionDAO;
import com.gaowj.business.util.Page; import com.gaowj.business.util.Page;
import com.gaowj.business.util.SessionUtil; import com.gaowj.business.util.SessionUtil;
...@@ -19,6 +33,12 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus ...@@ -19,6 +33,12 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus
private procdefinitionmodelsDAO procdefinitionmodelsDAO; private procdefinitionmodelsDAO procdefinitionmodelsDAO;
private procdefinitionDAO procdefinitionDAO;
private RepositoryService repositoryService;
private ManagementService managementService;
public procdefinitionmodelsDAO getProcdefinitionmodelsDAO() { public procdefinitionmodelsDAO getProcdefinitionmodelsDAO() {
return procdefinitionmodelsDAO; return procdefinitionmodelsDAO;
} }
...@@ -27,38 +47,61 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus ...@@ -27,38 +47,61 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus
this.procdefinitionmodelsDAO = procdefinitionmodelsDAO; this.procdefinitionmodelsDAO = procdefinitionmodelsDAO;
} }
public void setRepositoryService(RepositoryService repositoryService) {
this.repositoryService = repositoryService;
}
public void setProcdefinitionDAO(procdefinitionDAO procdefinitionDAO) {
this.procdefinitionDAO = procdefinitionDAO;
}
public void setManagementService(ManagementService managementService) {
this.managementService = managementService;
}
@Override @Override
public Map<String, Object> insert_procde_finition_models(Map<String, Object> entity) throws BusinessException { public Map<String, Object> insert_procde_finition_models(Map<String, Object> entity) throws BusinessException {
if (entity.get("UUID") == null) { // 查询流程记录(为了获取该流程的流程部署key值)
entity.put("UUID", java.util.UUID.randomUUID().toString()); Map<String, Object> query = new HashMap<String, Object>();
query.put("UUID", entity.get("PROCID"));
String deploymentKey = procdefinitionDAO.list_procde_finition(query).get(0).get("DEPLOYMENT_KEY").toString();
// 添加model
Model model = createModel(entity.get("MODEL_NAME").toString(), entity.get("DESCRIPTION").toString(), deploymentKey);
// 添加model和流程表的匹配
Map<String, Object> procdefinitionmodels = new HashMap<String, Object>();
procdefinitionmodels.put("MODEL_ID", model.getId());
procdefinitionmodels.put("PROC_DEFINITION_ID", entity.get("PROCID"));
if (procdefinitionmodels.get("UUID") == null) {
procdefinitionmodels.put("UUID", java.util.UUID.randomUUID().toString());
} }
if (entity.get("CREATE_TIME") == null) { if (procdefinitionmodels.get("CREATE_TIME") == null) {
entity.put("CREATE_TIME", new Date()); procdefinitionmodels.put("CREATE_TIME", new Date());
} }
if (entity.get("CREATE_ID") == null) { if (procdefinitionmodels.get("CREATE_ID") == null) {
entity.put("CREATE_ID", SessionUtil.getCode()); procdefinitionmodels.put("CREATE_ID", SessionUtil.getCode());
} }
if (entity.get("UPDATE_ID") == null) { if (procdefinitionmodels.get("UPDATE_ID") == null) {
entity.put("UPDATE_ID", SessionUtil.getCode()); procdefinitionmodels.put("UPDATE_ID", SessionUtil.getCode());
} }
if (entity.get("UPDATE_TIME") == null) { if (procdefinitionmodels.get("UPDATE_TIME") == null) {
entity.put("UPDATE_TIME", new Date()); procdefinitionmodels.put("UPDATE_TIME", new Date());
} }
// 动态传值插入 // 动态传值插入
List<String> infoListKey = new ArrayList<String>(); List<String> infoListKey = new ArrayList<String>();
List<Object> infoList = new ArrayList<Object>(); List<Object> infoList = new ArrayList<Object>();
if (entity.keySet() != null) { if (procdefinitionmodels.keySet() != null) {
Set<String> key = entity.keySet(); Set<String> key = procdefinitionmodels.keySet();
// 将map集合中的key和value 取出来分别放到list集合里 // 将map集合中的key和value 取出来分别放到list集合里
for (String str : key) { for (String str : key) {
infoList.add(entity.get(str)); infoList.add(procdefinitionmodels.get(str));
infoListKey.add(str); infoListKey.add(str);
} }
entity.put("infoListKey", infoListKey); procdefinitionmodels.put("infoListKey", infoListKey);
entity.put("infoList", infoList); procdefinitionmodels.put("infoList", infoList);
} }
procdefinitionmodelsDAO.insert_procde_finition_models(entity); procdefinitionmodelsDAO.insert_procde_finition_models(procdefinitionmodels);
return entity; return entity;
} }
...@@ -79,21 +122,76 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus ...@@ -79,21 +122,76 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus
@Override @Override
public Page<Map<String, Object>> list_procde_finition_models(int pageNo, int pageSize, Map<String, Object> query) throws BusinessException { public Page<Map<String, Object>> list_procde_finition_models(int pageNo, int pageSize, Map<String, Object> query) throws BusinessException {
machining(query);
// 计算起始记录 // 计算起始记录
int pageStart = (pageNo - 1) * pageSize; int pageStart = (pageNo - 1) * pageSize;
// 获取列表 // 获取列表(流程定义id下的全部模块id)
List<Map<String, Object>> items = procdefinitionmodelsDAO.list_procde_finition_models(new RowBounds(pageStart, pageSize), query); Map<String, Object> query2=new HashMap<String, Object>();
query2.put("PROC_DEFINITION_ID", query.get("PROCID"));
List<Map<String, Object>> items = procdefinitionmodelsDAO.list_procde_finition_models(query2);
List<String> listId = new ArrayList<String>();
for (Map<String, Object> m : items) {
listId.add(m.get("MODEL_ID").toString());
}
// 申明一个基于Model的自定义查询
NativeModelQuery nativeModelQuery = repositoryService.createNativeModelQuery();
String sql = " FROM " + managementService.getTableName(Model.class) + " T";
StringBuffer where = new StringBuffer();
if (listId.size() > 0) {
StringBuffer condition = new StringBuffer();
condition.append("T.ID_ IN (");
for (int i = 0; i < listId.size(); i++) {
if (i != 0) {
condition.append(",");
}
condition.append("#{modelId" + i + "}");
nativeModelQuery.parameter("modelId" + i, listId.get(i));
}
condition.append(")");
addCondition(where, condition.toString());
}
// 设置查询条件
if (query.get("modelName")!=null&&!"".equals(query.get("modelName"))) {
addCondition(where, "NAME_ LIKE #{modelName}");
nativeModelQuery.parameter("modelName", "%" + query.get("modelName") + "%");
}
sql += where.toString();
// 获取列表个数 // 获取列表个数
int count = listCount_procde_finition_models(query); int count = Integer.valueOf(nativeModelQuery.sql("SELECT count(*) " + sql).count() + "");
List<Model> listModel=nativeModelQuery.sql("SELECT * "+sql).listPage((pageNo-1) * pageSize, pageSize);
List<Map<String,Object>> listModelMap=new ArrayList<Map<String,Object>>();
for(Model model:listModel){
Map<String,Object> m=new HashMap<String, Object>();
listModelMap.add(m);
m.put("ID", model.getId());
m.put("REVISION", model.getVersion());
m.put("NAME", model.getName());
m.put("KEY", model.getKey());
m.put("CATEGORY", model.getCategory());
m.put("CREATETIME", model.getCreateTime());
m.put("LASTUPDATETIME", model.getLastUpdateTime());
m.put("METAINFO", model.getMetaInfo());
m.put("KEY", model.getKey());
List<String> listKey=new ArrayList<String>();
for(String k:m.keySet()){
if(m.get(k)==null){
listKey.add(k);
}
}
for(String k:listKey){
m.remove(k);
}
}
// 创建分页对象 // 创建分页对象
Page<Map<String, Object>> page = new Page<Map<String, Object>>(); Page<Map<String, Object>> page = new Page<Map<String, Object>>();
page.setStart(pageStart); page.setStart(pageStart);
page.setLimit(pageSize); page.setLimit(pageSize);
page.setCount(count); page.setCount(count);
page.setItems(items); page.setItems(listModelMap);
return page; return page;
} }
...@@ -109,6 +207,35 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus ...@@ -109,6 +207,35 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus
machining(query); machining(query);
return procdefinitionmodelsDAO.listCount_procde_finition_models(query); return procdefinitionmodelsDAO.listCount_procde_finition_models(query);
} }
@Override
public void deploy(Map<String, Object> query) throws BusinessException {
String procId=query.get("PROCID").toString();
String modelId=query.get("MODELID").toString();
Model modelData = repositoryService.getModel(modelId);
ObjectNode modelNode = null;
try {
modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
} catch (JsonProcessingException e) {
throw new BusinessException(e.getMessage());
} catch (IOException e) {
throw new BusinessException(e.getMessage());
}
byte[] bpmnBytes = null;
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
bpmnBytes = new BpmnXMLConverter().convertToXML(model);
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
//将部署id存入流程定义表
Map<String,Object> entity=new HashMap<String, Object>();
entity.put("UUID", procId);
entity.put("DEPLOYMENT_ID", deployment.getId());
convertEntity(entity);
procdefinitionDAO.update_procde_finition(entity);
}
/** /**
* 更新或者插入时,处理map对象的形式(将字段信息存储为list,便于mybatis代码调用) * 更新或者插入时,处理map对象的形式(将字段信息存储为list,便于mybatis代码调用)
...@@ -133,10 +260,65 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus ...@@ -133,10 +260,65 @@ public class ProcdefinitionmodelsBusinessImpl implements ProcdefinitionmodelsBus
} }
entity.put("info", updateList); entity.put("info", updateList);
} }
private void machining(Map<String, Object> query) {
if (query.get("PROC_NAME") != null && !"".equals(query.get("PROC_NAME"))) {
query.put("PROC_NAME", "%" + query.get("PROC_NAME") + "%");
}
}
/**
* 添加model
*
* @param modelName
* @param description
* @param modelKey
* @return
*/
private Model createModel(String modelName, String description, String deploymentKey) {
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode editorNode = objectMapper.createObjectNode();
editorNode.put("id", "canvas");
editorNode.put("resourceId", "canvas");
ObjectNode stencilSetNode = objectMapper.createObjectNode();
stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
editorNode.put("stencilset", stencilSetNode);
ObjectNode properties = objectMapper.createObjectNode();
properties.put("process_id", deploymentKey);
editorNode.put("properties", properties);
Model modelData = repositoryService.newModel();
ObjectNode modelObjectNode = objectMapper.createObjectNode();
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, modelName);
modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
description = org.apache.commons.lang3.StringUtils.defaultString(description);
modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description);
modelData.setMetaInfo(modelObjectNode.toString());
modelData.setName(modelName);
modelData.setKey(org.apache.commons.lang3.StringUtils.defaultString(deploymentKey));
repositoryService.saveModel(modelData);
try {
repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return repositoryService.createModelQuery().modelId(modelData.getId()).singleResult();
}
private void machining(Map<String, Object> query){ /**
if(query.get("PROC_NAME")!=null&&!"".equals(query.get("PROC_NAME"))){ * 添加条件
query.put("PROC_NAME", "%"+query.get("PROC_NAME")+"%"); * @param where
* @param condition
*/
private void addCondition(StringBuffer where, String condition) {
if (where.length() == 0) {
where.append(" WHERE");
}else{
where.append(" AND");
} }
where.append(" ").append(condition).toString();
} }
} }
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.gaowj.business.ProcdefinitionBusiness; import com.gaowj.business.ProcdefinitionBusiness;
import com.gaowj.business.ProcdefinitionmodelsBusiness;
import com.gaowj.business.StudentBusiness; import com.gaowj.business.StudentBusiness;
import com.gaowj.business.SystemOpeBusiness; import com.gaowj.business.SystemOpeBusiness;
import com.gaowj.business.action.BasicAction; import com.gaowj.business.action.BasicAction;
...@@ -38,8 +39,8 @@ public class actAction extends BasicAction { ...@@ -38,8 +39,8 @@ public class actAction extends BasicAction {
* @param entity * @param entity
* @throws BusinessException * @throws BusinessException
*/ */
public String insertProcdefinition() throws BusinessException { public String insertProcdefinitionmodels() throws BusinessException {
ProcdefinitionBusiness business = BusinessManager.getBusiness(ProcdefinitionBusiness.class); ProcdefinitionmodelsBusiness business = BusinessManager.getBusiness(ProcdefinitionmodelsBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX); Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject(); jsonObject = new JSONObject();
...@@ -48,12 +49,12 @@ public class actAction extends BasicAction { ...@@ -48,12 +49,12 @@ public class actAction extends BasicAction {
//去除不要更新的字段 //去除不要更新的字段
entity.remove("OPETYPE"); entity.remove("OPETYPE");
//新增 //新增
Map<String,Object> procdefinition=business.insert_procde_finition(entity); Map<String,Object> procdefinitionmodels=business.insert_procde_finition_models(entity);
// 操作日志 // 操作日志
//sysbusiness.insert_logBusiness(具体方法,操作内容,操作描述,操作记录ID,操作记录中文描述,分类) //sysbusiness.insert_logBusiness(具体方法,操作内容,操作描述,操作记录ID,操作记录中文描述,分类)
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class); SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("insertProcdefinition", "" + entity, sysbusiness.insert_logBusiness("insertProcdefinitionmodels", "" + procdefinitionmodels,
"增加流程定义数据", (String) entity.get("UUID"), (String) entity.get("CONTENT"), "procdefinition"); "增加流程定义模板数据", (String) entity.get("UUID"), (String) entity.get("CONTENT"), "procdefinitionmodels");
// //
// //
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功")); jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
...@@ -64,8 +65,8 @@ public class actAction extends BasicAction { ...@@ -64,8 +65,8 @@ public class actAction extends BasicAction {
return "json"; return "json";
} }
public String updateProcdefinition() throws BusinessException { public String updateProcdefinitionmodels() throws BusinessException {
ProcdefinitionBusiness business = BusinessManager.getBusiness(ProcdefinitionBusiness.class); ProcdefinitionmodelsBusiness business = BusinessManager.getBusiness(ProcdefinitionmodelsBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX); Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject(); jsonObject = new JSONObject();
...@@ -74,12 +75,12 @@ public class actAction extends BasicAction { ...@@ -74,12 +75,12 @@ public class actAction extends BasicAction {
//去除不要更新的字段 //去除不要更新的字段
entity.remove("OPETYPE"); entity.remove("OPETYPE");
//新增 //新增
business.update_procde_finition(entity); business.update_procde_finition_models(entity);
// 操作日志 // 操作日志
//sysbusiness.insert_logBusiness(具体方法,操作内容,操作描述,操作记录ID,操作记录中文描述,分类) //sysbusiness.insert_logBusiness(具体方法,操作内容,操作描述,操作记录ID,操作记录中文描述,分类)
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class); SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("updateProcdefinition", "" + entity, sysbusiness.insert_logBusiness("updateProcdefinitionmodels", "" + entity,
"修改流程定义数据", (String) entity.get("UUID"), (String) entity.get("CONTENT"), "procdefinition"); "修改流程定义模板数据", (String) entity.get("UUID"), (String) entity.get("CONTENT"), "procdefinitionmodels");
// //
// //
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功")); jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
...@@ -90,18 +91,18 @@ public class actAction extends BasicAction { ...@@ -90,18 +91,18 @@ public class actAction extends BasicAction {
return "json"; return "json";
} }
public String deleteProcdefinition() throws BusinessException { public String deleteProcdefinitionmodels() throws BusinessException {
ProcdefinitionBusiness business = BusinessManager.getBusiness(ProcdefinitionBusiness.class); ProcdefinitionmodelsBusiness business = BusinessManager.getBusiness(ProcdefinitionmodelsBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX); Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
String deletekey = (String) entity.get("CODE"); String deletekey = (String) entity.get("CODE");
List<String> ListKey = QueryParamUtil.StringToList(deletekey); List<String> ListKey = QueryParamUtil.StringToList(deletekey);
try { try {
business.delete_procde_finition(ListKey); business.delete_procde_finition_models(ListKey);
// 操作日志 // 操作日志
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class); SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("deleteProcdefinition", "" + ListKey, sysbusiness.insert_logBusiness("deleteProcdefinitionmodels", "" + ListKey,
"删除流程定义数据", deletekey, "多个流水号","procdefinition"); "删除流程定义模板数据", deletekey, "多个流水号","procdefinitionmodels");
// //
jsonObject.putAll(Status.getStatusSuccessMessage("删除成功")); jsonObject.putAll(Status.getStatusSuccessMessage("删除成功"));
...@@ -111,5 +112,25 @@ public class actAction extends BasicAction { ...@@ -111,5 +112,25 @@ public class actAction extends BasicAction {
} }
return "json"; return "json";
} }
public String deploy() throws BusinessException {
ProcdefinitionmodelsBusiness business = BusinessManager.getBusiness(ProcdefinitionmodelsBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
try {
business.deploy(entity);
// 操作日志
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("deploy", "" + entity,
"部署流程定义模板数据", (String) entity.get("UUID"), (String) entity.get("CONTENT"), "procdefinitionmodels");
//
jsonObject.putAll(Status.getStatusSuccessMessage("部署成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("部署失败"));
e.printStackTrace();
}
return "json";
}
} }
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