Commit 744236c3 authored by ZZH's avatar ZZH

fix anshiu 2023-7-31

parent eda99d09
...@@ -66,36 +66,33 @@ async def get_search_scope(cid, pid, start, end, limit, offset): ...@@ -66,36 +66,33 @@ async def get_search_scope(cid, pid, start, end, limit, offset):
return data, total return data, total
async def query_search_scope(cid, pid, page_num, page_size, async def query_search_scope(cid, pids, page_num, page_size,
start_time, end_time, scope_g): start_time, end_time, scope_g):
""" """
查询录波列表 查询录波列表
""" """
if len(pid) > 1:
mtid = await get_mtids_by_pids_dao(pid)
else:
mtid = await get_mtid_by_pid_dao(pid)
where = "" where = ""
if cid: if len(pids) == 0:
where += f" and pe.cid={cid} " where += f" and pe.cid={cid} "
else:
mtids = await get_mtids_by_pids_dao(pids)
if len(mtids) == 1:
where += f" and pe.mtid={mtids[0]} "
else:
where += f" and pe.mtid in {tuple(mtids)} "
if start_time: if start_time:
where += f" and pt.event_datetime >= '{start_time}' " where += f" and pt.event_datetime >= '{start_time}' "
if end_time: if end_time:
where += f" and pe.create_time <= '{end_time}' " where += f" and pe.create_time <= '{end_time}' "
if mtid:
if len(mtid) == 1:
where += f" and pe.mtid = {mtid['mtid']} "
else:
where += f" and pe.mtid in {tuple(mtid)} "
if scope_g: if scope_g:
if len(scope_g) == 1: if len(scope_g) == 1:
where += f" AND pe.scope_g = {scope_g[0]} " where += f" AND pe.scope_g = {scope_g[0]} "
else: else:
where += f" AND pe.scope_g in {tuple(scope_g)} " where += f" AND pe.scope_g in {tuple(scope_g)} "
sql = f""" sql = f"""
SELECT SELECT
pt.event_id doc_id, pt.event_id doc_id,
...@@ -113,7 +110,7 @@ async def query_search_scope(cid, pid, page_num, page_size, ...@@ -113,7 +110,7 @@ async def query_search_scope(cid, pid, page_num, page_size,
ORDER BY ORDER BY
pe.create_time DESC pe.create_time DESC
LIMIT {page_num} , {page_size} """ LIMIT {page_num} , {page_size} """
total_sql = f""" total_sql = f"""
SELECT SELECT
count(*) total count(*) total
...@@ -126,10 +123,9 @@ async def query_search_scope(cid, pid, page_num, page_size, ...@@ -126,10 +123,9 @@ async def query_search_scope(cid, pid, page_num, page_size,
{where} {where}
""" """
async with MysqlUtil() as conn: async with MysqlUtil() as conn:
data = await conn.fetchall(sql, ) data = await conn.fetchall(sql, )
total = await conn.fetchone(total_sql) total = await conn.fetchone(total_sql)
return data, total return data, total
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment