From a42dda2bd3cc1cf8c20cc61e7ad9211eadecbaf3 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期四, 24 二月 2022 16:55:06 +0800 Subject: [PATCH] 规范数据库,添加必要约束,优化通道批量导入功能 --- src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 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 3d59260..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,11 +19,12 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil; import java.text.SimpleDateFormat; +import java.util.List; /** * @description: 鍦ㄧ嚎浜嬩欢鐩戝惉鍣紝鐩戝惉鍒扮绾垮悗锛屼慨鏀硅澶囩鍦ㄧ嚎鐘舵�併�� 璁惧鍦ㄧ嚎鏈変袱涓潵婧愶細 - * 1銆佽澶囦富鍔ㄦ敞閿�锛屽彂閫佹敞閿�鎸囦护锛寋@link com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.RegisterRequestProcessor} - * 2銆佽澶囨湭鐭ュ師鍥犵绾匡紝蹇冭烦瓒呮椂,{@link com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.MessageRequestProcessor} + * 1銆佽澶囦富鍔ㄦ敞閿�锛屽彂閫佹敞閿�鎸囦护 + * 2銆佽澶囨湭鐭ュ師鍥犵绾匡紝蹇冭烦瓒呮椂 * @author: swwheihei * @date: 2020骞�5鏈�6鏃� 涓嬪崍1:51:23 */ @@ -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