From 76208975bffec39eb62f8599a68d583a5cb6da18 Mon Sep 17 00:00:00 2001 From: leesam <leesam@leesam.cn> Date: 星期二, 19 三月 2024 16:53:01 +0800 Subject: [PATCH] [add]支持其他平台通过ApiKey调用系统相关接口 --- src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 47 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 14640d8..9de1ef2 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 @@ -3,10 +3,10 @@ import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.genersoft.iot.vmp.common.CivilCodePo; -import com.genersoft.iot.vmp.conf.CivilCodeFileConf; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; +import com.genersoft.iot.vmp.utils.CivilCodeUtil; import com.genersoft.iot.vmp.utils.DateUtil; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; @@ -75,6 +75,50 @@ Element e = em.element(tag); // return null == e ? null : e.getText().trim(); + } + + /** + * 鑾峰彇element瀵硅薄鐨則ext鐨勫�� + * + * @param em 鑺傜偣鐨勫璞� + * @param tag 鑺傜偣鐨則ag + * @return 鑺傜偣 + */ + public static Double getDouble(Element em, String tag) { + if (null == em) { + return null; + } + Element e = em.element(tag); + if (null == e) { + return null; + } + String text = e.getText().trim(); + if (ObjectUtils.isEmpty(text) || !NumberUtils.isParsable(text)) { + return null; + } + return Double.parseDouble(text); + } + + /** + * 鑾峰彇element瀵硅薄鐨則ext鐨勫�� + * + * @param em 鑺傜偣鐨勫璞� + * @param tag 鑺傜偣鐨則ag + * @return 鑺傜偣 + */ + public static Integer getInteger(Element em, String tag) { + if (null == em) { + return null; + } + Element e = em.element(tag); + if (null == e) { + return null; + } + String text = e.getText().trim(); + if (ObjectUtils.isEmpty(text) || !NumberUtils.isParsable(text)) { + return null; + } + return Integer.parseInt(text); } /** @@ -196,7 +240,7 @@ CivilCode, BusinessGroup,VirtualOrganization,Other } - public static DeviceChannel channelContentHandler(Element itemDevice, Device device, String event, CivilCodeFileConf civilCodeFileConf){ + public static DeviceChannel channelContentHandler(Element itemDevice, Device device, String event){ DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setDeviceId(device.getDeviceId()); Element channdelIdElement = itemDevice.element("DeviceID"); @@ -223,7 +267,7 @@ } if(channelId.length() <= 8) { deviceChannel.setHasAudio(false); - CivilCodePo parentCode = civilCodeFileConf.getParentCode(channelId); + CivilCodePo parentCode = CivilCodeUtil.INSTANCE.getParentCode(channelId); if (parentCode != null) { deviceChannel.setParentId(parentCode.getCode()); deviceChannel.setCivilCode(parentCode.getCode()); -- Gitblit v1.8.0