|
@@ -106,6 +106,11 @@ public class TableElementConverter implements ITableElementConverter {
|
|
|
|
|
|
public JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ private final Converter in;
|
|
|
+ private final Converter out;
|
|
|
+ /*计量属性*/
|
|
|
+ private Long periodId;
|
|
|
+ /*计量属性*/
|
|
|
/**根据表名获取对应表页对象*/
|
|
|
public LinkedList<NodeTable> getTableByName(String initTableName){
|
|
|
LinkedList<NodeTable> list = new LinkedList<>();
|
|
@@ -117,6 +122,24 @@ public class TableElementConverter implements ITableElementConverter {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ public TableElementConverter(List<TableInfo> tableInfoList, List<KeyMapper> keyMappers, List<Formula> formulas, Map<String, Map<String, String>> coordinateMap, CurrentNode wtc, List<NodeTable> tableAll) {
|
|
|
+ this.tableInfoList = tableInfoList;
|
|
|
+ this.keyMappers = keyMappers;
|
|
|
+ this.formulas = formulas;
|
|
|
+ if (Func.isNotEmpty(formulas)) {
|
|
|
+ this.formulas.forEach(f -> {
|
|
|
+ this.formulaMap.put(f.getId(), f);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.coordinateMap = coordinateMap;
|
|
|
+ this.nodeId = wtc.getPkId();
|
|
|
+ this.wbsTreeId = wtc.getId();
|
|
|
+ this.currentNode = wtc;
|
|
|
+ this.tableAll = tableAll;
|
|
|
+ this.in=new BeforeA();
|
|
|
+ this.out=new AfterA();
|
|
|
+ }
|
|
|
+
|
|
|
/*优化测试新增属性start*/
|
|
|
|
|
|
public TableElementConverter(List<TableInfo> tableInfoList,List<FormData>curFormDatas,List<FormData> processFds,Map<String,List<Long>> tableNamePkeyIdMap, Map<String, Map<String, String>> coordinateMap, CurrentNode wtc, List<NodeTable> tableAll) {
|
|
@@ -141,26 +164,17 @@ public class TableElementConverter implements ITableElementConverter {
|
|
|
this.pkeyIdTableNameMap=tableAll.stream().collect(Collectors.toMap(NodeTable::getPKeyId,NodeTable::getInitTableName));
|
|
|
/*开启新流程*/
|
|
|
this.isNew=true;
|
|
|
+ this.in=new BeforeB();
|
|
|
+ this.out=new AfterB();
|
|
|
}
|
|
|
/*优化测试新增属性end*/
|
|
|
|
|
|
- public TableElementConverter(List<TableInfo> tableInfoList, List<KeyMapper> keyMappers, List<Formula> formulas, Map<String, Map<String, String>> coordinateMap, CurrentNode wtc, List<NodeTable> tableAll) {
|
|
|
- this.tableInfoList = tableInfoList;
|
|
|
- this.keyMappers = keyMappers;
|
|
|
- this.formulas = formulas;
|
|
|
- if (Func.isNotEmpty(formulas)) {
|
|
|
- this.formulas.forEach(f -> {
|
|
|
- this.formulaMap.put(f.getId(), f);
|
|
|
- });
|
|
|
- }
|
|
|
- this.coordinateMap = coordinateMap;
|
|
|
- this.nodeId = wtc.getPkId();
|
|
|
- this.wbsTreeId = wtc.getId();
|
|
|
- this.currentNode = wtc;
|
|
|
- this.tableAll = tableAll;
|
|
|
+ /*计量*/
|
|
|
+ public TableElementConverter() {
|
|
|
+ this.in=new BeforeC();
|
|
|
+ this.out=new AfterC();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public Boolean isPresent() {
|
|
|
if(isNew){
|
|
|
return BaseUtils.isNotNull(this.formDataList, this.nodeId);
|
|
@@ -172,80 +186,88 @@ public class TableElementConverter implements ITableElementConverter {
|
|
|
|
|
|
@Override
|
|
|
public void before() {
|
|
|
- if (Func.isNotEmpty(this.keyMappers) && Func.isNotEmpty(this.formulas)) {
|
|
|
- /*当前节点所有已经配置的公式*/
|
|
|
- Map<Long, Formula> formulaMap = new HashMap<>(this.formulas.size() * 2);
|
|
|
- this.formulas.forEach(e -> {
|
|
|
- formulaMap.put(e.getId(), e);
|
|
|
- });
|
|
|
- /*根据元素id对keyMappers分组*/
|
|
|
- LinkedHashMap<String, List<KeyMapper>> dataMap = keyMappers.stream().collect(Collectors.groupingBy(KeyMapper::getCodeAndId, LinkedHashMap<String, List<KeyMapper>>::new, Collectors.toList()));
|
|
|
- dataMap.forEach((e, kms) -> {
|
|
|
- String[] codeAndId = e.split(StringPool.AT);
|
|
|
- KeyMapper one = kms.get(0);
|
|
|
- Formula formula = formulaMap.get(one.getFormulaId());
|
|
|
- FormData fd = new FormData(codeAndId[0], new ArrayList<>(), formula, this.coordinateMap.getOrDefault(one.getTableName(), new HashMap<>()).get(one.getField()));
|
|
|
- fd.setIsCurrentNodeElement(Boolean.TRUE);
|
|
|
- fd.setEName(one.getEName());
|
|
|
- fd.setEAllowDeviation(one.getEAllowDeviation());
|
|
|
- fd.setEType(one.getEType());
|
|
|
- fd.setId(one.getFieldId());
|
|
|
- /*初始化元素数据集*/
|
|
|
- List<ElementData> eds = fd.getValues();
|
|
|
- for (int i = 0; i < kms.size(); i++) {
|
|
|
- /*每一页都有自己对立的Id*/
|
|
|
- KeyMapper km = kms.get(i);
|
|
|
- TableInfo tableInfo = this.tableInfoList.stream().filter(t -> StringUtils.isEquals(t.getPkeyId(), km.getPkId())).findFirst().orElseGet(TableInfo::new);
|
|
|
- int groupId = Integer.parseInt(tableInfo.getGroupId());
|
|
|
- LinkedHashMap<String, String> pageData = tableInfo.getDataMap();
|
|
|
- if (Func.isNotEmpty(pageData)) {
|
|
|
- Map<String, Object> tmpMap = new LinkedHashMap<>();
|
|
|
- String v = pageData.get(km.getField());
|
|
|
- if (StringUtils.isNotEmpty(v)) {
|
|
|
- String[] values = v.split("☆");
|
|
|
- for (String s : values) {
|
|
|
- String[] t = s.split("_\\^_");
|
|
|
- String[] c = t[1].split("_");
|
|
|
- tmpMap.put(StringUtils.join(fd.getCode(), groupId, i, Func.toInt(c[1]), Func.toInt(c[0]), StringPool.AT), t[0].trim());
|
|
|
+ this.in.convert();
|
|
|
+ }
|
|
|
+ public class BeforeA implements Converter{
|
|
|
+ @Override
|
|
|
+ public void convert() {
|
|
|
+ if (Func.isNotEmpty(keyMappers) && Func.isNotEmpty(formulas)) {
|
|
|
+ /*当前节点所有已经配置的公式*/
|
|
|
+ Map<Long, Formula> formulaMap = new HashMap<>(formulas.size() * 2);
|
|
|
+ formulas.forEach(e -> {
|
|
|
+ formulaMap.put(e.getId(), e);
|
|
|
+ });
|
|
|
+ /*根据元素id对keyMappers分组*/
|
|
|
+ LinkedHashMap<String, List<KeyMapper>> dataMap = keyMappers.stream().collect(Collectors.groupingBy(KeyMapper::getCodeAndId, LinkedHashMap<String, List<KeyMapper>>::new, Collectors.toList()));
|
|
|
+ dataMap.forEach((e, kms) -> {
|
|
|
+ String[] codeAndId = e.split(StringPool.AT);
|
|
|
+ KeyMapper one = kms.get(0);
|
|
|
+ Formula formula = formulaMap.get(one.getFormulaId());
|
|
|
+ FormData fd = new FormData(codeAndId[0], new ArrayList<>(), formula, coordinateMap.getOrDefault(one.getTableName(), new HashMap<>()).get(one.getField()));
|
|
|
+ fd.setIsCurrentNodeElement(Boolean.TRUE);
|
|
|
+ fd.setEName(one.getEName());
|
|
|
+ fd.setEAllowDeviation(one.getEAllowDeviation());
|
|
|
+ fd.setEType(one.getEType());
|
|
|
+ fd.setId(one.getFieldId());
|
|
|
+ /*初始化元素数据集*/
|
|
|
+ List<ElementData> eds = fd.getValues();
|
|
|
+ for (int i = 0; i < kms.size(); i++) {
|
|
|
+ /*每一页都有自己对立的Id*/
|
|
|
+ KeyMapper km = kms.get(i);
|
|
|
+ TableInfo tableInfo = tableInfoList.stream().filter(t -> StringUtils.isEquals(t.getPkeyId(), km.getPkId())).findFirst().orElseGet(TableInfo::new);
|
|
|
+ int groupId = Integer.parseInt(tableInfo.getGroupId());
|
|
|
+ LinkedHashMap<String, String> pageData = tableInfo.getDataMap();
|
|
|
+ if (Func.isNotEmpty(pageData)) {
|
|
|
+ Map<String, Object> tmpMap = new LinkedHashMap<>();
|
|
|
+ String v = pageData.get(km.getField());
|
|
|
+ if (StringUtils.isNotEmpty(v)) {
|
|
|
+ String[] values = v.split("☆");
|
|
|
+ for (String s : values) {
|
|
|
+ String[] t = s.split("_\\^_");
|
|
|
+ String[] c = t[1].split("_");
|
|
|
+ tmpMap.put(StringUtils.join(fd.getCode(), groupId, i, Func.toInt(c[1]), Func.toInt(c[0]), StringPool.AT), t[0].trim());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (Func.isNotEmpty(fd.getCoordsList())) {
|
|
|
- for (Coords c : fd.getCoordsList()) {
|
|
|
- Object val = null;
|
|
|
- String key = StringUtils.join(fd.getCode(), groupId, i, c.getX(), c.getY(), StringPool.AT);
|
|
|
- if (tmpMap.containsKey(key)) {
|
|
|
- val = tmpMap.get(key);
|
|
|
+ if (Func.isNotEmpty(fd.getCoordsList())) {
|
|
|
+ for (Coords c : fd.getCoordsList()) {
|
|
|
+ Object val = null;
|
|
|
+ String key = StringUtils.join(fd.getCode(), groupId, i, c.getX(), c.getY(), StringPool.AT);
|
|
|
+ if (tmpMap.containsKey(key)) {
|
|
|
+ val = tmpMap.get(key);
|
|
|
+ }
|
|
|
+ eds.add(new ElementData(i, groupId, val, c.getX(), c.getY()));
|
|
|
}
|
|
|
- eds.add(new ElementData(i, groupId, val, c.getX(), c.getY()));
|
|
|
+ } else {
|
|
|
+ tmpMap.forEach((k, val) -> {
|
|
|
+ String[] sa = k.split(StringPool.AT);
|
|
|
+ eds.add(new ElementData(Func.toInt(sa[2]), Func.toInt(sa[1]), val, Func.toInt(sa[3]), Func.toInt(sa[4])));
|
|
|
+ });
|
|
|
}
|
|
|
- } else {
|
|
|
- tmpMap.forEach((k, val) -> {
|
|
|
- String[] sa = k.split(StringPool.AT);
|
|
|
- eds.add(new ElementData(Func.toInt(sa[2]), Func.toInt(sa[1]), val, Func.toInt(sa[3]), Func.toInt(sa[4])));
|
|
|
- });
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (Func.isEmpty(fd.getCoordsList())) {
|
|
|
- log.put(FormulaLog.POSITION,fd.getCode()+"("+fd.getEName()+")");
|
|
|
- }
|
|
|
- /*备份原始数据,用于更新比较*/
|
|
|
- fd.init();
|
|
|
- this.formDataMap.put(fd.getCode(), fd);
|
|
|
- if (fd.getFormula() != null) {
|
|
|
- /*只有需要执行公式的才放这里*/
|
|
|
- this.formDataList.add(fd);
|
|
|
- }
|
|
|
- });
|
|
|
+ if (Func.isEmpty(fd.getCoordsList())) {
|
|
|
+ log.put(FormulaLog.POSITION,fd.getCode()+"("+fd.getEName()+")");
|
|
|
+ }
|
|
|
+ /*备份原始数据,用于更新比较*/
|
|
|
+ fd.init();
|
|
|
+ formDataMap.put(fd.getCode(), fd);
|
|
|
+ if (fd.getFormula() != null) {
|
|
|
+ /*只有需要执行公式的才放这里*/
|
|
|
+ formDataList.add(fd);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- public void before2(){
|
|
|
- /*表单数据集合{table{pkeyId{k:v...}}}*/
|
|
|
- Map<String,Map<String,Object>> formMap= new HashMap<>(30);
|
|
|
- for(TableInfo info:this.tableInfoList){
|
|
|
+ public class BeforeB implements Converter {
|
|
|
+ @Override
|
|
|
+ public void convert() {
|
|
|
+ /*表单数据集合{table{pkeyId{k:v...}}}*/
|
|
|
+ Map<String,Map<String,Object>> formMap= new HashMap<>(30);
|
|
|
+ for(TableInfo info:tableInfoList){
|
|
|
Long pkeyId=Long.parseLong(info.getPkeyId());
|
|
|
- String tbn=this.pkeyIdTableNameMap.get(pkeyId);
|
|
|
- List<Long> plist=this.tableNamePkeyIdMap.get(tbn);
|
|
|
+ String tbn=pkeyIdTableNameMap.get(pkeyId);
|
|
|
+ List<Long> plist=tableNamePkeyIdMap.get(tbn);
|
|
|
int index=plist.indexOf(pkeyId);
|
|
|
LinkedHashMap<String, String> pageData = info.getDataMap();
|
|
|
Map<String,Object> tmpMap =formMap.computeIfAbsent(tbn,k->new HashMap<>(100));
|
|
@@ -265,119 +287,144 @@ public class TableElementConverter implements ITableElementConverter {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- for(FormData fd:this.formDataList){
|
|
|
- /*根据单元格信息、表单页对象、单元格原始数据 初始化元素数据*/
|
|
|
- try {
|
|
|
- fd.setIsCurrentNodeElement(Boolean.TRUE);
|
|
|
- String coords =this.coordinateMap.getOrDefault(fd.getTableName(), new HashMap<>(20)).get(fd.getKey());
|
|
|
- if(Func.isNotBlank(coords)){
|
|
|
- fd.flushCoords(coords);
|
|
|
- }else{
|
|
|
- log.put(FormulaLog.POSITION,fd.getCode()+"("+fd.getEName()+")");
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<Long> pkeyIds= this.tableNamePkeyIdMap.get(fd.getTableName());
|
|
|
- List<Coords> coordsList= fd.getCoordsList();
|
|
|
- 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));
|
|
|
- if(fd.getIsCurrentSubmitElement()){
|
|
|
- Map<String,Object> formTableMap =formMap.get(fd.getTableName());
|
|
|
- for(int i=0;i<pkeyIds.size();i++){
|
|
|
- for(Coords c:coordsList){
|
|
|
- String k=StringUtils.join( i, c.getX(), c.getY(), StringPool.AT);
|
|
|
- /*优先写人表单数据*/
|
|
|
- eds.add(new ElementData(i,0,formTableMap.getOrDefault(k,map.get(k)),c.getX(),c.getY()));
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- for(int i=0;i<pkeyIds.size();i++){
|
|
|
- for(Coords c:coordsList){
|
|
|
- String k=StringUtils.join( i, c.getX(), c.getY(), StringPool.AT);
|
|
|
- eds.add(new ElementData(i,0,map.get(k),c.getX(),c.getY()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- /*数据初始化加载*/
|
|
|
- fd.setInitReady(true);
|
|
|
- /*备份原始数据,用于更新比较*/
|
|
|
- fd.init();
|
|
|
- }catch (Exception e){
|
|
|
- log.put(FormulaLog.POSITION,fd.getCode()+"("+fd.getEName()+")");
|
|
|
- }
|
|
|
+ for(FormData fd:formDataList){
|
|
|
+ /*根据单元格信息、表单页对象、单元格原始数据 初始化元素数据*/
|
|
|
+ try {
|
|
|
+ fd.setIsCurrentNodeElement(Boolean.TRUE);
|
|
|
+ String coords =coordinateMap.getOrDefault(fd.getTableName(), new HashMap<>(20)).get(fd.getKey());
|
|
|
+ if(Func.isNotBlank(coords)){
|
|
|
+ fd.flushCoords(coords);
|
|
|
+ }else{
|
|
|
+ log.put(FormulaLog.POSITION,fd.getCode()+"("+fd.getEName()+")");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<Long> pkeyIds= tableNamePkeyIdMap.get(fd.getTableName());
|
|
|
+ List<Coords> coordsList= fd.getCoordsList();
|
|
|
+ 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));
|
|
|
+ if(fd.getIsCurrentSubmitElement()){
|
|
|
+ Map<String,Object> formTableMap =formMap.get(fd.getTableName());
|
|
|
+ for(int i=0;i<pkeyIds.size();i++){
|
|
|
+ for(Coords c:coordsList){
|
|
|
+ String k=StringUtils.join( i, c.getX(), c.getY(), StringPool.AT);
|
|
|
+ /*优先写人表单数据*/
|
|
|
+ eds.add(new ElementData(i,0,formTableMap.getOrDefault(k,map.get(k)),c.getX(),c.getY()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ for(int i=0;i<pkeyIds.size();i++){
|
|
|
+ for(Coords c:coordsList){
|
|
|
+ String k=StringUtils.join( i, c.getX(), c.getY(), StringPool.AT);
|
|
|
+ eds.add(new ElementData(i,0,map.get(k),c.getX(),c.getY()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*数据初始化加载*/
|
|
|
+ fd.setInitReady(true);
|
|
|
+ /*备份原始数据,用于更新比较*/
|
|
|
+ fd.init();
|
|
|
+ }catch (Exception e){
|
|
|
+ log.put(FormulaLog.POSITION,fd.getCode()+"("+fd.getEName()+")");
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ public class BeforeC implements Converter{
|
|
|
+ @Override
|
|
|
+ public void convert() {
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
@Override
|
|
|
public void after() {
|
|
|
- /*这个方法的核心就是把fds的数据按照既定格式(key_xxx_val_y_x)回写到tableInfo,对fds进行tableName分组,非空循环写人*/
|
|
|
- LinkedHashMap<String, List<KeyMapper>> tabs = keyMappers.stream().collect(Collectors.groupingBy(KeyMapper::getCode, LinkedHashMap::new, Collectors.toList()));
|
|
|
- List<FormData> updateList = this.formDataMap.values().stream().filter(e -> e.getUpdate() == 1 && e.isCurrentNodeElement).collect(Collectors.toList());
|
|
|
- if (Func.isNotEmpty(updateList)) {
|
|
|
- for (FormData fd : updateList) {
|
|
|
- if (fd.getUpdate().equals(1)) {
|
|
|
- try {
|
|
|
- List<ElementData> elementDataList = fd.getValues();
|
|
|
- List<KeyMapper> kms = tabs.get(fd.getCode());
|
|
|
- List<TableInfo> tables = new ArrayList<>();
|
|
|
- for (TableInfo t : this.tableInfoList) {
|
|
|
- if (kms.stream().anyMatch(e -> StringUtils.isEquals(e.getPkId(), t.getPkeyId()))) {
|
|
|
- /*获取将要写入的tableInfo*/
|
|
|
- tables.add(t);
|
|
|
+ this.out.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ public class AfterA implements Converter{
|
|
|
+ @Override
|
|
|
+ public void convert() {
|
|
|
+ /*这个方法的核心就是把fds的数据按照既定格式(key_xxx_val_y_x)回写到tableInfo,对fds进行tableName分组,非空循环写人*/
|
|
|
+ LinkedHashMap<String, List<KeyMapper>> tabs = keyMappers.stream().collect(Collectors.groupingBy(KeyMapper::getCode, LinkedHashMap::new, Collectors.toList()));
|
|
|
+ List<FormData> updateList = formDataMap.values().stream().filter(e -> e.getUpdate() == 1 && e.isCurrentNodeElement).collect(Collectors.toList());
|
|
|
+ if (Func.isNotEmpty(updateList)) {
|
|
|
+ for (FormData fd : updateList) {
|
|
|
+ if (fd.getUpdate().equals(1)) {
|
|
|
+ try {
|
|
|
+ List<ElementData> elementDataList = fd.getValues();
|
|
|
+ List<KeyMapper> kms = tabs.get(fd.getCode());
|
|
|
+ List<TableInfo> tables = new ArrayList<>();
|
|
|
+ for (TableInfo t : tableInfoList) {
|
|
|
+ if (kms.stream().anyMatch(e -> StringUtils.isEquals(e.getPkId(), t.getPkeyId()))) {
|
|
|
+ /*获取将要写入的tableInfo*/
|
|
|
+ tables.add(t);
|
|
|
+ }
|
|
|
}
|
|
|
+ LinkedHashMap<Integer, List<ElementData>> pages = elementDataList.stream().collect(Collectors.groupingBy(ElementData::getIndex, LinkedHashMap::new, Collectors.toList()));
|
|
|
+ for (int i = 0; i < pages.size(); i++) {
|
|
|
+ /*每一页映射一个tableInfo*/
|
|
|
+ List<ElementData> p = pages.get(i);
|
|
|
+ TableInfo info = tables.get(i);
|
|
|
+ info.setToBeUpdated(true);
|
|
|
+ info.getDataMap().put(fd.getKey(), FormulaUtils.recovery(p));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ StaticLog.error("元素{}回写报错", fd.getCode());
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- LinkedHashMap<Integer, List<ElementData>> pages = elementDataList.stream().collect(Collectors.groupingBy(ElementData::getIndex, LinkedHashMap::new, Collectors.toList()));
|
|
|
- for (int i = 0; i < pages.size(); i++) {
|
|
|
- /*每一页映射一个tableInfo*/
|
|
|
- List<ElementData> p = pages.get(i);
|
|
|
- TableInfo info = tables.get(i);
|
|
|
- info.setToBeUpdated(true);
|
|
|
- info.getDataMap().put(fd.getKey(), FormulaUtils.recovery(p));
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- StaticLog.error("元素{}回写报错", fd.getCode());
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ log.put(FormulaLog.OTHER,"公式未插入或者修改任何数据");
|
|
|
}
|
|
|
- } else {
|
|
|
- log.put(FormulaLog.OTHER,"公式未插入或者修改任何数据");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- public void after2(){
|
|
|
- /*判断需要更新的元素*/
|
|
|
- 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);
|
|
|
+ public class AfterB implements Converter{
|
|
|
+ @Override
|
|
|
+ public void convert() {
|
|
|
+ /*判断需要更新的元素*/
|
|
|
+ List<FormData> updateList = 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 = 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);
|
|
|
+ /*判断需要更新的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= tableInfoList.stream().collect(Collectors.toMap(TableInfo::getPkeyId,t->t));
|
|
|
+ updateGroup.forEach((k, v) -> {
|
|
|
+ List<Long> tmp = 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 class AfterC implements Converter{
|
|
|
+ @Override
|
|
|
+ public void convert() {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ interface Converter {
|
|
|
+ /*入参出参转换;核心问题就是如何把原始数据转换成FormData,计算完成后又把FormData输出成保存接口的入参*/
|
|
|
+ void convert();
|
|
|
}
|
|
|
|
|
|
public void write(JSONArray dataArray){
|