|
@@ -2,27 +2,20 @@ package org.jeecg.modules.activiti.service.Impl;
|
|
|
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
import cn.hutool.core.map.MapUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import jdk.nashorn.internal.scripts.JS;
|
|
|
|
import org.activiti.engine.delegate.DelegateExecution;
|
|
import org.activiti.engine.delegate.DelegateExecution;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
-import org.jeecg.common.exception.JeecgBootException;
|
|
|
|
import org.jeecg.modules.activiti.entity.ActBusiness;
|
|
import org.jeecg.modules.activiti.entity.ActBusiness;
|
|
import org.jeecg.modules.activiti.mapper.ActBusinessMapper;
|
|
import org.jeecg.modules.activiti.mapper.ActBusinessMapper;
|
|
import org.jeecg.modules.activiti.service.IActBusinessService;
|
|
import org.jeecg.modules.activiti.service.IActBusinessService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
|
-
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 流程业务扩展表
|
|
* @Description: 流程业务扩展表
|
|
@@ -47,7 +40,7 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
|
|
String tableName = request.getParameter("tableName");
|
|
String tableName = request.getParameter("tableName");
|
|
String filedNames = request.getParameter("filedNames");
|
|
String filedNames = request.getParameter("filedNames");
|
|
//子表
|
|
//子表
|
|
- String tableNameB= request.getParameter("tableNameB");
|
|
|
|
|
|
+ String tableNameB= request.getParameter("table_name_b");
|
|
String filedNamesB= request.getParameter("filedNamesB");
|
|
String filedNamesB= request.getParameter("filedNamesB");
|
|
String childstr= request.getParameter("childList"); //
|
|
String childstr= request.getParameter("childList"); //
|
|
|
|
|
|
@@ -67,9 +60,11 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
|
|
|
|
|
|
JSONArray jsonArray = JSONArray.parseArray(childstr);
|
|
JSONArray jsonArray = JSONArray.parseArray(childstr);
|
|
for(int i =0; i< jsonArray.size(); i++) {
|
|
for(int i =0; i< jsonArray.size(); i++) {
|
|
|
|
+ //子表id
|
|
String tableBId = IdUtil.simpleUUID();
|
|
String tableBId = IdUtil.simpleUUID();
|
|
StringBuilder filedIdB = new StringBuilder("id");
|
|
StringBuilder filedIdB = new StringBuilder("id");
|
|
StringBuilder filedIdVB = new StringBuilder("'" + tableBId + "'");
|
|
StringBuilder filedIdVB = new StringBuilder("'" + tableBId + "'");
|
|
|
|
+ //主表id
|
|
filedIdB.append("," + tableName + "_id");
|
|
filedIdB.append("," + tableName + "_id");
|
|
filedIdVB.append(",'" + tableId + "'");
|
|
filedIdVB.append(",'" + tableId + "'");
|
|
String[] fileds2 = filedNamesB.split(",");
|
|
String[] fileds2 = filedNamesB.split(",");
|
|
@@ -81,6 +76,11 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
|
|
filedIdVB.append(",'" + jobj.getString(filed) + "'");
|
|
filedIdVB.append(",'" + jobj.getString(filed) + "'");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //排序
|
|
|
|
+ filedIdB.append(",sort");
|
|
|
|
+ filedIdVB.append(",'" + i + "'");
|
|
|
|
+
|
|
|
|
+ //新增子表
|
|
this.baseMapper.insertBusiData(String.format("INSERT INTO %s (%s) VALUES (%s)", tableNameB, filedIdB.toString(), filedIdVB.toString()));
|
|
this.baseMapper.insertBusiData(String.format("INSERT INTO %s (%s) VALUES (%s)", tableNameB, filedIdB.toString(), filedIdVB.toString()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -100,25 +100,30 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
|
|
if(StringUtils.isNotBlank(tableNameB)) {
|
|
if(StringUtils.isNotBlank(tableNameB)) {
|
|
JSONArray jsonArray = JSONArray.parseArray(childstr);
|
|
JSONArray jsonArray = JSONArray.parseArray(childstr);
|
|
for(int i = 0; i < jsonArray.size(); i++) {
|
|
for(int i = 0; i < jsonArray.size(); i++) {
|
|
- StringBuilder setSql2 = new StringBuilder();
|
|
|
|
|
|
+ //子表id
|
|
|
|
+ String tableBId = IdUtil.simpleUUID();
|
|
|
|
+ StringBuilder filedIdB = new StringBuilder("id");
|
|
|
|
+ StringBuilder filedIdVB = new StringBuilder("'" + tableBId + "'");
|
|
|
|
+ //主表id
|
|
|
|
+ filedIdB.append("," + tableName + "_id");
|
|
|
|
+ filedIdVB.append(",'" + tableId + "'");
|
|
|
|
+ String[] fileds2 = filedNamesB.split(",");
|
|
JSONObject jobj = (JSONObject) jsonArray.get(i);
|
|
JSONObject jobj = (JSONObject) jsonArray.get(i);
|
|
- String tableBId = jobj.getString("id");
|
|
|
|
- if(StringUtils.isBlank(tableBId)){
|
|
|
|
- throw new JeecgBootException("子表id不能为空");
|
|
|
|
- }
|
|
|
|
|
|
|
|
- String[] fileds2 = filedNamesB.split(",");
|
|
|
|
|
|
|
|
- for(String filed : fileds2) {
|
|
|
|
- String parameter2 = jobj.getString(filed);
|
|
|
|
- if(parameter2 == null) {
|
|
|
|
- setSql2.append(String.format("%s = null,", filed));
|
|
|
|
- } else {
|
|
|
|
- setSql2.append(String.format("%s = '%s',", filed, parameter2));
|
|
|
|
- }
|
|
|
|
|
|
+ for (String filed : fileds2) {
|
|
|
|
+ filedIdB.append(","+filed);
|
|
|
|
+ filedIdVB.append(",'"+jobj.getString(filed)+"'");
|
|
}
|
|
}
|
|
- String substring2 = setSql.substring(0, setSql2.length() - 1);//去掉最后一个,号
|
|
|
|
- this.baseMapper.insertBusiData(String.format("update %s set %s where id = '%s'", tableNameB, substring2, tableBId));
|
|
|
|
|
|
+
|
|
|
|
+ //排序
|
|
|
|
+ filedIdB.append(",sort");
|
|
|
|
+ filedIdVB.append(",'" + i + "'");
|
|
|
|
+ //删除子表
|
|
|
|
+ this.baseMapper.deletetBusiData(String.format("DELETE FROM %s WHERE %s = %s", tableNameB, tableName + "_id", tableBId));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ this.baseMapper.insertBusiData(String.format("INSERT INTO %s (%s) VALUES (%s)", tableNameB, filedIdB.toString(), filedIdVB.toString()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|