|
@@ -50,7 +50,7 @@ END """
|
|
|
video += ','
|
|
|
sql = f"""SELECT T1.indexcode,T2.`name`,T1.longitude,T1.latitude,
|
|
|
{location} AS distance,T2.area,T2.ip,T2.`status`,T2.status_lifetime,T2.record_status,T2.inspection_datetime,T2.video_code_int,T2.video_code
|
|
|
- FROM tp_video_base T1 RIGHT JOIN tp_video_log T2 on T1.indexcode=T2.video_code_int where T1.longitude is not NULL
|
|
|
+ FROM tp_video_base T1 RIGHT JOIN tp_video_log T2 on T1.indexcode=T2.video_code_int -- where T1.longitude is not NULL
|
|
|
ORDER BY {video} {orddis} """
|
|
|
totalsql = f'select count(*) from ({sql})t'
|
|
|
print(video_list)
|
|
@@ -161,12 +161,31 @@ async def get_video_forest_fire_list(
|
|
|
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=='茂名市视频数据共享管理平台')
|
|
|
+ # 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`,T1.`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
|
|
|
+ '高州市'
|
|
|
+ WHEN IFNULL(T3.area,T1.area) like '%信宜%' THEN
|
|
|
+ '信宜市'
|
|
|
+ WHEN IFNULL(T3.area,T1.area) like '%化州%' THEN
|
|
|
+ '化州市'
|
|
|
+ WHEN IFNULL(T3.area,T1.area) like '%茂南%' THEN
|
|
|
+ '茂南区'
|
|
|
+ WHEN IFNULL(T3.area,T1.area) like '%电白%' THEN
|
|
|
+ '电白区'
|
|
|
+ ELSE
|
|
|
+ '直辖市'
|
|
|
+ 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 '''
|
|
|
+ # 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:
|
|
|
-
|
|
|
- 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))
|
|
|
+ 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()]
|
|
@@ -175,29 +194,37 @@ async def get_video_forest_fire_list(
|
|
|
# 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}%'))
|
|
|
+ sql += f''' and T1.name like '%{name}%' '''
|
|
|
+ # video_list = video_list.filter(TpVideoLog.name.like(f'%{name}%'))
|
|
|
# 计算总条目数
|
|
|
- total_items = video_list.count()
|
|
|
+ # 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)
|
|
|
+ # 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()
|
|
|
+ # 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
|
|
|
else:
|
|
|
pageSize = total_items
|
|
|
totalPages = 1
|
|
|
- video_list = video_list.all()
|
|
|
+ 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 = 0
|
|
|
- latitude = 0
|
|
|
- area = '直辖市'
|
|
|
+ # 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:
|
|
@@ -207,33 +234,39 @@ async def get_video_forest_fire_list(
|
|
|
# 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 = '化州区'
|
|
|
+ # 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,
|
|
|
- "video_code":video_info.video_code_int,
|
|
|
+ "video_code":video_info.video_code,
|
|
|
# "video_type_label":video_type_label,
|
|
|
"longitude":longitude,
|
|
|
"latitude":latitude})
|