修复WVP作为下级平台接收DeviceStatus指令固定响应的问题
| | |
| | | * @param fromTag |
| | | * @return |
| | | */ |
| | | void deviceStatusResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException; |
| | | void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,int status) throws SipException, InvalidArgumentException, ParseException; |
| | | |
| | | /** |
| | | * 向上级回复移动位置订阅消息 |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public void deviceStatusResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException { |
| | | public void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,int status) throws SipException, InvalidArgumentException, ParseException { |
| | | if (parentPlatform == null) { |
| | | return ; |
| | | } |
| | | String statusStr = (status==1)?"ONLINE":"OFFLINE"; |
| | | String characterSet = parentPlatform.getCharacterSet(); |
| | | StringBuffer deviceStatusXml = new StringBuffer(600); |
| | | deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| | | deviceStatusXml.append("<Response>\r\n"); |
| | | deviceStatusXml.append("<CmdType>DeviceStatus</CmdType>\r\n"); |
| | | deviceStatusXml.append("<SN>" +sn + "</SN>\r\n"); |
| | | deviceStatusXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); |
| | | deviceStatusXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); |
| | | deviceStatusXml.append("<Result>OK</Result>\r\n"); |
| | | deviceStatusXml.append("<Online>ONLINE</Online>\r\n"); |
| | | deviceStatusXml.append("<Online>"+statusStr+"</Online>\r\n"); |
| | | deviceStatusXml.append("<Status>OK</Status>\r\n"); |
| | | deviceStatusXml.append("</Response>\r\n"); |
| | | |
| | |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | import com.genersoft.iot.vmp.conf.SipConfig; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; |
| | |
| | | import javax.sip.header.FromHeader; |
| | | import javax.sip.message.Response; |
| | | import java.text.ParseException; |
| | | |
| | | import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; |
| | | |
| | | @Component |
| | | public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { |
| | |
| | | FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); |
| | | // 回复200 OK |
| | | try { |
| | | responseAck((SIPRequest) evt.getRequest(), Response.OK); |
| | | responseAck((SIPRequest) evt.getRequest(), Response.OK); |
| | | } catch (SipException | InvalidArgumentException | ParseException e) { |
| | | logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复200OK: {}", e.getMessage()); |
| | | } |
| | | String sn = rootElement.element("SN").getText(); |
| | | String channelId = getText(rootElement, "DeviceID"); |
| | | DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId); |
| | | if (deviceChannel ==null){ |
| | | logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); |
| | | return; |
| | | } |
| | | try { |
| | | cmderFroPlatform.deviceStatusResponse(parentPlatform, sn, fromHeader.getTag()); |
| | | cmderFroPlatform.deviceStatusResponse(parentPlatform,channelId, sn, fromHeader.getTag(),deviceChannel.getStatus()); |
| | | } catch (SipException | InvalidArgumentException | ParseException e) { |
| | | logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage()); |
| | | } |