perf: 优化异常告警一天仅一次

dev
huangfeng 8 months ago
parent be09597c16
commit 5ad3f511e0

@ -79,7 +79,11 @@ public class IEDCollectService {
} catch (Exception ex) {
String err = "61850采集数据异常, ied=" + ied.getName() + ", ip=" + ied.getIp() + ", port=" + ied.getPort();
log.error(err, ex);
_webSocketServer.sendMessage(err, null);
String key = ied.getName() + ied.getIp() + ied.getPort();
if (!StaticVariable.doneWarnMap.containsKey(key)) {
StaticVariable.doneWarnMap.put(key, "1");
_webSocketServer.sendMessage(err, null);
}
} finally {
iecClient.disconnect();
}
@ -174,7 +178,7 @@ public class IEDCollectService {
}
}
} catch (Exception ex) {
String err = "61850下载文件异常, ied=" + ied.getName() + ", ip=" + ied.getIp() + ", path=" + config.getPath();
String err = "61850采集文件异常, ied=" + ied.getName() + ", ip=" + ied.getIp() + ", path=" + config.getPath();
log.error(err, ex);
_webSocketServer.sendMessage(err, null);
}

@ -15,6 +15,7 @@ public class StaticVariable {
public static HashMap<Integer, IecServer> iecServerMap = new HashMap<>();
public static HashMap<Integer, HashMap<String, String>> sensorLastDataMap = new HashMap<>();
public static HashMap<String, String> paramRelationMap = new HashMap<>();
public static HashMap<String, String> doneWarnMap = new HashMap<>();
public static HashMap<String, String> unit_Cache = new HashMap<>();
public static List<ModevType> modevType_Cache = null;

@ -25,6 +25,7 @@ public class CacheTask {
StaticVariable.jg_Cache = null;
StaticVariable.zsb_Cache = null;
StaticVariable.rule_Cache.clear();
StaticVariable.doneWarnMap.clear();
}

@ -2,6 +2,7 @@ package com.xydl.cac.task;
import com.xydl.cac.adapter.BusiAdapter;
import com.xydl.cac.entity.*;
import com.xydl.cac.model.StaticVariable;
import com.xydl.cac.repository.I2syncRecordRepository;
import com.xydl.cac.repository.NSensorRepository;
import com.xydl.cac.service.DataService;
@ -63,8 +64,12 @@ public class I2syncTask {
} catch (Exception e) {
log.error("I2syncTask.syncAll error.", e);
String str = "i2同步导出数据异常: " + e.getMessage();
webSocketServer.sendMessage(str, null);
dingTalkPushUtil.pushText(str);
String key = "i2";
if (!StaticVariable.doneWarnMap.containsKey(key)) {
StaticVariable.doneWarnMap.put(key, "1");
webSocketServer.sendMessage(str, null);
dingTalkPushUtil.pushText(str);
}
}
}
}

@ -4,6 +4,7 @@ import com.jcraft.jsch.ChannelSftp;
import com.xydl.cac.config.BizConfig;
import com.xydl.cac.entity.*;
import com.xydl.cac.entity.constants.Constants;
import com.xydl.cac.model.StaticVariable;
import com.xydl.cac.service.RemoteConfigService;
import com.xydl.cac.service.RemoteDownloadService;
import com.xydl.cac.socket.WebSocketServer;
@ -51,22 +52,15 @@ public class SftpDownloadTask {
List<RemoteConfig> configList = configService.listAll();
if (!CollectionUtils.isEmpty(configList)) {
log.info("AmpliDownloadTask.downloadAll 开始.");
try {
for (RemoteConfig config : configList) {
this.downloadServer(config);
}
log.info("AmpliDownloadTask.downloadAll 结束.");
} catch (Exception e) {
log.error("AmpliDownloadTask.downloadAll error.", e);
String str = "SFTP下载文件异常: " + e.getMessage();
webSocketServer.sendMessage(str, null);
dingTalkPushUtil.pushText(str);
for (RemoteConfig config : configList) {
this.downloadServer(config);
}
log.info("AmpliDownloadTask.downloadAll 结束.");
}
}
// 下载一个远端服务器
private void downloadServer(RemoteConfig config) throws Exception {
private void downloadServer(RemoteConfig config) {
if (shutdown == 1) {
return;
}
@ -88,8 +82,12 @@ public class SftpDownloadTask {
log.error("AmpliDownloadTask.downloadServer error.", e);
String str = "SFTP下载文件异常: " + config.getName() + " " +
config.getIp() + " " + e.getMessage();
webSocketServer.sendMessage(str, null);
dingTalkPushUtil.pushText(str);
String key = "sftp" + config.getId();
if (!StaticVariable.doneWarnMap.containsKey(key)) {
StaticVariable.doneWarnMap.put(key, "1");
webSocketServer.sendMessage(str, null);
dingTalkPushUtil.pushText(str);
}
} finally {
sftpTool.disconnect();
}

Loading…
Cancel
Save