修复MobilePosition的更新问题 #1643

pull/1651/head
648540858 2024-10-15 15:34:53 +08:00
parent c96119176c
commit d9eb0bb08b
1 changed files with 19 additions and 16 deletions

View File

@ -86,12 +86,12 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
Element rootElement = getRootElement(evt); Element rootElement = getRootElement(evt);
if (rootElement == null) { if (rootElement == null) {
log.error("处理MobilePosition移动位置Notify时未获取到消息体,{}", evt.getRequest()); log.error("处理MobilePosition移动位置Notify时未获取到消息体,{}", evt.getRequest());
return; continue;
} }
Device device = redisCatchStorage.getDevice(deviceId); Device device = redisCatchStorage.getDevice(deviceId);
if (device == null) { if (device == null) {
log.error("处理MobilePosition移动位置Notify时未获取到device,{}", deviceId); log.error("处理MobilePosition移动位置Notify时未获取到device,{}", deviceId);
return; continue;
} }
MobilePosition mobilePosition = new MobilePosition(); MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setDeviceId(device.getDeviceId()); mobilePosition.setDeviceId(device.getDeviceId());
@ -100,17 +100,18 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
DeviceChannel deviceChannel = null; DeviceChannel deviceChannel = null;
List<Element> elements = rootElement.elements(); List<Element> elements = rootElement.elements();
for (Element element : elements) { readDocument: for (Element element : elements) {
switch (element.getName()){ switch (element.getName()){
case "DeviceID": case "DeviceID":
String channelId = element.getStringValue(); String channelId = element.getStringValue();
if (!deviceId.equals(channelId)) {
deviceChannel = deviceChannelService.getOne(device.getDeviceId(), channelId); deviceChannel = deviceChannelService.getOne(device.getDeviceId(), channelId);
if (deviceChannel != null) { if (deviceChannel != null) {
mobilePosition.setChannelId(deviceChannel.getId()); mobilePosition.setChannelId(deviceChannel.getId());
}else {
log.error("[notify-移动位置] 未找到通道 {}/{}", device.getDeviceId(), channelId);
break readDocument;
} }
} break;
continue;
case "Time": case "Time":
String timeVal = element.getStringValue(); String timeVal = element.getStringValue();
if (ObjectUtils.isEmpty(timeVal)) { if (ObjectUtils.isEmpty(timeVal)) {
@ -118,13 +119,13 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
} else { } else {
mobilePosition.setTime(SipUtils.parseTime(timeVal)); mobilePosition.setTime(SipUtils.parseTime(timeVal));
} }
continue; break;
case "Longitude": case "Longitude":
mobilePosition.setLongitude(Double.parseDouble(element.getStringValue())); mobilePosition.setLongitude(Double.parseDouble(element.getStringValue()));
continue; break;
case "Latitude": case "Latitude":
mobilePosition.setLatitude(Double.parseDouble(element.getStringValue())); mobilePosition.setLatitude(Double.parseDouble(element.getStringValue()));
continue; break;
case "Speed": case "Speed":
String speedVal = element.getStringValue(); String speedVal = element.getStringValue();
if (NumericUtil.isDouble(speedVal)) { if (NumericUtil.isDouble(speedVal)) {
@ -132,7 +133,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
} else { } else {
mobilePosition.setSpeed(0.0); mobilePosition.setSpeed(0.0);
} }
continue; break;
case "Direction": case "Direction":
String directionVal = element.getStringValue(); String directionVal = element.getStringValue();
if (NumericUtil.isDouble(directionVal)) { if (NumericUtil.isDouble(directionVal)) {
@ -140,7 +141,7 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
} else { } else {
mobilePosition.setDirection(0.0); mobilePosition.setDirection(0.0);
} }
continue; break;
case "Altitude": case "Altitude":
String altitudeVal = element.getStringValue(); String altitudeVal = element.getStringValue();
if (NumericUtil.isDouble(altitudeVal)) { if (NumericUtil.isDouble(altitudeVal)) {
@ -148,10 +149,13 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
} else { } else {
mobilePosition.setAltitude(0.0); mobilePosition.setAltitude(0.0);
} }
continue; break;
} }
} }
if (deviceChannel == null) {
continue;
}
log.info("[收到移动位置订阅通知]{}/{}->{}.{}, 时间: {}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(), log.info("[收到移动位置订阅通知]{}/{}->{}.{}, 时间: {}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(),
mobilePosition.getLongitude(), mobilePosition.getLatitude(), System.currentTimeMillis() - startTime); mobilePosition.getLongitude(), mobilePosition.getLatitude(), System.currentTimeMillis() - startTime);
@ -198,7 +202,6 @@ public class NotifyRequestForMobilePositionProcessor extends SIPRequestProcessor
log.error("未处理的异常 ", e); log.error("未处理的异常 ", e);
} }
} }
taskQueue.clear();
} }
// @Scheduled(fixedRate = 10000) // @Scheduled(fixedRate = 10000)
// public void execute(){ // public void execute(){