libushang 3 miesięcy temu
rodzic
commit
973ffa1637
1 zmienionych plików z 62 dodań i 21 usunięć
  1. 62 21
      routers/api/videoResource/avcon.py

+ 62 - 21
routers/api/videoResource/avcon.py

@@ -166,7 +166,7 @@ async def get_device_tree(
         data = AvconH5API.get_search_region("指挥终端")
         if data is not None:
             result1 = []
-            fomat_device_result(data[0], result1)
+            fomat_device_group_result(data[0], result1)
             result.append({
                 "id": data[0]["group_id"],
                 "label": data[0]["group_name"],
@@ -176,7 +176,7 @@ async def get_device_tree(
         data = AvconH5API.get_search_region("H323会议视频")
         if data is not None:
             result1 = []
-            fomat_device_result(data[0], result1)
+            fomat_device_group_result(data[0], result1)
             result.append({
                 "id": data[0]["group_id"],
                 "label": data[0]["group_name"],
@@ -186,7 +186,7 @@ async def get_device_tree(
         data = AvconH5API.get_search_region("手机App")
         if data is not None:
             result1 = []
-            fomat_device_result(data[0], result1)
+            fomat_device_group_result(data[0], result1)
             result.append({
                 "id": data[0]["group_id"],
                 "label": data[0]["group_name"],
@@ -206,7 +206,7 @@ async def get_device_tree(
             "msg": "无法获取视频终端"
         }
     
-def fomat_device_result(data: dict, result: dict) -> dict:
+def fomat_device_group_result(data: dict, result: dict) -> dict:
     if "child_group" in data:
         for n in data["child_group"]:
             new_item = {
@@ -218,22 +218,6 @@ def fomat_device_result(data: dict, result: dict) -> dict:
             fomat_device_result(n, result1)
             new_item["children"] = result1
             result.append(new_item)
-
-            print('\r\n', n)
-
-    '''
-    if "child_device" in data:
-        for n in data["child_device"]:
-            new_item = {
-                "id": n['dev_id'],
-                "label": n['dev_name'],
-                "dev_type": n['dev_type'],
-                # "order_id": n['order_id'],
-                "isLeaf": True
-            }
-            result.append(new_item)
-            print('\r\n', n)
-    '''
     
 @router.get("/get_device_list/{group_id}")
 async def get_device_list(
@@ -277,4 +261,61 @@ def get_avcon_type_text(type: str) -> str:
     elif type == '100':
         return 'H.323终端'
     
-    return "未知终端"
+    return "未知终端"
+
+# 无人机
+@router.get("/get_drone_tree")
+async def get_drone_tree(
+    body = Depends(remove_xss_json),
+    db: Session = Depends(get_db),
+    user_id = Depends(valid_access_token)
+):
+    try:
+        result = []
+        data = AvconH5API.get_search_region("无人机视频")
+        if data is not None:
+            result1 = []
+            fomat_device_result(data[0], result1)
+            result.append({
+                "id": data[0]["group_id"],
+                "label": data[0]["group_name"],
+                "children": result1
+            })
+        
+        return {
+            "code": 0,
+            "msg": "success",
+            "data": result
+        }
+
+    except Exception as e:
+        traceback.print_exc()
+        return {
+            "code": 500,
+            "msg": "无法获取视频终端"
+        }
+    
+
+def fomat_device_result(data: dict, result: dict) -> dict:
+    if "child_group" in data:
+        for n in data["child_group"]:
+            new_item = {
+                "id": n['group_id'],
+                "label": n['group_name'],
+                "order_id": n['order_id']
+            }
+            result1 = []
+            fomat_device_result(n, result1)
+            new_item["children"] = result1
+            result.append(new_item)
+
+    if "child_device" in data:
+        for n in data["child_device"]:
+            new_item = {
+                "id": n['dev_id'],
+                "label": n['dev_name'],
+                "dev_type": n['dev_type'],
+                # "order_id": n['order_id'],
+                "isLeaf": True
+            }
+            result.append(new_item)