|
@@ -1,6 +1,8 @@
|
|
|
package org.eco.als.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.date.format.FastDateFormat;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
@@ -15,11 +17,14 @@ import org.eco.als.utils.CheckVibrationDuration;
|
|
|
import org.eco.als.utils.CsvUtils;
|
|
|
import org.eco.common.core.constant.Constants;
|
|
|
import org.eco.common.core.exception.BusinessException;
|
|
|
+import org.eco.common.core.utils.DateUtils;
|
|
|
import org.eco.common.core.utils.StringUtils;
|
|
|
import org.eco.system.domain.vo.SysOssVo;
|
|
|
import org.eco.system.service.ISysOssService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.time.Duration;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -65,13 +70,16 @@ public class FormulaService implements IFormulaService {
|
|
|
|
|
|
JSONArray arr = CsvUtils.fileCsvToJsonRegex(path);
|
|
|
for (Object object : arr) {
|
|
|
+ timeFlag = ((JSONObject) object).getStr("时间");
|
|
|
+ if (durationTime(expressBo.getCutTime(),timeFlag)< 1) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
DefaultContext<String, Object> context = new DefaultContext<>();
|
|
|
Map<String, Object> variables = CollUtil.isEmpty(expressBo.getVariables()) ? buildVariableContext(expressBo, (JSONObject) object) : expressBo.getVariables();
|
|
|
context.putAll(variables);
|
|
|
Boolean isMatch = (Boolean) runner.execute(expressBo.getExpression(), context, null, true, false);
|
|
|
log.info("isMatch==========================:{}", isMatch);
|
|
|
if (isMatch) {
|
|
|
- timeFlag = ((JSONObject) object).getStr("时间");
|
|
|
// 实警
|
|
|
result = 0;
|
|
|
break;
|
|
@@ -99,6 +107,13 @@ public class FormulaService implements IFormulaService {
|
|
|
return variables;
|
|
|
}
|
|
|
|
|
|
+ private int durationTime(int cutTime, String timeStr) {
|
|
|
+ LocalTime time = LocalTime.parse(timeStr);
|
|
|
+ Duration duration = Duration.between(LocalTime.MIN, time);
|
|
|
+ Duration minutesDuration = Duration.ofMinutes(cutTime);
|
|
|
+ return duration.compareTo(minutesDuration);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 解析表达式中的变量名。
|
|
|
*/
|