|
@@ -1,10 +1,13 @@
|
|
|
package com.persagy.test;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.googlecode.aviator.AviatorEvaluator;
|
|
|
+import com.googlecode.aviator.Expression;
|
|
|
import org.springframework.data.redis.core.Cursor;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.data.redis.core.ScanOptions;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
@@ -51,5 +54,31 @@ public class TestController {
|
|
|
long time = 111L;
|
|
|
alarmRedisTemplate.opsForValue().set("test", time);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
+ paramMap.put("ACATFU_SeasonChangeSet", 1.0d);
|
|
|
+ String trigger = "(" +
|
|
|
+ "(ACATFU_SupplyAirTemp!=NaN) || " +
|
|
|
+ "(ACATFU_ManualAutoStatus!=NaN) || " +
|
|
|
+ "(ACATFU_SeasonChangeSet!=NaN)) && " +
|
|
|
+ "(" +
|
|
|
+ "((ACATFU_SupplyAirTemp==NaN)?false:((ACATFU_SupplyAirTemp>=1))) ||" +
|
|
|
+ " ((ACATFU_ManualAutoStatus==NaN)?false:((ACATFU_ManualAutoStatus==1))) || " +
|
|
|
+ "((ACATFU_SeasonChangeSet==NaN)?false:((ACATFU_SeasonChangeSet==1))))";
|
|
|
+ Expression triggerExp = AviatorEvaluator.compile(trigger, true);
|
|
|
+ Boolean triggerResult = (Boolean) triggerExp.execute(paramMap);
|
|
|
+ System.out.println(triggerResult);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/testAlarmCondition")
|
|
|
+ public Boolean testAlarmCondition(@RequestBody JSONObject body) {
|
|
|
+ String trigger = body.getString("trigger");
|
|
|
+ JSONObject paramMap = body.getJSONObject("paramMap");
|
|
|
+ Expression triggerExp = AviatorEvaluator.compile(trigger, true);
|
|
|
+ return (Boolean) triggerExp.execute(paramMap);
|
|
|
+ }
|
|
|
}
|
|
|
|