|
@@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.jfireel.expression.Expression;
|
|
|
import com.mixsmart.utils.CustomFunction;
|
|
|
import com.mixsmart.utils.FormulaUtils;
|
|
@@ -5915,18 +5916,23 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
Map<String, Object> currentMap = createCurrentMap(el, tec);
|
|
|
|
|
|
//根据分号分组 数据样例:a=x -> b=0; a=y -> c=1; else -> d=2
|
|
|
- String[] ruleArray = content.trim().split(";");
|
|
|
- for (String rule : ruleArray) {
|
|
|
- if (rule.startsWith("else")) {
|
|
|
- String[] parts = rule.split("!");
|
|
|
- String[] action = parts[1].split("=");
|
|
|
+ String[] ruleArray = content.trim().split(",");
|
|
|
+ if(ruleArray.length % 2 != 0){
|
|
|
+ throw new ServiceException("数据格式错误");
|
|
|
+ }
|
|
|
+ List<String> list = Arrays.asList(ruleArray);
|
|
|
+ //2条数据为一组
|
|
|
+ List<List<String>> partition = Lists.partition(list, 2);
|
|
|
+ for (List<String> strings : partition) {
|
|
|
+ String s = strings.get(0);
|
|
|
+ String s1 = strings.get(1);
|
|
|
+ String[] action = s1.split("=");
|
|
|
+ if ("else".equals(s)) {
|
|
|
key = action[0];
|
|
|
value = action[1];
|
|
|
break;
|
|
|
}
|
|
|
- String[] parts = rule.split("!");
|
|
|
- String[] action = parts[1].split("=");
|
|
|
- Expression parse = Expression.parse(parts[0] + "?1:0");
|
|
|
+ Expression parse = Expression.parse(s.replaceAll("=","==") + "?1:0");
|
|
|
Object data = parse.calculate(currentMap);
|
|
|
if(Objects.equals("1",String.valueOf(data))){
|
|
|
key = action[0];
|