Commit 141b2282675269e7cd18b78bb3b95e33bb46ccc7
1 parent
26cd7dba
修复WVP作为下级平台接收DeviceInfo指令固定响应的问题
Showing
6 changed files
with
53 additions
and
11 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
| @@ -51,11 +51,11 @@ public interface ISIPCommanderForPlatform { | @@ -51,11 +51,11 @@ public interface ISIPCommanderForPlatform { | ||
| 51 | /** | 51 | /** |
| 52 | * 向上级回复DeviceInfo查询信息 | 52 | * 向上级回复DeviceInfo查询信息 |
| 53 | * @param parentPlatform 平台信息 | 53 | * @param parentPlatform 平台信息 |
| 54 | - * @param sn | ||
| 55 | - * @param fromTag | 54 | + * @param sn SN |
| 55 | + * @param fromTag FROM头的tag信息 | ||
| 56 | * @return | 56 | * @return |
| 57 | */ | 57 | */ |
| 58 | - void deviceInfoResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException; | 58 | + void deviceInfoResponse(ParentPlatform parentPlatform,Device device, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException; |
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | * 向上级回复DeviceStatus查询信息 | 61 | * 向上级回复DeviceStatus查询信息 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| @@ -255,7 +255,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -255,7 +255,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 255 | * @return | 255 | * @return |
| 256 | */ | 256 | */ |
| 257 | @Override | 257 | @Override |
| 258 | - public void deviceInfoResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException { | 258 | + public void deviceInfoResponse(ParentPlatform parentPlatform,Device device, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException { |
| 259 | if (parentPlatform == null) { | 259 | if (parentPlatform == null) { |
| 260 | return; | 260 | return; |
| 261 | } | 261 | } |
| @@ -265,11 +265,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -265,11 +265,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 265 | deviceInfoXml.append("<Response>\r\n"); | 265 | deviceInfoXml.append("<Response>\r\n"); |
| 266 | deviceInfoXml.append("<CmdType>DeviceInfo</CmdType>\r\n"); | 266 | deviceInfoXml.append("<CmdType>DeviceInfo</CmdType>\r\n"); |
| 267 | deviceInfoXml.append("<SN>" +sn + "</SN>\r\n"); | 267 | deviceInfoXml.append("<SN>" +sn + "</SN>\r\n"); |
| 268 | - deviceInfoXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); | ||
| 269 | - deviceInfoXml.append("<DeviceName>" + parentPlatform.getName() + "</DeviceName>\r\n"); | ||
| 270 | - deviceInfoXml.append("<Manufacturer>wvp</Manufacturer>\r\n"); | ||
| 271 | - deviceInfoXml.append("<Model>wvp-28181-2.0</Model>\r\n"); | ||
| 272 | - deviceInfoXml.append("<Firmware>2.0.202107</Firmware>\r\n"); | 268 | + deviceInfoXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); |
| 269 | + deviceInfoXml.append("<DeviceName>" + device.getName() + "</DeviceName>\r\n"); | ||
| 270 | + deviceInfoXml.append("<Manufacturer>" + device.getManufacturer() + "</Manufacturer>\r\n"); | ||
| 271 | + deviceInfoXml.append("<Model>" + device.getModel() + "</Model>\r\n"); | ||
| 272 | + deviceInfoXml.append("<Firmware>" + device.getFirmware() + "</Firmware>\r\n"); | ||
| 273 | deviceInfoXml.append("<Result>OK</Result>\r\n"); | 273 | deviceInfoXml.append("<Result>OK</Result>\r\n"); |
| 274 | deviceInfoXml.append("</Response>\r\n"); | 274 | deviceInfoXml.append("</Response>\r\n"); |
| 275 | 275 |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java
| @@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; | @@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; | ||
| 6 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; | 6 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| 7 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; | 7 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| 8 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; | 8 | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; |
| 9 | +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; | ||
| 9 | import gov.nist.javax.sip.message.SIPRequest; | 10 | import gov.nist.javax.sip.message.SIPRequest; |
| 10 | import org.dom4j.Element; | 11 | import org.dom4j.Element; |
| 11 | import org.slf4j.Logger; | 12 | import org.slf4j.Logger; |
| @@ -21,6 +22,8 @@ import javax.sip.header.FromHeader; | @@ -21,6 +22,8 @@ import javax.sip.header.FromHeader; | ||
| 21 | import javax.sip.message.Response; | 22 | import javax.sip.message.Response; |
| 22 | import java.text.ParseException; | 23 | import java.text.ParseException; |
| 23 | 24 | ||
| 25 | +import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; | ||
| 26 | + | ||
| 24 | @Component | 27 | @Component |
| 25 | public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { | 28 | public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { |
| 26 | 29 | ||
| @@ -32,6 +35,8 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp | @@ -32,6 +35,8 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp | ||
| 32 | 35 | ||
| 33 | @Autowired | 36 | @Autowired |
| 34 | private SIPCommanderFroPlatform cmderFroPlatform; | 37 | private SIPCommanderFroPlatform cmderFroPlatform; |
| 38 | + @Autowired | ||
| 39 | + private IVideoManagerStorage storager; | ||
| 35 | 40 | ||
| 36 | @Override | 41 | @Override |
| 37 | public void afterPropertiesSet() throws Exception { | 42 | public void afterPropertiesSet() throws Exception { |
| @@ -52,10 +57,20 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp | @@ -52,10 +57,20 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp | ||
| 52 | responseAck((SIPRequest) evt.getRequest(), Response.OK); | 57 | responseAck((SIPRequest) evt.getRequest(), Response.OK); |
| 53 | } catch (SipException | InvalidArgumentException | ParseException e) { | 58 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 54 | logger.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); | 59 | logger.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); |
| 60 | + return; | ||
| 55 | } | 61 | } |
| 56 | String sn = rootElement.element("SN").getText(); | 62 | String sn = rootElement.element("SN").getText(); |
| 63 | + /*根据WVP原有的数据结构,设备和通道是分开放置,设备信息都是存放在设备表里,通道表里的设备信息不可作为真实信息处理 | ||
| 64 | + 大部分NVR/IPC设备对他的通道信息实现都是返回默认的值没有什么参考价值。NVR/IPC通道我们统一使用设备表的设备信息来作为返回。 | ||
| 65 | + 我们这里使用查询数据库的方式来实现这个设备信息查询的功能,在其他地方对设备信息更新达到正确的目的。*/ | ||
| 66 | + String channelId = getText(rootElement, "DeviceID"); | ||
| 67 | + Device device = storager.queryDeviceInfoByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); | ||
| 68 | + if (device ==null){ | ||
| 69 | + logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); | ||
| 70 | + return; | ||
| 71 | + } | ||
| 57 | try { | 72 | try { |
| 58 | - cmderFroPlatform.deviceInfoResponse(parentPlatform, sn, fromHeader.getTag()); | 73 | + cmderFroPlatform.deviceInfoResponse(parentPlatform,device, sn, fromHeader.getTag()); |
| 59 | } catch (SipException | InvalidArgumentException | ParseException e) { | 74 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 60 | logger.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); | 75 | logger.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); |
| 61 | } | 76 | } |
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
| @@ -186,7 +186,13 @@ public interface IVideoManagerStorage { | @@ -186,7 +186,13 @@ public interface IVideoManagerStorage { | ||
| 186 | 186 | ||
| 187 | Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); | 187 | Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); |
| 188 | 188 | ||
| 189 | - | 189 | + /** |
| 190 | + * 针对deviceinfo指令的查询接口 | ||
| 191 | + * @param platformId 平台id | ||
| 192 | + * @param channelId 通道id | ||
| 193 | + * @return 设备信息 | ||
| 194 | + */ | ||
| 195 | + Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId); | ||
| 190 | /** | 196 | /** |
| 191 | * 添加Mobile Position设备移动位置 | 197 | * 添加Mobile Position设备移动位置 |
| 192 | * @param mobilePosition | 198 | * @param mobilePosition |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
| @@ -107,4 +107,11 @@ public interface PlatformChannelMapper { | @@ -107,4 +107,11 @@ public interface PlatformChannelMapper { | ||
| 107 | "DELETE FROM platform_gb_channel WHERE platformId=#{platformId} and catalogId=#{catalogId}" + | 107 | "DELETE FROM platform_gb_channel WHERE platformId=#{platformId} and catalogId=#{catalogId}" + |
| 108 | "</script>") | 108 | "</script>") |
| 109 | int delChannelForGBByCatalogId(String platformId, String catalogId); | 109 | int delChannelForGBByCatalogId(String platformId, String catalogId); |
| 110 | + | ||
| 111 | + @Select("select dc.channelId deviceId,dc.name,d.manufacturer,d.model,d.firmware\n" + | ||
| 112 | + "from platform_gb_channel pgc\n" + | ||
| 113 | + " left join device_channel dc on dc.id = pgc.deviceChannelId\n" + | ||
| 114 | + " left join device d on dc.deviceId = d.deviceId\n" + | ||
| 115 | + "where dc.channelId = #{channelId} and pgc.platformId=#{platformId}") | ||
| 116 | + List<Device> queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId); | ||
| 110 | } | 117 | } |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
| @@ -471,6 +471,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | @@ -471,6 +471,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | ||
| 471 | 471 | ||
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | + @Override | ||
| 475 | + public Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId) { | ||
| 476 | + List<Device> devices = platformChannelMapper.queryDeviceInfoByPlatformIdAndChannelId(platformId, channelId); | ||
| 477 | + if (devices.size() > 1) { | ||
| 478 | + // 出现长度大于0的时候肯定是国标通道的ID重复了 | ||
| 479 | + logger.warn("国标ID存在重复:{}", channelId); | ||
| 480 | + } | ||
| 481 | + if (devices.size() == 0) { | ||
| 482 | + return null; | ||
| 483 | + }else { | ||
| 484 | + return devices.get(0); | ||
| 485 | + } | ||
| 486 | + } | ||
| 487 | + | ||
| 474 | /** | 488 | /** |
| 475 | * 查询最新移动位置 | 489 | * 查询最新移动位置 |
| 476 | * @param deviceId | 490 | * @param deviceId |