diff --git a/skyeye-activiti/src/main/java/com/skyeye/activiti/controller/ActivitiModelController.java b/skyeye-activiti/src/main/java/com/skyeye/activiti/controller/ActivitiModelController.java index b68a726546f050d9492f7e00c1c1482b61aea878..76e8f3ebf3c1380c80133f3da5bc61906f4a516a 100644 --- a/skyeye-activiti/src/main/java/com/skyeye/activiti/controller/ActivitiModelController.java +++ b/skyeye-activiti/src/main/java/com/skyeye/activiti/controller/ActivitiModelController.java @@ -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 diff --git a/skyeye-activiti/src/main/java/com/skyeye/activiti/service/ActivitiModelService.java b/skyeye-activiti/src/main/java/com/skyeye/activiti/service/ActivitiModelService.java index fa8d42663c368ac191781d8ae8fb7dd45b1b41ad..2ef5d09086b0bda2f3ba1b278198501842238b8a 100644 --- a/skyeye-activiti/src/main/java/com/skyeye/activiti/service/ActivitiModelService.java +++ b/skyeye-activiti/src/main/java/com/skyeye/activiti/service/ActivitiModelService.java @@ -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; diff --git a/skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/ActivitiModelServiceImpl.java b/skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/ActivitiModelServiceImpl.java index f7282c9b3c38a084709b69aaa0e579db69bfcbb1..d613d3055429b8f50e05b2e831b0347fc2087190 100644 --- a/skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/ActivitiModelServiceImpl.java +++ b/skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/ActivitiModelServiceImpl.java @@ -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 map = inputObject.getParams(); - Map 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 = "数据不能为空."; diff --git a/skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/DsFormActivitiServiceImpl.java b/skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/DsFormActivitiServiceImpl.java index ecaf825757d675ed9e61ffcd26b2ffc4df28ab07..df3caf9e697cd5ba7bb5b17be2513822792f4457 100644 --- a/skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/DsFormActivitiServiceImpl.java +++ b/skyeye-activiti/src/main/java/com/skyeye/activiti/service/impl/DsFormActivitiServiceImpl.java @@ -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 map = inputObject.getParams(); Map 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> beans = new ArrayList>(); - List> jsonArray = new ArrayList<>(); - Map> 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 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 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 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> jsonArray = JSONArray.fromObject(str); + String sequenceId = ToolUtil.getSurFaceId(); + List> 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 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> pageDatas) { + Map result = new HashMap<>(); + for(Map 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> getDsFormPageData(List> jsonArray, String sequenceId, String userId) throws Exception { + List> pageDatas = new ArrayList<>(); + for (Map 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 pageData = dsFormPageService.getDsFormPageData(pageContentId, value, text, item.get("showType").toString(), sequenceId, userId); + pageData.put("formItemType", item.get("controlType")); + pageDatas.add(pageData); } + return pageDatas; } /** diff --git a/skyeye-activiti/src/main/java/com/skyeye/eve/service/impl/ActModleTypeServiceImpl.java b/skyeye-activiti/src/main/java/com/skyeye/eve/service/impl/ActModleTypeServiceImpl.java index 4449c41085d5e2a4292067ba53d154b14823406f..32d2a67cd833078a602715f4c3e09aced3c01f41 100644 --- a/skyeye-activiti/src/main/java/com/skyeye/eve/service/impl/ActModleTypeServiceImpl.java +++ b/skyeye-activiti/src/main/java/com/skyeye/eve/service/impl/ActModleTypeServiceImpl.java @@ -650,28 +650,24 @@ public class ActModleTypeServiceImpl implements ActModleTypeService { @Transactional(value="transactionManager") public void editDsFormMationBySequenceId(InputObject inputObject, OutputObject outputObject) throws Exception { Map 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> json = JSONUtil.toList(str, null); - Map params = (Map) taskService.getVariable(taskId, "baseTask"); - String contentId = ""; - Map cenBean; - for(int i = 0; i < json.size(); i++){ - Map jObject = json.get(i);// 遍历 jsonarray 数组,把每一个对象转成 json 对象 - actModleTypeDao.editDsFormMationBySequenceId(jObject); - contentId = jObject.get("contentId").toString(); - System.out.println(contentId); - if(params.containsKey(contentId)){ - cenBean = (Map) 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> json = JSONUtil.toList(map.get("jsonStr").toString(), null); + + Map params = (Map) taskService.getVariable(taskId, "baseTask"); + + for(int i = 0; i < json.size(); i++){ + Map jObject = json.get(i);// 遍历 jsonarray 数组,把每一个对象转成 json 对象 + actModleTypeDao.editDsFormMationBySequenceId(jObject); + String pageDataId = jObject.get("rowId").toString(); + if(params.containsKey(pageDataId)){ + Map cenBean = (Map) params.get(pageDataId); + cenBean.put("text", jObject.get("text")); + cenBean.put("value", jObject.get("value")); + params.put(pageDataId, cenBean); + } } + runtimeService.setVariable(processInstanceId, "baseTask", params); } /** diff --git a/skyeye-activiti/src/main/java/com/skyeye/eve/service/impl/PageSequenceServiceImpl.java b/skyeye-activiti/src/main/java/com/skyeye/eve/service/impl/PageSequenceServiceImpl.java index 3e5b82ca3aff78ed66ea93eaab283ceb736ee0fe..cd3c26bbaf35a7381b1dca8a186c2a7d9ebda1f2 100644 --- a/skyeye-activiti/src/main/java/com/skyeye/eve/service/impl/PageSequenceServiceImpl.java +++ b/skyeye-activiti/src/main/java/com/skyeye/eve/service/impl/PageSequenceServiceImpl.java @@ -132,13 +132,10 @@ public class PageSequenceServiceImpl implements PageSequenceService{ public void editDsFormISDraftById(InputObject inputObject, OutputObject outputObject) throws Exception { Map map = inputObject.getParams(); String str = map.get("jsonStr").toString();//前端传来的数据json串 - if(ToolUtil.isJson(str)){ - List> json = JSONUtil.toList(str, null); - for(int i = 0; i < json.size(); i++){ - Map jObject = json.get(i);// 遍历 jsonarray 数组,把每一个对象转成 json 对象 - dsFormPageSequenceDao.editDsFormISDraftById(jObject); - } - } + List> json = JSONUtil.toList(str, null); + json.forEach(bean -> { + dsFormPageSequenceDao.editDsFormISDraftById(bean); + }); } /** @@ -156,7 +153,7 @@ public class PageSequenceServiceImpl implements PageSequenceService{ Map map = inputObject.getParams(); Map user = inputObject.getLogParams(); map.put("userId", user.get("id")); - //查询为草稿状态的提交项 + // 查询为草稿状态的提交项 Map bean = dsFormPageSequenceDao.queryDsFormStateById(map); if(bean != null && !bean.isEmpty()){ if(!bean.containsKey("actKey") || ToolUtil.isBlank(bean.get("actKey").toString())){ diff --git a/skyeye-activiti/src/main/resources/mapper/activiti/ActModelMapper.xml b/skyeye-activiti/src/main/resources/mapper/activiti/ActModelMapper.xml index a832f8c505fe8fcb1ac3816dd0b210956c826535..2130b234bb1479b97051323014077154cba0f773 100644 --- a/skyeye-activiti/src/main/resources/mapper/activiti/ActModelMapper.xml +++ b/skyeye-activiti/src/main/resources/mapper/activiti/ActModelMapper.xml @@ -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, diff --git a/skyeye-activiti/src/main/resources/mapper/activiti/ActUserProcessInstanceIdMapper.xml b/skyeye-activiti/src/main/resources/mapper/activiti/ActUserProcessInstanceIdMapper.xml index 0b2e400c4a6dc8eb7ba9b0a3206c4d1c82dd4159..dbccfbd3fbe590d29ef8d89651b1a7b10b31d4df 100644 --- a/skyeye-activiti/src/main/resources/mapper/activiti/ActUserProcessInstanceIdMapper.xml +++ b/skyeye-activiti/src/main/resources/mapper/activiti/ActUserProcessInstanceIdMapper.xml @@ -5,10 +5,10 @@