|
@@ -1,6 +1,7 @@
|
|
package org.springblade.manager.service.impl;
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.HashUtil;
|
|
import cn.hutool.log.StaticLog;
|
|
import cn.hutool.log.StaticLog;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.jfireel.expression.Expression;
|
|
import com.jfireel.expression.Expression;
|
|
@@ -60,7 +61,7 @@ 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= "(checkpoints|avg|min|max|sum)\\(([^)]+)\\)";
|
|
|
|
|
|
+ public static final String POLY_REG= "(checkpoints|avg|min|max|sum|join|repeat|removeEmpty|listAt)\\(([^)]+)\\)";
|
|
public static final Pattern POLY = Pattern.compile(POLY_REG);
|
|
public static final Pattern POLY = Pattern.compile(POLY_REG);
|
|
public final static String CTI="ContractInfo";
|
|
public final static String CTI="ContractInfo";
|
|
public final static String PJI="ProjectInfo";
|
|
public final static String PJI="ProjectInfo";
|
|
@@ -201,6 +202,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
fd.getFormula().setFormula(tmp);
|
|
fd.getFormula().setFormula(tmp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ /*聚合运算*/
|
|
polymerization();
|
|
polymerization();
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
@@ -460,11 +462,13 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
if(Func.isNotEmpty(formula)){
|
|
if(Func.isNotEmpty(formula)){
|
|
String f=formula.getFormula();
|
|
String f=formula.getFormula();
|
|
if(Func.isNotBlank(f)) {
|
|
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(")) {
|
|
|
|
|
|
+ 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);
|
|
Matcher m = POLY.matcher(f);
|
|
while (m.find()) {
|
|
while (m.find()) {
|
|
- List<String> elementCodes = CustomFunction.parseElementCode(m.group(2));
|
|
|
|
|
|
+ //List<String> elementCodes = CustomFunction.parseElementCode(m.group(2));
|
|
Map<String, Object> currentMap = new HashMap<>(this.env.constantMap);
|
|
Map<String, Object> currentMap = new HashMap<>(this.env.constantMap);
|
|
List<String> relyList = fd.getFormula().getRelyList();
|
|
List<String> relyList = fd.getFormula().getRelyList();
|
|
List<FormData> tmp = this.env.formDataList.stream().filter(e -> relyList.contains(e.getCode())).collect(Collectors.toList());
|
|
List<FormData> tmp = this.env.formDataList.stream().filter(e -> relyList.contains(e.getCode())).collect(Collectors.toList());
|
|
@@ -475,20 +479,21 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
data = CustomFunction.setScale(data, StringUtils.getScale(data));
|
|
data = CustomFunction.setScale(data, StringUtils.getScale(data));
|
|
}
|
|
}
|
|
/*必须要用括号套壳,不然无法处理负数*/
|
|
/*必须要用括号套壳,不然无法处理负数*/
|
|
- if(StringUtils.isNumber(data)){
|
|
|
|
- f = f.replace(CustomFunction.CLASS_CALL + m.group(), "("+data.toString()+")");
|
|
|
|
- }else{
|
|
|
|
- f = f.replace(CustomFunction.CLASS_CALL + m.group(), "'"+data.toString()+"'");
|
|
|
|
- }
|
|
|
|
|
|
+ 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);
|
|
fd.getFormula().setFormula(f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|