Merge pull request #729 from gaofuwang/wvp-28181-2.0
修复WVP作为下级平台接收DeviceInfo指令固定响应的问题
| | |
| | | /** |
| | | * 向上级回复DeviceInfo查询信息 |
| | | * @param parentPlatform 平台信息 |
| | | * @param sn |
| | | * @param fromTag |
| | | * @param sn SN |
| | | * @param fromTag FROM头的tag信息 |
| | | * @return |
| | | */ |
| | | void deviceInfoResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException; |
| | | void deviceInfoResponse(ParentPlatform parentPlatform,Device device, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException; |
| | | |
| | | /** |
| | | * 向上级回复DeviceStatus查询信息 |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void deviceInfoResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException { |
| | | public void deviceInfoResponse(ParentPlatform parentPlatform,Device device, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException { |
| | | if (parentPlatform == null) { |
| | | return; |
| | | } |
| | | String characterSet = parentPlatform.getCharacterSet(); |
| | | StringBuffer deviceInfoXml = new StringBuffer(600); |
| | | deviceInfoXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n") |
| | | .append("<Response>\r\n") |
| | | .append("<CmdType>DeviceInfo</CmdType>\r\n") |
| | | .append("<SN>" +sn + "</SN>\r\n") |
| | | .append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n") |
| | | .append("<DeviceName>" + parentPlatform.getName() + "</DeviceName>\r\n") |
| | | .append("<Manufacturer>wvp</Manufacturer>\r\n") |
| | | .append("<Model>wvp-28181-2.0</Model>\r\n") |
| | | .append("<Firmware>2.0.202107</Firmware>\r\n") |
| | | .append("<Result>OK</Result>\r\n") |
| | | .append("</Response>\r\n"); |
| | | deviceInfoXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| | | deviceInfoXml.append("<Response>\r\n"); |
| | | deviceInfoXml.append("<CmdType>DeviceInfo</CmdType>\r\n"); |
| | | deviceInfoXml.append("<SN>" +sn + "</SN>\r\n"); |
| | | deviceInfoXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); |
| | | deviceInfoXml.append("<DeviceName>" + device.getName() + "</DeviceName>\r\n"); |
| | | deviceInfoXml.append("<Manufacturer>" + device.getManufacturer() + "</Manufacturer>\r\n"); |
| | | deviceInfoXml.append("<Model>" + device.getModel() + "</Model>\r\n"); |
| | | deviceInfoXml.append("<Firmware>" + device.getFirmware() + "</Firmware>\r\n"); |
| | | deviceInfoXml.append("<Result>OK</Result>\r\n"); |
| | | deviceInfoXml.append("</Response>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import org.dom4j.Element; |
| | | import org.slf4j.Logger; |
| | |
| | | import javax.sip.message.Response; |
| | | import java.text.ParseException; |
| | | |
| | | import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; |
| | | |
| | | @Component |
| | | public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private SIPCommanderFroPlatform cmderFroPlatform; |
| | | @Autowired |
| | | private IVideoManagerStorage storager; |
| | | |
| | | @Override |
| | | public void afterPropertiesSet() throws Exception { |
| | |
| | | responseAck((SIPRequest) evt.getRequest(), Response.OK); |
| | | } catch (SipException | InvalidArgumentException | ParseException e) { |
| | | logger.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); |
| | | return; |
| | | } |
| | | String sn = rootElement.element("SN").getText(); |
| | | /*根据WVP原有的数据结构,设备和通道是分开放置,设备信息都是存放在设备表里,通道表里的设备信息不可作为真实信息处理 |
| | | 大部分NVR/IPC设备对他的通道信息实现都是返回默认的值没有什么参考价值。NVR/IPC通道我们统一使用设备表的设备信息来作为返回。 |
| | | 我们这里使用查询数据库的方式来实现这个设备信息查询的功能,在其他地方对设备信息更新达到正确的目的。*/ |
| | | String channelId = getText(rootElement, "DeviceID"); |
| | | Device device = storager.queryDeviceInfoByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); |
| | | if (device ==null){ |
| | | logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); |
| | | return; |
| | | } |
| | | try { |
| | | cmderFroPlatform.deviceInfoResponse(parentPlatform, sn, fromHeader.getTag()); |
| | | cmderFroPlatform.deviceInfoResponse(parentPlatform,device, sn, fromHeader.getTag()); |
| | | } catch (SipException | InvalidArgumentException | ParseException e) { |
| | | logger.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); |
| | | } |
| | |
| | | |
| | | Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); |
| | | |
| | | |
| | | /** |
| | | * 针对deviceinfo指令的查询接口 |
| | | * @param platformId 平台id |
| | | * @param channelId 通道id |
| | | * @return 设备信息 |
| | | */ |
| | | Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId); |
| | | /** |
| | | * 添加Mobile Position设备移动位置 |
| | | * @param mobilePosition |
| | |
| | | "DELETE FROM platform_gb_channel WHERE platformId=#{platformId} and catalogId=#{catalogId}" + |
| | | "</script>") |
| | | int delChannelForGBByCatalogId(String platformId, String catalogId); |
| | | |
| | | @Select("select dc.channelId deviceId,dc.name,d.manufacturer,d.model,d.firmware\n" + |
| | | "from platform_gb_channel pgc\n" + |
| | | " left join device_channel dc on dc.id = pgc.deviceChannelId\n" + |
| | | " left join device d on dc.deviceId = d.deviceId\n" + |
| | | "where dc.channelId = #{channelId} and pgc.platformId=#{platformId}") |
| | | List<Device> queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId) { |
| | | List<Device> devices = platformChannelMapper.queryDeviceInfoByPlatformIdAndChannelId(platformId, channelId); |
| | | if (devices.size() > 1) { |
| | | // 出现长度大于0的时候肯定是国标通道的ID重复了 |
| | | logger.warn("国标ID存在重复:{}", channelId); |
| | | } |
| | | if (devices.size() == 0) { |
| | | return null; |
| | | }else { |
| | | return devices.get(0); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询最新移动位置 |
| | | * @param deviceId |