From 41616f726dafafe7c015bf4f3e02a7aa9488a3a2 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 07 三月 2022 10:47:06 +0800
Subject: [PATCH] 修复导入通道时无平台关联时的bug
---
src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
index b347891..c0de8de 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
@@ -1,7 +1,13 @@
package com.genersoft.iot.vmp.gb28181.event.online;
import com.genersoft.iot.vmp.conf.SipConfig;
+import com.genersoft.iot.vmp.conf.UserSetup;
import com.genersoft.iot.vmp.gb28181.bean.Device;
+import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
+import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
+import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
+import com.genersoft.iot.vmp.service.IDeviceService;
+import com.genersoft.iot.vmp.storager.dao.dto.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +19,7 @@
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import java.text.SimpleDateFormat;
+import java.util.List;
/**
* @description: 鍦ㄧ嚎浜嬩欢鐩戝惉鍣紝鐩戝惉鍒扮绾垮悗锛屼慨鏀硅澶囩鍦ㄧ嚎鐘舵�併�� 璁惧鍦ㄧ嚎鏈変袱涓潵婧愶細
@@ -28,12 +35,21 @@
@Autowired
private IVideoManagerStorager storager;
+
+ @Autowired
+ private IDeviceService deviceService;
@Autowired
private RedisUtil redis;
@Autowired
private SipConfig sipConfig;
+
+ @Autowired
+ private UserSetup userSetup;
+
+ @Autowired
+ private EventPublisher eventPublisher;
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -44,7 +60,8 @@
logger.debug("璁惧涓婄嚎浜嬩欢瑙﹀彂锛宒eviceId锛�" + event.getDevice().getDeviceId() + ",from:" + event.getFrom());
}
Device device = event.getDevice();
- String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + event.getDevice().getDeviceId();
+ if (device == null) return;
+ String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDevice().getDeviceId();
switch (event.getFrom()) {
// 娉ㄥ唽鏃惰Е鍙戠殑鍦ㄧ嚎浜嬩欢锛屽厛鍦╮edis涓鍔犺秴鏃惰秴鏃剁洃鍚�
@@ -71,10 +88,18 @@
}
device.setOnline(1);
+ Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
+ if (deviceInStore != null && deviceInStore.getOnline() == 0) {
+ List<DeviceChannel> deviceChannelList = storager.queryOnlineChannelsByDeviceId(device.getDeviceId());
+ eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON);
+ }
// 澶勭悊涓婄嚎鐩戝惉
storager.updateDevice(device);
- // TODO 涓婄嚎娣诲姞璁㈤槄
+ // 涓婄嚎娣诲姞璁㈤槄
+ if (device.getSubscribeCycleForCatalog() > 0) {
+ deviceService.addCatalogSubscribe(device);
+ }
}
}
--
Gitblit v1.8.0