Commit f21859b9 authored by ZZH's avatar ZZH

fix anshiu read tdengine 2023-7-31

parent 744236c3
...@@ -8,24 +8,20 @@ from pot_libs.mysql_util.mysql_util import MysqlUtil ...@@ -8,24 +8,20 @@ from pot_libs.mysql_util.mysql_util import MysqlUtil
async def get_aiao_1min_dao(mtid, start_time, end_time): async def get_aiao_1min_dao(mtid, start_time, end_time):
# 查1min温度漏电流 # 查1min温度漏电流
sid_data = await get_sid_by_mtid_dao(mtid) sid_data = await get_sid_by_mtid_dao(mtid)
sid = sid_data['sid'].lower() sid_lower = sid_data["sid"].lower()
su_table = "new_adio_stb" td_mt_table = get_td_table_name("adio", mtid)
td_mt_table = get_td_table_name(su_table, mtid)
url = f"{SETTING.stb_url}db_adio" url = f"{SETTING.stb_url}db_adio"
# td的精度过高,采用 >= start and < end的形式查询 sql = f"select ts, temp1, temp2, temp3, temp4, residual_current " \
f"from db_adio.{td_mt_table} WHERE " \
sql = f"select last_row( ts, temp1, temp2, temp3, temp4, residual_current) " \
f"from adio_stb where TBNAME = '{td_mt_table}' and " \
f"ts >= '{start_time}' AND ts <'{end_time}' " \ f"ts >= '{start_time}' AND ts <'{end_time}' " \
f"Interval(60s) order by ts asc" f"order by ts asc"
is_succ, results = await get_td_engine_data(url, sql) is_succ, results = await get_td_engine_data(url, sql)
if not results: if not results:
su_table = "old_adio_stb" td_mt_table = f"s_{sid_lower}_a"
td_mt_table = get_td_table_name(su_table, sid) sql = f"select ts, temp1, temp2, temp3, temp4, residual_current " \
sql = f"select last_row( ts, temp1, temp2, temp3, temp4, residual_current) " \ f"from db_adio.{td_mt_table} WHERE " \
f"from adio_stb where TBNAME = '{td_mt_table}' and " \
f"ts >= '{start_time}' AND ts <'{end_time}' " \ f"ts >= '{start_time}' AND ts <'{end_time}' " \
f"Interval(60s) order by ts asc" f"order by ts asc"
is_succ, results = await get_td_engine_data(url, sql) is_succ, results = await get_td_engine_data(url, sql)
if not is_succ: if not is_succ:
raise BusinessException() raise BusinessException()
...@@ -112,24 +108,21 @@ async def get_point_1min_chart_dao(mtid, ctnum, start_time, end_time): ...@@ -112,24 +108,21 @@ async def get_point_1min_chart_dao(mtid, ctnum, start_time, end_time):
] ]
# 查1min温度漏电流 # 查1min温度漏电流
sid_data = await get_sid_by_mtid_dao(mtid) sid_data = await get_sid_by_mtid_dao(mtid)
sid = sid_data['sid'].lower() sid_lower = sid_data["sid"].lower()
su_table = "new_electric_stb" td_mt_table = get_td_table_name("electric", mtid)
td_mt_table = get_td_table_name(su_table, mtid)
url = f"{SETTING.stb_url}db_electric" url = f"{SETTING.stb_url}db_electric"
# td的精度过高,采用 >= start and < end的形式查询 # td的精度过高,采用 >= start and < end的形式查询
stats_items.insert(0, 'ts') stats_items.insert(0, 'ts')
sql = f"select last_row({','.join(stats_items)}) " \ sql = f"select {','.join(stats_items)} " \
f"from electric_stb where TBNAME = '{td_mt_table}' and " \ f"from db_electric.{td_mt_table} WHERE " \
f"ts >= '{start_time}' AND ts <'{end_time}' " \ f"ts >= '{start_time}' AND ts <'{end_time}' " \
f"Interval(60s) order by ts asc" f"order by ts asc"
is_succ, results = await get_td_engine_data(url, sql) is_succ, results = await get_td_engine_data(url, sql)
if not results: if not results:
su_table = "old_electric_stb" sql = f"select {','.join(stats_items)} " \
td_mt_table = get_td_table_name(su_table, sid) f"from db_electric.s_{sid_lower}_e WHERE " \
sql = f"select last_row( {','.join(stats_items)}) " \
f"from electric_stb where TBNAME = '{td_mt_table}' and " \
f"ts >= '{start_time}' AND ts <'{end_time}' " \ f"ts >= '{start_time}' AND ts <'{end_time}' " \
f"Interval(60s) order by ts asc" f"order by ts asc"
is_succ, results = await get_td_engine_data(url, sql) is_succ, results = await get_td_engine_data(url, sql)
if not is_succ: if not is_succ:
raise BusinessException() raise BusinessException()
......
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