优化通道刷新
This commit is contained in:
@@ -44,6 +44,12 @@ public class CatalogDataCatch {
|
||||
return catalogData.getChannelList();
|
||||
}
|
||||
|
||||
public int getTotal(String key) {
|
||||
CatalogData catalogData = data.get(key);
|
||||
if (catalogData == null) return 0;
|
||||
return catalogData.getTotal();
|
||||
}
|
||||
|
||||
public void del(String key) {
|
||||
data.remove(key);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.sip.*;
|
||||
import javax.sip.address.SipURI;
|
||||
import javax.sip.header.HeaderAddress;
|
||||
import javax.sip.header.ToHeader;
|
||||
import javax.sip.message.Response;
|
||||
import java.text.ParseException;
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -103,6 +104,18 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||
if (!StringUtils.isEmpty(getText(rootElement,"PTZCmd")) && !parentPlatform.getServerGBId().equals(targetGBId)) {
|
||||
String cmdString = getText(rootElement,"PTZCmd");
|
||||
Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
|
||||
if (deviceForPlatform == null) {
|
||||
try {
|
||||
responseAck(evt, Response.NOT_FOUND);
|
||||
return;
|
||||
} catch (SipException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
cmder.fronEndCmd(deviceForPlatform, channelId, cmdString, eventResult -> {
|
||||
// 失败的回复
|
||||
try {
|
||||
|
||||
@@ -115,16 +115,15 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||
continue;
|
||||
}
|
||||
//by brewswang
|
||||
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置
|
||||
processNotifyMobilePosition(evt, itemDevice);
|
||||
}
|
||||
|
||||
// if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置
|
||||
// processNotifyMobilePosition(evt, itemDevice);
|
||||
// }
|
||||
DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice);
|
||||
deviceChannel.setDeviceId(device.getDeviceId());
|
||||
logger.debug("收到来自设备【{}】的通道: {}【{}】", device.getDeviceId(), deviceChannel.getName(), deviceChannel.getChannelId());
|
||||
|
||||
channelList.add(deviceChannel);
|
||||
}
|
||||
|
||||
logger.debug("收到来自设备【{}】的通道: {}个,{}/{}", device.getDeviceId(), channelList.size(), catalogDataCatch.get(key) == null ? 0 :catalogDataCatch.get(key).size(), sumNum);
|
||||
catalogDataCatch.put(key, sumNum, device, channelList);
|
||||
if (catalogDataCatch.get(key).size() == sumNum) {
|
||||
// 数据已经完整接收
|
||||
@@ -230,4 +229,9 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getChannelSyncProgress(String deviceId) {
|
||||
String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + deviceId;
|
||||
return catalogDataCatch.get(key) == null ? "0/0" : catalogDataCatch.get(key).size() + "/" + catalogDataCatch.getTotal(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||
channels = deviceChannelList;
|
||||
}
|
||||
if (stringBuilder.length() > 0) {
|
||||
logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder);
|
||||
logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder);
|
||||
}
|
||||
try {
|
||||
int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);
|
||||
|
||||
@@ -175,22 +175,23 @@ public class DeviceQuery {
|
||||
});
|
||||
// 等待其他相同请求返回时一起返回
|
||||
if (resultHolder.exist(key, null)) {
|
||||
resultHolder.put(key, uuid, result);
|
||||
return result;
|
||||
}else {
|
||||
cmder.catalogQuery(device, event -> {
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setKey(key);
|
||||
msg.setId(uuid);
|
||||
WVPResult<Object> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(-1);
|
||||
wvpResult.setData(device);
|
||||
wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg));
|
||||
msg.setData(wvpResult);
|
||||
resultHolder.invokeAllResult(msg);
|
||||
});
|
||||
resultHolder.put(key, uuid, result);
|
||||
return result;
|
||||
}
|
||||
cmder.catalogQuery(device, event -> {
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setKey(key);
|
||||
msg.setId(uuid);
|
||||
WVPResult<Object> wvpResult = new WVPResult<>();
|
||||
wvpResult.setCode(-1);
|
||||
wvpResult.setData(device);
|
||||
wvpResult.setMsg(String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg));
|
||||
msg.setData(wvpResult);
|
||||
resultHolder.invokeAllResult(msg);
|
||||
});
|
||||
|
||||
resultHolder.put(key, uuid, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user