瀏覽代碼

fix: 预警问题

jackzhou 5 月之前
父節點
當前提交
068d635afc

+ 6 - 0
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/core/alarm/bean/SensorAlarm.java

@@ -82,6 +82,12 @@ public class SensorAlarm extends OrgEntity {
     @Schema(description = "设备ID,指示告警是由哪个设备触发的")
     private String deviceId;
 
+    /**
+     * 房间名称(可选)
+     */
+    @Schema(description = "房间名称")
+    private String roomName;
+
     /**
      * 设备名称,给出触发告警的设备的名称(可选)
      */

+ 2 - 3
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/core/alarm/offline/DeviceOfflineDetectionService.java

@@ -4,7 +4,6 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.jetbrains.annotations.NotNull;
 import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import vip.xiaonuo.coldchain.core.alarm.bean.SensorAlarm;
@@ -51,7 +50,7 @@ public class DeviceOfflineDetectionService {
      *
      * @param deviceCode 设备标识符
      */
-    @Async("coldChainAsyncTask")
+//    @Async("coldChainAsyncTask")
     public void reportDeviceTime(String deviceCode, Integer route) {
         // 获取当前时间并格式化为字符串
         String currentTime = LocalDateTime.now().format(DATE_TIME_FORMATTER);
@@ -64,7 +63,7 @@ public class DeviceOfflineDetectionService {
      * 定期检测设备状态是否离线
      * 每 5 分钟运行一次
      */
-    @Scheduled(fixedRate = 300000) // 每 5 分钟(以毫秒为单位)
+    @Scheduled(fixedRate = 60000) // 每 5 分钟(以毫秒为单位)
 //    @Scheduled(fixedRateString = "${coldchain.device-offline-interval:300000}")
     public void checkDeviceStatus() {
         log.info("开始检测离线设备状态...");

+ 7 - 1
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/core/alarm/service/messagepush/impl/WechatMessagePushService.java

@@ -24,7 +24,7 @@ public class WechatMessagePushService implements MessagePushService {
         PushParam pushParam = null;
         if (alarm.getValue() == 0 || alarm.getThreshold() == 0) {
             pushParam = new PushParam();
-            pushParam.setValue("设备离线/断电");
+            pushParam.setValue("Device Offline or Power Failure");
         } else {
             //数据异常
             pushParam = new PushParam(alarm.getValue() + "/" + alarm.getThreshold());
@@ -34,6 +34,12 @@ public class WechatMessagePushService implements MessagePushService {
         } else {
             pushParam.setContext(alarm.getMessage());
         }
+        // 添加房间名称
+        if (StrUtil.isNotBlank(alarm.getRoomName())) {
+            pushParam.setDeviceName(alarm.getSource() + "(" + alarm.getRoomName() + ")");
+        } else {
+            pushParam.setDeviceName(alarm.getSource());
+        }
         pushParam.setDeviceName(alarm.getSource());
         pushParam.setNoticeTime(new Date());
         pushParam.setType(alarm.getAlarmType());

+ 1 - 1
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/core/config/JfcloudColdChainConstants.java

@@ -65,7 +65,7 @@ public interface JfcloudColdChainConstants {
     /**
      * redis 缓存用户推送消息频率限制
      */
-    String REDIS_PUSH_HISTORY_KEY_PREFIX = "alarm_push_history";
+    String REDIS_PUSH_HISTORY_KEY_PREFIX = "ALARM_PUSH_HISTORY";
 
     /**
      * 每 5 分钟定期执行设备缓存更新