From 7145ce07e6a84854fc1e5afd65b664c54a47bffd Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期三, 20 四月 2022 14:16:10 +0800 Subject: [PATCH] Merge pull request #439 from hotcoffie/wvp-28181-2.0 --- src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 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 c0de8de..b97457a 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,13 +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.conf.UserSetting; 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; @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.redis.RedisUtil; import java.text.SimpleDateFormat; @@ -34,7 +34,7 @@ private final static Logger logger = LoggerFactory.getLogger(OnlineEventListener.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IDeviceService deviceService; @@ -46,10 +46,14 @@ private SipConfig sipConfig; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private EventPublisher eventPublisher; + + @Autowired + private SIPCommander cmder; + private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -61,14 +65,20 @@ } Device device = event.getDevice(); if (device == null) return; - String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDevice().getDeviceId(); - + String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDevice().getDeviceId(); + Device deviceInStore = storager.queryVideoDevice(device.getDeviceId()); + device.setOnline(1); 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); + deviceService.sync(device); + } break; // 璁惧涓诲姩鍙戦�佸績璺宠Е鍙戠殑鍦ㄧ嚎浜嬩欢 case VideoManagerConstants.EVENT_ONLINE_KEEPLIVE: @@ -86,20 +96,15 @@ break; } - - 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); - // 涓婄嚎娣诲姞璁㈤槄 if (device.getSubscribeCycleForCatalog() > 0) { + // 鏌ヨ鍦ㄧ嚎璁惧閭d簺寮�鍚簡璁㈤槄锛屼负璁惧寮�鍚畾鏃剁殑鐩綍璁㈤槄 deviceService.addCatalogSubscribe(device); } - + if (device.getSubscribeCycleForMobilePosition() > 0) { + deviceService.addMobilePositionSubscribe(device); + } } } -- Gitblit v1.8.0