From fc89b7b517e191fb6c9b66fa86dd05ebab0f54c5 Mon Sep 17 00:00:00 2001
From: jiang <893224616@qq.com>
Date: 星期三, 13 七月 2022 11:29:46 +0800
Subject: [PATCH] 测试提交权限

---
 src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java |   98 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 92 insertions(+), 6 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..72206d8 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
@@ -2,7 +2,9 @@
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
+import com.genersoft.iot.vmp.utils.DateUtil;
 import org.dom4j.Attribute;
 import org.dom4j.Document;
 import org.dom4j.DocumentException;
@@ -180,7 +182,7 @@
         return xml.getRootElement();
     }
 
-    public static DeviceChannel channelContentHander(Element itemDevice){
+    public static DeviceChannel channelContentHander(Element itemDevice, Device device){
         Element channdelNameElement = itemDevice.element("Name");
         String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : "";
         Element statusElement = itemDevice.element("Status");
@@ -204,13 +206,71 @@
         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")));
+            // 鐢变簬娴峰悍浼氶敊璇殑鍙戦��65535浣滀负杩欓噷鐨勫彇鍊�,鎵�浠ヨ繖閲岄櫎闈炴槸0鍚﹀垯璁や负鏄�1
+            deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental")) == 1?1:0);
         }
-        deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID"));
+        /**
+         * 琛屾斂鍖哄垝灞曠ず璁惧鏍戜笌涓氬姟鍒嗙粍灞曠ず璁惧鏍戞槸涓ょ涓嶅悓鐨勬ā寮�
+         * 琛屾斂鍖哄垝灞曠ず璁惧鏍� 鍚勪釜鐩綍涔嬮棿涓昏闈燿eviceId鍋氬叧鑱�,鎽勫儚澶撮�氳繃CivilCode鎸囧畾鍏跺睘浜庨偅涓鏀垮尯鍒�;閮芥槸涓嶈秴杩囧崄浣嶇殑缂栧彿; 缁撴瀯濡備笅:
+         * 娌冲寳鐪�
+         *    --> 鐭冲搴勫競
+         *          --> 鎽勫儚澶�
+         *          --> 姝e畾鍘�
+         *                  --> 鎽勫儚澶�
+         *                  --> 鎽勫儚澶�
+         *
+         * 涓氬姟鍒嗙粍灞曠ず璁惧鏍戞槸椤剁骇鏄笟鍔″垎缁�,鍏朵笅鐨勮櫄鎷熺粍缁囬潬BusinessGroupID鎸囧畾鍏舵墍灞炵殑涓氬姟鍒嗙粍;鎽勫儚澶撮�氳繃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);
+            }
+        }
+        deviceChannel.setBusinessGroupId(businessGroupID);
+
+//        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.setBusinessGroupId(businessGroupID);
+//                }else if (Integer.parseInt(device.getDeviceId().substring(10, 13) )== 118) {//NVR 濡傛灉涓婄骇璁惧缂栧彿鏄疦VR鍒欑洿鎺ュ皢NVR鐨勭紪鍙疯缃粰閫氶亾鐨勪笂绾х紪鍙�
+//                    deviceChannel.setParentId(device.getDeviceId());
+//                }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);
@@ -255,6 +315,32 @@
         } else {
             deviceChannel.setLatitude(0.00);
         }
+        deviceChannel.setGpsTime(DateUtil.getNow());
+        if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
+            if ("WGS84".equals(device.getGeoCoordSys())) {
+                deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
+                deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
+                Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
+                deviceChannel.setLongitudeGcj02(position[0]);
+                deviceChannel.setLatitudeGcj02(position[1]);
+            }else if ("GCJ02".equals(device.getGeoCoordSys())) {
+                deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
+                deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
+                Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
+                deviceChannel.setLongitudeWgs84(position[0]);
+                deviceChannel.setLatitudeWgs84(position[1]);
+            }else {
+                deviceChannel.setLongitudeGcj02(0.00);
+                deviceChannel.setLatitudeGcj02(0.00);
+                deviceChannel.setLongitudeWgs84(0.00);
+                deviceChannel.setLatitudeWgs84(0.00);
+            }
+        }else {
+            deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
+            deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
+            deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
+            deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
+        }
         if (XmlUtil.getText(itemDevice, "PTZType") == null || "".equals(XmlUtil.getText(itemDevice, "PTZType"))) {
             //鍏煎INFO涓殑淇℃伅
             Element info = itemDevice.element("Info");
@@ -269,4 +355,4 @@
         deviceChannel.setHasAudio(true); // 榛樿鍚湁闊抽锛屾挱鏀炬椂鍐嶆鏌ユ槸鍚︽湁闊抽鍙婃槸鍚AC
         return deviceChannel;
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.8.0