From ea32cd2673b83b9481e8cc45705d2d3a84e884bb Mon Sep 17 00:00:00 2001 From: 64850858 <648540858@qq.com> Date: 星期一, 26 七月 2021 13:21:03 +0800 Subject: [PATCH] 重启后对心跳超时的设备设置为离线。 --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java | 41 ++++++++++++++++++++++++++--------------- 1 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java index 1842efe..d46c0c4 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java @@ -2,7 +2,6 @@ import java.io.ByteArrayInputStream; import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.*; import javax.sip.address.SipURI; @@ -283,7 +282,7 @@ //String result = XmlUtil.getText(rootElement, "Result"); // 鍥炲200 OK responseAck(evt); - if (rootElement.getName().equals("Response")) {//} !XmlUtil.isEmpty(result)) { + if (rootElement.getName().equals("Response")) {//} !StringUtils.isEmpty(result)) { // 姝ゅ鏄鏈钩鍙板彂鍑篋eviceControl鎸囦护鐨勫簲绛� JSONObject json = new JSONObject(); XmlUtil.node2Json(rootElement, json); @@ -300,7 +299,7 @@ String platformId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser(); String targetGBId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser(); // 杩滅▼鍚姩鍔熻兘 - if (!XmlUtil.isEmpty(XmlUtil.getText(rootElement, "TeleBoot"))) { + if (!StringUtils.isEmpty(XmlUtil.getText(rootElement, "TeleBoot"))) { if (deviceId.equals(targetGBId)) { // 杩滅▼鍚姩鏈钩鍙帮細闇�瑕佸湪閲嶆柊鍚姩绋嬪簭鍚庡厛瀵筍ipStack瑙g粦 logger.info("鎵ц杩滅▼鍚姩鏈钩鍙板懡浠�"); @@ -338,7 +337,7 @@ } } // 浜戝彴/鍓嶇鎺у埗鍛戒护 - if (!XmlUtil.isEmpty(XmlUtil.getText(rootElement,"PTZCmd")) && !deviceId.equals(targetGBId)) { + if (!StringUtils.isEmpty(XmlUtil.getText(rootElement,"PTZCmd")) && !deviceId.equals(targetGBId)) { String cmdString = XmlUtil.getText(rootElement,"PTZCmd"); Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(platformId, deviceId); cmder.fronEndCmd(device, deviceId, cmdString); @@ -422,7 +421,7 @@ String deviceId = XmlUtil.getText(rootElement, "DeviceID"); // 鍥炲200 OK responseAck(evt); - if (rootElement.getName().equals("Response")) {// !XmlUtil.isEmpty(result)) { + if (rootElement.getName().equals("Response")) {// !StringUtils.isEmpty(result)) { // 姝ゅ鏄鏈钩鍙板彂鍑篋eviceControl鎸囦护鐨勫簲绛� JSONObject json = new JSONObject(); XmlUtil.node2Json(rootElement, json); @@ -719,7 +718,7 @@ deviceAlarm.setLatitude(0.00); } - if (!XmlUtil.isEmpty(deviceAlarm.getAlarmMethod())) { + if (!StringUtils.isEmpty(deviceAlarm.getAlarmMethod())) { if ( deviceAlarm.getAlarmMethod().equals("4")) { MobilePosition mobilePosition = new MobilePosition(); mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); @@ -772,19 +771,31 @@ Element rootElement = getRootElement(evt); String deviceId = XmlUtil.getText(rootElement, "DeviceID"); Device device = storager.queryVideoDevice(deviceId); - // 妫�鏌ヨ澶囨槸鍚﹀瓨鍦ㄥ苟鍦ㄧ嚎锛� 涓嶅瓨鍦ㄥ垯涓嶅洖澶� - if (device != null && device.getOnline() == 1) { + + // 妫�鏌ヨ澶囨槸鍚﹀瓨鍦ㄥ苟鍦ㄧ嚎锛� 涓嶅湪绾垮垯璁剧疆涓哄湪绾� + if (device != null ) { // 鍥炲200 OK responseAck(evt); - if (offLineDetector.isOnline(deviceId)) { - publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); - } else { - } - }else { - logger.warn("鏀跺埌[ "+deviceId+" ]蹇冭烦淇℃伅, 浣嗘槸璁惧" + (device == null? "涓嶅瓨鍦�":"绂荤嚎") + ", 鍥炲401"); - Response response = getMessageFactory().createResponse(Response.UNAUTHORIZED, evt.getRequest()); + publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); + }else{ + logger.warn("鏀跺埌[ "+deviceId+" ]蹇冭烦淇℃伅, 浣嗘槸璁惧涓嶅瓨鍦�, 鍥炲404"); + Response response = getMessageFactory().createResponse(Response.NOT_FOUND, evt.getRequest()); getServerTransaction(evt).sendResponse(response); } + +// if (device != null && device.getOnline() == 1) { +// +// if (offLineDetector.isOnline(deviceId)) { +// publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); +// } else { +// } +// }else { +//// logger.warn("鏀跺埌[ "+deviceId+" ]蹇冭烦淇℃伅, 浣嗘槸璁惧" + (device == null? "涓嶅瓨鍦�":"绂荤嚎") + ", 鍥炲401"); +//// Response response = getMessageFactory().createResponse(Response.UNAUTHORIZED, evt.getRequest()); +//// getServerTransaction(evt).sendResponse(response); +// publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); +// +// } } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { e.printStackTrace(); } -- Gitblit v1.8.0