From d9eb0bb08b89724a5d164e4fc7220a3550ef089c Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 15 Oct 2024 15:34:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DMobilePosition=E7=9A=84?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98=20#1643?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tifyRequestForMobilePositionProcessor.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java index 9c326db4..c4124cad 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForMobilePositionProcessor.java @@ -86,12 +86,12 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor Element rootElement = getRootElement(evt); if (rootElement == null) { log.error("处理MobilePosition移动位置Notify时未获取到消息体,{}", evt.getRequest()); - return; + continue; } Device device = redisCatchStorage.getDevice(deviceId); if (device == null) { log.error("处理MobilePosition移动位置Notify时未获取到device,{}", deviceId); - return; + continue; } MobilePosition mobilePosition = new MobilePosition(); mobilePosition.setDeviceId(device.getDeviceId()); @@ -100,17 +100,18 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor DeviceChannel deviceChannel = null; List elements = rootElement.elements(); - for (Element element : elements) { + readDocument: for (Element element : elements) { switch (element.getName()){ case "DeviceID": String channelId = element.getStringValue(); - if (!deviceId.equals(channelId)) { - deviceChannel = deviceChannelService.getOne(device.getDeviceId(), channelId); - if (deviceChannel != null) { - mobilePosition.setChannelId(deviceChannel.getId()); - } + deviceChannel = deviceChannelService.getOne(device.getDeviceId(), channelId); + if (deviceChannel != null) { + mobilePosition.setChannelId(deviceChannel.getId()); + }else { + log.error("[notify-移动位置] 未找到通道 {}/{}", device.getDeviceId(), channelId); + break readDocument; } - continue; + break; case "Time": String timeVal = element.getStringValue(); if (ObjectUtils.isEmpty(timeVal)) { @@ -118,13 +119,13 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor } else { mobilePosition.setTime(SipUtils.parseTime(timeVal)); } - continue; + break; case "Longitude": mobilePosition.setLongitude(Double.parseDouble(element.getStringValue())); - continue; + break; case "Latitude": mobilePosition.setLatitude(Double.parseDouble(element.getStringValue())); - continue; + break; case "Speed": String speedVal = element.getStringValue(); if (NumericUtil.isDouble(speedVal)) { @@ -132,7 +133,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor } else { mobilePosition.setSpeed(0.0); } - continue; + break; case "Direction": String directionVal = element.getStringValue(); if (NumericUtil.isDouble(directionVal)) { @@ -140,7 +141,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor } else { mobilePosition.setDirection(0.0); } - continue; + break; case "Altitude": String altitudeVal = element.getStringValue(); if (NumericUtil.isDouble(altitudeVal)) { @@ -148,10 +149,13 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor } else { mobilePosition.setAltitude(0.0); } - continue; + break; } } + if (deviceChannel == null) { + continue; + } log.info("[收到移动位置订阅通知]:{}/{}->{}.{}, 时间: {}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(), mobilePosition.getLongitude(), mobilePosition.getLatitude(), System.currentTimeMillis() - startTime); @@ -198,7 +202,6 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor log.error("未处理的异常 ", e); } } - taskQueue.clear(); } // @Scheduled(fixedRate = 10000) // public void execute(){