|
@@ -10,6 +10,7 @@ import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.manager.dto.ElementData;
|
|
|
import org.springblade.manager.dto.FormData;
|
|
|
+import org.springblade.manager.dto.LocalVariable;
|
|
|
import org.springblade.manager.entity.Formula;
|
|
|
import org.springblade.manager.entity.WbsParam;
|
|
|
import org.springblade.manager.entity.WbsTree;
|
|
@@ -129,7 +130,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
for(Map.Entry<Integer,Map<String,List<Object>>> entry:dataSource.entrySet()){
|
|
|
if(entry.getValue().keySet().size()>=ele.size()){
|
|
|
List<ElementData> eds = slice(entry.getValue(),constantMap,f,entry.getKey());
|
|
|
- System.out.println(eds);
|
|
|
fd.setValues(eds);
|
|
|
}
|
|
|
}
|
|
@@ -161,8 +161,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
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<>();
|
|
|
- Map<String,Object> currentMap = new HashMap<>();
|
|
|
- Map<String,Object> E=getMap(currentMap,"E");
|
|
|
for(Map.Entry<String,List<Object>> entry:elementMap.entrySet()){
|
|
|
List<Object> tmp = entry.getValue();
|
|
|
if(min==0){
|
|
@@ -172,18 +170,28 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
}
|
|
|
if(min>0){
|
|
|
- currentMap.putAll(constantMap);
|
|
|
+ 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));
|
|
|
}
|
|
|
- Object data = Expression.parse(formula).calculate(currentMap);
|
|
|
- result.add(new ElementData(i,groupId,data));
|
|
|
+ lvab.add(new LocalVariable(i,formula,currentMap));
|
|
|
+ }
|
|
|
+ /*并发执行*/
|
|
|
+ List<ElementData> r= lvab.parallelStream().map(e->{
|
|
|
+ Object data =Expression.parse(e.getFormula()).calculate(e.getCurrentMap());
|
|
|
+ return new ElementData(e.getIndex(),groupId,data);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if(CollectionUtil.isNotEmpty(r)){
|
|
|
+ result.addAll(r);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public static final String WP_REG= "(?<=P\\[)[^]]+(?=\\])";
|
|
|
public static final Pattern PP = Pattern.compile(WP_REG);
|
|
|
|