|
@@ -11,6 +11,7 @@ import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.manager.dto.ElementData;
|
|
import org.springblade.manager.dto.ElementData;
|
|
import org.springblade.manager.dto.FormData;
|
|
import org.springblade.manager.dto.FormData;
|
|
import org.springblade.manager.dto.LocalVariable;
|
|
import org.springblade.manager.dto.LocalVariable;
|
|
|
|
+import org.springblade.manager.entity.ContractInfo;
|
|
import org.springblade.manager.entity.Formula;
|
|
import org.springblade.manager.entity.Formula;
|
|
import org.springblade.manager.entity.WbsParam;
|
|
import org.springblade.manager.entity.WbsParam;
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
@@ -18,9 +19,7 @@ import org.springblade.manager.formula.Container;
|
|
import org.springblade.manager.formula.FormulaStrategyFactory;
|
|
import org.springblade.manager.formula.FormulaStrategyFactory;
|
|
import org.springblade.manager.formula.impl.TableElementConverter;
|
|
import org.springblade.manager.formula.impl.TableElementConverter;
|
|
import org.springblade.manager.mapper.FormulaMapper;
|
|
import org.springblade.manager.mapper.FormulaMapper;
|
|
-import org.springblade.manager.service.IFormulaService;
|
|
|
|
-import org.springblade.manager.service.IWbsParamService;
|
|
|
|
-import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
|
|
|
+import org.springblade.manager.service.*;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -41,6 +40,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
private final IWbsParamService wpService;
|
|
private final IWbsParamService wpService;
|
|
private final IWbsTreeContractService treeContractService;
|
|
private final IWbsTreeContractService treeContractService;
|
|
private final FormulaStrategyFactory formulaStrategyFactory;
|
|
private final FormulaStrategyFactory formulaStrategyFactory;
|
|
|
|
+ private final IContractInfoService contractInfoService;
|
|
|
|
+ private final IProjectInfoService projectInfoService;
|
|
private final Container env;
|
|
private final Container env;
|
|
|
|
|
|
|
|
|
|
@@ -56,6 +57,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
public static final String ELE_CODE_REG= "(?<=E\\[)[^]]+(?=\\])";
|
|
public static final String ELE_CODE_REG= "(?<=E\\[)[^]]+(?=\\])";
|
|
public static final Pattern P = Pattern.compile(ELE_CODE_REG);
|
|
public static final Pattern P = Pattern.compile(ELE_CODE_REG);
|
|
|
|
+ public static final String POLY_REG= "(avg|min|max|sum)\\(([^)]+)\\)";
|
|
|
|
+ public static final Pattern POLY = Pattern.compile(POLY_REG);
|
|
|
|
+ public final static String CTI="ContractInfo";
|
|
|
|
+ public final static String PJI="ProjectInfo";
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -82,6 +88,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
this.env.constantMap=new HashMap<>(100);
|
|
this.env.constantMap=new HashMap<>(100);
|
|
this.env.formDataList=list;
|
|
this.env.formDataList=list;
|
|
this.env.constantMap.put("contractId",contractId);
|
|
this.env.constantMap.put("contractId",contractId);
|
|
|
|
+ ContractInfo info =this.contractInfoService.getById(contractId);
|
|
|
|
+ /*合同段信息*/
|
|
|
|
+ this.env.constantMap.put(CTI,info);
|
|
|
|
+ /*项目信息*/
|
|
|
|
+ this.env.constantMap.put(PJI,this.projectInfoService.getById(info.getPId()));
|
|
List<WbsTreeContract> nodes = treeContractService.searchParentAllNode(primaryKeyId,contractId);
|
|
List<WbsTreeContract> nodes = treeContractService.searchParentAllNode(primaryKeyId,contractId);
|
|
this.env.constantMap.put(CHAIN,nodes.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList()));
|
|
this.env.constantMap.put(CHAIN,nodes.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList()));
|
|
List<WbsParam> wps = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getWbsId,primaryKeyId));
|
|
List<WbsParam> wps = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getWbsId,primaryKeyId));
|
|
@@ -144,6 +155,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
fd.getFormula().setFormula(tmp);
|
|
fd.getFormula().setFormula(tmp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ polymerization();
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -302,22 +314,29 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
|
|
|
|
public void polymerization(){
|
|
public void polymerization(){
|
|
-// if(f.contains(CustomFunction.CLASS_CALL+"avg(")||f.contains(CustomFunction.CLASS_CALL+"min(")||f.contains(CustomFunction.CLASS_CALL+"max(")||f.contains(CustomFunction.CLASS_CALL+"sum(")){
|
|
|
|
-// /*聚合*/
|
|
|
|
-// Matcher m = POLY.matcher(f);
|
|
|
|
-// while (m.find()){
|
|
|
|
-// /**/
|
|
|
|
-// List<String> elementCodes=CustomFunction.parseElementCode(m.group(2));
|
|
|
|
-// List<FormData> tmp = ele.stream().filter(e->elementCodes.contains(e.getCode())).collect(Collectors.toList());
|
|
|
|
-// ele.removeAll(tmp);
|
|
|
|
-//
|
|
|
|
-// tmp.forEach(e-> E.put(e.getCode(),e.getValues().stream().map(ElementData::getValue).collect(Collectors.toList())));
|
|
|
|
-// Object data = Expression.parse(CustomFunction.CLASS_CALL+m.group()).calculate(currentMap);
|
|
|
|
-//
|
|
|
|
-// f = f.replace(CustomFunction.CLASS_CALL+m.group(),data.toString());
|
|
|
|
-// fd.getFormula().setFormula(f);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
|
|
+ for(FormData fd:this.env.formDataList){
|
|
|
|
+ Formula formula = fd.getFormula();
|
|
|
|
+ if(Func.isNotEmpty(formula)){
|
|
|
|
+ String f=formula.getFormula();
|
|
|
|
+ if(Func.isNotBlank(f)) {
|
|
|
|
+ if (f.contains(CustomFunction.CLASS_CALL + "avg(") || f.contains(CustomFunction.CLASS_CALL + "min(") || f.contains(CustomFunction.CLASS_CALL + "max(") || f.contains(CustomFunction.CLASS_CALL + "sum(")) {
|
|
|
|
+ /*聚合*/
|
|
|
|
+ Matcher m = POLY.matcher(f);
|
|
|
|
+ while (m.find()) {
|
|
|
|
+ List<String> elementCodes = CustomFunction.parseElementCode(m.group(2));
|
|
|
|
+ Map<String, Object> currentMap = new HashMap<>(this.env.constantMap);
|
|
|
|
+ List<String> relyList = fd.getFormula().getRelyList();
|
|
|
|
+ List<FormData> tmp = this.env.formDataList.stream().filter(e -> relyList.contains(e.getCode())).collect(Collectors.toList());
|
|
|
|
+ Map<String, Object> E = getMap(currentMap, "E");
|
|
|
|
+ tmp.forEach(e -> E.put(e.getCode(), e.getValues().stream().map(ElementData::getValue).collect(Collectors.toList())));
|
|
|
|
+ Object data = Expression.parse(CustomFunction.CLASS_CALL + m.group()).calculate(currentMap);
|
|
|
|
+ f = f.replace(CustomFunction.CLASS_CALL + m.group(), data.toString());
|
|
|
|
+ fd.getFormula().setFormula(f);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|