提交 3a19011c 编写于 作者: doc_wei's avatar doc_wei

动态表单整合工作流完成

上级 15c6c585
......@@ -77,22 +77,6 @@ public class ActivitiModelController {
activitiModelService.editActivitiModelToDeploy(inputObject, outputObject);
}
/**
*
* @Title: editActivitiModelToStartProcess
* @Description: 启动流程
* @param inputObject
* @param outputObject
* @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/ActivitiModelController/editActivitiModelToStartProcess")
@ResponseBody
public void editActivitiModelToStartProcess(InputObject inputObject, OutputObject outputObject) throws Exception{
activitiModelService.editActivitiModelToStartProcess(inputObject, outputObject);
}
/**
*
* @Title: deleteActivitiModelById
......
......@@ -29,8 +29,6 @@ public interface ActivitiModelService {
public void editActivitiModelToDeploy(InputObject inputObject, OutputObject outputObject) throws Exception;
public void editActivitiModelToStartProcess(InputObject inputObject, OutputObject outputObject) throws Exception;
public void deleteActivitiModelById(InputObject inputObject, OutputObject outputObject) throws Exception;
public void deleteReleasedActivitiModelById(InputObject inputObject, OutputObject outputObject) throws Exception;
......
......@@ -254,55 +254,6 @@ public class ActivitiModelServiceImpl implements ActivitiModelService{
LOGGER.info("流程【{}】成功发布", processName);
}
/**
* @Title: editActivitiModelToStartProcess
* @Description: 启动流程
* @param inputObject
* @param outputObject
* @throws Exception 参数
* @return void 返回类型
* @throws
*/
@Override
@ActivitiAndBaseTransaction(value = {"activitiTransactionManager", "transactionManager"})
public void editActivitiModelToStartProcess(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> user = inputObject.getLogParams();
// 流程定义的key
String keyName = map.get("keyName").toString();
/**
* jsonStr参数介绍
* name: "",----标题
* value: "",----值
* orderBy: 1,----排序,值越大越往后
* showType: 1----展示类型:1.文本展示;2.附件展示;3.富文本展示;4.图片上传;5.表格展示
* proportion: 6----展示比例,前端界面百分比分为12份
* editableNodeId:可编辑节点Id
* editableNodeName:可编辑节点名称
* formItemType: 原始表单类型
* formItem:表单内容
*/
String str = map.get("jsonStr").toString();
if(ToolUtil.isBlank(str)){
outputObject.setreturnMessage("数据不能为空.");
}else{
try{
// 流程存在的时候才能执行
if(judgeProcessKeyIsLive(keyName)){
// 启动流程
startProcess(str, user, keyName, "");
outputObject.setBean(map);
}else{
LOGGER.info("this processDefinitionKey's [{}] process is non-exits", keyName);
outputObject.setreturnMessage("任务发起失败,不存在该流程模型.");
}
}catch(Exception e){
LOGGER.warn("start Process failed", e);
outputObject.setreturnMessage("任务发起失败.");
}
}
}
/**
* 启动流程
*
......@@ -438,6 +389,17 @@ public class ActivitiModelServiceImpl implements ActivitiModelService{
/**
* 启动流程--其他方法调用
*
* jsonStr参数介绍
* * name: "",----标题
* * value: "",----值
* * orderBy: 1,----排序,值越大越往后
* * showType: 1----展示类型:1.文本展示;2.附件展示;3.富文本展示;4.图片上传;5.表格展示
* * proportion: 6----展示比例,前端界面百分比分为12份
* * editableNodeId:可编辑节点Id
* * editableNodeName:可编辑节点名称
* * formItemType: 原始表单类型
* * formItem:表单内容
*
* @param map
* @param user 用户信息
* @param id 数据id
......@@ -449,18 +411,6 @@ public class ActivitiModelServiceImpl implements ActivitiModelService{
String keyName = map.get("keyName").toString();
map.put("code", "-1");
String message = "";
/**
* jsonStr参数介绍
* name: "",----标题
* value: "",----值
* orderBy: 1,----排序,值越大越往后
* showType: 1----展示类型:1.文本展示;2.附件展示;3.富文本展示;4.图片上传;5.表格展示
* proportion: 6----展示比例,前端界面百分比分为12份
* editableNodeId:可编辑节点Id
* editableNodeName:可编辑节点名称
* formItemType: 原始表单类型
* formItem:表单内容
*/
String str = JSONUtil.toJsonStr(map.get("jsonStr"));//前端传来的数据json串
if(ToolUtil.isBlank(str)){//如果数据为空
message = "数据不能为空.";
......
......@@ -4,7 +4,7 @@
package com.skyeye.activiti.service.impl;
import cn.hutool.json.JSONUtil;
import com.gexin.fastjson.JSON;
import com.skyeye.activiti.service.ActivitiModelService;
import com.skyeye.activiti.service.DsFormActivitiService;
import com.skyeye.annotation.transaction.ActivitiAndBaseTransaction;
......@@ -15,14 +15,12 @@ import com.skyeye.eve.dao.ActUserProcessInstanceIdDao;
import com.skyeye.eve.dao.DsFormPageDataDao;
import com.skyeye.eve.dao.DsFormPageSequenceDao;
import com.skyeye.eve.service.DsFormPageService;
import net.sf.json.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @ClassName: DsFormActivitiServiceImpl
......@@ -68,42 +66,54 @@ public class DsFormActivitiServiceImpl implements DsFormActivitiService {
public void insertDSFormProcess(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> user = inputObject.getLogParams();
String userId = user.get("id").toString();
String str = map.get("jsonStr").toString();//前端传来的数据json串
if(ToolUtil.isBlank(str)){//如果数据为空
outputObject.setreturnMessage("数据不能为空.");
}else{
try{
List<Map<String, Object>> beans = new ArrayList<Map<String,Object>>();
List<Map<String, Object>> jsonArray = new ArrayList<>();
Map<String, Map<String, Object>> jOb = JSONUtil.toBean(str, null);
//遍历数据存入JSONArray集合
for(String key : jOb.keySet()){
jsonArray.add(jOb.get(key));
}
String sequenceId = ToolUtil.getSurFaceId();
String userId = user.get("id").toString();
String pageId = "";
for (Map<String, Object> item : jsonArray) {
String pageContentId = item.get("rowId").toString();
String value = item.containsKey("value") == true ? item.get("value").toString() : "";
String text = item.containsKey("text") == true ? item.get("text").toString() : "";
Map<String, Object> m = dsFormPageService.getDsFormPageData(pageContentId, value, text, item.get("showType").toString(), sequenceId, userId);
pageId = m.get("pageId").toString();
beans.add(m);
}
activitiModelService.editActivitiModelToStartProcessByMap(map, user, sequenceId);
if("0".equals(map.get("code").toString())){//启动流程成功
dsFormPageDataDao.insertDsFormPageData(beans);//插入DsFormPageData表
Map<String, Object> entity = dsFormPageService.getDsFormPageSequence(userId, pageId, map.get("message").toString(), StringUtils.EMPTY);
entity.put("sequenceId", sequenceId);
dsFormPageSequenceDao.insertDsFormPageSequence(Arrays.asList(entity));
}else{
outputObject.setreturnMessage(map.get("message").toString());
}
}catch(Exception e){
outputObject.setreturnMessage("任务发起失败.");
String pageId = map.get("pageId").toString();
try{
// 1.构造动态表单的数据
List<Map<String, Object>> jsonArray = JSONArray.fromObject(str);
String sequenceId = ToolUtil.getSurFaceId();
List<Map<String, Object>> pageDatas = getDsFormPageData(jsonArray, sequenceId, userId);
// 2.将动态表单的数据构造成工作流需要的数据
String actData = getActDataByDsFormData(pageDatas);
map.put("jsonStr", actData);
activitiModelService.editActivitiModelToStartProcessByMap(map, user, sequenceId);
if("0".equals(map.get("code").toString())){//启动流程成功
dsFormPageDataDao.insertDsFormPageData(pageDatas);//插入DsFormPageData表
Map<String, Object> entity = dsFormPageService.getDsFormPageSequence(userId, pageId, map.get("message").toString(), StringUtils.EMPTY);
entity.put("sequenceId", sequenceId);
dsFormPageSequenceDao.insertDsFormPageSequence(Arrays.asList(entity));
}else{
outputObject.setreturnMessage(map.get("message").toString());
}
}catch(Exception e){
outputObject.setreturnMessage("任务发起失败.");
}
}
private String getActDataByDsFormData(List<Map<String, Object>> pageDatas) {
Map<String, Object> result = new HashMap<>();
for(Map<String, Object> bean: pageDatas){
bean.put("formItem", bean);
bean.put("name", bean.get("title"));
bean.put("proportion", bean.get("defaultWidth"));
bean.put("rowId", bean.get("contentId"));
result.put(bean.get("contentId").toString(), bean);
}
return JSON.toJSONString(result);
}
private List<Map<String, Object>> getDsFormPageData(List<Map<String, Object>> jsonArray, String sequenceId, String userId) throws Exception {
List<Map<String, Object>> pageDatas = new ArrayList<>();
for (Map<String, Object> item : jsonArray) {
String pageContentId = item.get("rowId").toString();
String value = item.containsKey("value") == true ? item.get("value").toString() : "";
String text = item.containsKey("text") == true ? item.get("text").toString() : "";
Map<String, Object> pageData = dsFormPageService.getDsFormPageData(pageContentId, value, text, item.get("showType").toString(), sequenceId, userId);
pageData.put("formItemType", item.get("controlType"));
pageDatas.add(pageData);
}
return pageDatas;
}
/**
......
......@@ -650,28 +650,24 @@ public class ActModleTypeServiceImpl implements ActModleTypeService {
@Transactional(value="transactionManager")
public void editDsFormMationBySequenceId(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
String str = map.get("jsonStr").toString();//前端传来的数据json串
String taskId = map.get("taskId").toString();//任务id
String processInstanceId = map.get("processInstanceId").toString();//流程id
if(ToolUtil.isJson(str)){
List<Map<String, Object>> json = JSONUtil.toList(str, null);
Map<String, Object> params = (Map<String, Object>) taskService.getVariable(taskId, "baseTask");
String contentId = "";
Map<String, Object> cenBean;
for(int i = 0; i < json.size(); i++){
Map<String, Object> jObject = json.get(i);// 遍历 jsonarray 数组,把每一个对象转成 json 对象
actModleTypeDao.editDsFormMationBySequenceId(jObject);
contentId = jObject.get("contentId").toString();
System.out.println(contentId);
if(params.containsKey(contentId)){
cenBean = (Map<String, Object>) params.get(contentId);
cenBean.put("text", jObject.get("text"));
cenBean.put("value", jObject.get("value"));
params.put(contentId, cenBean);
}
}
runtimeService.setVariable(processInstanceId, "baseTask", params);
List<Map<String, Object>> json = JSONUtil.toList(map.get("jsonStr").toString(), null);
Map<String, Object> params = (Map<String, Object>) taskService.getVariable(taskId, "baseTask");
for(int i = 0; i < json.size(); i++){
Map<String, Object> jObject = json.get(i);// 遍历 jsonarray 数组,把每一个对象转成 json 对象
actModleTypeDao.editDsFormMationBySequenceId(jObject);
String pageDataId = jObject.get("rowId").toString();
if(params.containsKey(pageDataId)){
Map<String, Object> cenBean = (Map<String, Object>) params.get(pageDataId);
cenBean.put("text", jObject.get("text"));
cenBean.put("value", jObject.get("value"));
params.put(pageDataId, cenBean);
}
}
runtimeService.setVariable(processInstanceId, "baseTask", params);
}
/**
......
......@@ -132,13 +132,10 @@ public class PageSequenceServiceImpl implements PageSequenceService{
public void editDsFormISDraftById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
String str = map.get("jsonStr").toString();//前端传来的数据json串
if(ToolUtil.isJson(str)){
List<Map<String, Object>> json = JSONUtil.toList(str, null);
for(int i = 0; i < json.size(); i++){
Map<String, Object> jObject = json.get(i);// 遍历 jsonarray 数组,把每一个对象转成 json 对象
dsFormPageSequenceDao.editDsFormISDraftById(jObject);
}
}
List<Map<String, Object>> json = JSONUtil.toList(str, null);
json.forEach(bean -> {
dsFormPageSequenceDao.editDsFormISDraftById(bean);
});
}
/**
......@@ -156,7 +153,7 @@ public class PageSequenceServiceImpl implements PageSequenceService{
Map<String, Object> map = inputObject.getParams();
Map<String, Object> user = inputObject.getLogParams();
map.put("userId", user.get("id"));
//查询为草稿状态的提交项
// 查询为草稿状态的提交项
Map<String, Object> bean = dsFormPageSequenceDao.queryDsFormStateById(map);
if(bean != null && !bean.isEmpty()){
if(!bean.containsKey("actKey") || ToolUtil.isBlank(bean.get("actKey").toString())){
......
......@@ -190,7 +190,7 @@
a.id,
a.title,
a.act_id actId,
IF ( IFNULL( a.page_url, '' ) = '', '../../tpl/actmodelpage/dsFormPageModel.html', a.page_url ) pageUrl,
IF ( IFNULL( a.page_url, '' ) = '', '../../tpl/dsFormPageSequence/dsFormPageSequenceDraftProcessAdd.html', a.page_url ) pageUrl,
a.background_color backgroundColor,
IFNULL(a.ds_form_id, '') dsFormId,
a.menu_icon_type menuIconType,
......@@ -242,7 +242,7 @@
a.id,
a.title,
a.act_id actId,
IF ( IFNULL( a.page_url, '' ) = '', '../../tpl/actmodelpage/dsFormPageModel.html', a.page_url ) pageUrl,
IF ( IFNULL( a.page_url, '' ) = '', '../../tpl/dsFormPageSequence/dsFormPageSequenceDraftProcessAdd.html', a.page_url ) pageUrl,
a.background_color backgroundColor,
IFNULL(a.ds_form_id, '') dsFormId,
a.menu_icon_type menuIconType,
......
......@@ -5,10 +5,10 @@
<select id="queryStartProcessNotSubByUserId" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.process_instance_id processInstanceId,
IFNULL(b.id, "") sequenceId,
IFNULL(b.id, '') sequenceId,
a.create_time createTime,
a.data_id dataId,
IF(IFNULL(c.edit_page_url, '') = '', '../../tpl/myactiviti/myactivitiedit.html', c.edit_page_url) pageUrl,
IF(IFNULL(c.edit_page_url, '') = '', '../../tpl/dsFormPageSequence/dsFormPageSequenceDraftProcessEditToAct.html', c.edit_page_url) pageUrl,
c.title taskType,
IF(IFNULL(c.revoke_mapping, '') = '', 'dsformrevoke001', c.revoke_mapping) revokeMapping
FROM
......
......@@ -16,10 +16,6 @@
<url id="activitimode003" path="/post/ActivitiModelController/editActivitiModelToDeploy" val="发布模型为流程定义" allUse="1" groupName="工作流操作">
<property id="modelId" name="modelId" ref="required" var="模型id"/>
</url>
<url id="activitimode004" path="/post/ActivitiModelController/editActivitiModelToStartProcess" val="启动流程" allUse="2" groupName="工作流操作">
<property id="keyName" name="keyName" ref="required" var="模型key"/>
<property id="jsonStr" name="jsonStr" ref="required" var="form表单数据json串"/>
</url>
<url id="activitimode006" path="/post/ActivitiModelController/deleteActivitiModelById" val="删除模型" allUse="1" groupName="工作流操作">
<property id="rowId" name="id" ref="required" var="模型id"/>
</url>
......@@ -123,15 +119,16 @@
</url>
<!-- 工作流用户相关操作结束 -->
<!-- 动态表单审核中撤销开始 -->
<!-- 动态表单工作流开始 -->
<url id="activitimode022" path="/post/DsFormActivitiController/insertDSFormProcess" val="动态表单类型的工作流提交审批" allUse="2" groupName="动态表单工作流操作">
<property id="keyName" name="keyName" ref="required" var="模型key"/>
<property id="pageId" name="pageId" ref="required" var="页面id"/>
<property id="jsonStr" name="jsonStr" ref="required" var="form表单数据json串"/>
</url>
<url id="dsformrevoke001" path="/post/DsFormActivitiController/editDsFormContentToRevokeByProcessInstanceId" val="动态表单类型的工作流进行撤销操作" allUse="2" groupName="动态表单工作流操作">
<property id="processInstanceId" name="processInstanceId" ref="required" var="流程id" />
</url>
<!-- 动态表单审核中撤销结束 -->
<!-- 动态表单工作流结束 -->
<!-- 动态表单草稿操作开始 -->
<url id="pagesequence001" path="/post/PageSequenceController/queryDsFormISDraftListByUser" val="获取所有草稿状态的动态表单提交项" allUse="2">
......@@ -147,7 +144,7 @@
<property id="rowId" name="id" ref="required" var="表单提交序列id" />
</url>
<url id="pagesequence004" path="/post/PageSequenceController/editDsFormISDraftById" val="编辑动态表单(无工作流)" allUse="2">
<property id="jsonStr" name="jsonStr" ref="required" var="form表单数据json串"/>
<property id="jsonStr" name="jsonStr" ref="required,json" var="form表单数据json串"/>
</url>
<url id="pagesequence005" path="/post/PageSequenceController/editDsFormISDraftToSubApprovalById" val="按钮直接提交审批" allUse="2">
<property id="rowId" name="id" ref="required" var="表单提交序列id" />
......
......@@ -29,7 +29,7 @@ public interface DsFormPageSequenceDao {
List<Map<String, Object>> queryDsFormISDraftToEditById(Map<String, Object> map) throws Exception;
int editDsFormISDraftById(Map<String, Object> map) throws Exception;
int editDsFormISDraftById(Map<String, Object> map);
int editDsFormISDraftToSubApprovalById(Map<String, Object> map) throws Exception;
......
......@@ -8,7 +8,9 @@ import cn.hutool.json.JSONUtil;
import com.gexin.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.skyeye.cache.redis.RedisCache;
import com.skyeye.common.constans.Constants;
import com.skyeye.common.constans.RedisConstants;
import com.skyeye.common.constans.SystemFoundationSettingsConstants;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
......@@ -51,10 +53,13 @@ public class DsFormPageServiceImpl implements DsFormPageService {
private DsFormPageDataDao dsFormPageDataDao;
@Autowired
public JedisClientService jedisClient;
private JedisClientService jedisClient;
@Autowired
private DsFormPageSequenceDao dsFormPageSequenceDao;
@Autowired
private RedisCache redisCache;
/**
*
......@@ -330,8 +335,8 @@ public class DsFormPageServiceImpl implements DsFormPageService {
@Override
public void queryDsFormContentListByPageId(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
String pageId = map.get("").toString();
List<Map<String, Object>> beans = getDsFormPageContentByFormId(pageId);
String pageId = map.get("pageId").toString();
List<Map<String, Object>> beans = this.getDsFormPageContentByFormId(pageId);
if(!beans.isEmpty()){
outputObject.setBeans(beans);
outputObject.settotal(beans.size());
......@@ -340,16 +345,15 @@ public class DsFormPageServiceImpl implements DsFormPageService {
@Override
public List<Map<String, Object>> getDsFormPageContentByFormId(String dsFormPageId) throws Exception {
List<Map<String, Object>> beans;
if(ToolUtil.isBlank(jedisClient.get(Constants.dsFormContentListByPageId(dsFormPageId)))){
// 若缓存中无值,从数据库中查询
beans = dsFormPageDao.queryDsFormContentListByPageId(dsFormPageId);
// 将从数据库中查来的内容存到缓存中
jedisClient.set(Constants.dsFormContentListByPageId(dsFormPageId), JSONUtil.toJsonStr(beans));
}else{
beans = JSONUtil.toList(jedisClient.get(Constants.dsFormContentListByPageId(dsFormPageId)), null);
}
return beans;
String cacheKey = Constants.dsFormContentListByPageId(dsFormPageId);
return redisCache.getList(cacheKey, key -> {
try {
return dsFormPageDao.queryDsFormContentListByPageId(dsFormPageId);
} catch (Exception ee) {
LOGGER.warn("getDsFormPageContentByFormId failed, dsFormPageId is {}.", dsFormPageId, ee);
}
return null;
}, RedisConstants.THIRTY_DAY_SECONDS);
}
/**
......
......@@ -107,7 +107,7 @@
a.editable_node_name editableNodeName,
'' formItemType,
a.order_by orderBy,
IF(IFNULL(a.key_id, '') = '', a.content_id, a.key_id) keyId
a.content_id keyId
FROM
ds_form_page_data a
WHERE
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册