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 {}
