|
@@ -13,10 +13,13 @@ import org.springblade.manager.dto.ElementData;
|
|
import org.springblade.manager.dto.FormData;
|
|
import org.springblade.manager.dto.FormData;
|
|
import org.springblade.manager.entity.Formula;
|
|
import org.springblade.manager.entity.Formula;
|
|
import org.springblade.manager.dto.Coords;
|
|
import org.springblade.manager.dto.Coords;
|
|
|
|
+import org.springblade.manager.entity.WbsTreeContract;
|
|
import org.springblade.manager.formula.ITableElementConverter;
|
|
import org.springblade.manager.formula.ITableElementConverter;
|
|
import org.springblade.manager.formula.KeyMapper;
|
|
import org.springblade.manager.formula.KeyMapper;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
@@ -32,6 +35,7 @@ public class TableElementConverter implements ITableElementConverter {
|
|
private List<TableInfo> tableInfoList;
|
|
private List<TableInfo> tableInfoList;
|
|
private Long contractId;
|
|
private Long contractId;
|
|
private Long nodeId;
|
|
private Long nodeId;
|
|
|
|
+ private Long wbsTreeId;
|
|
List<KeyMapper> keyMappers;
|
|
List<KeyMapper> keyMappers;
|
|
List<Formula> formulas;
|
|
List<Formula> formulas;
|
|
/**公式执行时的元素对象*/
|
|
/**公式执行时的元素对象*/
|
|
@@ -40,12 +44,13 @@ public class TableElementConverter implements ITableElementConverter {
|
|
Map<String,ElementData> elementDataMap = new HashMap<>();
|
|
Map<String,ElementData> elementDataMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
- public TableElementConverter(List<TableInfo> tableInfoList, List<KeyMapper> keyMappers, List<Formula> formulas,Map<String,Map<String,String>> coordinateMap,Long nodeId) {
|
|
|
|
|
|
+ public TableElementConverter(List<TableInfo> tableInfoList, List<KeyMapper> keyMappers, List<Formula> formulas, Map<String,Map<String,String>> coordinateMap, WbsTreeContract wtc) {
|
|
this.tableInfoList = tableInfoList;
|
|
this.tableInfoList = tableInfoList;
|
|
this.keyMappers = keyMappers;
|
|
this.keyMappers = keyMappers;
|
|
this.formulas = formulas;
|
|
this.formulas = formulas;
|
|
this.coordinateMap=coordinateMap;
|
|
this.coordinateMap=coordinateMap;
|
|
- this.nodeId=nodeId;
|
|
|
|
|
|
+ this.nodeId=wtc.getPKeyId();
|
|
|
|
+ this.wbsTreeId=Func.isNotEmpty(wtc.getOldId())? Long.valueOf(wtc.getOldId()) :wtc.getId();
|
|
if(Func.isNotEmpty(tableInfoList)){
|
|
if(Func.isNotEmpty(tableInfoList)){
|
|
this.contractId = Long.parseLong(tableInfoList.get(0).getContractId());
|
|
this.contractId = Long.parseLong(tableInfoList.get(0).getContractId());
|
|
}
|
|
}
|
|
@@ -55,6 +60,20 @@ public class TableElementConverter implements ITableElementConverter {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void relyParse(Formula f){
|
|
|
|
+ if(Func.isNotBlank(f.getFormula())){
|
|
|
|
+ List<String> l = new ArrayList<>();
|
|
|
|
+ Matcher m = Pattern.compile("(?<=E\\[)[^]]+(?=\\])").matcher(f.getFormula());
|
|
|
|
+ while (m.find()){
|
|
|
|
+ l.add(m.group());
|
|
|
|
+ }
|
|
|
|
+ if(l.size()>0){
|
|
|
|
+ f.setRely(String.join(",", l));
|
|
|
|
+ }else{
|
|
|
|
+ f.setRely("");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
public Boolean isPresent(){
|
|
public Boolean isPresent(){
|
|
return BaseUtils.isNotNull(this.keyMappers,this.formulas,this.nodeId,this.contractId);
|
|
return BaseUtils.isNotNull(this.keyMappers,this.formulas,this.nodeId,this.contractId);
|
|
@@ -65,9 +84,9 @@ public class TableElementConverter implements ITableElementConverter {
|
|
public void before() {
|
|
public void before() {
|
|
if(Func.isNotEmpty(this.keyMappers)&&Func.isNotEmpty(this.formulas)){
|
|
if(Func.isNotEmpty(this.keyMappers)&&Func.isNotEmpty(this.formulas)){
|
|
/*当前节点所有已经配置的公式*/
|
|
/*当前节点所有已经配置的公式*/
|
|
- Map<String,Formula> formulaMap = new HashMap<>(this.formulas.size()*2);
|
|
|
|
|
|
+ Map<Long,Formula> formulaMap = new HashMap<>(this.formulas.size()*2);
|
|
this.formulas.forEach(e->{
|
|
this.formulas.forEach(e->{
|
|
- formulaMap.put(e.getElementId().toString(),e);
|
|
|
|
|
|
+ formulaMap.put(e.getId(),e);
|
|
});
|
|
});
|
|
/*根据元素id对keyMappers分组*/
|
|
/*根据元素id对keyMappers分组*/
|
|
LinkedHashMap<String,List<KeyMapper>> dataMap =keyMappers.stream().collect(Collectors.groupingBy(KeyMapper::getCodeAndId,LinkedHashMap<String,List<KeyMapper>>::new,Collectors.toList()));
|
|
LinkedHashMap<String,List<KeyMapper>> dataMap =keyMappers.stream().collect(Collectors.groupingBy(KeyMapper::getCodeAndId,LinkedHashMap<String,List<KeyMapper>>::new,Collectors.toList()));
|
|
@@ -75,7 +94,12 @@ public class TableElementConverter implements ITableElementConverter {
|
|
String[] codeAndId = e.split(StringPool.AT);
|
|
String[] codeAndId = e.split(StringPool.AT);
|
|
List<KeyMapper> kms = dataMap.get(e);
|
|
List<KeyMapper> kms = dataMap.get(e);
|
|
KeyMapper one = kms.get(0);
|
|
KeyMapper one = kms.get(0);
|
|
- FormData fd=new FormData(codeAndId[0],new ArrayList<>(),formulaMap.get(codeAndId[1]),this.coordinateMap.get(one.getTableName()).get(one.getField()));
|
|
|
|
|
|
+ Formula formula =formulaMap.get(one.getFormulaId());
|
|
|
|
+ /*过滤掉本节点的前缀信息*/
|
|
|
|
+ String sf= formula.getFormula().replace(this.wbsTreeId+StringPool.COLON,StringPool.EMPTY);
|
|
|
|
+ formula.setFormula(sf);
|
|
|
|
+ relyParse(formula);
|
|
|
|
+ FormData fd=new FormData(codeAndId[0],new ArrayList<>(),formula,this.coordinateMap.get(one.getTableName()).get(one.getField()));
|
|
/*初始化元素数据集*/
|
|
/*初始化元素数据集*/
|
|
List<ElementData> eds =fd.getValues();
|
|
List<ElementData> eds =fd.getValues();
|
|
String coords = this.coordinateMap.get(fd.getTableName()).get(fd.getKey());
|
|
String coords = this.coordinateMap.get(fd.getTableName()).get(fd.getKey());
|
|
@@ -85,7 +109,7 @@ public class TableElementConverter implements ITableElementConverter {
|
|
for(int i=0;i<kms.size();i++){
|
|
for(int i=0;i<kms.size();i++){
|
|
/*每一页都有自己对立的Id*/
|
|
/*每一页都有自己对立的Id*/
|
|
KeyMapper km=kms.get(i);
|
|
KeyMapper km=kms.get(i);
|
|
- TableInfo tableInfo =this.tableInfoList.stream().filter(t-> StringUtils.isEquals(t.getPkeyId(),km.getNodeId())).findFirst().orElseGet(TableInfo::new);
|
|
|
|
|
|
+ TableInfo tableInfo =this.tableInfoList.stream().filter(t-> StringUtils.isEquals(t.getPkeyId(),km.getPkId())).findFirst().orElseGet(TableInfo::new);
|
|
int groupId=Integer.parseInt(tableInfo.getGroupId());
|
|
int groupId=Integer.parseInt(tableInfo.getGroupId());
|
|
LinkedHashMap<String,String> pageData = tableInfo.getDataMap();
|
|
LinkedHashMap<String,String> pageData = tableInfo.getDataMap();
|
|
if(Func.isNotEmpty(pageData)){
|
|
if(Func.isNotEmpty(pageData)){
|
|
@@ -112,27 +136,6 @@ public class TableElementConverter implements ITableElementConverter {
|
|
}else{
|
|
}else{
|
|
StaticLog.error("FORMULA_LOG@元素{}定位信息不存在,请检查配置",fd.getTableName()+StringPool.COLON+fd.getKey());
|
|
StaticLog.error("FORMULA_LOG@元素{}定位信息不存在,请检查配置",fd.getTableName()+StringPool.COLON+fd.getKey());
|
|
}
|
|
}
|
|
-// AtomicInteger index= new AtomicInteger(0);
|
|
|
|
-// kms.forEach(b->{
|
|
|
|
-// List<TableInfo> elements =this.tableInfoList.stream().filter(t-> StringUtils.isEquals(t.getPkeyId(),b.getNodeId())).collect(Collectors.toList());
|
|
|
|
-// //String coords = this.coordinateMap.get(fd.getTableName()).get(fd.getKey());
|
|
|
|
-// elements.forEach(k->{
|
|
|
|
-// /*把页面上所有的元素区映射对象*/
|
|
|
|
-// LinkedHashMap<String,String> page = k.getDataMap();
|
|
|
|
-// String v=page.get(b.getField());
|
|
|
|
-// if(StringUtils.isNotEmpty(v)){
|
|
|
|
-// String[] values = v.split("☆");
|
|
|
|
-// for(String s:values){
|
|
|
|
-// String[] t = s.split("_\\^_");
|
|
|
|
-// String[] c =t[1].split("_");
|
|
|
|
-// ElementData ed = new ElementData(index.get(),0,t[0],Func.toInt(c[1]),Func.toInt(c[0]));
|
|
|
|
-// this.elementDataMap.put(StringUtils.join(b.getCode(),ed.getGroupId(),ed.getIndex(),Func.toInt(c[1]),Func.toInt(c[0]),StringPool.AT),ed);
|
|
|
|
-// eds.add(ed);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// index.getAndIncrement();
|
|
|
|
-// });
|
|
|
|
-// });
|
|
|
|
this.fds.add(fd);
|
|
this.fds.add(fd);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -151,7 +154,7 @@ public class TableElementConverter implements ITableElementConverter {
|
|
List<KeyMapper> kms = tabs.get(fd.getCode());
|
|
List<KeyMapper> kms = tabs.get(fd.getCode());
|
|
List<TableInfo> tables = new ArrayList<>();
|
|
List<TableInfo> tables = new ArrayList<>();
|
|
for(TableInfo t:this.tableInfoList){
|
|
for(TableInfo t:this.tableInfoList){
|
|
- if(kms.stream().anyMatch(e->StringUtils.isEquals(e.getNodeId(),t.getPkeyId()))){
|
|
|
|
|
|
+ if(kms.stream().anyMatch(e->StringUtils.isEquals(e.getPkId(),t.getPkeyId()))){
|
|
/*获取将要写入的tableInfo*/
|
|
/*获取将要写入的tableInfo*/
|
|
tables.add(t);
|
|
tables.add(t);
|
|
}
|
|
}
|
|
@@ -190,7 +193,7 @@ public class TableElementConverter implements ITableElementConverter {
|
|
if(tableMap.containsKey(fd.getTableName())){
|
|
if(tableMap.containsKey(fd.getTableName())){
|
|
tables=tableMap.get(fd.getTableName());
|
|
tables=tableMap.get(fd.getTableName());
|
|
}else{
|
|
}else{
|
|
- List<Long> tableIds=keyMappers.stream().filter(e -> StringUtils.isEquals(e.getCode(),fd.getCode())).map(KeyMapper::getNodeId).collect(Collectors.toList());
|
|
|
|
|
|
+ List<Long> tableIds=keyMappers.stream().filter(e -> StringUtils.isEquals(e.getCode(),fd.getCode())).map(KeyMapper::getPkId).collect(Collectors.toList());
|
|
tables = this.tableInfoList.stream().filter(e->tableIds.contains(Long.parseLong(e.getPkeyId()))).collect(Collectors.toList());
|
|
tables = this.tableInfoList.stream().filter(e->tableIds.contains(Long.parseLong(e.getPkeyId()))).collect(Collectors.toList());
|
|
tableMap.put(fd.getTableName(),tables);
|
|
tableMap.put(fd.getTableName(),tables);
|
|
}
|
|
}
|