From 14699711028f0d157eddfb0432e26ab91f1b4493 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期二, 22 十一月 2022 15:02:25 +0800 Subject: [PATCH] 支持配置设备上线时自动更新查询通道,修复通道刷新进度展示 --- src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java | 33 +++++++++++++++++++++++---------- 1 files changed, 23 insertions(+), 10 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 ced97ef..35d563d 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 @@ -1,7 +1,7 @@ package com.genersoft.iot.vmp.gb28181.utils; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.TreeType; @@ -14,6 +14,7 @@ import org.dom4j.io.SAXReader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import javax.sip.RequestEvent; @@ -118,12 +119,12 @@ // 濡傛灉鏄睘鎬� for (Object o : element.attributes()) { Attribute attr = (Attribute) o; - if (!StringUtils.isEmpty(attr.getValue())) { + if (!ObjectUtils.isEmpty(attr.getValue())) { json.put("@" + attr.getName(), attr.getValue()); } } List<Element> chdEl = element.elements(); - if (chdEl.isEmpty() && !StringUtils.isEmpty(element.getText())) {// 濡傛灉娌℃湁瀛愬厓绱�,鍙湁涓�涓�� + if (chdEl.isEmpty() && !ObjectUtils.isEmpty(element.getText())) {// 濡傛灉娌℃湁瀛愬厓绱�,鍙湁涓�涓�� json.put(element.getName(), element.getText()); } @@ -154,7 +155,7 @@ } else { // 瀛愬厓绱犳病鏈夊瓙鍏冪礌 for (Object o : element.attributes()) { Attribute attr = (Attribute) o; - if (!StringUtils.isEmpty(attr.getValue())) { + if (!ObjectUtils.isEmpty(attr.getValue())) { json.put("@" + attr.getName(), attr.getValue()); } } @@ -197,7 +198,7 @@ return null; } String channelId = channdelIdElement.getTextTrim(); - if (StringUtils.isEmpty(channelId)) { + if (ObjectUtils.isEmpty(channelId)) { logger.warn("瑙f瀽Catalog娑堟伅鏃跺彂鐜扮己灏� DeviceID"); return null; } @@ -210,17 +211,26 @@ ChannelType channelType = ChannelType.Other; if (channelId.length() <= 8) { channelType = ChannelType.CivilCode; + deviceChannel.setHasAudio(false); }else { if (channelId.length() == 20) { int code = Integer.parseInt(channelId.substring(10, 13)); switch (code){ case 215: channelType = ChannelType.BusinessGroup; + deviceChannel.setHasAudio(false); break; case 216: channelType = ChannelType.VirtualOrganization; + deviceChannel.setHasAudio(false); + break; + case 136: + case 137: + case 138: + deviceChannel.setHasAudio(true); break; default: + deviceChannel.setHasAudio(false); break; } @@ -288,6 +298,10 @@ }else { deviceChannel.setParentId(parentId); } + // 鍏煎璁惧閫氶亾淇℃伅涓嚜宸变负鑷繁鐖惰妭鐐圭殑鎯呭喌 + if (deviceChannel.getParentId().equals(deviceChannel.getChannelId())) { + deviceChannel.setParentId(null); + } } deviceChannel.setBusinessGroupId(businessGroupID); if (channelType.equals(ChannelType.BusinessGroup) || channelType.equals(ChannelType.VirtualOrganization)) { @@ -316,7 +330,7 @@ // 璇嗗埆鑷甫鐨勭洰褰曟爣璇� String parental = XmlUtil.getText(itemDevice, "Parental"); // 鐢变簬娴峰悍浼氶敊璇殑鍙戦��65535浣滀负杩欓噷鐨勫彇鍊�,鎵�浠ヨ繖閲岄櫎闈炴槸0鍚﹀垯璁や负鏄�1 - if (!StringUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) { + if (!ObjectUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) { deviceChannel.setParental(0); }else { deviceChannel.setParental(1); @@ -332,14 +346,14 @@ deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password")); String safetyWay = XmlUtil.getText(itemDevice, "SafetyWay"); - if (StringUtils.isEmpty(safetyWay)) { + if (ObjectUtils.isEmpty(safetyWay)) { deviceChannel.setSafetyWay(0); } else { deviceChannel.setSafetyWay(Integer.parseInt(safetyWay)); } String registerWay = XmlUtil.getText(itemDevice, "RegisterWay"); - if (StringUtils.isEmpty(registerWay)) { + if (ObjectUtils.isEmpty(registerWay)) { deviceChannel.setRegisterWay(1); } else { deviceChannel.setRegisterWay(Integer.parseInt(registerWay)); @@ -395,7 +409,6 @@ } else { deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); } - deviceChannel.setHasAudio(true); // 榛樿鍚湁闊抽锛屾挱鏀炬椂鍐嶆鏌ユ槸鍚︽湁闊抽鍙婃槸鍚AC return deviceChannel; } } \ No newline at end of file -- Gitblit v1.8.0