Commit 7129b651 authored by lcn's avatar lcn

bug修复

parent 56ab5c00
import pendulum
from pot_libs.settings import SETTING
from unify_api.constants import CST
from unify_api.modules.common.service.td_engine_service import \
get_td_engine_data
from unify_api.utils.taos_new import parse_td_columns
from unify_api.utils.taos_new import parse_td_columns, td3_tbl_compate
async def elec_current_data(mtids, cid):
res_map = {}
last_15min_time = pendulum.now(tz=CST).subtract(minutes=15).format(
"YYYY-MM-DD HH:mm:ss")
url = f"{SETTING.stb_url}db_electric?tz=Asia/Shanghai"
sql = f"""
select tbname,last_row(*) from electric_stb
where cpyid={cid}
group by tbname
"""
table_name = ["mt{}_ele".format(mtid) for mtid in mtids]
td_tables = td3_tbl_compate(table_name)
sql = f"select last_row(*) from electric_stb " \
f"where TBNAME IN {td_tables} and ts >= '{last_15min_time}' " \
f"group by tbname"
is_succ, results = await get_td_engine_data(url, sql)
if is_succ:
head = parse_td_columns(results)
......
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