优化设备状态查询
This commit is contained in:
@@ -82,7 +82,7 @@ public interface ISIPCommanderForPlatform {
|
||||
* @param fromTag
|
||||
* @return
|
||||
*/
|
||||
void deviceStatusResponse(Platform parentPlatform, String channelId, String sn, String fromTag, boolean status) throws SipException, InvalidArgumentException, ParseException;
|
||||
void deviceStatusResponse(Platform parentPlatform, String channelId, String sn, String fromTag, Boolean status) throws SipException, InvalidArgumentException, ParseException;
|
||||
|
||||
/**
|
||||
* 向上级回复移动位置订阅消息
|
||||
|
||||
@@ -329,22 +329,29 @@ public class SIPCommanderForPlatform implements ISIPCommanderForPlatform {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deviceStatusResponse(Platform parentPlatform, String channelId, String sn, String fromTag, boolean status) throws SipException, InvalidArgumentException, ParseException {
|
||||
public void deviceStatusResponse(Platform parentPlatform, String channelId, String sn, String fromTag, Boolean status) throws SipException, InvalidArgumentException, ParseException {
|
||||
if (parentPlatform == null) {
|
||||
return ;
|
||||
}
|
||||
String statusStr = (status)?"ONLINE":"OFFLINE";
|
||||
String statusStr = null;
|
||||
if (status != null) {
|
||||
statusStr = (status)?"ONLINE":"OFFLINE";
|
||||
}
|
||||
String characterSet = parentPlatform.getCharacterSet();
|
||||
StringBuffer deviceStatusXml = new StringBuffer(600);
|
||||
deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
|
||||
.append("<Response>\r\n")
|
||||
.append("<CmdType>DeviceStatus</CmdType>\r\n")
|
||||
.append("<SN>" +sn + "</SN>\r\n")
|
||||
.append("<DeviceID>" + channelId + "</DeviceID>\r\n")
|
||||
.append("<Result>OK</Result>\r\n")
|
||||
.append("<Online>"+statusStr+"</Online>\r\n")
|
||||
.append("<Status>OK</Status>\r\n")
|
||||
.append("</Response>\r\n");
|
||||
.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||
if (statusStr == null) {
|
||||
deviceStatusXml.append("<Result>ERROR</Result>\r\n");
|
||||
}else {
|
||||
deviceStatusXml.append("<Result>OK</Result>\r\n")
|
||||
.append("<Online>"+statusStr+"</Online>\r\n")
|
||||
.append("<Status>OK</Status>\r\n");
|
||||
}
|
||||
deviceStatusXml.append("</Response>\r\n");
|
||||
|
||||
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||
|
||||
|
||||
@@ -86,14 +86,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
|
||||
} else if (CmdType.CATALOG.equals(cmd)) {
|
||||
processNotifyCatalogList(request, rootElement);
|
||||
} else {
|
||||
log.info("接收到消息:" + cmd);
|
||||
log.info("接收到消息:{}", cmd);
|
||||
|
||||
Response response = getMessageFactory().createResponse(200, request);
|
||||
if (response != null) {
|
||||
ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30);
|
||||
response.setExpires(expireHeader);
|
||||
}
|
||||
log.info("response : " + response);
|
||||
log.info("response : {}", response);
|
||||
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
|
||||
}
|
||||
} catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
|
||||
@@ -126,9 +126,6 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
|
||||
.append("<DeviceID>").append(deviceId).append("</DeviceID>\r\n")
|
||||
.append("<Result>OK</Result>\r\n")
|
||||
.append("</Response>\r\n");
|
||||
|
||||
|
||||
|
||||
try {
|
||||
int expires = request.getExpires().getExpires();
|
||||
SIPResponse response = responseXmlAck(request, resultXml.toString(), platform, expires);
|
||||
|
||||
@@ -73,7 +73,13 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i
|
||||
}
|
||||
CommonGBChannel channel= channelService.queryOneWithPlatform(platform.getId(), channelId);
|
||||
if (channel ==null){
|
||||
log.error("[平台没有该通道的使用权限]:platformId"+platform.getServerGBId()+" deviceID:"+channelId);
|
||||
log.error("[平台没有该通道的使用权限]:platformId: {} deviceID:{}", platform.getServerGBId(), channelId);
|
||||
// 上级平台查询本平台状态
|
||||
try {
|
||||
cmderFroPlatform.deviceStatusResponse(platform, channelId, sn, fromHeader.getTag(), null);
|
||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||
log.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user