From 764d04b497356ba6bcbb75fd42b51eca750f7223 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期三, 29 五月 2024 15:02:51 +0800 Subject: [PATCH] 调整上级观看消息的发送 --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java old mode 100644 new mode 100755 index 2d8af9b..c16d7f5 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -1,6 +1,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; -import com.genersoft.iot.vmp.conf.CivilCodeFileConf; +import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; @@ -29,6 +29,7 @@ import java.util.Iterator; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicBoolean; /** * 鐩綍鏌ヨ鐨勫洖澶� @@ -37,6 +38,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { private Logger logger = LoggerFactory.getLogger(CatalogResponseMessageHandler.class); + private final String cmdType = "Catalog"; @Autowired @@ -55,7 +57,8 @@ private ThreadPoolTaskExecutor taskExecutor; @Autowired - private CivilCodeFileConf civilCodeFileConf; + private SipConfig sipConfig; + private AtomicBoolean processing = new AtomicBoolean(false); @Override public void afterPropertiesSet() throws Exception { @@ -64,7 +67,6 @@ @Override public void handForDevice(RequestEvent evt, Device device, Element element) { - boolean isEmpty = taskQueue.isEmpty(); taskQueue.offer(new HandlerCatchData(evt, device, element)); // 鍥炲200 OK try { @@ -72,8 +74,8 @@ } catch (SipException | InvalidArgumentException | ParseException e) { logger.error("[鍛戒护鍙戦�佸け璐 鐩綍鏌ヨ鍥炲: {}", e.getMessage()); } - // 濡傛灉涓嶄负绌哄垯璇存槑宸茬粡寮�鍚秷鎭鐞� - if (isEmpty) { + // 宸茬粡寮�鍚秷鎭鐞嗗垯璺宠繃 + if (processing.compareAndSet(false, true)) { taskExecutor.execute(() -> { while (!taskQueue.isEmpty()) { // 鍏ㄥ眬寮傚父鎹曡幏锛屼繚璇佷笅涓�鏉″彲浠ュ緱鍒板鐞� @@ -112,11 +114,18 @@ if (channelDeviceElement == null) { continue; } - DeviceChannel deviceChannel = XmlUtil.channelContentHandler(itemDevice, device, null, civilCodeFileConf); - deviceChannel = SipUtils.updateGps(deviceChannel, device.getGeoCoordSys()); - deviceChannel.setDeviceId(take.getDevice().getDeviceId()); + DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null); + if (channel == null) { + logger.info("[鏀跺埌鐩綍璁㈤槄]锛氫絾鏄В鏋愬け璐� {}", new String(evt.getRequest().getRawContent())); + continue; + } + if (channel.getParentId() != null && channel.getParentId().equals(sipConfig.getId())) { + channel.setParentId(null); + } + SipUtils.updateGps(channel, device.getGeoCoordSys()); + channel.setDeviceId(take.getDevice().getDeviceId()); - channelList.add(deviceChannel); + channelList.add(channel); } int sn = Integer.parseInt(snElement.getText()); catalogDataCatch.put(take.getDevice().getDeviceId(), sn, sumNum, take.getDevice(), channelList); @@ -135,11 +144,12 @@ } } - }catch (Exception e) { + } catch (Exception e) { logger.warn("[鏀跺埌閫氶亾] 鍙戠幇鏈鐞嗙殑寮傚父, \r\n{}", evt.getRequest()); logger.error("[鏀跺埌閫氶亾] 寮傚父鍐呭锛� ", e); } } + processing.set(false); }); } -- Gitblit v1.8.0