|
@@ -2,6 +2,7 @@ package com.persagy.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.googlecode.aviator.AviatorEvaluator;
|
|
|
import com.googlecode.aviator.Expression;
|
|
|
import com.persagy.cache.AlarmInfoCache;
|
|
@@ -235,6 +236,29 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @description: 发送报警仍在继续的消息
|
|
|
+ * @param: alarmId 报警记录id
|
|
|
+ * @param: lastTime 报警持续时间(单位:s)
|
|
|
+ * @param: paramMap 当前采集值
|
|
|
+ * @param: projectId 项目id
|
|
|
+ * @return: void
|
|
|
+ * @exception:
|
|
|
+ * @author: lixing
|
|
|
+ * @company: Persagy Technology Co.,Ltd
|
|
|
+ * @since: 2020/12/17 4:40 下午
|
|
|
+ * @version: V1.0
|
|
|
+ */
|
|
|
+ private void sendAlarmContinueMessage(String alarmId, long lastTime, HashMap paramMap, String projectId) throws InterruptedException {
|
|
|
+ NettyMessage<JSONObject> nettyMessage = new NettyMessage<>(11, projectId);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("id", alarmId);
|
|
|
+ jsonObject.put("lastTime", lastTime);
|
|
|
+ jsonObject.put("iotData", paramMap);
|
|
|
+ jsonObject.put("groupCode", groupCode);
|
|
|
+ nettyMessage.setContent(Lists.newArrayList(jsonObject));
|
|
|
+ groupNettyClient.sendMessage(nettyMessage.toString());
|
|
|
+ }
|
|
|
+ /**
|
|
|
* @param alarmDefine 报警定义
|
|
|
* @param dateTime :IOT数据采集时间
|
|
|
* @param condition :报警定义条件
|
|
@@ -278,6 +302,14 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
}
|
|
|
if (inEffectTime) {
|
|
|
//之前是报警状态,现在还是报警,报警值没变化
|
|
|
+ if (AlarmState.State.NOT_DEAL.getType().equals(alarmState.getState())) {
|
|
|
+ // 获取报警持续时间
|
|
|
+ String alarmStartTime = alarmState.getAlarmStartTime();
|
|
|
+ long lastTime = DateUtils.betweenTwoTimeSecond(alarmStartTime, dateTime);
|
|
|
+ String alarmId = alarmRecordRepository.findById(defineId).orElse(new ZktAlarmRecordDO()).getAlarmId();
|
|
|
+ // 发送报警仍在继续的消息
|
|
|
+ sendAlarmContinueMessage(alarmId, lastTime, paramMap, alarmDefine.getProjectId());
|
|
|
+ }
|
|
|
//之前是是正常时候
|
|
|
if (AlarmState.State.NORMAL.getType().equals(alarmState.getState())) {
|
|
|
long timeSecond = 0;
|