|
@@ -202,8 +202,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
fd.getFormula().setFormula(tmp);
|
|
|
}
|
|
|
}
|
|
|
- /*聚合运算*/
|
|
|
- polymerization();
|
|
|
+
|
|
|
return this;
|
|
|
}
|
|
|
|
|
@@ -229,6 +228,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
Formula formula =fd.getFormula();
|
|
|
String f=formula.getFormula();
|
|
|
if(Func.isNotBlank(f)){
|
|
|
+ /*聚合运算*/
|
|
|
+ polymerization();
|
|
|
Map<String, Object> currentMap = new HashMap<>(this.env.constantMap);
|
|
|
List<String> relyList = fd.getFormula().getRelyList();
|
|
|
if(CollectionUtil.isNotEmpty(relyList)){
|
|
@@ -481,33 +482,37 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
Formula formula = fd.getFormula();
|
|
|
if(Func.isNotEmpty(formula)){
|
|
|
String f=formula.getFormula();
|
|
|
- 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(")
|
|
|
- ) {
|
|
|
- /*聚合*/
|
|
|
- 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);
|
|
|
- if(StringUtils.isNotEmpty(data)) {
|
|
|
- data = CustomFunction.setScale(data, StringUtils.getScale(data));
|
|
|
+ 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(")
|
|
|
+ ) {
|
|
|
+ /*聚合*/
|
|
|
+ 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);
|
|
|
+ if(StringUtils.isNotEmpty(data)) {
|
|
|
+ data = CustomFunction.setScale(data, StringUtils.getScale(data));
|
|
|
+ }
|
|
|
+ /*必须要用括号套壳,不然无法处理负数*/
|
|
|
+ String key ="HA"+HashUtil.identityHashCode(data);
|
|
|
+ this.env.constantMap.put(key,data);
|
|
|
+ f = f.replace(CustomFunction.CLASS_CALL + m.group(), key);
|
|
|
+ fd.getFormula().setFormula(f);
|
|
|
+ /*更新依赖*/
|
|
|
+ relyParse(fd.getFormula());
|
|
|
}
|
|
|
- /*必须要用括号套壳,不然无法处理负数*/
|
|
|
- String key ="HA"+HashUtil.identityHashCode(data);
|
|
|
- this.env.constantMap.put(key,data);
|
|
|
- f = f.replace(CustomFunction.CLASS_CALL + m.group(), key);
|
|
|
- fd.getFormula().setFormula(f);
|
|
|
- /*更新依赖*/
|
|
|
- relyParse(fd.getFormula());
|
|
|
}
|
|
|
+ System.out.println("聚合处理");
|
|
|
}
|
|
|
- System.out.println("聚合处理");
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|