feat: 增加低电压告警

dev
huangfeng 9 months ago
parent 91f8134686
commit bb19b442ab

@ -11,8 +11,10 @@ import java.util.HashMap;
@Service
public class ClearCacheTask {
public static HashMap<Integer, Long> warnMap = new HashMap<>();
public static HashMap<Integer, Long> reportCountMap = new HashMap<>();
public static HashMap<Integer, Long> activityMap = new HashMap<>();
public static HashMap<String, Long> heartbeatMap = new HashMap<>();
public static HashMap<Integer, Long> lowVoltMap = new HashMap<>();
@Resource
NewCacheService newCacheService;
@ -24,13 +26,15 @@ public class ClearCacheTask {
@Scheduled(cron = "0 0 9 * * MON-FRI")
private void clearWarnMap() {
warnMap.clear();
reportCountMap.clear();
activityMap.clear();
heartbeatMap.clear();
}
@Scheduled(cron = "0 0 10 * * ?")
private void clearFubin() {
PulliceModel.fubinDoneMap.clear();
lowVoltMap.clear();
}
}

@ -28,6 +28,7 @@ public class MntnCheckTask {
private int maxCount = 50;
private int maxDay = 3;
private int lostPer = 10;
private float lowVolt = 15;
public HashMap<Integer, Long> lostingMap = new HashMap<>();
private HashMap<Integer, Long> _lostMap;
@ -97,11 +98,14 @@ public class MntnCheckTask {
MntnRawReportsExample.Criteria criteria = example.createCriteria();
criteria.andTermIdEqualTo(termId);
criteria.andCreateTimeGreaterThan(time);
if (shutdown == 0) {
if (shutdown == 1) {
return;
}
long count = rawReportsMapper.countByExample(example);
if (count > maxCount) {
this.sendWarningCount(term, count);
} else if (count <= 0) {
}
example = new MntnRawReportsExample();
criteria = example.createCriteria();
criteria.andTermIdEqualTo(termId);
@ -109,26 +113,42 @@ public class MntnCheckTask {
PageHelper.startPage(1, 1);
List<MntnRawReports> list = rawReportsMapper.selectByExample(example);
if (!CollectionUtils.isEmpty(list)) {
Long lasttime = list.get(0).getCreateTime();
MntnRawReports last = list.get(0);
Long lasttime = last.getCreateTime();
long days = (System.currentTimeMillis() / 1000 - lasttime) / 60 / 60 / 24;
if (days >= maxDay) {
_lostMap.put(termId, days);
} else {
last.makeRawReport();
try {
Object chargeVolt = last.getReportMap().get("batteryChargingVoltage");
float volt = Float.parseFloat(chargeVolt.toString());
if (volt < lowVolt) {
// this.sendWarningLowVolt(term, chargeVolt);
}
} catch (Exception ignore) {
}
}
}
}
private void sendWarningLowVolt(Terminals term, Object chargeVolt) {
String str = "装置" + term.getCmdid() + "最新充电电压" + chargeVolt
+ "V, 低于设定的阈值" + lowVolt + "V;";
if (!ClearCacheTask.lowVoltMap.containsKey(term.getId())) {
ClearCacheTask.lowVoltMap.put(term.getId(), 1L);
log.warn(str);
DingTalkPushUtil.alertYW.add(str);
}
}
private void sendWarningCount(Terminals term, long count) {
String str = "装置" + term.getCmdid() + "最近" + minutes + "分钟内,运维报送次数:" + count
+ "次, 超过设定的阈值" + maxCount + "次;";
if (ClearCacheTask.warnMap.containsKey(term.getId())) {
Long cnt = ClearCacheTask.warnMap.get(term.getId());
cnt++;
ClearCacheTask.warnMap.put(term.getId(), cnt);
} else {
ClearCacheTask.warnMap.put(term.getId(), 1L);
if (!ClearCacheTask.reportCountMap.containsKey(term.getId())) {
ClearCacheTask.reportCountMap.put(term.getId(), 1L);
log.warn(str);
DingTalkPushUtil.alertYW.add(str);
}
@ -139,8 +159,8 @@ public class MntnCheckTask {
+ maxDay + "天的有" + lostCount + "台,超过设定的阈值" + lostPer + "%;";
int id = activity.getId() - 100000;
if (!ClearCacheTask.warnMap.containsKey(id)) {
ClearCacheTask.warnMap.put(id, 1L);
if (!ClearCacheTask.activityMap.containsKey(id)) {
ClearCacheTask.activityMap.put(id, 1L);
log.warn(str);
DingTalkPushUtil.alertYW.add(str);
}

Loading…
Cancel
Save