diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java index 8a3bc842..199f8267 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java @@ -44,6 +44,12 @@ public class CatalogDataCatch { return catalogData.getChannelList(); } + public int getTotal(String key) { + CatalogData catalogData = data.get(key); + if (catalogData == null) return 0; + return catalogData.getTotal(); + } + public void del(String key) { data.remove(key); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index 770d2f7a..129f5df1 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -23,6 +23,7 @@ import javax.sip.*; import javax.sip.address.SipURI; import javax.sip.header.HeaderAddress; import javax.sip.header.ToHeader; +import javax.sip.message.Response; import java.text.ParseException; import java.util.Iterator; @@ -103,6 +104,18 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) { String cmdString = getText(rootElement,"PTZCmd"); Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); + if (deviceForPlatform == null) { + try { + responseAck(evt, Response.NOT_FOUND); + return; + } catch (SipException e) { + e.printStackTrace(); + } catch (InvalidArgumentException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } + } cmder.fronEndCmd(deviceForPlatform, channelId, cmdString, eventResult -> { // 失败的回复 try { 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 index cc54ec95..32b645c0 100644 --- 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 @@ -115,16 +115,15 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp continue; } //by brewswang - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置 - processNotifyMobilePosition(evt, itemDevice); - } - +// if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置 +// processNotifyMobilePosition(evt, itemDevice); +// } DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice); deviceChannel.setDeviceId(device.getDeviceId()); - logger.debug("收到来自设备【{}】的通道: {}【{}】", device.getDeviceId(), deviceChannel.getName(), deviceChannel.getChannelId()); + channelList.add(deviceChannel); } - + logger.debug("收到来自设备【{}】的通道: {}个,{}/{}", device.getDeviceId(), channelList.size(), catalogDataCatch.get(key) == null ? 0 :catalogDataCatch.get(key).size(), sumNum); catalogDataCatch.put(key, sumNum, device, channelList); if (catalogDataCatch.get(key).size() == sumNum) { // 数据已经完整接收 @@ -230,4 +229,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp e.printStackTrace(); } } + + public String getChannelSyncProgress(String deviceId) { + String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId; + return catalogDataCatch.get(key) == null ? "0/0" : catalogDataCatch.get(key).size() + "/" + catalogDataCatch.getTotal(key); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 439ecd87..667a6197 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -274,7 +274,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { channels = deviceChannelList; } if (stringBuilder.length() > 0) { - logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder); + logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder); } try { int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index 5e9cd609..64133963 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -175,22 +175,23 @@ public class DeviceQuery { }); // 等待其他相同请求返回时一起返回 if (resultHolder.exist(key, null)) { + resultHolder.put(key, uuid, result); + return result; + }else { + cmder.catalogQuery(device, event -> { + RequestMessage msg = new RequestMessage(); + msg.setKey(key); + msg.setId(uuid); + WVPResult wvpResult = new WVPResult<>(); + wvpResult.setCode(-1); + wvpResult.setData(device); + wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg)); + msg.setData(wvpResult); + resultHolder.invokeAllResult(msg); + }); + resultHolder.put(key, uuid, result); return result; } - cmder.catalogQuery(device, event -> { - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setId(uuid); - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(-1); - wvpResult.setData(device); - wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg)); - msg.setData(wvpResult); - resultHolder.invokeAllResult(msg); - }); - - resultHolder.put(key, uuid, result); - return result; } /** diff --git a/web_src/src/components/DeviceList.vue b/web_src/src/components/DeviceList.vue index 74e3fbc2..8a156d5b 100644 --- a/web_src/src/components/DeviceList.vue +++ b/web_src/src/components/DeviceList.vue @@ -57,7 +57,7 @@