|
@@ -147,6 +147,112 @@ 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_list')
|
|
|
+async def get_video_forest_fire_list(
|
|
|
+ video_type:str = Query(None),
|
|
|
+ area:str = Query(None),
|
|
|
+ name:str = Query(None),
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ page: int = Query(1, gt=0, description='页码'),
|
|
|
+ pageSize: int = Query(0, gt=0, description='每页条目数量'),
|
|
|
+ body=Depends(remove_xss_json),
|
|
|
+ user_id=Depends(valid_access_token)):
|
|
|
+
|
|
|
+ try:
|
|
|
+ # video_type_list = ['sjyld','sgdfd','jtdd','dzzhyhd']
|
|
|
+ # 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.area=='茂名市视频数据共享管理平台')
|
|
|
+ if video_type:
|
|
|
+ # if video_type in video_type_list:
|
|
|
+
|
|
|
+ lis = [i.video_code for i in db.query(TpVideoTag.video_code).filter(TpVideoTag.dict_value==video_type , TpVideoTag.del_flag =='0').all()]
|
|
|
+ video_list = video_list.filter(TpVideoLog.video_code.in_(lis))
|
|
|
+ # if area:
|
|
|
+ # if area=='直辖市':
|
|
|
+ # lis = [i.video_code for i in db.query(TpVideoLogTransportationAreaInfo.video_code).all()]
|
|
|
+ # video_list = video_list.filter(TpVideoLog.video_code.in_(lis))
|
|
|
+ # else:
|
|
|
+ # lis = [i.video_code for i in db.query(TpVideoLogTransportationAreaInfo.video_code).filter(TpVideoLogTransportationAreaInfo.area == area).all()]
|
|
|
+ # video_list = video_list.filter(TpVideoLog.video_code.in_(lis))
|
|
|
+ if name:
|
|
|
+ video_list = video_list.filter(TpVideoLog.name.like(f'%{name}%'))
|
|
|
+ # 计算总条目数
|
|
|
+ total_items = video_list.count()
|
|
|
+ # 排序
|
|
|
+
|
|
|
+ video_list = video_list.order_by(TpVideoLog.video_code)
|
|
|
+ # 执行分页查询
|
|
|
+ # print(video_list.offset((page - 1) * pageSize).limit(pageSize))
|
|
|
+ if pageSize!=0:
|
|
|
+ video_list = video_list.offset((page - 1) * pageSize).limit(pageSize).all()
|
|
|
+ totalPages= (total_items + pageSize - 1) // pageSize
|
|
|
+ else:
|
|
|
+ pageSize = total_items
|
|
|
+ totalPages = 1
|
|
|
+ video_list = video_list.all()
|
|
|
+ result = []
|
|
|
+ # print(total_items,len(video_list),(page - 1) * pageSize,pageSize)
|
|
|
+ for video_info in video_list:
|
|
|
+ video_code = video_info.video_code
|
|
|
+ # video_type_label='其他'
|
|
|
+ longitude = 0
|
|
|
+ latitude = 0
|
|
|
+ area = '直辖市'
|
|
|
+ # video_type_li = db.query(TpVideoTag).filter(TpVideoTag.video_code == video_code,
|
|
|
+ # TpVideoTag.del_flag == '0').first()
|
|
|
+ # if video_type_li:
|
|
|
+ # query = db.query(SysDictData)
|
|
|
+ # query = query.filter(SysDictData.del_flag != '2')
|
|
|
+ # query = query.filter(SysDictData.dict_type == 'video_type')
|
|
|
+ # query = query.filter(SysDictData.dict_value == video_type_li.dict_value).first()
|
|
|
+ # if query:
|
|
|
+ # video_type_label = query.dict_label
|
|
|
+ if '茂名市交通运输局' in video_info.name:
|
|
|
+ video_base_info = db.query(TpVideoLogTransportationAreaInfo).filter(TpVideoLogTransportationAreaInfo.video_code==video_code).first()
|
|
|
+ if video_base_info:
|
|
|
+ longitude = video_base_info.longitude
|
|
|
+ latitude = video_base_info.latitude
|
|
|
+ area = video_base_info.area
|
|
|
+ else:
|
|
|
+ video_base_info = db.query(TpVideoBase).filter(
|
|
|
+ TpVideoBase.indexcode == video_code).first()
|
|
|
+ if video_base_info:
|
|
|
+ longitude = video_base_info.longitude
|
|
|
+ latitude = video_base_info.latitude
|
|
|
+ area = video_info.name
|
|
|
+ if '茂南' in area:
|
|
|
+ area = '茂南区'
|
|
|
+ elif '电白' in area:
|
|
|
+ area = '电白区'
|
|
|
+ elif '高州' in area:
|
|
|
+ area = '高州区'
|
|
|
+ elif '信宜' in area:
|
|
|
+ area = '信宜区'
|
|
|
+ elif '化州' in area:
|
|
|
+ area = '化州区'
|
|
|
+ result.append({"area":area,
|
|
|
+ "status":video_info.status,
|
|
|
+ "name":video_info.name,
|
|
|
+ "video_code":video_info.video_code_int,
|
|
|
+ # "video_type_label":video_type_label,
|
|
|
+ "longitude":longitude,
|
|
|
+ "latitude":latitude})
|
|
|
+
|
|
|
+
|
|
|
+ return {
|
|
|
+ "code": 200,
|
|
|
+ "msg": "成功",
|
|
|
+ "data": result,
|
|
|
+ 'total':total_items,
|
|
|
+ "page": page,
|
|
|
+ "pageSize": pageSize,
|
|
|
+ "totalPages": totalPages
|
|
|
+ }
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+
|
|
|
@router.get('/get_video_transportation_list')
|
|
|
async def get_video_forest_fire_list(
|
|
|
video_type:str = Query(None),
|
|
@@ -207,7 +313,7 @@ async def get_video_forest_fire_list(
|
|
|
longitude = video_base_info.longitude
|
|
|
latitude = video_base_info.latitude
|
|
|
area = video_base_info.area
|
|
|
- result.append({"area":area,"status":video_info.status,"name":video_info.name,"video_code":video_info.video_code,"video_type_label":video_type_label,"longitude":longitude,"latitude":latitude})
|
|
|
+ result.append({"area":area,"status":video_info.status,"name":video_info.name,"video_code":video_info.video_code_int,"video_type_label":video_type_label,"longitude":longitude,"latitude":latitude})
|
|
|
|
|
|
|
|
|
return {
|
|
@@ -271,7 +377,7 @@ async def get_video_forest_fire_list(
|
|
|
longitude = video_base_info.longitude
|
|
|
latitude = video_base_info.latitude
|
|
|
area = video_base_info.area
|
|
|
- result.append({"area":area,"status":video_info.status,"name":video_info.name,"video_code":video_info.video_code,"video_type_label":video_type_label,"longitude":longitude,"latitude":latitude})
|
|
|
+ result.append({"area":area,"status":video_info.status,"name":video_info.name,"video_code":video_info.video_code_int,"video_type_label":video_type_label,"longitude":longitude,"latitude":latitude})
|
|
|
|
|
|
|
|
|
return {
|