|
@@ -2,7 +2,9 @@ package org.springblade.manager.formula.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.log.StaticLog;
|
|
import cn.hutool.log.StaticLog;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.mixsmart.utils.FormulaUtils;
|
|
import com.mixsmart.utils.FormulaUtils;
|
|
import com.mixsmart.utils.StringUtils;
|
|
import com.mixsmart.utils.StringUtils;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
@@ -102,6 +104,9 @@ public class TableElementConverter implements ITableElementConverter {
|
|
/**汇总公式*/
|
|
/**汇总公式*/
|
|
public List<FormData> summary = new ArrayList<>();
|
|
public List<FormData> summary = new ArrayList<>();
|
|
|
|
|
|
|
|
+ /**是否使用新流程,默认关闭*/
|
|
|
|
+ public boolean isNew=false;
|
|
|
|
+
|
|
/**根据表名获取对应表页对象*/
|
|
/**根据表名获取对应表页对象*/
|
|
public LinkedList<NodeTable> getTableByName(String initTableName){
|
|
public LinkedList<NodeTable> getTableByName(String initTableName){
|
|
LinkedList<NodeTable> list = new LinkedList<>();
|
|
LinkedList<NodeTable> list = new LinkedList<>();
|
|
@@ -135,6 +140,8 @@ public class TableElementConverter implements ITableElementConverter {
|
|
this.currentNode = wtc;
|
|
this.currentNode = wtc;
|
|
this.tableAll = tableAll;
|
|
this.tableAll = tableAll;
|
|
this.pkeyIdTableNameMap=tableAll.stream().collect(Collectors.toMap(NodeTable::getPKeyId,NodeTable::getInitTableName));
|
|
this.pkeyIdTableNameMap=tableAll.stream().collect(Collectors.toMap(NodeTable::getPKeyId,NodeTable::getInitTableName));
|
|
|
|
+ /*开启新流程*/
|
|
|
|
+ this.isNew=true;
|
|
}
|
|
}
|
|
/*优化测试新增属性end*/
|
|
/*优化测试新增属性end*/
|
|
|
|
|
|
@@ -158,7 +165,9 @@ public class TableElementConverter implements ITableElementConverter {
|
|
public Boolean isPresent() {
|
|
public Boolean isPresent() {
|
|
return BaseUtils.isNotNull(this.keyMappers, this.formulas, this.nodeId);
|
|
return BaseUtils.isNotNull(this.keyMappers, this.formulas, this.nodeId);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ public Boolean isPresent2() {
|
|
|
|
+ return BaseUtils.isNotNull(this.formDataList, this.nodeId);
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void before() {
|
|
public void before() {
|
|
@@ -240,12 +249,17 @@ public class TableElementConverter implements ITableElementConverter {
|
|
LinkedHashMap<String, String> pageData = info.getDataMap();
|
|
LinkedHashMap<String, String> pageData = info.getDataMap();
|
|
Map<String,Object> tmpMap =formMap.computeIfAbsent(tbn,k->new HashMap<>(100));
|
|
Map<String,Object> tmpMap =formMap.computeIfAbsent(tbn,k->new HashMap<>(100));
|
|
pageData.forEach((k,v)->{
|
|
pageData.forEach((k,v)->{
|
|
- if (StringUtils.isNotEmpty(v)) {
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(v)&&k.startsWith("key_")) {
|
|
String[] values = v.split("☆");
|
|
String[] values = v.split("☆");
|
|
for (String s : values) {
|
|
for (String s : values) {
|
|
- String[] t = s.split("_\\^_");
|
|
|
|
- String[] c = t[1].split("_");
|
|
|
|
- tmpMap.put(StringUtils.join( index,Func.toInt(c[1]), Func.toInt(c[0]), StringPool.AT), t[0].trim());
|
|
|
|
|
|
+ try {
|
|
|
|
+ String[] t = s.split("_\\^_");
|
|
|
|
+ String[] c = t[1].split("_");
|
|
|
|
+ tmpMap.put(StringUtils.join( index,Func.toInt(c[1]), Func.toInt(c[0]), StringPool.AT), t[0].trim());
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -263,7 +277,8 @@ public class TableElementConverter implements ITableElementConverter {
|
|
}
|
|
}
|
|
List<Long> pkeyIds= this.tableNamePkeyIdMap.get(fd.getTableName());
|
|
List<Long> pkeyIds= this.tableNamePkeyIdMap.get(fd.getTableName());
|
|
List<Coords> coordsList= fd.getCoordsList();
|
|
List<Coords> coordsList= fd.getCoordsList();
|
|
- List<ElementData> eds =fd.getValues();
|
|
|
|
|
|
+ List<ElementData> eds =new ArrayList<>();
|
|
|
|
+ fd.setValues(eds);
|
|
Map<String,Object> map = fd.getCellDataVoList().stream().collect(Collectors.toMap(e-> StringUtils.join( pkeyIds.indexOf(e.getPageId()), e.getX(), e.getY(), StringPool.AT), CellDataVo::getValue));
|
|
Map<String,Object> map = fd.getCellDataVoList().stream().collect(Collectors.toMap(e-> StringUtils.join( pkeyIds.indexOf(e.getPageId()), e.getX(), e.getY(), StringPool.AT), CellDataVo::getValue));
|
|
if(fd.getIsCurrentSubmitElement()){
|
|
if(fd.getIsCurrentSubmitElement()){
|
|
Map<String,Object> formTableMap =formMap.get(fd.getTableName());
|
|
Map<String,Object> formTableMap =formMap.get(fd.getTableName());
|
|
@@ -332,22 +347,54 @@ public class TableElementConverter implements ITableElementConverter {
|
|
}
|
|
}
|
|
public void after2(){
|
|
public void after2(){
|
|
/*判断需要更新的元素*/
|
|
/*判断需要更新的元素*/
|
|
- List<FormData> updateList = this.formDataMap.values().stream().filter(e->e.getIsCurrentSubmitElement()&&e.getUpdate()==1&&e.hasChange()).collect(Collectors.toList());
|
|
|
|
- List<TableInfo> tableInfoList = this.tableInfoList;
|
|
|
|
- Set<String> tableNameSet= updateList.stream().map(FormData::getTableName).collect(Collectors.toSet());
|
|
|
|
- List<Long> pkeyIds = new ArrayList<>();
|
|
|
|
- for(String tk:tableNameSet){
|
|
|
|
- List<Long> tmp = this.tableNamePkeyIdMap.get(tk);
|
|
|
|
- if(tmp!=null){
|
|
|
|
- pkeyIds.addAll(tmp);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- /*判断需要更新的tableInfo*/
|
|
|
|
- tableInfoList.removeIf(t->!pkeyIds.contains(Long.parseLong(t.getPkeyId())));
|
|
|
|
- /*筛查需要更新的元素数据*/
|
|
|
|
- }
|
|
|
|
|
|
+ List<FormData> updateList = this.formDataMap.values().stream().filter(e->e.getIsCurrentSubmitElement()&&e.hasChange()).collect(Collectors.toList());
|
|
|
|
+ if(updateList.size()>0) {
|
|
|
|
+ List<TableInfo> tableInfoList = this.tableInfoList;
|
|
|
|
+ Set<String> tableNameSet = updateList.stream().map(FormData::getTableName).collect(Collectors.toSet());
|
|
|
|
+ List<Long> pkeyIds = new ArrayList<>();
|
|
|
|
+ for (String tk : tableNameSet) {
|
|
|
|
+ List<Long> tmp = this.tableNamePkeyIdMap.get(tk);
|
|
|
|
+ if (tmp != null) {
|
|
|
|
+ pkeyIds.addAll(tmp);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /*判断需要更新的tableInfo*/
|
|
|
|
+ tableInfoList.removeIf(t -> !pkeyIds.contains(Long.parseLong(t.getPkeyId())));
|
|
|
|
+ Map<String, List<FormData>> updateGroup = updateList.stream().collect(Collectors.groupingBy(FormData::getTableName));
|
|
|
|
+ Map<String,TableInfo> tableInfoMap= this.tableInfoList.stream().collect(Collectors.toMap(TableInfo::getPkeyId,t->t));
|
|
|
|
+ updateGroup.forEach((k, v) -> {
|
|
|
|
+ List<Long> tmp = this.tableNamePkeyIdMap.get(k);
|
|
|
|
+ v.forEach(fd->{
|
|
|
|
+ List<List<ElementData>> pages=BaseUtils.splitList(fd.getValues(),fd.getCoordsList().size());
|
|
|
|
+ for(int i=0;i<tmp.size();i++){
|
|
|
|
+ TableInfo tbi= tableInfoMap.get(tmp.get(i).toString());
|
|
|
|
+ Map<String,String> tmpMap = pages.get(i).stream().filter(e->!e.isEmpty()).collect(Collectors.toMap(e->fd.getKey()+"__"+e.getY()+"_"+e.getX(), ElementData::stringValue));
|
|
|
|
+ if(tmpMap.size()>0){
|
|
|
|
+ tbi.getResultMap().putAll(tmpMap);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ public void write(JSONArray dataArray){
|
|
|
|
+ if(dataArray!=null&&this.tableInfoList!=null) {
|
|
|
|
+ JSONObject one = dataArray.getJSONObject(0);
|
|
|
|
+ dataArray.clear();
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
+ Map<String,String> templateMap = (Map<String,String>)JSON.parseObject(JSON.toJSONString(one), Map.class);
|
|
|
|
+ List<String> removeKeys = new ArrayList<>(templateMap.keySet());
|
|
|
|
+ removeKeys.stream().filter(k->k.startsWith("key_")).forEach(templateMap::remove);
|
|
|
|
+ this.tableInfoList.stream().filter(b->b.getResultMap().size()>0).forEach(b->{
|
|
|
|
+ Map<String,String> tmp = new HashMap<>(templateMap);
|
|
|
|
+ tmp.put("p_key_id",b.getPkeyId());
|
|
|
|
+ tmp.putAll(b.getResultMap());
|
|
|
|
+ dataArray.add(JSONObject.parse(JSON.toJSONString(tmp)));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
public String recovery(List<ElementData> dataList) {
|
|
public String recovery(List<ElementData> dataList) {
|
|
if (Func.isNotEmpty(dataList)) {
|
|
if (Func.isNotEmpty(dataList)) {
|