From 4e0a463f883816d78a4c4241ab23e79b2e805f98 Mon Sep 17 00:00:00 2001 From: 648540858 <456panlinlin> Date: 星期四, 28 四月 2022 09:47:46 +0800 Subject: [PATCH] 优化对Parental字段的判断 --- src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java | 41 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java index 09e7a04..57831df 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java @@ -204,13 +204,48 @@ deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); + String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID"); if (XmlUtil.getText(itemDevice, "Parental") == null - || XmlUtil.getText(itemDevice, "Parental") == "") { - deviceChannel.setParental(0); + || XmlUtil.getText(itemDevice, "Parental").equals("")) { + if (deviceChannel.getChannelId().length() <= 10 + || (deviceChannel.getChannelId().length() == 20 && ( + Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 215 + || Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216 + ) + ) + ) { + deviceChannel.setParental(1); + }else { + deviceChannel.setParental(0); + } } else { deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental"))); } deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); + String parentId = XmlUtil.getText(itemDevice, "ParentID"); + if (parentId != null) { + if (parentId.contains("/")) { + String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1); + deviceChannel.setParentId(lastParentId); + }else { + deviceChannel.setParentId(parentId); + } + }else { + if (deviceChannel.getChannelId().length() <= 10) { // 姝ゆ椂涓鸿鏀垮尯鍒�, 涓婁笅绾ц鏀垮尯鍒掍娇鐢―eviceId鍏宠仈 + deviceChannel.setParentId(deviceChannel.getChannelId().substring(0, deviceChannel.getChannelId().length() - 2)); + }else if (deviceChannel.getChannelId().length() == 20) { + if (Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216) { // 铏氭嫙缁勭粐 + deviceChannel.setParentId(businessGroupID); + }else if (deviceChannel.getCivilCode() != null) { + // 璁惧锛� 鏃爌arentId鐨�20浣嶆槸浣跨敤CivilCode琛ㄧず涓婄骇鐨勮澶囷紝 + // 娉細215 涓氬姟鍒嗙粍鏄渶瑕佹湁parentId鐨� + deviceChannel.setParentId(deviceChannel.getCivilCode()); + } + }else { + deviceChannel.setParentId(deviceChannel.getDeviceId()); + } + } + if (XmlUtil.getText(itemDevice, "SafetyWay") == null || XmlUtil.getText(itemDevice, "SafetyWay") == "") { deviceChannel.setSafetyWay(0); @@ -269,4 +304,4 @@ deviceChannel.setHasAudio(true); // 榛樿鍚湁闊抽锛屾挱鏀炬椂鍐嶆鏌ユ槸鍚︽湁闊抽鍙婃槸鍚AC return deviceChannel; } -} +} \ No newline at end of file -- Gitblit v1.8.0