chenc vor 3 Jahren
Ursprung
Commit
57b89471ee

+ 10 - 0
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/entity/TbTableInfoPractice.java

@@ -1,12 +1,14 @@
 package org.jeecg.modules.activiti.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 import java.util.Date;
+import java.util.List;
 
 @Data
 public class TbTableInfoPractice {
@@ -19,6 +21,8 @@ public class TbTableInfoPractice {
     //json => String
     @JsonIgnore
     private String content;
+    @TableField(exist = false)
+    private Object jsonContent;
     //修改人
     private String updateBy;
     //修改时间
@@ -47,6 +51,12 @@ public class TbTableInfoPractice {
     private String isInitial;
     //业务表id(外键)
     private String businessTableId;
+    //是否可以保存
+    @TableField(exist = false)
+    private Boolean isSave;
+    //多条数据集合
+    @TableField(exist = false)
+    private List<TbTableInfo> tbTableInfoList;
 
 
     public TbTableInfoPractice() {

+ 17 - 23
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/ActBusinessController.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.activiti.web;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.collect.Lists;
@@ -17,23 +18,15 @@ import org.checkerframework.checker.units.qual.Area;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.activiti.entity.ActBusiness;
-import org.jeecg.modules.activiti.entity.ActZprocess;
-import org.jeecg.modules.activiti.entity.ActivitiConstant;
-import org.jeecg.modules.activiti.entity.ProcessNodeVo;
-import org.jeecg.modules.activiti.entity.TbTableInfo;
-import org.jeecg.modules.activiti.entity.TbTableInfoPractice;
+import org.jeecg.modules.activiti.entity.*;
 import org.jeecg.modules.activiti.service.ITbTableInfoPracticeService;
 import org.jeecg.modules.activiti.service.ITbTableInfoService;
 import org.jeecg.modules.activiti.service.Impl.ActBusinessServiceImpl;
 import org.jeecg.modules.activiti.service.Impl.ActZprocessServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -69,13 +62,13 @@ public class ActBusinessController {
 
     /*添加申请草稿状态*/
     @RequestMapping(value = "/add", method = RequestMethod.POST)
-    public Result add(HttpServletRequest request) throws IOException {
+    public Result add(HttpServletRequest request, @RequestBody JsonContent jsonContent) throws IOException {
         Result result=new Result();
         try {
             String procDefId = request.getParameter("procDefId");
             String procDeTitle = request.getParameter("procDeTitle");
             String tableName = request.getParameter("tableName");
-            String josonContent = request.getParameter("jsonContent");
+            String josonContent = JSON.toJSONString(jsonContent.getJsonContent());
             /*保存业务表单数据到数据库表*/
             String tableId = IdUtil.simpleUUID();
             List<TbTableInfo> tableInfoList = tbTableInfoService.list(new LambdaQueryWrapper<TbTableInfo>().eq(TbTableInfo::getBusinessTable, tableName));
@@ -173,15 +166,7 @@ public class ActBusinessController {
         /*保存业务表单数据到数据库表*/
         String tableId = request.getParameter("tableId");
         String tableName = request.getParameter("tableName");
-        String jsonContent = request.getParameter("jsonContent");
-        if(StringUtils.isNotBlank(jsonContent)){
-            List<TbTableInfoPractice> list = tbTableInfoPracticeService.list(new LambdaQueryWrapper<TbTableInfoPractice>()
-                    .eq(TbTableInfoPractice::getBusinessTableId, tableId));
-            for(TbTableInfoPractice tbTableInfoPractice : list) {
-                //修改申请保存后的表单json
-                tbTableInfoPracticeService.updateById(new TbTableInfoPractice(tbTableInfoPractice.getId(), jsonContent));
-            }
-        }
+
 
 
         Map<String, Object> map = actBusinessService.getApplyForm(tableId, tableName);
@@ -230,9 +215,18 @@ public class ActBusinessController {
     }
     /*修改业务表单信息*/
     @RequestMapping(value = "/editForm", method = RequestMethod.POST)
-    public Result editForm(HttpServletRequest request) throws IOException {
+    public Result editForm(HttpServletRequest request, @RequestBody JsonContent jsonContent) throws IOException {
         /*保存业务表单数据到数据库表*/
         String tableId = request.getParameter("id");
+        String jsonContent1 = JSON.toJSONString(jsonContent.getJsonContent());
+        if(StringUtils.isNotBlank(jsonContent1)){
+            List<TbTableInfoPractice> list = tbTableInfoPracticeService.list(new LambdaQueryWrapper<TbTableInfoPractice>()
+                    .eq(TbTableInfoPractice::getBusinessTableId, tableId));
+            for(TbTableInfoPractice tbTableInfoPractice : list) {
+                //修改申请保存后的表单json
+                tbTableInfoPracticeService.updateById(new TbTableInfoPractice(tbTableInfoPractice.getId(), jsonContent1));
+            }
+        }
         actBusinessService.saveApplyForm(tableId,request);
         return Result.ok();
     }

+ 79 - 29
jeecg-boot/jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/TbTableInfoController.java

@@ -9,6 +9,8 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.activiti.entity.ActNode;
 import org.jeecg.modules.activiti.entity.TbTableInfo;
+import org.jeecg.modules.activiti.entity.TbTableInfoPractice;
+import org.jeecg.modules.activiti.service.ITbTableInfoPracticeService;
 import org.jeecg.modules.activiti.service.ITbTableInfoService;
 import org.jeecg.modules.activiti.service.Impl.ActNodeServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,11 +30,13 @@ public class TbTableInfoController {
    private ITbTableInfoService tbTableInfoService;
     @Autowired
     private ActNodeServiceImpl actNodeService;
+    @Autowired
+    private ITbTableInfoPracticeService iTbTableInfoPracticeService;
 
    @ResponseBody
     @RequestMapping("/list")
     public Result<Object> list(){
-        List<TbTableInfo> list = tbTableInfoService.list(new QueryWrapper<TbTableInfo>().orderByAsc("create_time").groupBy("business_table"));
+        List<TbTableInfo> list = tbTableInfoService.list(new QueryWrapper<TbTableInfo>().eq("del_flag","0").orderByAsc("create_time").groupBy("business_table"));
         for(TbTableInfo t : list){
             Object obj = JSONObject.parseObject(t.getContent());
             t.setJsonContent(obj);
@@ -93,37 +97,83 @@ public class TbTableInfoController {
      * @desc 条件查询
      */
     @RequestMapping("/query")
-    public Result<Object> query(String businessTable,String taskNodeId){
-            boolean isSave=false;
-            QueryWrapper<TbTableInfo> queryWrapper = new QueryWrapper<TbTableInfo>().eq("business_table", businessTable);
-            //查询任务节点是否关联表
-            List<ActNode> actNodeList=  actNodeService.list(new QueryWrapper<ActNode>().eq("node_id",taskNodeId));
-            if(actNodeList!=null&&actNodeList.size()>0&&StringUtils.isNotBlank(actNodeList.get(0).getTbTableInfoId())){
-                //如果任务节点id不为空则根据任务节点id查询
-                queryWrapper.eq("task_node_id",taskNodeId);
-                isSave=true;//分流程节点填写不同内容的表单 强制给到前台解除保存按钮禁用状态
-            }else{//没有关联表则不把流程节点id当作查询条件
-                queryWrapper.and(qw->qw.eq("is_initial","1").or().isNull("is_initial"));
-            }
-           TbTableInfo tableInfo = tbTableInfoService.getOne(queryWrapper);
-           if(tableInfo==null) {
-             return Result.error("未找到实体");
+    public Result<Object> query(String businessTable,String taskNodeId,String tableId){
+            if(StringUtils.isNotBlank(tableId)){
+                //表单发起申请完查询随着业务流动json
+                return queryBusiness(businessTable,taskNodeId,tableId);
+            }else{
+                //表单发起申请时查询json(新增)
+                return queryInitial(businessTable,taskNodeId);
             }
-            Object obj = JSONObject.parseObject(tableInfo.getContent());
-            tableInfo.setJsonContent(obj);
-            if(isSave){
-                tableInfo.setIsSave(isSave);
+    }
+
+    //获取初始表单Json
+    public Result queryInitial(String businessTable,String taskNodeId){
+        boolean isSave=false;
+        QueryWrapper<TbTableInfo> queryWrapper = new QueryWrapper<TbTableInfo>().eq("business_table", businessTable);
+        //查询任务节点是否关联表
+        List<ActNode> actNodeList=  actNodeService.list(new QueryWrapper<ActNode>().eq("node_id",taskNodeId));
+        if(actNodeList!=null&&actNodeList.size()>0&&StringUtils.isNotBlank(actNodeList.get(0).getTbTableInfoId())){
+            //如果任务节点id不为空则根据任务节点id查询
+            queryWrapper.eq("task_node_id",taskNodeId);
+            isSave=true;//分流程节点填写不同内容的表单 强制给到前台解除保存按钮禁用状态
+        }else{//没有关联表则不把流程节点id当作查询条件
+            queryWrapper.and(qw->qw.eq("is_initial","1").or().isNull("is_initial"));
+        }
+        TbTableInfo tableInfo = tbTableInfoService.getOne(queryWrapper);
+        if(tableInfo==null) {
+            return Result.error("未找到实体");
+        }
+        Object obj = JSONObject.parseObject(tableInfo.getContent());
+        tableInfo.setJsonContent(obj);
+        if(isSave){
+            tableInfo.setIsSave(isSave);
+        }
+        //获取当前表名称所有的表单数据
+        QueryWrapper<TbTableInfo> queryWrapper2 = new QueryWrapper<TbTableInfo>().eq("business_table", businessTable).eq("del_flag","0").orderByAsc("create_time");
+        List<TbTableInfo> tbTableInfoList=tbTableInfoService.list(queryWrapper2);
+        if(tbTableInfoList!=null){
+            for(TbTableInfo t:tbTableInfoList){
+                Object obj2 = JSONObject.parseObject(t.getContent());
+                t.setJsonContent(obj2);
             }
-            //获取当前表名称所有的表单数据
-            QueryWrapper<TbTableInfo> queryWrapper2 = new QueryWrapper<TbTableInfo>().eq("business_table", businessTable).eq("del_flag","0").orderByAsc("create_time");
-            List<TbTableInfo> tbTableInfoList=tbTableInfoService.list(queryWrapper2);
-            if(tbTableInfoList!=null){
-                for(TbTableInfo t:tbTableInfoList){
-                    Object obj2 = JSONObject.parseObject(t.getContent());
-                    t.setJsonContent(obj2);
-                }
+        }
+        tableInfo.setTbTableInfoList(tbTableInfoList);
+        return Result.ok(tableInfo);
+    }
+
+    //随着业务不断变化的json
+    public Result queryBusiness(String businessTable,String taskNodeId,String tableId){
+        boolean isSave=false;
+        QueryWrapper<TbTableInfoPractice> queryWrapper = new QueryWrapper<TbTableInfoPractice>().eq("business_table_id", tableId);
+        //查询任务节点是否关联表
+        List<ActNode> actNodeList=  actNodeService.list(new QueryWrapper<ActNode>().eq("node_id",taskNodeId));
+        if(actNodeList!=null&&actNodeList.size()>0&&StringUtils.isNotBlank(actNodeList.get(0).getTbTableInfoId())){
+            //如果任务节点id不为空则根据任务节点id查询
+            queryWrapper.eq("task_node_id",taskNodeId);
+            isSave=true;//分流程节点填写不同内容的表单 强制给到前台解除保存按钮禁用状态
+        }else{//没有关联表则不把流程节点id当作查询条件
+            queryWrapper.and(qw->qw.eq("is_initial","1").or().isNull("is_initial"));
+        }
+        TbTableInfoPractice tableInfo = iTbTableInfoPracticeService.getOne(queryWrapper);
+        if(tableInfo==null) {
+            return Result.error("未找到实体");
+        }
+        Object obj = JSONObject.parseObject(tableInfo.getContent());
+        tableInfo.setJsonContent(obj);
+        if(isSave){
+            tableInfo.setIsSave(isSave);
+        }
+        //获取当前表名称所有的表单数据
+        QueryWrapper<TbTableInfo> queryWrapper2 = new QueryWrapper<TbTableInfo>().eq("business_table", businessTable).eq("del_flag","0").orderByAsc("create_time");
+        List<TbTableInfo> tbTableInfoList=tbTableInfoService.list(queryWrapper2);
+        if(tbTableInfoList!=null){
+            for(TbTableInfo t:tbTableInfoList){
+                Object obj2 = JSONObject.parseObject(t.getContent());
+                t.setJsonContent(obj2);
             }
-            tableInfo.setTbTableInfoList(tbTableInfoList);
+        }
+        tableInfo.setTbTableInfoList(tbTableInfoList);
         return Result.ok(tableInfo);
     }