|
@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
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.CustomFunction;
|
|
@@ -4968,6 +4969,132 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
max++;
|
|
max++;
|
|
} while (f.contains("ifelse") && max < 20);
|
|
} while (f.contains("ifelse") && max < 20);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //试验-判断
|
|
|
|
+ if (f.contains(".syifelse")) {
|
|
|
|
+ int max = 0;
|
|
|
|
+ Pattern pattern = Pattern.compile("^-?\\d+(\\.\\d+)?$");
|
|
|
|
+ do {
|
|
|
|
+ Matcher m = RegexUtils.matcher(FC_REG + "(syifelse)\\(([^)]+)\\)", f);
|
|
|
|
+ while (m.find()) {
|
|
|
|
+ String el = m.group();
|
|
|
|
+ String pstr = el.replaceAll("^" + FC_REG + "syifelse\\(", "").replaceAll("\\)$", "");
|
|
|
|
+ String[] pa = pstr.split(",");
|
|
|
|
+ if (pa.length == 3) {
|
|
|
|
+ String s2 = pa[0];
|
|
|
|
+ String[] split = pa[0].split("&");
|
|
|
|
+ //处理位置
|
|
|
|
+ //试验-处理数据
|
|
|
|
+ Map<String, Object> currentMap = createCurrentMap(el, tec);
|
|
|
|
+ Map<String,List<String>> map = (HashMap<String, List<String>>) currentMap.get("E");
|
|
|
|
+
|
|
|
|
+ //匹配成功的计数
|
|
|
|
+ Integer count = 0;
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ String[] split1 = s.split("\\|");
|
|
|
|
+ String s0 = split1[0].replaceAll("E\\[", "").replaceAll("'", "").replaceAll("]", "");
|
|
|
|
+ String s1 = split1[1].replaceAll("E\\[", "").replaceAll("'", "").replaceAll("]", "");
|
|
|
|
+ List<String> list1 = map.get(s0);
|
|
|
|
+ List<String> list2 = map.get(s1);
|
|
|
|
+
|
|
|
|
+ if(CollectionUtils.isEmpty(list1) || CollectionUtils.isEmpty(list2)){
|
|
|
|
+ f = f.replace(el, "缺少数据无法匹配");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //带后缀的数据去掉留纯数据
|
|
|
|
+ List<String> strings1 = extractPureNumbers(list1.get(0));
|
|
|
|
+ List<String> strings2 = extractPureNumbers(list1.get(1));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String s3 = list1.get(0);
|
|
|
|
+ String s4 = list2.get(0);
|
|
|
|
+ if(CollectionUtils.isNotEmpty(strings1)){
|
|
|
|
+ s3 = strings1.get(0);
|
|
|
|
+ }
|
|
|
|
+ if(CollectionUtils.isNotEmpty(strings2)){
|
|
|
|
+ s4 = strings2.get(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //比较符
|
|
|
|
+ String operator = "";
|
|
|
|
+ //公式组装
|
|
|
|
+ String formulaData = "";
|
|
|
|
+ //不是纯数字
|
|
|
|
+ if(!pattern.matcher(s3).matches() && pattern.matcher(s4).matches()){
|
|
|
|
+ if(s3.contains(" ")){
|
|
|
|
+
|
|
|
|
+ String[] split2 = s3.split(" ");
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
+ for (String string : split2) {
|
|
|
|
+ //获取比较符
|
|
|
|
+ operator = string.substring(0, 1);
|
|
|
|
+ String number = string.substring(1);
|
|
|
|
+ list1.set(0,number);
|
|
|
|
+
|
|
|
|
+ operator = strReplace(operator);
|
|
|
|
+
|
|
|
|
+ String str = extractPureNumbers(split1[1]).get(0) + operator + extractPureNumbers(number).get(0);
|
|
|
|
+ list.add(str);
|
|
|
|
+ }
|
|
|
|
+ formulaData = String.join("&&",list);
|
|
|
|
+ }else{
|
|
|
|
+ //获取比较符
|
|
|
|
+ operator = s3.substring(0, 1);
|
|
|
|
+ String number = s3.substring(1);
|
|
|
|
+ list1.set(0,number);
|
|
|
|
+
|
|
|
|
+ operator = strReplace(operator);
|
|
|
|
+
|
|
|
|
+ formulaData = extractPureNumbers(split1[1]).get(0) + operator + extractPureNumbers(number).get(0);
|
|
|
|
+ }
|
|
|
|
+ }else if (pattern.matcher(s3).matches() && !pattern.matcher(s4).matches()){
|
|
|
|
+ if(s4.contains(" ")){
|
|
|
|
+ String[] split2 = s4.split(" ");
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
+ for (String string : split2) {
|
|
|
|
+ //获取比较符
|
|
|
|
+ operator = string.substring(0, 1);
|
|
|
|
+ String number = string.substring(1);
|
|
|
|
+ list1.set(0,number);
|
|
|
|
+
|
|
|
|
+ operator = strReplace(operator);
|
|
|
|
+
|
|
|
|
+ String str = extractPureNumbers(split1[0]).get(0) + operator + extractPureNumbers(number).get(0);
|
|
|
|
+ list.add(str);
|
|
|
|
+ }
|
|
|
|
+ formulaData = String.join("&&",list);
|
|
|
|
+ }else{
|
|
|
|
+ //获取比较符
|
|
|
|
+ operator = s4.substring(0, 1);
|
|
|
|
+ String number = s4.substring(1);
|
|
|
|
+ list2.set(0,number);
|
|
|
|
+
|
|
|
|
+ operator = strReplace(operator);
|
|
|
|
+
|
|
|
|
+ formulaData = extractPureNumbers(split1[0]).get(0) + operator + extractPureNumbers(number).get(0);
|
|
|
|
+ }
|
|
|
|
+ } else{
|
|
|
|
+ f = f.replace(el, "数据错误,无法比较");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ Integer ist = Expression.parse(formulaData + "?1:0").calculate(currentMap);
|
|
|
|
+ count += ist;
|
|
|
|
+ }
|
|
|
|
+ Object data = null;
|
|
|
|
+ if(count == split.length){
|
|
|
|
+ data = pa[1];
|
|
|
|
+ }else{
|
|
|
|
+ data = pa[2];
|
|
|
|
+ }
|
|
|
|
+ f = f.replace(el, putDataWithKey(data, tec));
|
|
|
|
+ } else {
|
|
|
|
+ f = f.replace(el, "参数格式错误");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ max++;
|
|
|
|
+ } while (f.contains("syifelse") && max < 20);
|
|
|
|
+ }
|
|
if (f.contains("avg4segment")) {
|
|
if (f.contains("avg4segment")) {
|
|
Matcher m = RegexUtils.matcher(FC_REG + "(avg4segment)\\(([^)]+)\\)", f);
|
|
Matcher m = RegexUtils.matcher(FC_REG + "(avg4segment)\\(([^)]+)\\)", f);
|
|
while (m.find()) {
|
|
while (m.find()) {
|
|
@@ -5003,6 +5130,42 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 符号替换
|
|
|
|
+ * @param s1
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public String strReplace(String s1){
|
|
|
|
+ if(Objects.equals("≥",s1)){
|
|
|
|
+ s1 = ">=";
|
|
|
|
+ }
|
|
|
|
+ if(Objects.equals("≤",s1)){
|
|
|
|
+ s1 = "<=";
|
|
|
|
+ }
|
|
|
|
+ if(Objects.equals("≠",s1)){
|
|
|
|
+ s1 = "!=";
|
|
|
|
+ }
|
|
|
|
+ return s1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 字符串取数字
|
|
|
|
+ * @param input
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public static List<String> extractPureNumbers(String input) {
|
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
|
+ // 正则表达式:匹配整数或小数(包括小数点),忽略其他字符
|
|
|
|
+ Pattern pattern = Pattern.compile("\\d+(?:\\.\\d+)?");
|
|
|
|
+ Matcher matcher = pattern.matcher(input);
|
|
|
|
+
|
|
|
|
+ while (matcher.find()) {
|
|
|
|
+ result.add(matcher.group());
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/*合格率预处理*/
|
|
/*合格率预处理*/
|
|
public void quantity(Formula formula, FormData fd, String f, TableElementConverter tec) {
|
|
public void quantity(Formula formula, FormData fd, String f, TableElementConverter tec) {
|
|
/*聚合*/
|
|
/*聚合*/
|