|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import org.activiti.engine.delegate.DelegateExecution;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.jeecg.modules.activiti.entity.ActBusiness;
|
|
@@ -14,6 +15,7 @@ import org.jeecg.modules.activiti.service.IActBusinessService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -42,7 +44,13 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
|
|
|
//子表
|
|
|
String tableNameB= request.getParameter("table_name_b");
|
|
|
String filedNamesB= request.getParameter("filedNamesB");
|
|
|
- String childstr= request.getParameter("childList"); //
|
|
|
+ String childstr= request.getParameter("childList");
|
|
|
+
|
|
|
+ String tableNameChildren = request.getParameter("table_name_children"); //其他子表集合
|
|
|
+ List<String> tableNameChildrenList = Lists.newArrayList();
|
|
|
+ if(StringUtils.isNotBlank(tableNameChildren)){
|
|
|
+ tableNameChildrenList = Arrays.asList(tableNameChildren.split(","));
|
|
|
+ }
|
|
|
|
|
|
Map<String, Object> busiData = this.baseMapper.getBusiData(tableId, tableName);
|
|
|
String[] fileds = filedNames.split(",");
|
|
@@ -64,7 +72,7 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
|
|
|
if(StringUtils.isNotBlank(tableNameB)) {
|
|
|
|
|
|
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();
|
|
|
StringBuilder filedIdB = new StringBuilder("id");
|
|
@@ -75,19 +83,53 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
|
|
|
String[] fileds2 = filedNamesB.split(",");
|
|
|
JSONObject jobj = (JSONObject) jsonArray.get(i);
|
|
|
|
|
|
-
|
|
|
for(String filed : fileds2) {
|
|
|
- filedIdB.append(",`" + filed+"`");
|
|
|
- filedIdVB.append(",'" + jobj.getString(filed) + "'");
|
|
|
+ filedIdB.append(",`" + 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()));
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(tableNameChildren)){
|
|
|
+ //新增其他子表数据
|
|
|
+ for(int j = 1; j<= tableNameChildrenList.size(); j++){
|
|
|
+ String childFiledNames= request.getParameter("childFiledNames" + j); //其他子表字段
|
|
|
+ String childList= request.getParameter("childList"+j); //其他子表List数据
|
|
|
+ JSONArray childrenArray = JSONArray.parseArray(childList);
|
|
|
+ for(int i =0; i< childrenArray.size(); i++){
|
|
|
+ //子表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 = childFiledNames.split(",");
|
|
|
+ JSONObject jobj = (JSONObject) childrenArray.get(i);
|
|
|
+
|
|
|
+
|
|
|
+ for(String filed : fileds2) {
|
|
|
+ filedIdB.append(",`" + filed+"`");
|
|
|
+ filedIdVB.append(",'" + jobj.getString(filed) + "'");
|
|
|
+ }
|
|
|
+
|
|
|
+ //排序
|
|
|
+ filedIdB.append(",sort");
|
|
|
+ filedIdVB.append(",'" + i + "'");
|
|
|
+
|
|
|
+ //新增子表
|
|
|
+ String childTableName = tableNameChildrenList.get(j - 1);
|
|
|
+ this.baseMapper.insertBusiData(String.format("INSERT INTO %s (%s) VALUES (%s)", childTableName, filedIdB.toString(), filedIdVB.toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}else { //有,修改
|
|
|
StringBuilder setSql = new StringBuilder();
|
|
@@ -129,9 +171,41 @@ public class ActBusinessServiceImpl extends ServiceImpl<ActBusinessMapper, ActBu
|
|
|
this.baseMapper.insertBusiData(String.format("INSERT INTO %s (%s) VALUES (%s)", tableNameB, filedIdB.toString(), filedIdVB.toString()));
|
|
|
}
|
|
|
}
|
|
|
+ if(StringUtils.isNotBlank(tableNameChildren)){
|
|
|
+ //修改其他子表逻辑
|
|
|
+ for(int j = 1; j<= tableNameChildrenList.size(); j++){
|
|
|
+ String childFiledNames= request.getParameter("childFiledNames" + j); //其他子表字段
|
|
|
+ String childList= request.getParameter("childList"+j); //其他子表List数据
|
|
|
+ String childTableName = tableNameChildrenList.get(j - 1); //其他子表名
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(childList);
|
|
|
|
|
|
- }
|
|
|
+ //删除子表
|
|
|
+ this.baseMapper.deletetBusiData(String.format("DELETE FROM %s WHERE %s = %s", childTableName, tableName + "_id", "'" + tableId + "'"));
|
|
|
+ for(int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ //子表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 = childFiledNames.split(",");
|
|
|
+ JSONObject jobj = (JSONObject) jsonArray.get(i);
|
|
|
+
|
|
|
+
|
|
|
+ for (String filed : fileds2) {
|
|
|
+ filedIdB.append(",`"+filed+"`");
|
|
|
+ filedIdVB.append(",'"+jobj.getString(filed)+"'");
|
|
|
+ }
|
|
|
|
|
|
+ //排序
|
|
|
+ filedIdB.append(",sort");
|
|
|
+ filedIdVB.append(",'" + i + "'");
|
|
|
+ this.baseMapper.insertBusiData(String.format("INSERT INTO %s (%s) VALUES (%s)", childTableName, filedIdB.toString(), filedIdVB.toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> getApplyForm(String tableId, String tableName) {
|