Browse Source

修复更新通道状态回复不准的问题

pull/439/head
648540858 3 years ago
parent
commit
20622d20d6
  1. 7
      src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java
  2. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java
  3. 7
      src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
  4. 5
      src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
  5. 7
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java

7
src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java

@ -78,7 +78,6 @@ public class CatalogDataCatch {
public SyncStatus getSyncStatus(String deviceId) { public SyncStatus getSyncStatus(String deviceId) {
CatalogData catalogData = data.get(deviceId); CatalogData catalogData = data.get(deviceId);
if (catalogData == null) return null; if (catalogData == null) return null;
if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) return null;
SyncStatus syncStatus = new SyncStatus(); SyncStatus syncStatus = new SyncStatus();
syncStatus.setCurrent(catalogData.getChannelList().size()); syncStatus.setCurrent(catalogData.getChannelList().size());
syncStatus.setTotal(catalogData.getTotal()); syncStatus.setTotal(catalogData.getTotal());
@ -86,6 +85,12 @@ public class CatalogDataCatch {
return syncStatus; 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秒未更新则移除数据并认为数据接收超时 @Scheduled(fixedRate = 5 * 1000) //每5秒执行一次, 发现数据5秒未更新则移除数据并认为数据接收超时
private void timerTask(){ private void timerTask(){
Set<String> keys = data.keySet(); Set<String> keys = data.keySet();

8
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) { public void setChannelSyncReady(Device device, int sn) {
catalogDataCatch.addReady(device, sn); catalogDataCatch.addReady(device, sn);
} }

7
src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java

@ -43,6 +43,13 @@ public interface IDeviceService {
*/ */
SyncStatus getChannelSyncStatus(String deviceId); SyncStatus getChannelSyncStatus(String deviceId);
/**
* 查看是否仍在同步
* @param deviceId 设备ID
* @return
*/
Boolean isSyncRunning(String deviceId);
/** /**
* 通道同步 * 通道同步
* @param device * @param device

5
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java

@ -99,6 +99,11 @@ public class DeviceServiceImpl implements IDeviceService {
return catalogResponseMessageHandler.getChannelSyncProgress(deviceId); return catalogResponseMessageHandler.getChannelSyncProgress(deviceId);
} }
@Override
public Boolean isSyncRunning(String deviceId) {
return catalogResponseMessageHandler.isSyncRunning(deviceId);
}
@Override @Override
public void sync(Device device) { public void sync(Device device) {
if (catalogResponseMessageHandler.getChannelSyncProgress(device.getDeviceId()) != null) { if (catalogResponseMessageHandler.getChannelSyncProgress(device.getDeviceId()) != null) {

7
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java

@ -164,12 +164,13 @@ public class DeviceQuery {
logger.debug("设备通道信息同步API调用,deviceId:" + deviceId); logger.debug("设备通道信息同步API调用,deviceId:" + deviceId);
} }
Device device = storager.queryVideoDevice(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<SyncStatus> wvpResult = new WVPResult<>(); WVPResult<SyncStatus> wvpResult = new WVPResult<>();
wvpResult.setCode(0); wvpResult.setCode(0);
wvpResult.setData(syncStatus); SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId);
wvpResult.setData(channelSyncStatus);
return wvpResult; return wvpResult;
} }
deviceService.sync(device); deviceService.sync(device);

Loading…
Cancel
Save