|
@@ -4,10 +4,7 @@ package org.springblade.manager.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.jfireel.expression.Expression;
|
|
import com.jfireel.expression.Expression;
|
|
-import com.mixsmart.utils.CustomFunction;
|
|
|
|
-import com.mixsmart.utils.ListUtils;
|
|
|
|
-import com.mixsmart.utils.ReflectionUtil;
|
|
|
|
-import com.mixsmart.utils.StringUtils;
|
|
|
|
|
|
+import com.mixsmart.utils.*;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.springblade.business.feign.MileageClient;
|
|
import org.springblade.business.feign.MileageClient;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
@@ -18,8 +15,9 @@ import org.springblade.manager.dto.FormData;
|
|
import org.springblade.manager.dto.LocalVariable;
|
|
import org.springblade.manager.dto.LocalVariable;
|
|
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.WbsTree;
|
|
|
|
|
|
+import org.springblade.manager.entity.WbsTreeContract;
|
|
import org.springblade.manager.formula.IFcHandler;
|
|
import org.springblade.manager.formula.IFcHandler;
|
|
|
|
+import org.springblade.manager.formula.FormulaStrategyFactory;
|
|
import org.springblade.manager.mapper.FormulaMapper;
|
|
import org.springblade.manager.mapper.FormulaMapper;
|
|
import org.springblade.manager.service.IFormulaService;
|
|
import org.springblade.manager.service.IFormulaService;
|
|
import org.springblade.manager.service.IWbsTreeContractService;
|
|
import org.springblade.manager.service.IWbsTreeContractService;
|
|
@@ -43,6 +41,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
private final WbsParamServiceImpl wpService;
|
|
private final WbsParamServiceImpl wpService;
|
|
private final MileageClient mileageClient;
|
|
private final MileageClient mileageClient;
|
|
private final IWbsTreeContractService treeContractService;
|
|
private final IWbsTreeContractService treeContractService;
|
|
|
|
+ private final FormulaStrategyFactory formulaStrategyFactory;
|
|
|
|
|
|
|
|
|
|
public final static String WP="WP";
|
|
public final static String WP="WP";
|
|
@@ -54,18 +53,28 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
public static final Pattern MILE_P = Pattern.compile("(?<=MILE<)([^,]+),([^,]+)(?=,)");
|
|
public static final Pattern MILE_P = Pattern.compile("(?<=MILE<)([^,]+),([^,]+)(?=,)");
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void execute(List<FormData> list ,Long contractId){
|
|
|
|
|
|
+ public void execute(List<FormData> list ,Long contractId,Long primaryKeyId){
|
|
|
|
|
|
|
|
+ /*变量准备*/
|
|
|
|
+ /*依赖排序*/
|
|
|
|
+ /*公式预处理*/
|
|
|
|
+ /*公式运算*/
|
|
|
|
+ System.out.println();
|
|
Map<Boolean,List<FormData>> map = list.stream().collect(Collectors.partitioningBy(e->e!=null&&e.getFormula().getFormula().contains("E[")));
|
|
Map<Boolean,List<FormData>> map = list.stream().collect(Collectors.partitioningBy(e->e!=null&&e.getFormula().getFormula().contains("E[")));
|
|
List<FormData>total = new ArrayList<>();
|
|
List<FormData>total = new ArrayList<>();
|
|
/*用来保存所有变量*/
|
|
/*用来保存所有变量*/
|
|
Map<String,Object> constantMap = new HashMap<>();
|
|
Map<String,Object> constantMap = new HashMap<>();
|
|
/*预设变量start*/
|
|
/*预设变量start*/
|
|
- List<WbsTree> trees = new ArrayList<>();
|
|
|
|
- for(int i=0;i<6;i++){
|
|
|
|
- WbsTree t= new WbsTree();
|
|
|
|
- t.setDeptName("第"+i+"层");
|
|
|
|
- trees.add(t);
|
|
|
|
|
|
+ List<WbsTreeContract> trees = new ArrayList<>();
|
|
|
|
+ List<WbsTreeContract> nodes = treeContractService.searchParentAllNode(primaryKeyId,contractId);
|
|
|
|
+ if(CollectionUtil.isEmpty(nodes)){
|
|
|
|
+ for(int i=0;i<6;i++){
|
|
|
|
+ WbsTreeContract t= new WbsTreeContract();
|
|
|
|
+ t.setDeptName("第"+i+"层");
|
|
|
|
+ trees.add(t);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ trees=nodes;
|
|
}
|
|
}
|
|
List<WbsParam> wps = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getWbsId,123456));
|
|
List<WbsParam> wps = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getWbsId,123456));
|
|
Map<String,Object> wpMap= new HashMap<>();
|
|
Map<String,Object> wpMap= new HashMap<>();
|
|
@@ -87,11 +96,10 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
sort(rely,((rely.size()+1)/2)*rely.size());
|
|
sort(rely,((rely.size()+1)/2)*rely.size());
|
|
total.addAll(rely);
|
|
total.addAll(rely);
|
|
}
|
|
}
|
|
-
|
|
|
|
if(CollectionUtil.isNotEmpty(total)){
|
|
if(CollectionUtil.isNotEmpty(total)){
|
|
/*变量环境加载*/
|
|
/*变量环境加载*/
|
|
constantMap.put(WP,wpMap);
|
|
constantMap.put(WP,wpMap);
|
|
- constantMap.put(CHAIN,trees.stream().map(WbsTree::getDeptName).collect(Collectors.toList()));
|
|
|
|
|
|
+ constantMap.put(CHAIN,trees.stream().map(WbsTreeContract::getDeptName).collect(Collectors.toList()));
|
|
for(FormData fd:total){
|
|
for(FormData fd:total){
|
|
/*预处理公式脚本*/
|
|
/*预处理公式脚本*/
|
|
String tmp =fd.getFormula().getFormula();
|
|
String tmp =fd.getFormula().getFormula();
|
|
@@ -157,10 +165,14 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
fd.getFormula().setFormula(tmp);
|
|
fd.getFormula().setFormula(tmp);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/*公式执行*/
|
|
/*公式执行*/
|
|
for(FormData fd:total){
|
|
for(FormData fd:total){
|
|
Formula formula= fd.getFormula();
|
|
Formula formula= fd.getFormula();
|
|
-
|
|
|
|
|
|
+ formulaStrategyFactory.get(fd).forEach(e->e.execute(list,constantMap));
|
|
if(formula!=null){
|
|
if(formula!=null){
|
|
String f=formula.getFormula();
|
|
String f=formula.getFormula();
|
|
if(Func.isNotBlank(f)){
|
|
if(Func.isNotBlank(f)){
|
|
@@ -326,42 +338,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- public static final Pattern MILE_ARGS= Pattern.compile("(?<=MILE<)[^>]+(?=>)");
|
|
|
|
- /**
|
|
|
|
- * @Description
|
|
|
|
- * @Param [fd]
|
|
|
|
- * @return void
|
|
|
|
- * @Author yangyj
|
|
|
|
- * @Date 2022.07.08 16:39
|
|
|
|
- **/
|
|
|
|
- public void mileageCalc(FormData fd,List<FormData> fds,Map<String,Object> constantMap){
|
|
|
|
- List<ElementData> eds = fd.getValues();
|
|
|
|
- Map<String,String[]> mileages = (Map<String, String[]>) constantMap.get("mileages");
|
|
|
|
- if(ListUtils.isNotEmpty(eds)){
|
|
|
|
- Matcher m= MILE_ARGS.matcher(fd.getCode());
|
|
|
|
- if(m.find()){
|
|
|
|
- String tmp =m.group();
|
|
|
|
- tmp=tmp.replace("E[","").replace("]","");
|
|
|
|
- List<String> cp = Arrays.asList(tmp.split(","));
|
|
|
|
- Map<String,FormData> map = new LinkedHashMap<>();
|
|
|
|
- fds.forEach(e->{
|
|
|
|
- if(cp.contains(e.getCode())){
|
|
|
|
- map.put(e.getCode(),fd);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- /*测点名称*/
|
|
|
|
- List<ElementData> a = map.get(cp.get(0)).getValues();
|
|
|
|
- /*编号*/
|
|
|
|
- List<ElementData> b = map.get(cp.get(2)).getValues();
|
|
|
|
- int size=Math.min(a.size(),b.size());
|
|
|
|
- for(int i=0;i<size;i++){
|
|
|
|
- String k =a.get(i).getValue().toString();
|
|
|
|
- String jz=b.get(i).getValue().toString();
|
|
|
|
- String[] coordinate = mileages.get(k+"@"+jz);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
/* public static void main(String[] args) {
|
|
/* public static void main(String[] args) {
|
|
Set<Class<?>> classList = ReflectionUtil.getClassSetBySuper(IFcHandler.class);
|
|
Set<Class<?>> classList = ReflectionUtil.getClassSetBySuper(IFcHandler.class);
|
|
@@ -378,6 +354,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
System.out.println();
|
|
System.out.println();
|
|
}*/
|
|
}*/
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|