|
@@ -15,83 +15,15 @@ from datetime import datetime
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
-# @router.get('/get_video_list_new')
|
|
|
-# async def get_video_url_by_id(
|
|
|
-# area_code :str = Query(None, description='区划编码'),
|
|
|
-# video_from :str = Query(None, description='视频来源'),
|
|
|
-# video_tag :str = Query(None, description='视频标签'),
|
|
|
-# video_name :str = Query(None, description='视频名称'),
|
|
|
-# longitude:float = Query(None, description='经度'),
|
|
|
-# latitude:float = Query(None, description='纬度'),
|
|
|
-# db: Session = Depends(get_db),
|
|
|
-# body=Depends(remove_xss_json),
|
|
|
-# user_id=Depends(valid_access_token),
|
|
|
-# page: int = Query(1, gt=0, description='页码'),
|
|
|
-# pageSize: int = Query(10, gt=0, description='每页条目数量')
|
|
|
-# ):
|
|
|
-# querystr = ''
|
|
|
-# if area_code:
|
|
|
-# querystr +=f"and gbIndexCode like '%{area_code}%'"
|
|
|
-# if video_from:
|
|
|
-# querystr +=f"and regionPath like '%{video_from}%'"
|
|
|
-# if video_name:
|
|
|
-# querystr +=f"and `name` like '%{video_name}%'"
|
|
|
-# if video_tag:
|
|
|
-# videoli = tag_get_video_tag_list(db, video_tag)
|
|
|
-# querystr +=f"and gbIndexCode in {videoli}"
|
|
|
-# if longitude is not None and latitude is not None:
|
|
|
-# location = f"""ST_Distance_Sphere(
|
|
|
-# ST_GeomFromText(CONCAT('POINT(', longitude, ' ', latitude, ')')),
|
|
|
-# ST_PointFromText('POINT({longitude} {latitude})'))"""
|
|
|
-# orddis = 'distance'
|
|
|
-# else:
|
|
|
-# location = 0
|
|
|
-# orddis = ''
|
|
|
-# videoIds = user_id_get_user_videoIds(db, user_id)
|
|
|
-# video_list = [i.video_code_int for i in videoIds]
|
|
|
-# if len(video_list)==0:
|
|
|
-# video = ''
|
|
|
-# else:
|
|
|
-# video = ""
|
|
|
-# for i in video_list:
|
|
|
-# video += f"WHEN '{i}' THEN 0 \n"
|
|
|
-#
|
|
|
-# video = f"""CASE video_code_int
|
|
|
-# {video}
|
|
|
-# ELSE 1
|
|
|
-# END """
|
|
|
-# if orddis != '' and video !='':
|
|
|
-# video += ','
|
|
|
-# sql = f"""SELECT T1.*,
|
|
|
-# {location} AS distance
|
|
|
-# FROM tp_video_info T1 where 1=1
|
|
|
-# ORDER BY {video} {orddis} """
|
|
|
-# totalsql = f'select count(*) from ({sql})t'
|
|
|
-# print(video_list)
|
|
|
-#
|
|
|
-# total_items = db.execute(totalsql).first()[0]
|
|
|
-#
|
|
|
-# lim = f"limit {pageSize*(page-1)}, {pageSize};"
|
|
|
-# videos = db.execute(sql+lim).fetchall()
|
|
|
-#
|
|
|
-# return {
|
|
|
-# "code": 200,
|
|
|
-# "msg": "操作成功",
|
|
|
-# "rows": videos,
|
|
|
-# "total": total_items,
|
|
|
-# "page": page,
|
|
|
-# "pageSize": pageSize,
|
|
|
-# "totalPages": (total_items + pageSize - 1) // pageSize
|
|
|
-# }
|
|
|
@router.get('/video_from')
|
|
|
async def get_dict_data_by_type(
|
|
|
db: Session = Depends(get_db),
|
|
|
body = Depends(remove_xss_json),
|
|
|
user_id = Depends(valid_access_token)
|
|
|
):
|
|
|
+ # 视频来源
|
|
|
try:
|
|
|
# 根据 dict_type 查询字典数据
|
|
|
- # dict_data = db.query(SysDictData).filter_by(dict_type=dictType).all()
|
|
|
query = db.query(TPVideoRegion)
|
|
|
|
|
|
# 添加查询条件
|
|
@@ -144,6 +76,7 @@ async def get_video_url_by_id(
|
|
|
page: int = Query(1, gt=0, description='页码'),
|
|
|
pageSize: int = Query(10, gt=0, description='每页条目数量')
|
|
|
):
|
|
|
+ # 大屏左下角视频及更多视频
|
|
|
try:
|
|
|
query = db.query(TPVideoInfo)
|
|
|
|
|
@@ -239,6 +172,7 @@ async def get_video_url_by_id(
|
|
|
page: int = Query(1, gt=0, description='页码'),
|
|
|
pageSize: int = Query(10, gt=0, description='每页条目数量')
|
|
|
):
|
|
|
+ # 用户视频排序
|
|
|
if longitude is not None and latitude is not None:
|
|
|
location = f"""ST_Distance_Sphere(
|
|
|
ST_GeomFromText(CONCAT('POINT(', longitude, ' ', latitude, ')')),
|
|
@@ -273,16 +207,6 @@ END """
|
|
|
|
|
|
lim = f"limit {pageSize*(page-1)}, {pageSize};"
|
|
|
videos = db.execute(sql+lim).all()
|
|
|
- # query = db.query(TpVideoLog)
|
|
|
- # total_items = query.count()
|
|
|
- #
|
|
|
- # query = query.order_by(
|
|
|
- # case(
|
|
|
- # [(TpVideoLog.video_code_int == video_code_int, 0) for video_code_int in video_list],
|
|
|
- # else_=1
|
|
|
- # )
|
|
|
- # )
|
|
|
- # videos = query.offset((page - 1) * pageSize).limit(pageSize).all()
|
|
|
video_list1 = []
|
|
|
for video in videos:
|
|
|
videoInfo = {
|
|
@@ -318,7 +242,7 @@ async def get_waterlogged_all_video_info(
|
|
|
page: int = Query(1, gt=0, description='页码'),
|
|
|
pageSize: int = Query(10, gt=0, description='每页条目数量'),
|
|
|
user_id=Depends(valid_access_token)):
|
|
|
-
|
|
|
+ # 雨窝点视频
|
|
|
try:
|
|
|
if radius is None:
|
|
|
radius=500
|
|
@@ -336,13 +260,6 @@ async def get_waterlogged_all_video_info(
|
|
|
SELECT indexcode,`name`,longitude,latitude
|
|
|
FROM tp_video_base where longitude is not null and latitude is not null and ({tj}) and `status`='ON'
|
|
|
) T limit {pageSize*(page-1)}, {pageSize}""")
|
|
|
- # ,
|
|
|
- # ST_Distance_Sphere(
|
|
|
- # ST_GeomFromText(CONCAT('POINT(', longitude, ' ', latitude, ')')),
|
|
|
- # ST_PointFromText('{location}')
|
|
|
- # )
|
|
|
- # AS
|
|
|
- # distance ,"distance":info.distance ORDER BY distance ASC
|
|
|
resutl=db.execute(sql).all()
|
|
|
|
|
|
print(3, datetime.now)
|
|
@@ -373,9 +290,6 @@ async def get_video_forest_fire_list(
|
|
|
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()]
|
|
|
- # sql = '''SELECT * FROM tp_video_log T1 LEFT JOIN (SELECT indexcode,longitude,latitude FROM `tp_video_base`where latitude>0) T2 on T1.video_code_int=T2.indexcode where 1=1 '''
|
|
|
sql = '''SELECT T1.`name`,IF(T1.`status`='在线',1,0) as `status`,T1.`video_code_int`as `video_code`,IFNULL(IFNULL(T3.longitude,T2.longitude),0) as longitude,IFNULL(IFNULL(T3.latitude,T2.latitude),0) as latitude,CASE
|
|
|
WHEN IFNULL(T3.area,T1.area) like '%高州%' THEN
|
|
|
'440981'
|
|
@@ -391,39 +305,17 @@ async def get_video_forest_fire_list(
|
|
|
'440900'
|
|
|
END
|
|
|
as area FROM tp_video_log T1 LEFT JOIN (SELECT indexcode,longitude,latitude FROM `tp_video_base`where latitude>0) T2 on T1.video_code_int=T2.indexcode LEFT JOIN tp_video_log_transportation_area_info T3 on T1.video_code_int=T3.video_code where 1=1 and T2.longitude>0 '''
|
|
|
- # video_list = db.query(TpVideoLog,TpVideoBase.longitude,TpVideoBase.latitude).join(
|
|
|
- # TpVideoBase,
|
|
|
- # TpVideoBase.indexcode == TpVideoLog.video_code,isouter=True
|
|
|
- # ).filter(TpVideoBase.longitude >0)
|
|
|
+
|
|
|
if video_type:
|
|
|
- # if video_type in video_type_list:
|
|
|
sql += f''' and T1.video_code_int in (select video_code from Tp_Video_Tag where del_flag ='0' and dict_value='{video_type}')'''
|
|
|
- # 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:
|
|
|
sql += f''' and T1.name like '%{name}%' '''
|
|
|
- # video_list = video_list.filter(TpVideoLog.name.like(f'%{name}%'))
|
|
|
# 计算总条目数
|
|
|
- # print(sql)
|
|
|
totalsql = f'select count(*) as ct from ({sql})t where longitude > 0'
|
|
|
- # print(totalsql)
|
|
|
-
|
|
|
- # total_items = video_list.count()
|
|
|
total_items = db.execute(totalsql).first().ct
|
|
|
# 排序
|
|
|
|
|
|
- # 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()
|
|
|
sql = f'''select * from ({sql} limit {pageSize*(page-1)}, {pageSize})t where longitude > 0 '''
|
|
|
video_list = db.execute(sql).all()
|
|
|
totalPages= (total_items + pageSize - 1) // pageSize
|
|
@@ -432,51 +324,10 @@ async def get_video_forest_fire_list(
|
|
|
totalPages = 1
|
|
|
video_list = db.execute(f"""select * from ({sql})t where longitude > 0 """).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 = None
|
|
|
- # latitude = None
|
|
|
- # 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.area:
|
|
|
- # 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.longitude,TpVideoBase.latitude).filter(
|
|
|
- # TpVideoBase.indexcode == video_code).first()
|
|
|
- # if video_base_info:
|
|
|
- # # longitude = video_base_info.longitude
|
|
|
- # # latitude = video_base_info.latitude
|
|
|
- # longitude,latitude = video_base_info
|
|
|
longitude = video_info.longitude
|
|
|
latitude = video_info.latitude
|
|
|
area = video_info.area
|
|
|
- # if '茂南' in area:
|
|
|
- # area = '茂南区'
|
|
|
- # elif '电白' in area:
|
|
|
- # area = '电白区'
|
|
|
- # elif '高州' in area:
|
|
|
- # area = '高州区'
|
|
|
- # elif '信宜' in area:
|
|
|
- # area = '信宜区'
|
|
|
- # elif '化州' in area:
|
|
|
- # area = '化州区'
|
|
|
- # else:
|
|
|
- # area = '直辖市'
|
|
|
- # if longitude:
|
|
|
result.append({"area":area,
|
|
|
"status":video_info.status,
|
|
|
"name":video_info.name,
|
|
@@ -576,6 +427,7 @@ async def get_video_forest_fire_list(
|
|
|
except Exception as e:
|
|
|
traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+
|
|
|
@router.get('/get_point_info_transportation_video')
|
|
|
@router.post('/get_point_info_transportation_video')
|
|
|
async def get_video_forest_fire_list(
|
|
@@ -651,7 +503,7 @@ async def get_dict_data_by_type(
|
|
|
# 根据 dict_type 查询字典数据
|
|
|
video_type_list = ['sjyld','sgdfd','jtdd','dzzhyhd']
|
|
|
query = db.query(SysDictData)
|
|
|
- query = query.filter(SysDictData.dict_type=='video_type')
|
|
|
+ query = query.filter(SysDictData.dict_type=='video_type_8')
|
|
|
query = query.filter(SysDictData.dict_value.in_(video_type_list))
|
|
|
query = query.filter(SysDictData.del_flag != '2')
|
|
|
query = query.order_by(SysDictData.dict_sort)
|
|
@@ -748,8 +600,6 @@ async def get_video_tag_info(
|
|
|
video_code:str = Query(None),
|
|
|
db: Session = Depends(get_db),
|
|
|
body=Depends(remove_xss_json),
|
|
|
- # page: int = Query(1, gt=0, description='页码'),
|
|
|
- # pageSize: int = Query(10, gt=0, description='每页条目数量'),
|
|
|
user_id=Depends(valid_access_token)
|
|
|
):
|
|
|
try:
|