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);