| | |
| | | package com.ard.gb28181.transmit.event.request.impl.message.response.cmd; |
| | | |
| | | import com.ard.gb28181.api.domain.Device; |
| | | import com.ard.gb28181.domain.GbDevice; |
| | | import com.ard.gb28181.service.IDeviceService; |
| | | import com.ard.gb28181.service.IGbDeviceService; |
| | | import com.ard.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| | | import com.ard.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| | | import com.ard.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; |
| | |
| | | |
| | | @Autowired |
| | | private IDeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private IGbDeviceService gbDeviceService; |
| | | |
| | | @Override |
| | | public void afterPropertiesSet() throws Exception { |
| | |
| | | device.setStreamMode("TCP-PASSIVE"); |
| | | } |
| | | deviceService.updateDevice(device); |
| | | // 同步更新 ard_gb_device 表中的设备名称、IP、端口、厂商、型号、固件 |
| | | try { |
| | | GbDevice gbDevice = gbDeviceService.selectGbDeviceByGbDeviceId(device.getDeviceId()); |
| | | if (gbDevice != null) { |
| | | boolean needUpdate = false; |
| | | if (device.getName() != null && !device.getName().equals(gbDevice.getDeviceName())) { |
| | | gbDevice.setDeviceName(device.getName()); |
| | | needUpdate = true; |
| | | } |
| | | if (device.getIp() != null && !device.getIp().equals(gbDevice.getIp())) { |
| | | gbDevice.setIp(device.getIp()); |
| | | needUpdate = true; |
| | | } |
| | | if (gbDevice.getPort() == null || device.getPort() != gbDevice.getPort()) { |
| | | gbDevice.setPort(device.getPort()); |
| | | needUpdate = true; |
| | | } |
| | | if (device.getManufacturer() != null && !device.getManufacturer().equals(gbDevice.getManufacturer())) { |
| | | gbDevice.setManufacturer(device.getManufacturer()); |
| | | needUpdate = true; |
| | | } |
| | | if (device.getModel() != null && !device.getModel().equals(gbDevice.getModel())) { |
| | | gbDevice.setModel(device.getModel()); |
| | | needUpdate = true; |
| | | } |
| | | if (device.getFirmware() != null && !device.getFirmware().equals(gbDevice.getFirmware())) { |
| | | gbDevice.setFirmware(device.getFirmware()); |
| | | needUpdate = true; |
| | | } |
| | | if (needUpdate) { |
| | | gbDeviceService.updateGbDevice(gbDevice); |
| | | log.info("[DeviceInfo] 更新设备信息: {} -> name={}, ip={}, port={}, manufacturer={}, model={}, firmware={}", |
| | | device.getDeviceId(), device.getName(), device.getIp(), device.getPort(), |
| | | device.getManufacturer(), device.getModel(), device.getFirmware()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("[DeviceInfo] 更新GbDevice信息失败: {}", device.getDeviceId(), e); |
| | | } |
| | | responseMessageHandler.handMessageEvent(rootElement, device); |
| | | |
| | | } catch (DocumentException e) { |