修复更新通道状态回复不准的问题
This commit is contained in:
parent
15b36e7be6
commit
2d7a571832
@ -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<String> keys = data.keySet();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -43,6 +43,13 @@ public interface IDeviceService {
|
||||
*/
|
||||
SyncStatus getChannelSyncStatus(String deviceId);
|
||||
|
||||
/**
|
||||
* 查看是否仍在同步
|
||||
* @param deviceId 设备ID
|
||||
* @return
|
||||
*/
|
||||
Boolean isSyncRunning(String deviceId);
|
||||
|
||||
/**
|
||||
* 通道同步
|
||||
* @param device
|
||||
|
@ -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) {
|
||||
|
@ -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<SyncStatus> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(0);
|
||||
wvpResult.setData(syncStatus);
|
||||
SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId);
|
||||
wvpResult.setData(channelSyncStatus);
|
||||
return wvpResult;
|
||||
}
|
||||
deviceService.sync(device);
|
||||
|
Loading…
Reference in New Issue
Block a user