Browse Source

no message

libushang 3 weeks ago
parent
commit
a284befdf4
1 changed files with 99 additions and 3 deletions
  1. 99 3
      routers/api/videoResource/avcon.py

+ 99 - 3
routers/api/videoResource/avcon.py

@@ -255,8 +255,9 @@ async def get_device_list(
     except Exception as e:
         traceback.print_exc()
         return {
-            "code": 500,
-            "msg": "无法获取视频终端"
+            "code": 200,
+            "msg": "无法获取视频终端",
+            "data": []
         }
 
 def get_avcon_type_text(type: str) -> str:
@@ -370,4 +371,99 @@ def fomat_device_result(data: dict, result: dict) -> dict:
                 # "order_id": n['order_id'],
                 "isLeaf": True
             }
-            result.append(new_item)
+            result.append(new_item)
+
+# 手机工作台
+@router.post("/get_mobile_workstation_info")
+async def get_mobile_workstation_info(
+    db: Session = Depends(get_db),
+    body = Depends(remove_xss_json),
+    user_id = Depends(valid_access_token)
+):
+    try:
+        current = body['current']
+        size = body['size']
+        keywords = body['query']['keywords']
+        result = []
+        total = 0
+        data = AvconH5API.get_search_region("手机App")
+        if data is not None:
+            for n in data[0]['child_device']:
+                dev_id = n['dev_id']
+                dev_name = n['dev_name']
+
+                if keywords == "" or dev_name.find(keywords) != -1:
+                    result.append({
+                        "dev_id": dev_id,
+                        "dev_name": dev_name
+                    })
+
+            total = len(result)
+            result = paginate(result, size, current)
+
+
+        return {
+            "code": 0,
+            "msg": "success",
+            "data": result,
+            "total": total
+        }
+
+    except Exception as e:
+        traceback.print_exc()
+        return {
+            "code": 200,
+            "msg": "无法获取视频终端",
+            "data": [],
+            "total": 0
+        }
+
+# 移动指挥车
+@router.post("/get_mobile_command_vehicle_list_info")
+async def get_mobile_command_vehicle_list_info(
+    db: Session = Depends(get_db),
+    body = Depends(remove_xss_json),
+    user_id = Depends(valid_access_token)
+):
+    try:
+        current = body['current']
+        size = body['size']
+        keywords = body['query']['keywords']
+        result = []
+        total = 0
+        data = AvconH5API.get_search_region("指挥终端")
+        if data is not None:
+            for n in data[0]['child_device']:
+                dev_id = n['dev_id']
+                dev_name = n['dev_name']
+
+                if keywords == "" or dev_name.find(keywords) != -1:
+                    result.append({
+                        "dev_id": dev_id,
+                        "dev_name": dev_name
+                    })
+
+            total = len(result)
+            result = paginate(result, size, current)
+
+        return {
+            "code": 0,
+            "msg": "success",
+            "data": result,
+            "total": total
+        }
+
+    except Exception as e:
+        traceback.print_exc()
+        return {
+            "code": 200,
+            "msg": "无法获取视频终端",
+            "data": [],
+            "total": 0
+        }
+    
+def paginate(array, page_size, page_number):
+    start_index = (page_number - 1) * page_size
+    end_index = start_index + page_size
+    return array[start_index:end_index]
+