Commit 3e5aea6a authored by lcn's avatar lcn

bug修复

parent 3f4da3fe
......@@ -59,6 +59,7 @@ async def get_search_scope(cid, pid, start, end):
f"event_datetime >= '{start}' and event_datetime <='{end}' ")
where_str = " and ".join(where_list)
sql = f"select * from point_1min_event where {where_str} " \
f"and event_mode='scope' " \
f"ORDER BY event_datetime desc limit 5000"
async with MysqlUtil() as conn:
if cid:
......@@ -141,46 +142,9 @@ async def get_scope_pids(pids, start, end):
f"event_datetime<={end}"
else:
where_str = f"pid in {pids}"
sql = f"select * from point_1min_event where {where_str} " \
sql = f"select * from point_1min_event where {where_str} and " \
f"event_mode='scope' " \
f"ORDER BY event_datetime desc limit 5000"
async with MysqlUtil() as conn:
data = await conn.fetchall(sql)
return data
async def query_search_scope_pids(pids, page_num, page_size, start, end):
query_body = {
"from": (page_num - 1) * page_size,
"size": page_size,
"query": {
"bool": {
"must": [
{"term": {"mode.keyword": "scope"}},
{"terms": {"point_id": pids}}
]
}
},
"sort": [
{
"datetime": {
"order": "desc"
}
}
]
}
if start and end:
start_es = convert_es_str(start)
end_es = convert_es_str(end)
query_body["query"]["bool"]["must"].append(
{
"range": {
"datetime": {
"gte": start_es,
"lte": end_es
}
}
}
)
async with EsUtil() as es:
es_re = await es.search_origin(body=query_body, index=SCOPE_DATABASE)
return es_re
from pot_libs.mysql_util.mysql_util import MysqlUtil
async def get_event_info_by_event_id(event_id):
"""获取报警信息"""
sql = f"""
SELECT
mtid, name, pid point_id, UNIX_TIMESTAMP(event_datetime) time,
cid, message, event_datetime datetime
FROM point_1min_event
WHERE event_id = "{event_id}"
"""
async with MysqlUtil() as conn:
data = await conn.fetchone(sql)
return data if data else {}
async def get_scope_info_pds(mtid, create_time):
"""获取录波报警信息"""
sql = f"""
SELECT
fault_type, create_time datetime, index_loc result, url context_url
FROM point_1min_scope
WHERE mtid = "{mtid}"
AND create_time = "{create_time}"
"""
async with MysqlUtil() as conn:
data = await conn.fetchone(sql)
return data if data else {}
from pot_libs.mysql_util.mysql_util import MysqlUtil
async def get_event_info_by_event_id(event_id):
"""获取报警信息"""
sql = f"""
SELECT
mtid, name, pid point_id, UNIX_TIMESTAMP(event_datetime) time,
cid, message, event_datetime datetime
FROM point_1min_event
WHERE id = "{event_id}"
"""
async with MysqlUtil() as conn:
data = await conn.fetchone(sql)
return data if data else {}
async def get_scope_info_pds(mtid, create_time):
"""获取录波报警信息"""
sql = f"""
SELECT
fault_type, create_time datetime, index_loc result, url context_url
FROM point_1min_scope
WHERE mtid = "{mtid}"
AND create_time = "{create_time}"
"""
async with MysqlUtil() as conn:
data = await conn.fetchone(sql)
return data if data else {}
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