|
@@ -2,6 +2,7 @@ package com.zd.alg.monitor;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.zd.common.core.alert.DingTalkAlert;
|
|
|
import com.zd.common.core.redis.RedisService;
|
|
import com.zd.common.core.redis.RedisService;
|
|
|
import com.zd.common.core.utils.HttpUtils;
|
|
import com.zd.common.core.utils.HttpUtils;
|
|
|
import com.zd.common.core.utils.StringUtils;
|
|
import com.zd.common.core.utils.StringUtils;
|
|
@@ -39,12 +40,6 @@ public class HardwareDeviceMonitor {
|
|
|
@Value("${monitor.alert.dingTalkNotice}")
|
|
@Value("${monitor.alert.dingTalkNotice}")
|
|
|
private Boolean dingTalkNotice;
|
|
private Boolean dingTalkNotice;
|
|
|
|
|
|
|
|
- @Value("${monitor.alert.dingTalkSubject}")
|
|
|
|
|
- private String dingTalkSubject;
|
|
|
|
|
-
|
|
|
|
|
- @Value("${monitor.alert.dingTalkUrl}")
|
|
|
|
|
- private String dingTalkUrl;
|
|
|
|
|
-
|
|
|
|
|
private String redisPrefix = "HARDWARE_DEVICE_MONITOR:";
|
|
private String redisPrefix = "HARDWARE_DEVICE_MONITOR:";
|
|
|
|
|
|
|
|
private long expire = 30L;
|
|
private long expire = 30L;
|
|
@@ -57,7 +52,7 @@ public class HardwareDeviceMonitor {
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 */9 * * * ?")
|
|
@Scheduled(cron = "0 */9 * * * ?")
|
|
|
public void checkPowerUse() {
|
|
public void checkPowerUse() {
|
|
|
- if (dingTalkNotice != null && dingTalkNotice && StringUtils.isNotEmpty(dingTalkUrl)) {
|
|
|
|
|
|
|
+ if (dingTalkNotice != null && dingTalkNotice) {
|
|
|
log.info("【设备监听提醒】 开始执行检查..............");
|
|
log.info("【设备监听提醒】 开始执行检查..............");
|
|
|
ResultData result = remoteLabHardwareService.statistics();
|
|
ResultData result = remoteLabHardwareService.statistics();
|
|
|
if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
|
|
if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
|
|
@@ -86,7 +81,7 @@ public class HardwareDeviceMonitor {
|
|
|
if (!map.isEmpty()) {
|
|
if (!map.isEmpty()) {
|
|
|
Set<String> code = map.keySet();
|
|
Set<String> code = map.keySet();
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
- buffer.append("【"+dingTalkSubject+"-设备掉线提醒】离线继电器信息:\n");
|
|
|
|
|
|
|
+ buffer.append("系统接入继电器设备离线信息:\n");
|
|
|
boolean isSend = Boolean.FALSE;
|
|
boolean isSend = Boolean.FALSE;
|
|
|
for (String key : code) {
|
|
for (String key : code) {
|
|
|
Integer num = redisService.getCacheObject(redisPrefix+key);
|
|
Integer num = redisService.getCacheObject(redisPrefix+key);
|
|
@@ -102,7 +97,7 @@ public class HardwareDeviceMonitor {
|
|
|
//通知
|
|
//通知
|
|
|
if (isSend) {
|
|
if (isSend) {
|
|
|
String msg = "{\"msgtype\": \"text\",\"text\": {\"content\":\"" + buffer.toString() + "\"}}";
|
|
String msg = "{\"msgtype\": \"text\",\"text\": {\"content\":\"" + buffer.toString() + "\"}}";
|
|
|
- String rs = HttpUtils.sendPost(dingTalkUrl, msg, "application/json", null);
|
|
|
|
|
|
|
+ DingTalkAlert.sendAlert(msg);
|
|
|
//log.info("【设备监听提醒】 钉钉通知响应:" + rs);
|
|
//log.info("【设备监听提醒】 钉钉通知响应:" + rs);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|