|
@@ -36,9 +36,11 @@ public class FormulaService implements IFormulaService {
|
|
|
private ExpressRunner runner;
|
|
|
|
|
|
@Override
|
|
|
- public int evaluateExpression(ExpressBo expressBo) {
|
|
|
+ public JSONObject evaluateExpression(ExpressBo expressBo) {
|
|
|
// 虚警
|
|
|
int result = 1;
|
|
|
+ String timeFlag = null;
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
try {
|
|
|
// CsvUtils.getCsvHeaders("");
|
|
|
runner = new ExpressRunner();
|
|
@@ -57,7 +59,8 @@ public class FormulaService implements IFormulaService {
|
|
|
String[] variableNames = parseVariableNames(expressBo.getExpression());
|
|
|
if (!CollUtil.containsAll(headers, Arrays.asList(variableNames))) {
|
|
|
log.info("参数列名称匹配不成功:{}{}", Arrays.toString(variableNames), headers.toString());
|
|
|
- return 2;
|
|
|
+ resultJson.set("result", result);
|
|
|
+ return resultJson;
|
|
|
}
|
|
|
|
|
|
JSONArray arr = CsvUtils.fileCsvToJsonRegex(path);
|
|
@@ -68,6 +71,7 @@ public class FormulaService implements IFormulaService {
|
|
|
Boolean isMatch = (Boolean) runner.execute(expressBo.getExpression(), context, null, true, false);
|
|
|
log.info("isMatch==========================:{}", isMatch);
|
|
|
if (isMatch) {
|
|
|
+ timeFlag = "";
|
|
|
// 实警
|
|
|
result = 0;
|
|
|
break;
|
|
@@ -76,7 +80,9 @@ public class FormulaService implements IFormulaService {
|
|
|
} catch (Exception e) {
|
|
|
throw new BusinessException(e.getMessage());
|
|
|
}
|
|
|
- return result;
|
|
|
+ resultJson.set("timeFlag", timeFlag);
|
|
|
+ resultJson.set("result", result);
|
|
|
+ return resultJson;
|
|
|
}
|
|
|
|
|
|
private Map<String, Object> buildVariableContext(ExpressBo expressBo, JSONObject jsonObject) {
|