From 4ac63a158d16a0d2bce63f8fbadb9b7896397cd1 Mon Sep 17 00:00:00 2001 From: 648540858 <456panlinlin> Date: 星期五, 01 四月 2022 17:13:11 +0800 Subject: [PATCH] 使用getHostAddress代替getHostName避免经过DNS时间过久 --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java | 46 ++++++++++++++++------------------------------ 1 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java index 21f36b3..fc7e233 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java @@ -1,18 +1,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; -import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -28,20 +23,16 @@ @Component public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(CatalogNotifyMessageHandler.class); private final String cmdType = "Catalog"; @Autowired private NotifyMessageHandler notifyMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storage; @Autowired private SIPCommanderFroPlatform cmderFroPlatform; - - @Autowired - private SipConfig config; @Override public void afterPropertiesSet() throws Exception { @@ -64,12 +55,12 @@ Element snElement = rootElement.element("SN"); String sn = snElement.getText(); // 鍑嗗鍥炲閫氶亾淇℃伅 - List<ChannelReduce> channelReduces = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); + List<DeviceChannelInPlatform> deviceChannels = storage.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); // 鏌ヨ鍏宠仈鐨勭洿鎾�氶亾 - List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); - int size = channelReduces.size() + gbStreams.size(); + List<GbStream> gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); + int size = deviceChannels.size() + gbStreams.size(); // 鍥炲鐩綍淇℃伅 - List<PlatformCatalog> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); + List<PlatformCatalog> catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId()); if (catalogs.size() > 0) { for (PlatformCatalog catalog : catalogs) { if (catalog.getParentId().equals(catalog.getPlatformId())) { @@ -86,7 +77,7 @@ deviceChannel.setParental(1); deviceChannel.setParentId(catalog.getParentId()); deviceChannel.setRegisterWay(1); - deviceChannel.setCivilCode(config.getDomain().substring(0, config.getDomain().length() - 2)); + deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0,6)); deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setSecrecy("0"); @@ -96,14 +87,15 @@ } } // 鍥炲绾ц仈鐨勯�氶亾 - if (channelReduces.size() > 0) { - for (ChannelReduce channelReduce : channelReduces) { - if (channelReduce.getCatalogId().equals(parentPlatform.getServerGBId())) { - channelReduce.setCatalogId(parentPlatform.getDeviceGBId()); + if (deviceChannels.size() > 0) { + for (DeviceChannelInPlatform channel : deviceChannels) { + if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) { + channel.setCatalogId(parentPlatform.getDeviceGBId()); } - DeviceChannel deviceChannel = storager.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); + DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId()); deviceChannel.setParental(0); - deviceChannel.setParentId(channelReduce.getCatalogId()); + deviceChannel.setParentId(channel.getCatalogId()); + deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0, 6)); cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size); // 闃叉鍙戦�佽繃蹇� Thread.sleep(100); @@ -125,7 +117,7 @@ deviceChannel.setStatus(gbStream.isStatus()?1:0); deviceChannel.setParentId(gbStream.getCatalogId()); deviceChannel.setRegisterWay(1); - deviceChannel.setCivilCode(config.getDomain().substring(0, config.getDomain().length() - 2)); + deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0,6)); deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setParental(0); @@ -139,13 +131,7 @@ // 鍥炲鏃犻�氶亾 cmderFroPlatform.catalogQuery(null, parentPlatform, sn, fromHeader.getTag(), size); } - } catch (SipException e) { - e.printStackTrace(); - } catch (InvalidArgumentException e) { - e.printStackTrace(); - } catch (ParseException e) { - e.printStackTrace(); - } catch (InterruptedException e) { + } catch (SipException | InvalidArgumentException | ParseException | InterruptedException e) { e.printStackTrace(); } -- Gitblit v1.8.0