Commit 26cd7dbaf9394ff26f5229b18cfdb72c203a6bc3
1 parent
72a1f122
修复WVP作为下级平台接收DeviceStatus指令固定响应的问题
Showing
3 changed files
with
16 additions
and
7 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
| ... | ... | @@ -64,7 +64,7 @@ public interface ISIPCommanderForPlatform { |
| 64 | 64 | * @param fromTag |
| 65 | 65 | * @return |
| 66 | 66 | */ |
| 67 | - void deviceStatusResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException; | |
| 67 | + void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,int status) throws SipException, InvalidArgumentException, ParseException; | |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * 向上级回复移动位置订阅消息 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| ... | ... | @@ -287,19 +287,20 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 287 | 287 | * @return |
| 288 | 288 | */ |
| 289 | 289 | @Override |
| 290 | - public void deviceStatusResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException { | |
| 290 | + public void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,int status) throws SipException, InvalidArgumentException, ParseException { | |
| 291 | 291 | if (parentPlatform == null) { |
| 292 | 292 | return ; |
| 293 | 293 | } |
| 294 | + String statusStr = (status==1)?"ONLINE":"OFFLINE"; | |
| 294 | 295 | String characterSet = parentPlatform.getCharacterSet(); |
| 295 | 296 | StringBuffer deviceStatusXml = new StringBuffer(600); |
| 296 | 297 | deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| 297 | 298 | deviceStatusXml.append("<Response>\r\n"); |
| 298 | 299 | deviceStatusXml.append("<CmdType>DeviceStatus</CmdType>\r\n"); |
| 299 | 300 | deviceStatusXml.append("<SN>" +sn + "</SN>\r\n"); |
| 300 | - deviceStatusXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); | |
| 301 | + deviceStatusXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); | |
| 301 | 302 | deviceStatusXml.append("<Result>OK</Result>\r\n"); |
| 302 | - deviceStatusXml.append("<Online>ONLINE</Online>\r\n"); | |
| 303 | + deviceStatusXml.append("<Online>"+statusStr+"</Online>\r\n"); | |
| 303 | 304 | deviceStatusXml.append("<Status>OK</Status>\r\n"); |
| 304 | 305 | deviceStatusXml.append("</Response>\r\n"); |
| 305 | 306 | |
| ... | ... | @@ -307,7 +308,6 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 307 | 308 | |
| 308 | 309 | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| 309 | 310 | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| 310 | - | |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | @Override | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java
| ... | ... | @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query. |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 5 | +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | |
| 5 | 6 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 6 | 7 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 7 | 8 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; |
| ... | ... | @@ -24,6 +25,8 @@ import javax.sip.header.FromHeader; |
| 24 | 25 | import javax.sip.message.Response; |
| 25 | 26 | import java.text.ParseException; |
| 26 | 27 | |
| 28 | +import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; | |
| 29 | + | |
| 27 | 30 | @Component |
| 28 | 31 | public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { |
| 29 | 32 | |
| ... | ... | @@ -62,13 +65,19 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i |
| 62 | 65 | FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); |
| 63 | 66 | // 回复200 OK |
| 64 | 67 | try { |
| 65 | - responseAck((SIPRequest) evt.getRequest(), Response.OK); | |
| 68 | + responseAck((SIPRequest) evt.getRequest(), Response.OK); | |
| 66 | 69 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 67 | 70 | logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复200OK: {}", e.getMessage()); |
| 68 | 71 | } |
| 69 | 72 | String sn = rootElement.element("SN").getText(); |
| 73 | + String channelId = getText(rootElement, "DeviceID"); | |
| 74 | + DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId); | |
| 75 | + if (deviceChannel ==null){ | |
| 76 | + logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); | |
| 77 | + return; | |
| 78 | + } | |
| 70 | 79 | try { |
| 71 | - cmderFroPlatform.deviceStatusResponse(parentPlatform, sn, fromHeader.getTag()); | |
| 80 | + cmderFroPlatform.deviceStatusResponse(parentPlatform,channelId, sn, fromHeader.getTag(),deviceChannel.getStatus()); | |
| 72 | 81 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 73 | 82 | logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage()); |
| 74 | 83 | } | ... | ... |