From 20622d20d63870e54118c70b75bfa53839c4b801 Mon Sep 17 00:00:00 2001 From: 648540858 <456panlinlin> Date: Mon, 18 Apr 2022 12:55:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E9=80=9A?= =?UTF-8?q?=E9=81=93=E7=8A=B6=E6=80=81=E5=9B=9E=E5=A4=8D=E4=B8=8D=E5=87=86?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/session/CatalogDataCatch.java | 7 ++++++- .../response/cmd/CatalogResponseMessageHandler.java | 8 ++++++++ .../com/genersoft/iot/vmp/service/IDeviceService.java | 7 +++++++ .../genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 5 +++++ .../iot/vmp/vmanager/gb28181/device/DeviceQuery.java | 7 ++++--- 5 files changed, 30 insertions(+), 4 deletions(-) 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 759b317d..97360d28 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 @@ -78,7 +78,6 @@ public class CatalogDataCatch { public SyncStatus getSyncStatus(String deviceId) { CatalogData catalogData = data.get(deviceId); if (catalogData == null) return null; - if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) return null; SyncStatus syncStatus = new SyncStatus(); syncStatus.setCurrent(catalogData.getChannelList().size()); syncStatus.setTotal(catalogData.getTotal()); @@ -86,6 +85,12 @@ public class CatalogDataCatch { return syncStatus; } + public boolean isSyncRunning(String deviceId) { + CatalogData catalogData = data.get(deviceId); + if (catalogData == null) return false; + return !catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end); + } + @Scheduled(fixedRate = 5 * 1000) //每5秒执行一次, 发现数据5秒未更新则移除数据并认为数据接收超时 private void timerTask(){ Set keys = data.keySet(); 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 75a22447..92d0114d 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 @@ -223,6 +223,14 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp } } + public boolean isSyncRunning(String deviceId) { + if (catalogDataCatch.get(deviceId) == null) { + return false; + }else { + return catalogDataCatch.isSyncRunning(deviceId); + } + } + public void setChannelSyncReady(Device device, int sn) { catalogDataCatch.addReady(device, sn); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java index 08ccfffc..5621d2aa 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java @@ -43,6 +43,13 @@ public interface IDeviceService { */ SyncStatus getChannelSyncStatus(String deviceId); + /** + * 查看是否仍在同步 + * @param deviceId 设备ID + * @return + */ + Boolean isSyncRunning(String deviceId); + /** * 通道同步 * @param device diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index f36b3aed..6f0d179f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -99,6 +99,11 @@ public class DeviceServiceImpl implements IDeviceService { return catalogResponseMessageHandler.getChannelSyncProgress(deviceId); } + @Override + public Boolean isSyncRunning(String deviceId) { + return catalogResponseMessageHandler.isSyncRunning(deviceId); + } + @Override public void sync(Device device) { if (catalogResponseMessageHandler.getChannelSyncProgress(device.getDeviceId()) != null) { 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 cbcb4ff5..95d2843d 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 @@ -164,12 +164,13 @@ public class DeviceQuery { logger.debug("设备通道信息同步API调用,deviceId:" + deviceId); } Device device = storager.queryVideoDevice(deviceId); - SyncStatus syncStatus = deviceService.getChannelSyncStatus(deviceId); + boolean status = deviceService.isSyncRunning(deviceId); // 已存在则返回进度 - if (syncStatus != null && syncStatus.getErrorMsg() == null) { + if (status) { WVPResult wvpResult = new WVPResult<>(); wvpResult.setCode(0); - wvpResult.setData(syncStatus); + SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId); + wvpResult.setData(channelSyncStatus); return wvpResult; } deviceService.sync(device);