Browse Source

修改类型转化

Rmengdi 3 months ago
parent
commit
0b4dab0c58

+ 10 - 6
als-modules/agile-assurance/src/main/java/org/eco/als/service/impl/FormulaService.java

@@ -1,6 +1,7 @@
 package org.eco.als.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import com.ql.util.express.DefaultContext;
@@ -37,7 +38,7 @@ public class FormulaService implements IFormulaService {
     @Override
     public int evaluateExpression(ExpressBo expressBo) {
         // 虚警
-        int result = 0;
+        int result = 1;
         try {
 //            CsvUtils.getCsvHeaders("");
             runner = new ExpressRunner();
@@ -54,8 +55,8 @@ public class FormulaService implements IFormulaService {
             // 参数列名称
             List<String> headers = CsvUtils.getCsvHeaders(path);
             String[] variableNames = parseVariableNames(expressBo.getExpression());
-            if (!CollUtil.containsAll(Arrays.asList(variableNames), headers)) {
-                log.info("参数列名称匹配成功:{}{}", Arrays.toString(variableNames), headers.toString());
+            if (!CollUtil.containsAll(headers, Arrays.asList(variableNames))) {
+                log.info("参数列名称匹配成功:{}{}", Arrays.toString(variableNames), headers.toString());
                 return 2;
             }
 
@@ -68,7 +69,7 @@ public class FormulaService implements IFormulaService {
                 log.info("isMatch==========================:{}", isMatch);
                 if (isMatch) {
                     // 实警
-                    result = 1;
+                    result = 0;
                     break;
                 }
             }
@@ -83,9 +84,12 @@ public class FormulaService implements IFormulaService {
         Map<String, Object> variables = new HashMap<>();
         // 字段属性自定义值
         for (String fieldName : variableNames) {
-            variables.put(fieldName, jsonObject.get(fieldName));
+            if(StrUtil.equals("时间", fieldName)) {
+                variables.put(fieldName, jsonObject.get(fieldName));
+            } else {
+                variables.put(fieldName, Double.parseDouble((String) jsonObject.get(fieldName)));
+            }
         }
-        variables.put("时间", jsonObject.get("时间"));
         return variables;
     }