| | |
| | | // 遍历DeviceList |
| | | while (deviceListIterator.hasNext()) { |
| | | Element itemDevice = deviceListIterator.next(); |
| | | Element channelDeviceElement = itemDevice.element("DeviceID"); |
| | | if (channelDeviceElement == null) { |
| | | continue; |
| | | } |
| | | Element eventElement = itemDevice.element("Event"); |
| | | String event; |
| | | if (eventElement == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | // TODO 同一个通道如果先发送更新再发送离线可能无法正常离线 |
| | | private void executeSave(){ |
| | | try { |
| | | executeSaveForAdd(); |
| | | } catch (Exception e) { |
| | | logger.error("[存储收到的增加通道] 异常: ", e ); |
| | | } |
| | | try { |
| | | executeSaveForUpdate(); |
| | | } catch (Exception e) { |
| | | logger.error("[存储收到的更新通道] 异常: ", e ); |
| | | } |
| | | try { |
| | | executeSaveForDelete(); |
| | | } catch (Exception e) { |
| | | logger.error("[存储收到的删除通道] 异常: ", e ); |
| | | } |
| | | try { |
| | | executeSaveForOnline(); |
| | |
| | | } catch (Exception e) { |
| | | logger.error("[存储收到的通道离线] 异常: ", e ); |
| | | } |
| | | try { |
| | | executeSaveForUpdate(); |
| | | } catch (Exception e) { |
| | | logger.error("[存储收到的更新通道] 异常: ", e ); |
| | | } |
| | | try { |
| | | executeSaveForDelete(); |
| | | } catch (Exception e) { |
| | | logger.error("[存储收到的删除通道] 异常: ", e ); |
| | | } |
| | | |
| | | dynamicTask.stop(talkKey); |
| | | } |
| | | |
| | | private void executeSaveForUpdate(){ |
| | | if (!updateChannelMap.values().isEmpty()) { |
| | | logger.info("[存储收到的更新通道], 数量: {}", updateChannelMap.size()); |
| | | ArrayList<DeviceChannel> deviceChannels = new ArrayList<>(updateChannelMap.values()); |
| | | updateChannelMap.clear(); |
| | | deviceChannelService.batchUpdateChannel(deviceChannels); |
| | | updateChannelMap.clear(); |
| | | } |
| | | |
| | | } |