|
@@ -76,8 +76,13 @@ async def get_infos(
|
|
|
longitude_max = float(body['longitude_max'])
|
|
|
option = body['option'].split(',')
|
|
|
print("1",time.time())
|
|
|
- videos = get_videos(db,dict_value,latitude_min,latitude_max,longitude_min,longitude_max)
|
|
|
- infos = get_points(db,option,latitude_min,latitude_max,longitude_min,longitude_max)
|
|
|
+ iszjcj = ''
|
|
|
+ pac = ''
|
|
|
+ if 'iszjcj'in body:
|
|
|
+ iszjcj = body['iszjcj']
|
|
|
+ pac = body['pac']
|
|
|
+ videos = get_videos(db,dict_value,latitude_min,latitude_max,longitude_min,longitude_max,iszjcj)
|
|
|
+ infos = get_points(db,option,latitude_min,latitude_max,longitude_min,longitude_max,iszjcj,pac)
|
|
|
# 动态分组逻辑
|
|
|
groups = group_points(videos+infos, distance_threshold)
|
|
|
|
|
@@ -208,7 +213,7 @@ def group_points(points, distance_threshold):
|
|
|
|
|
|
return groups
|
|
|
|
|
|
-def get_videos(db:Session,dict_value,latitude_min,latitude_max,longitude_min,longitude_max):
|
|
|
+def get_videos(db:Session,dict_value,latitude_min,latitude_max,longitude_min,longitude_max,iszjcj):
|
|
|
que = True
|
|
|
if len(dict_value)>0:
|
|
|
videolist = []
|
|
@@ -221,6 +226,9 @@ def get_videos(db:Session,dict_value,latitude_min,latitude_max,longitude_min,lon
|
|
|
videolist += [i.video_code for i in tag_get_video_tag_list(db, value)]
|
|
|
else:
|
|
|
que = TPVideoInfo.gbIndexCode.in_(videolist)
|
|
|
+ if iszjcj!='':
|
|
|
+
|
|
|
+ pass
|
|
|
# 查询分组
|
|
|
query = (
|
|
|
select(
|
|
@@ -250,13 +258,24 @@ def get_videos(db:Session,dict_value,latitude_min,latitude_max,longitude_min,lon
|
|
|
return videos
|
|
|
|
|
|
|
|
|
-def get_points(db:Session,option,latitude_min,latitude_max,longitude_min,longitude_max):
|
|
|
+def get_points(db:Session,option,latitude_min,latitude_max,longitude_min,longitude_max,iszjcj='',pac=''):
|
|
|
# 使用参数化查询避免 SQL 注入
|
|
|
if isinstance(option, list):
|
|
|
option = tuple(option)
|
|
|
- query = text("""
|
|
|
+ if iszjcj=='zj':
|
|
|
+ zd = ',T2.name as pacname,T2.pac,T2.parent_pac'
|
|
|
+ pac = pac[:6]
|
|
|
+ zjcjtable = f"""select * from tp_geojson_data_zj where parent_pac={pac}"""
|
|
|
+ que = f' JOIN ({zjcjtable}) T2 on ST_Intersects(T2.geometry, ST_SRID(POINT(A.longitude, A.latitude), 4326))'
|
|
|
+ elif iszjcj=='cj':
|
|
|
+ pac = pac[:9]
|
|
|
+ zjcjtable = f"""select * from tp_geojson_data_cj_sq where parent_pac={pac}"""
|
|
|
+ que = f'LEFT JOIN ({zjcjtable}) T2 on ST_Intersects(T2.geometry, ST_SRID(POINT(A.longitude, A.latitude), 4326))'
|
|
|
+ else:
|
|
|
+ que=''
|
|
|
+ query = text(f"""
|
|
|
SELECT
|
|
|
- A.`name`,A.`id`,A.dataType,A.longitude,A.latitude,A.infoType
|
|
|
+ A.`name`,A.`id`,A.dataType,A.longitude,A.latitude,A.infoType
|
|
|
FROM (
|
|
|
SELECT
|
|
|
*,
|
|
@@ -268,8 +287,8 @@ def get_points(db:Session,option,latitude_min,latitude_max,longitude_min,longitu
|
|
|
longitude > 0
|
|
|
AND latitude BETWEEN :latitude_min AND :latitude_max
|
|
|
AND longitude BETWEEN :longitude_min AND :longitude_max
|
|
|
- AND dataType IN :option
|
|
|
- ) AS A
|
|
|
+ AND dataType IN :option
|
|
|
+ ) AS A {que}
|
|
|
WHERE rn = 1
|
|
|
""")
|
|
|
|