Commit 20622d20d63870e54118c70b75bfa53839c4b801
1 parent
596a633d
修复更新通道状态回复不准的问题
Showing
5 changed files
with
30 additions
and
4 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
| ... | ... | @@ -78,7 +78,6 @@ public class CatalogDataCatch { |
| 78 | 78 | public SyncStatus getSyncStatus(String deviceId) { |
| 79 | 79 | CatalogData catalogData = data.get(deviceId); |
| 80 | 80 | if (catalogData == null) return null; |
| 81 | - if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) return null; | |
| 82 | 81 | SyncStatus syncStatus = new SyncStatus(); |
| 83 | 82 | syncStatus.setCurrent(catalogData.getChannelList().size()); |
| 84 | 83 | syncStatus.setTotal(catalogData.getTotal()); |
| ... | ... | @@ -86,6 +85,12 @@ public class CatalogDataCatch { |
| 86 | 85 | return syncStatus; |
| 87 | 86 | } |
| 88 | 87 | |
| 88 | + public boolean isSyncRunning(String deviceId) { | |
| 89 | + CatalogData catalogData = data.get(deviceId); | |
| 90 | + if (catalogData == null) return false; | |
| 91 | + return !catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end); | |
| 92 | + } | |
| 93 | + | |
| 89 | 94 | @Scheduled(fixedRate = 5 * 1000) //每5秒执行一次, 发现数据5秒未更新则移除数据并认为数据接收超时 |
| 90 | 95 | private void timerTask(){ |
| 91 | 96 | Set<String> keys = data.keySet(); | ... | ... |
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 |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | + public boolean isSyncRunning(String deviceId) { | |
| 227 | + if (catalogDataCatch.get(deviceId) == null) { | |
| 228 | + return false; | |
| 229 | + }else { | |
| 230 | + return catalogDataCatch.isSyncRunning(deviceId); | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 226 | 234 | public void setChannelSyncReady(Device device, int sn) { |
| 227 | 235 | catalogDataCatch.addReady(device, sn); |
| 228 | 236 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
| ... | ... | @@ -44,6 +44,13 @@ public interface IDeviceService { |
| 44 | 44 | SyncStatus getChannelSyncStatus(String deviceId); |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | + * 查看是否仍在同步 | |
| 48 | + * @param deviceId 设备ID | |
| 49 | + * @return | |
| 50 | + */ | |
| 51 | + Boolean isSyncRunning(String deviceId); | |
| 52 | + | |
| 53 | + /** | |
| 47 | 54 | * 通道同步 |
| 48 | 55 | * @param device |
| 49 | 56 | */ | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
| ... | ... | @@ -100,6 +100,11 @@ public class DeviceServiceImpl implements IDeviceService { |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | @Override |
| 103 | + public Boolean isSyncRunning(String deviceId) { | |
| 104 | + return catalogResponseMessageHandler.isSyncRunning(deviceId); | |
| 105 | + } | |
| 106 | + | |
| 107 | + @Override | |
| 103 | 108 | public void sync(Device device) { |
| 104 | 109 | if (catalogResponseMessageHandler.getChannelSyncProgress(device.getDeviceId()) != null) { |
| 105 | 110 | logger.info("开启同步时发现同步已经存在"); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
| ... | ... | @@ -164,12 +164,13 @@ public class DeviceQuery { |
| 164 | 164 | logger.debug("设备通道信息同步API调用,deviceId:" + deviceId); |
| 165 | 165 | } |
| 166 | 166 | Device device = storager.queryVideoDevice(deviceId); |
| 167 | - SyncStatus syncStatus = deviceService.getChannelSyncStatus(deviceId); | |
| 167 | + boolean status = deviceService.isSyncRunning(deviceId); | |
| 168 | 168 | // 已存在则返回进度 |
| 169 | - if (syncStatus != null && syncStatus.getErrorMsg() == null) { | |
| 169 | + if (status) { | |
| 170 | 170 | WVPResult<SyncStatus> wvpResult = new WVPResult<>(); |
| 171 | 171 | wvpResult.setCode(0); |
| 172 | - wvpResult.setData(syncStatus); | |
| 172 | + SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId); | |
| 173 | + wvpResult.setData(channelSyncStatus); | |
| 173 | 174 | return wvpResult; |
| 174 | 175 | } |
| 175 | 176 | deviceService.sync(device); | ... | ... |