From 45e9fc880c61e12d6415755ee2a29f79fcf81fbb Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期五, 11 三月 2022 09:49:38 +0800 Subject: [PATCH] Merge branch 'wvp-28181-2.0' into wvp-28181-2.0 --- src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java | 45 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 37 insertions(+), 8 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..27bc4bc 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,14 @@ 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.gb28181.transmit.cmd.impl.SIPCommander; +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 +20,7 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil; import java.text.SimpleDateFormat; +import java.util.List; /** * @description: 鍦ㄧ嚎浜嬩欢鐩戝惉鍣紝鐩戝惉鍒扮绾垮悗锛屼慨鏀硅澶囩鍦ㄧ嚎鐘舵�併�� 璁惧鍦ㄧ嚎鏈変袱涓潵婧愶細 @@ -28,12 +36,24 @@ @Autowired private IVideoManagerStorager storager; + + @Autowired + private IDeviceService deviceService; @Autowired private RedisUtil redis; @Autowired private SipConfig sipConfig; + + @Autowired + private UserSetup userSetup; + + @Autowired + private EventPublisher eventPublisher; + + @Autowired + private SIPCommander cmder; private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -44,14 +64,23 @@ 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(); + Device deviceInStore = storager.queryVideoDevice(device.getDeviceId()); + device.setOnline(1); + // 澶勭悊涓婄嚎鐩戝惉 + storager.updateDevice(device); switch (event.getFrom()) { // 娉ㄥ唽鏃惰Е鍙戠殑鍦ㄧ嚎浜嬩欢锛屽厛鍦╮edis涓鍔犺秴鏃惰秴鏃剁洃鍚� case VideoManagerConstants.EVENT_ONLINE_REGISTER: // 瓒呮椂鏃堕棿 redis.set(key, event.getDevice().getDeviceId(), sipConfig.getKeepaliveTimeOut()); device.setRegisterTime(format.format(System.currentTimeMillis())); + if (deviceInStore == null) { //绗竴娆′笂绾� + logger.info("[{}] 棣栨娉ㄥ唽锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId()); + cmder.deviceInfoQuery(device); + cmder.catalogQuery(device, null); + } break; // 璁惧涓诲姩鍙戦�佸績璺宠Е鍙戠殑鍦ㄧ嚎浜嬩欢 case VideoManagerConstants.EVENT_ONLINE_KEEPLIVE: @@ -70,11 +99,11 @@ break; } - device.setOnline(1); - // 澶勭悊涓婄嚎鐩戝惉 - storager.updateDevice(device); - - // TODO 涓婄嚎娣诲姞璁㈤槄 - + List<DeviceChannel> deviceChannelList = storager.queryOnlineChannelsByDeviceId(device.getDeviceId()); + eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON); + // 涓婄嚎娣诲姞璁㈤槄 + if (device.getSubscribeCycleForCatalog() > 0) { + deviceService.addCatalogSubscribe(device); + } } } -- Gitblit v1.8.0