scope_operations_pds.py 914 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
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):
peng.xiaozhe's avatar
peng.xiaozhe committed
19
    """获取录波报警信息"""
20 21 22 23 24 25 26 27 28 29
    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 {}