提交 169631dc 编写于 作者: Skyeye云's avatar Skyeye云

新增动态表单数据保存接口

上级 f69025e9
......@@ -21,6 +21,7 @@ import com.skyeye.common.object.OutputObject;
import com.skyeye.common.util.DateUtil;
import com.skyeye.common.util.ToolUtil;
import com.skyeye.eve.dao.*;
import com.skyeye.eve.service.DsFormPageService;
import com.skyeye.exception.CustomException;
import com.skyeye.jedis.JedisClientService;
import com.skyeye.annotation.transaction.ActivitiAndBaseTransaction;
......@@ -149,6 +150,9 @@ public class ActivitiModelServiceImpl implements ActivitiModelService{
@Autowired
private ActModelDao actModelDao;
@Autowired
private DsFormPageService dsFormPageService;
/**
* form表单数据存储在task的varables的key
*/
......@@ -1764,7 +1768,6 @@ public class ActivitiModelServiceImpl implements ActivitiModelService{
}else{
try{
List<Map<String, Object>> beans = new ArrayList<Map<String,Object>>();
Map<String, Object> m = null;
List<Map<String, Object>> jsonArray = new ArrayList<>();
Map<String, Map<String, Object>> jOb = JSONUtil.toBean(str, null);
//遍历数据存入JSONArray集合
......@@ -1773,31 +1776,21 @@ public class ActivitiModelServiceImpl implements ActivitiModelService{
}
String sequenceId = ToolUtil.getSurFaceId();
String userId = user.get("id").toString();
String createTime = DateUtil.getTimeAndToString();
String pageId = "";
for (Map<String, Object> o : jsonArray) {
m = dsFormPageDao.queryFromDsFormPageContent((Map<String, Object>)o);
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();
m.put("sequenceId", sequenceId);
m.put("createId", userId);
m.put("createTime", createTime);
m.put("id", ToolUtil.getSurFaceId());
m.put("value", o.containsKey("value") == true ? o.get("value").toString() : "");//是否存在这个值
m.put("text", o.containsKey("text") == true ? o.get("text").toString() : "");
m.put("showType", o.get("showType"));
m.put("defaultWidth", o.get("proportion").toString());
beans.add(m);
}
editActivitiModelToStartProcessByMap(map, user, sequenceId);
if("0".equals(map.get("code").toString())){//启动流程成功
dsFormPageDao.insertDsFormPageData(beans);//插入DsFormPageData表
Map<String, Object> entity = new HashMap<>();
Map<String, Object> entity = dsFormPageService.getDsFormPageSequence(userId, pageId, map.get("message").toString(), StringUtils.EMPTY);
entity.put("sequenceId", sequenceId);
entity.put("createId", userId);
entity.put("createTime", createTime);
entity.put("pageId", pageId);
entity.put("processInstanceId", map.get("message"));//流程id
dsFormPageDao.insertDsFormPageSequence(entity);
dsFormPageDao.insertDsFormPageSequence(Arrays.asList(entity));
}else{
outputObject.setreturnMessage(map.get("message").toString());
}
......
......@@ -212,7 +212,7 @@ public class DsFormPageController {
}
/**
* 根据code获取动表单信息
* 根据code获取动表单信息
*
* @param inputObject
* @param outputObject
......@@ -223,5 +223,19 @@ public class DsFormPageController {
public void queryDsFormContentListByCode(InputObject inputObject, OutputObject outputObject) throws Exception{
dsFormPageService.queryDsFormContentListByCode(inputObject, outputObject);
}
/**
* 保存动态表单信息
*
* @param inputObject
* @param outputObject
* @throws Exception
*/
@RequestMapping("/post/DsFormPageController/saveDsFormDataList")
@ResponseBody
public void saveDsFormDataList(InputObject inputObject, OutputObject outputObject) throws Exception{
dsFormPageService.saveDsFormDataList(inputObject, outputObject);
}
}
......@@ -49,9 +49,9 @@ public interface DsFormPageDao {
public List<Map<String, Object>> queryDsFormContentListByPageId(@Param("dsFormPageId") String dsFormPageId) throws Exception;
public Map<String, Object> queryFromDsFormPageContent(Map<String, Object> o) throws Exception;
public Map<String, Object> queryFromDsFormPageContent(@Param("pageContentId") String pageContentId) throws Exception;
public int insertDsFormPageSequence(Map<String, Object> m) throws Exception;
public int insertDsFormPageSequence(List<Map<String, Object>> pageSequence) throws Exception;
public int insertDsFormPageData(List<Map<String, Object>> beans) throws Exception;
......
/*******************************************************************************
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.eve.service;
import com.skyeye.common.object.InputObject;
......@@ -38,4 +39,34 @@ public interface DsFormPageService {
List<Map<String, Object>> getDsFormPageContentByFormId(String dsFormPageId) throws Exception;
void queryDsFormContentListByCode(InputObject inputObject, OutputObject outputObject) throws Exception;
void saveDsFormDataList(InputObject inputObject, OutputObject outputObject) throws Exception;
/**
* 获取表单提交序列表对象信息
*
* @param userId 用户id
* @param dsFormPageId 动态表单id
* @param processInstanceId 流程id
* @param objectId 关联的其他对象的id
* @return
* @throws Exception
*/
Map<String, Object> getDsFormPageSequence(String userId, String dsFormPageId, String processInstanceId, String objectId) throws Exception;
/**
* 获取表单页面内容项和用户填写的值的信息
*
* @param pageContentId 表单内容项id
* @param value 用户填写的值
* @param text 用户提交供展示的值
* @param showType 展示类型
* @param sequenceId 表单提交序列表id
* @param userId 用户id
* @return
* @throws Exception
*/
Map<String, Object> getDsFormPageData(String pageContentId, String value, String text, String showType,
String sequenceId, String userId) throws Exception;
}
......@@ -5,6 +5,7 @@
package com.skyeye.eve.service.impl;
import cn.hutool.json.JSONUtil;
import com.gexin.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.skyeye.common.constans.Constants;
......@@ -17,10 +18,15 @@ import com.skyeye.common.util.ToolUtil;
import com.skyeye.eve.dao.DsFormPageDao;
import com.skyeye.eve.service.DsFormPageService;
import com.skyeye.jedis.JedisClientService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -37,6 +43,8 @@ import java.util.Map;
@Service
public class DsFormPageServiceImpl implements DsFormPageService {
private static Logger LOGGER = LoggerFactory.getLogger(DsFormPageServiceImpl.class);
@Autowired
private DsFormPageDao dsFormPageDao;
......@@ -358,4 +366,81 @@ public class DsFormPageServiceImpl implements DsFormPageService {
outputObject.settotal(dsFormList.size());
}
/**
* 保存动态表单信息
*
* @param inputObject
* @param outputObject
* @throws Exception
*/
@Override
@Transactional(value="transactionManager")
public void saveDsFormDataList(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 objectId = map.get("objectId").toString();
LOGGER.info("saveDsFormDataList objectId is {}", objectId);
// 前端传来的数据json串
String str = map.get("dataJson").toString();
Map<String, List<Map<String, Object>>> data = JSONObject.parseObject(str, Map.class);
List<Map<String, Object>> pageSequence = new ArrayList<>();
List<Map<String, Object>> pageData = new ArrayList<>();
for (Map.Entry<String, List<Map<String, Object>>> entry : data.entrySet()) {
// 获取表单提交序列表对象信息
Map<String, Object> sequence = this.getDsFormPageSequence(userId, entry.getKey(), StringUtils.EMPTY, objectId);
pageSequence.add(sequence);
for(Map<String, Object> item: entry.getValue()){
String value = item.containsKey("value") == true ? item.get("value").toString() : "";
String text = item.containsKey("text") == true ? item.get("text").toString() : "";
pageData.add(this.getDsFormPageData(item.get("rowId").toString(), value, text,
item.get("showType").toString(), sequence.get("sequenceId").toString(), userId));
}
}
// 插入ds_form_page_data表
if(!pageData.isEmpty()){
dsFormPageDao.insertDsFormPageData(pageData);
}
// 插入ds_form_page_sequence表
if(!pageSequence.isEmpty()){
dsFormPageDao.insertDsFormPageSequence(pageSequence);
}
}
/**
* 获取表单提交序列表对象信息
*
* @param userId 用户id
* @param dsFormPageId 动态表单id
* @param processInstanceId 流程id
* @param objectId 关联的其他信息id
* @return
* @throws Exception
*/
public Map<String, Object> getDsFormPageSequence(String userId, String dsFormPageId, String processInstanceId, String objectId) {
Map<String, Object> sequence = new HashMap<>();
sequence.put("sequenceId", ToolUtil.getSurFaceId());
sequence.put("pageId", dsFormPageId);
sequence.put("processInstanceId", processInstanceId);
sequence.put("createId", userId);
sequence.put("createTime", DateUtil.getTimeAndToString());
sequence.put("objectId", objectId);
return sequence;
}
@Override
public Map<String, Object> getDsFormPageData(String pageContentId, String value, String text, String showType,
String sequenceId, String userId) throws Exception {
Map<String, Object> data = dsFormPageDao.queryFromDsFormPageContent(pageContentId);
data.put("value", value);
data.put("text", text);
data.put("showType", showType);
data.put("sequenceId", sequenceId);
data.put("createId", userId);
data.put("createTime", DateUtil.getTimeAndToString());
data.put("id", ToolUtil.getSurFaceId());
data.put("defaultWidth", data.get("defaultWidth").toString().replace("layui-col-xs", ""));
return data;
}
}
......@@ -202,9 +202,7 @@
IFNULL(a.associated_data_types,'') associatedDataTypes,
IFNULL(a.a_data,'') aData,
IFNULL(d.template_content,'') templateContent,
GROUP_CONCAT(c.former_requirement separator '|') `require`,
a.editable_node_id editableNodeId,
a.editable_node_name editableNodeName
GROUP_CONCAT(c.former_requirement separator '|') `require`
FROM
ds_form_content b
LEFT JOIN ds_form_display_template d ON b.data_show_tpl = d.id,
......@@ -214,11 +212,10 @@
AND a.state = 1
AND b.id = a.form_content_id
GROUP BY a.id
ORDER BY
a.order_by ASC
ORDER BY a.order_by ASC
</select>
<select id="queryFromDsFormPageContent" parameterType="java.util.Map" resultType="java.util.Map">
<select id="queryFromDsFormPageContent" resultType="java.util.Map">
SELECT
a.id contentId,
a.page_id pageId,
......@@ -226,6 +223,7 @@
a.placeholder,
IFNULL(GROUP_CONCAT(c.former_requirement separator '|'), '') `require`,
a.html_content htmlContent,
a.default_width defaultWidth,
a.js_content jsContent,
a.associated_data_types associatedDataTypes,
a.a_data aData,
......@@ -238,26 +236,33 @@
IFNULL(d.template_content, '') displayTemplate
FROM
ds_form_content b
LEFT JOIN ds_form_display_template d ON b.data_show_tpl = d.id,
LEFT JOIN ds_form_display_template d ON b.data_show_tpl = d.id,
ds_form_page_content a
LEFT JOIN ds_form_limit_requirement c ON INSTR(CONCAT(',', a.`require`, ','), CONCAT(',', c.id, ','))
LEFT JOIN ds_form_limit_requirement c ON INSTR(CONCAT(',', a.`require`, ','), CONCAT(',', c.id, ','))
WHERE
a.id = #{rowId}
a.id = #{pageContentId}
AND b.id = a.form_content_id
</select>
<insert id="insertDsFormPageSequence" parameterType="java.util.Map">
INSERT INTO ds_form_page_sequence
(id, page_id, process_instance_id, create_id, create_time)
VALUES(#{sequenceId}, #{pageId}, #{processInstanceId}, #{createId}, #{createTime})
(id, page_id, process_instance_id, create_id, create_time, object_id)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.sequenceId}, #{item.pageId}, #{item.processInstanceId}, #{item.createId}, #{item.createTime}, #{item.objectId})
</foreach>
</insert>
<insert id="insertDsFormPageData" parameterType="java.util.Map">
INSERT INTO ds_form_page_data
(id, content_id, sequence_id, page_id, title, placeholder, `require`, html_content, js_content, associated_data_types, a_data, linked_data, display_template, key_id, editable_node_id, editable_node_name, order_by, default_width, `value`, text, show_type, create_id, create_time)
(id, content_id, sequence_id, page_id, title, placeholder, `require`, html_content, js_content,
associated_data_types, a_data, linked_data, display_template, key_id, editable_node_id, editable_node_name, order_by,
default_width, `value`, text, show_type, create_id, create_time)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id}, #{item.contentId}, #{item.sequenceId}, #{item.pageId}, #{item.title}, #{item.placeholder}, #{item.require}, #{item.htmlContent}, #{item.jsContent}, #{item.associatedDataTypes}, #{item.aData}, #{item.linkedData}, #{item.displayTemplate}, #{item.keyId}, #{item.editableNodeId}, #{item.editableNodeName}, #{item.orderBy}, #{item.defaultWidth}, #{item.value}, #{item.text}, #{item.showType}, #{item.createId}, #{item.createTime})
(#{item.id}, #{item.contentId}, #{item.sequenceId}, #{item.pageId}, #{item.title}, #{item.placeholder}, #{item.require}, #{item.htmlContent}, #{item.jsContent},
#{item.associatedDataTypes}, #{item.aData}, #{item.linkedData}, #{item.displayTemplate}, #{item.keyId}, #{item.editableNodeId}, #{item.editableNodeName}, #{item.orderBy},
#{item.defaultWidth}, #{item.value}, #{item.text}, #{item.showType}, #{item.createId}, #{item.createTime})
</foreach>
</insert>
......
......@@ -160,6 +160,10 @@
<url id="dsformpage013" path="/post/DsFormPageController/queryDsFormContentListByCode" val="根据code获取动态表单信息" allUse="2" method="GET" groupName="表单页面设计接口">
<property id="dsFormCode" name="dsFormCode" ref="required" var="com.skyeye.common.constans.SystemFoundationSettingsConstants.CustomWithDsFormObject中的code" />
</url>
<url id="dsformpage014" path="/post/DsFormPageController/saveDsFormDataList" val="保存动态表单信息" allUse="2" method="POST" groupName="表单页面设计接口">
<property id="dataJson" name="dataJson" ref="required,json" var="数据" />
<property id="objectId" name="objectId" ref="required" var="需要绑定的id" />
</url>
<!-- 动态表单页面设计结束 -->
<!-- 动态表单页面分类开始 -->
......
......@@ -180,6 +180,7 @@ public abstract class ErpOrderFactory {
this.submitData2Activiti(orderId,
Integer.parseInt(depothead.get("subType").toString()),
Integer.parseInt(depothead.get("submitType").toString()));
outputObject.setBean(depothead);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册