|
@@ -146,6 +146,58 @@ async def get_waterlogged_all_video_info(
|
|
|
traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
|
|
|
+@router.get('/get_video_forest_fire_list')
|
|
|
+async def get_video_forest_fire_list(
|
|
|
+ radius:int = Query(None),
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ body=Depends(remove_xss_json),
|
|
|
+ user_id=Depends(valid_access_token)):
|
|
|
+
|
|
|
+ try:
|
|
|
+
|
|
|
+ """
|
|
|
+ 根据层级路径构建带有 label 和 children 的树形结构。
|
|
|
+ :param paths: 包含层级路径的列表
|
|
|
+ :return: 树形结构的字典
|
|
|
+ """
|
|
|
+ video_code_list = [item[0] for item in db.query(TpVideoTag.id).filter(TpVideoTag.dict_value == '4').all()]
|
|
|
+ video_list = db.query(TpVideoLog).filter(TpVideoLog.video_code.in_(video_code_list)).all()
|
|
|
+ root = {"label": "Root", "children": [],"online":0,"total":0} # 创建根节点
|
|
|
+
|
|
|
+ for video_info in video_list:
|
|
|
+ levels = video_info.area.split('/')
|
|
|
+ current_node = root
|
|
|
+ current_node['total']+=1
|
|
|
+ if video_info.status == '在线':
|
|
|
+ current_node['online']+=1
|
|
|
+ for level in levels:
|
|
|
+ # 查找当前层级是否已存在
|
|
|
+ existing_node = next((node for node in current_node["children"] if node["label"] == level), None)
|
|
|
+ if not existing_node:
|
|
|
+ # 如果不存在,创建新节点
|
|
|
+ new_node = {"label": level, "children": [],"online":0,"total":0}
|
|
|
+ current_node["children"].append(new_node)
|
|
|
+ existing_node = new_node
|
|
|
+
|
|
|
+ # 移动到子节点
|
|
|
+ current_node = existing_node
|
|
|
+ current_node['total']+=1
|
|
|
+ if video_info.status == '在线':
|
|
|
+ current_node['online']+=1
|
|
|
+
|
|
|
+ current_node['children'].append({"label":video_info.name,"status":video_info.status,"video_code":video_info.video_code,"isLeaf":True})
|
|
|
+
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "成功",
|
|
|
+ "data": root['children'],
|
|
|
+ 'online':root['online'],
|
|
|
+ 'total':root['total']
|
|
|
+ }
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
|
|
|
|
|
|
|