Commit 2fb841ab authored by lcn's avatar lcn

bug修复

parent 7129b651
......@@ -128,9 +128,7 @@ async def get_aiao_1min_pds(slots, temp_res_data, res_curr_th):
async def get_aiao_data_pds(slots, temp_res_data, res_curr_th):
temp, res, s_value, a_value, b_value, c_value, n_value = [], [], {
"item": "漏电流", "threhold": res_curr_th}, {"item": "A相"}, {
"item": "B相"}, {
"item": "C相"}, {
"item": "N相"}
"item": "B相"}, {"item": "C相"}, {"item": "N线"}
temp1, temp2, temp3, temp4, res_curr = {}, {}, {}, {}, {}
for i in temp_res_data:
......
......@@ -87,19 +87,19 @@ async def get_point_chart_data(point_id, date_start, date_end, intervel,
elec_data = await get_point_15min_chart_dao(mtid, stats_items,
date_start,
date_end)
power, i, u = await get_point_data_chart_pds(ctnum, slots, elec_data)
i, v, power = await get_point_data_chart_pds(ctnum, slots, elec_data)
elif intervel == 86400:
elec_data = await get_point_1day_chart_dao(mtid, stats_items,
date_start,
date_end)
power, i, u = await get_point_data_chart_pds(ctnum, slots, elec_data)
i, v, power = await get_point_data_chart_pds(ctnum, slots, elec_data)
else:
elec_data = await get_point_1min_chart_dao(mtid, ctnum, date_start,
date_end)
power, i, u = await get_point_1min_chart_pds(ctnum, slots, elec_data)
i, v, power = await get_point_1min_chart_pds(ctnum, slots, elec_data)
return power, i, u, ctnum
return power, i, v, ctnum
async def electric_index_list_service(mtid, start_time, end_time,
......
......@@ -5,12 +5,12 @@ 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, td3_tbl_compate
from unify_api.utils.time_format import get_15min_ago
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")
last_15min_time = get_15min_ago()
url = f"{SETTING.stb_url}db_electric?tz=Asia/Shanghai"
table_name = ["mt{}_ele".format(mtid) for mtid in mtids]
......
......@@ -24,6 +24,7 @@ from unify_api.modules.electric.components.electric import (
ElecIndexResponse, ElecIndex, EscResp, QcsResp, EclResp, QclResp,
)
from unify_api.utils.taos_new import parse_td_columns
from unify_api.utils.time_format import get_15min_ago
async def elec_current_storeys_service(storeys):
......@@ -587,9 +588,10 @@ async def elec_current_service(point_id):
raise BusinessException(
message="没有该监测点的monitor信息,请联系运维人员!")
mtid = meter_info["mtid"]
last_15min_time = get_15min_ago()
# 获取子表中的实时数据
url = f"{SETTING.stb_url}db_electric?tz=Asia/Shanghai"
sql = f"select last_row(*) from mt{mtid}_ele where pid={point_id}"
sql = f"select last_row(*) from mt{mtid}_ele where ts>='{last_15min_time}'"
is_succ, results = await get_td_engine_data(url, sql)
if not is_succ or not results or results.get("code") > 0:
return '', {}
......
......@@ -1487,3 +1487,7 @@ def get_time_diff(start, end):
end_f = my_pendulum.from_format(end, YMD_Hms)
diff = end_f.int_timestamp - start_f.int_timestamp
return diff
def get_15min_ago(time_fmt="YYYY-MM-DD HH:mm:ss"):
return my_pendulum.now(tz=CST).subtract(minutes=15).format(time_fmt)
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