一小时内不重复告警

This commit is contained in:
zhangyue 2026-08-21 19:12:40 +08:00
parent 60780c0d35
commit 85b598a712
1 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package com.lanhai.service.Impl;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
//import cn.hutool.extra.mail.MailUtil;
import cn.hutool.json.JSONUtil;
@ -22,11 +23,13 @@ import com.lanhai.service.ISurvAlertRecordService;
import com.lanhai.service.ISurvDeviceDeployService;
import com.lanhai.service.ISurvStationInfoService;
import com.lanhai.util.DataUtil;
import com.xxl.job.core.context.XxlJobHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@ -127,6 +130,23 @@ public class SurvAlertRecordServiceImpl extends ServiceImpl<SurvAlertRecordMappe
String mn = baowenMap.get("mn");
String DataTime = baowenMap.get("DataTime");
if(deviceDeploy != null){
//检查该设备上一次的数据如果在60分钟以内不报警
SurvAlertRecord lastBaojing = lambdaQuery()
.eq(SurvAlertRecord::getDeployId,deviceDeploy.getId())
.orderByDesc(SurvAlertRecord::getAlertTime)
.last("limit 1")
.one();
if(lastBaojing != null){
if(lastBaojing.getAlertTime()!=null){
long times = DateUtil.between(lastBaojing.getAlertTime(), new Date(),DateUnit.MINUTE);
if(times<=60){
XxlJobHelper.log("&&&&&设备:{},编号:{}在60分钟以内不报警&&&&&",deviceDeploy.getDeployDes(),deviceDeploy.getDeployCode());
log.error("&&&&&设备:{},编号:{}在60分钟以内不报警&&&&",deviceDeploy.getDeployDes(),deviceDeploy.getDeployCode());
return;
}
}
}
LinkedHashMap<String, JSONObject> zhibiaomap = zhibiaoService.getAllZhiBiao(deviceDeploy.getScEquZhibiaoList());
StringBuilder sb = new StringBuilder();
JSONArray jsonarr = new JSONArray();