提升Catalog查询回复处理速度

pull/1669/head
648540858 2024-10-26 23:28:32 +08:00
parent fee8d2f8cd
commit 22fcab375f
1 changed files with 14 additions and 15 deletions

View File

@ -161,31 +161,30 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
int sn = Integer.parseInt(snElement.getText()); int sn = Integer.parseInt(snElement.getText());
catalogDataCatch.put(take.getDevice().getDeviceId(), sn, sumNum, take.getDevice(), catalogDataCatch.put(take.getDevice().getDeviceId(), sn, sumNum, take.getDevice(),
channelList, regionList, groupList); channelList, regionList, groupList);
List<DeviceChannel> deviceChannelList = catalogDataCatch.getDeviceChannelList(take.getDevice().getDeviceId()); log.info("[收到通道]设备: {} -> {}个,{}/{}", take.getDevice().getDeviceId(), channelList.size(), catalogDataCatch.size(take.getDevice().getDeviceId()), sumNum);
log.info("[收到通道]设备: {} -> {}个,{}/{}", take.getDevice().getDeviceId(), channelList.size(), deviceChannelList.size(), sumNum); }
if (deviceChannelList.size() == sumNum) { }
} catch (Exception e) {
log.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest());
log.error("[收到通道] 异常内容: ", e);
} finally {
if (catalogDataCatch.size(take.getDevice().getDeviceId()) == catalogDataCatch.sumNum(take.getDevice().getDeviceId())) {
// 数据已经完整接收, 此时可能存在某个设备离线变上线的情况,但是考虑到性能,此处不做处理, // 数据已经完整接收, 此时可能存在某个设备离线变上线的情况,但是考虑到性能,此处不做处理,
// 目前支持设备通道上线通知时和设备上线时向上级通知 // 目前支持设备通道上线通知时和设备上线时向上级通知
boolean resetChannelsResult = saveData(take.getDevice(), sn); boolean resetChannelsResult = saveData(take.getDevice());
if (!resetChannelsResult) { if (!resetChannelsResult) {
String errorMsg = "接收成功,写入失败,共" + sumNum + "条,已接收" + catalogDataCatch.getDeviceChannelList(take.getDevice().getDeviceId()).size() + "条"; String errorMsg = "接收成功,写入失败,共" + catalogDataCatch.sumNum(take.getDevice().getDeviceId()) + "条,已接收" + catalogDataCatch.getDeviceChannelList(take.getDevice().getDeviceId()).size() + "条";
catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), errorMsg); catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), errorMsg);
} else { } else {
catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), null); catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), null);
} }
} }
} }
}
} catch (Exception e) {
log.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest());
log.error("[收到通道] 异常内容: ", e);
}
} }
} }
@Transactional @Transactional
public boolean saveData(Device device, int sn) { public boolean saveData(Device device) {
boolean result = true; boolean result = true;
List<DeviceChannel> deviceChannelList = catalogDataCatch.getDeviceChannelList(device.getDeviceId()); List<DeviceChannel> deviceChannelList = catalogDataCatch.getDeviceChannelList(device.getDeviceId());