|
@@ -22,6 +22,7 @@ import org.springblade.manager.entity.WbsParam;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
|
import org.springblade.manager.formula.Container;
|
|
|
import org.springblade.manager.formula.FormulaStrategyFactory;
|
|
|
+import org.springblade.manager.formula.ITableElementConverter;
|
|
|
import org.springblade.manager.formula.KeyMapper;
|
|
|
import org.springblade.manager.formula.impl.CompositeDataAccess;
|
|
|
import org.springblade.manager.formula.impl.TableElementConverter;
|
|
@@ -88,24 +89,25 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
* @Date 2022.08.03 14:03
|
|
|
**/
|
|
|
@Override
|
|
|
- public void execute(List<FormData> list ,Long contractId,Long id ,Long primaryKeyId){
|
|
|
+ public void execute(TableElementConverter tec) {
|
|
|
+ this.env.tec=tec;
|
|
|
/*初始化变量>>依赖排序>>预处理>>特殊公式>>通用公式执行>>数据格式化*/
|
|
|
- this.init(list,contractId,id,primaryKeyId)
|
|
|
+ this.init()
|
|
|
.sort()
|
|
|
.pre()
|
|
|
.special()
|
|
|
.calculate()
|
|
|
.format();
|
|
|
+ // WbsTreeContract one= this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,tec.getNodeId()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void execute(TableElementConverter tec) {
|
|
|
- WbsTreeContract one= this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,tec.getNodeId()));
|
|
|
- this.execute(tec.getFds(),tec.getContractId(),Func.isNotEmpty(one.getOldId())?Long.parseLong(one.getOldId()):one.getParentId(),one.getPKeyId());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public IFormulaService init(List<FormData> list,Long contractId,Long id,Long primaryKeyId) {
|
|
|
+ public IFormulaService init() {
|
|
|
+ List<FormData> list =this.env.tec.getFds() ;
|
|
|
+ Long contractId=this.env.tec.getContractId();
|
|
|
+ WbsTreeContract one = this.env.tec.getOne();
|
|
|
+ Long id =Func.isNotEmpty(one.getOldId())?Long.parseLong(one.getOldId()):one.getParentId();
|
|
|
+ Long primaryKeyId=one.getPKeyId();
|
|
|
this.env.constantMap=new HashMap<>(100);
|
|
|
this.env.formDataList=list;
|
|
|
this.env.constantMap.put("contractId",contractId);
|
|
@@ -159,6 +161,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
System.out.println("跨节点元素:"+crossNodeFd.stream().map(FormData::getCode).collect(Collectors.joining(",")));
|
|
|
this.env.formDataList.addAll(crossNodeFd);
|
|
|
}
|
|
|
+ /*实测值参数*/
|
|
|
+
|
|
|
/*检查项目*/
|
|
|
return this;
|
|
|
}
|
|
@@ -428,47 +432,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
return CNDMap;
|
|
|
}
|
|
|
|
|
|
- public List<ElementData> _slice(Map<String,List<Object>> elementMap,Map<String,Object> constantMap,String formula,Integer groupId){
|
|
|
- int min =0;
|
|
|
- List<ElementData> result = new ArrayList<>();
|
|
|
- try {
|
|
|
- for(Map.Entry<String,List<Object>> entry:elementMap.entrySet()){
|
|
|
- List<Object> tmp = entry.getValue();
|
|
|
- min = min==0?tmp.size():Math.min(min,tmp.size());
|
|
|
- }
|
|
|
- if(min>0){
|
|
|
- List<LocalVariable> lvab= new ArrayList<>();
|
|
|
-
|
|
|
- for(int i=0;i<min;i++){
|
|
|
- Map<String, Object> currentMap = new HashMap<>(constantMap);
|
|
|
- Map<String,Object> E=getMap(currentMap,"E");
|
|
|
-
|
|
|
- for(Map.Entry<String,List<Object>> e:elementMap.entrySet()){
|
|
|
- E.put(e.getKey(),e.getValue().get(i));
|
|
|
- }
|
|
|
-
|
|
|
- lvab.add(new LocalVariable(0,formula,currentMap));
|
|
|
- }
|
|
|
- /*并发执行*/
|
|
|
- List<ElementData> r= lvab.stream().map(e->{
|
|
|
- try {
|
|
|
- Object data =Expression.parse(e.getFormula()).calculate(e.getCurrentMap());
|
|
|
- return new ElementData(e.getIndex(),groupId,data);
|
|
|
- }catch (Exception e2){
|
|
|
- e2.printStackTrace();
|
|
|
- }
|
|
|
- return new ElementData(e.getIndex(),groupId,"");
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- if(CollectionUtil.isNotEmpty(r)){
|
|
|
- result.addAll(r);
|
|
|
- }
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- StaticLog.error("公式:{},执行出错",formula);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
|
|
|
public List<Object> slice(List<LocalVariable> local,Map<String,Object> constantMap,String formula){
|
|
|
int min =0;
|
|
@@ -549,12 +512,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
try {
|
|
|
if(Func.isNotBlank(f)) {
|
|
|
if (f.contains(CustomFunction.CLASS_CALL + "checkpoints(") ||f.contains(CustomFunction.CLASS_CALL + "avg(") || f.contains(CustomFunction.CLASS_CALL + "min(") || f.contains(CustomFunction.CLASS_CALL + "max(") || f.contains(CustomFunction.CLASS_CALL + "sum(")
|
|
|
- ||f.contains(CustomFunction.CLASS_CALL+"listAt(")||f.contains(CustomFunction.CLASS_CALL+"join(")||f.contains(CustomFunction.CLASS_CALL+"repeat(")||f.contains(CustomFunction.CLASS_CALL+"removeEmpty(")
|
|
|
+ ||f.contains(CustomFunction.CLASS_CALL+"quantity(")||f.contains(CustomFunction.CLASS_CALL+"listAt(")||f.contains(CustomFunction.CLASS_CALL+"join(")||f.contains(CustomFunction.CLASS_CALL+"repeat(")||f.contains(CustomFunction.CLASS_CALL+"removeEmpty(")
|
|
|
) {
|
|
|
/*聚合*/
|
|
|
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());
|