From 9f680a2e9e8560cf5f38acdc30335e51d88b2001 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 26 八月 2022 18:03:09 +0800
Subject: [PATCH] 修复bug以及日志按照,错误/sip/数据库 分割

---
 src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java |   32 +++++++++++++++++++++++---------
 1 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java
index 4d1948a..1634234 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisAlarmMsgListener.java
@@ -4,6 +4,8 @@
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
+import com.genersoft.iot.vmp.service.IPlatformChannelService;
+import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.utils.DateUtil;
 import org.slf4j.Logger;
@@ -12,6 +14,9 @@
 import org.springframework.data.redis.connection.Message;
 import org.springframework.data.redis.connection.MessageListener;
 import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
+
+import java.util.List;
 
 
 @Component
@@ -37,8 +42,6 @@
             return;
         }
         String gbId = alarmChannelMessage.getGbId();
-        Device device = storage.queryVideoDevice(gbId);
-        ParentPlatform platform = storage.queryParentPlatByServerGBId(gbId);
 
         DeviceAlarm deviceAlarm = new DeviceAlarm();
         deviceAlarm.setCreateTime(DateUtil.getNow());
@@ -46,18 +49,29 @@
         deviceAlarm.setAlarmDescription(alarmChannelMessage.getAlarmDescription());
         deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn());
         deviceAlarm.setAlarmPriority("1");
-        deviceAlarm.setAlarmTime(DateUtil.getNow());
+        deviceAlarm.setAlarmTime(DateUtil.getNowForISO8601());
         deviceAlarm.setAlarmType("1");
         deviceAlarm.setLongitude(0);
         deviceAlarm.setLatitude(0);
 
-
-        if (device != null && platform == null) {
-            commander.sendAlarmMessage(device, deviceAlarm);
-        }else if (device == null && platform != null){
-            commanderForPlatform.sendAlarmMessage(platform, deviceAlarm);
+        if (ObjectUtils.isEmpty(gbId)) {
+            // 鍙戦�佺粰鎵�鏈夌殑涓婄骇
+            List<ParentPlatform> parentPlatforms = storage.queryEnableParentPlatformList(true);
+            if (parentPlatforms.size() > 0) {
+                for (ParentPlatform parentPlatform : parentPlatforms) {
+                    commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm);
+                }
+            }
         }else {
-           logger.warn("鏃犳硶纭畾" + gbId + "鏄钩鍙拌繕鏄澶�");
+            Device device = storage.queryVideoDevice(gbId);
+            ParentPlatform platform = storage.queryParentPlatByServerGBId(gbId);
+            if (device != null && platform == null) {
+                commander.sendAlarmMessage(device, deviceAlarm);
+            }else if (device == null && platform != null){
+                commanderForPlatform.sendAlarmMessage(platform, deviceAlarm);
+            }else {
+                logger.warn("鏃犳硶纭畾" + gbId + "鏄钩鍙拌繕鏄澶�");
+            }
         }
     }
 }

--
Gitblit v1.8.0