优化通道录入性能,优化启动后读取配置写入数据库的过程

This commit is contained in:
648540858
2021-12-07 17:43:55 +08:00
parent 381b3d15ca
commit a2f0854138
14 changed files with 190 additions and 59 deletions

View File

@@ -1163,7 +1163,7 @@ public class SIPCommander implements ISIPCommander {
@Override
public boolean catalogQuery(Device device, SipSubscribe.Event errorEvent) {
// 清空通道
storager.cleanChannelsForDevice(device.getDeviceId());
// storager.cleanChannelsForDevice(device.getDeviceId());
try {
StringBuffer catalogXml = new StringBuffer(200);
catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");

View File

@@ -27,7 +27,9 @@ import javax.sip.RequestEvent;
import javax.sip.SipException;
import javax.sip.message.Response;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText;
@@ -69,7 +71,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
Element deviceListElement = rootElement.element("DeviceList");
Iterator<Element> deviceListIterator = deviceListElement.elementIterator();
if (deviceListIterator != null) {
List<DeviceChannel> channelList = new ArrayList<>();
// 遍历DeviceList
while (deviceListIterator.hasNext()) {
Element itemDevice = deviceListIterator.next();
@@ -151,9 +153,10 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
deviceChannel.setPTZType(Integer.parseInt(getText(itemDevice, "PTZType")));
}
deviceChannel.setHasAudio(true); // 默认含有音频播放时再检查是否有音频及是否AAC
storager.updateChannel(device.getDeviceId(), deviceChannel);
// TODO 修改为批量插入
channelList.add(deviceChannel);
}
storager.updateChannels(device.getDeviceId(), channelList);
RequestMessage msg = new RequestMessage();
msg.setKey(key);
msg.setData(device);