Commit 8441b0f6 authored by lcn's avatar lcn

bug修复

parent e4a663a5
...@@ -15,7 +15,7 @@ async def get_kwh_p_dao(terms, start_time, end_time, ...@@ -15,7 +15,7 @@ async def get_kwh_p_dao(terms, start_time, end_time,
""" """
sql = f""" sql = f"""
select sum(p) p,count(*) p_count,DATE_FORMAT(create_time,"{time_fmt}") select sum(p) p,sum(kwh) kwh,DATE_FORMAT(create_time,"{time_fmt}")
as cal_time as cal_time
from {table_name} where cid in %s and create_time >= %s from {table_name} where cid in %s and create_time >= %s
and create_time <= %s group by cal_time and create_time <= %s group by cal_time
...@@ -35,8 +35,12 @@ async def get_pred_p_dao(terms, start_time, end_time, ...@@ -35,8 +35,12 @@ async def get_pred_p_dao(terms, start_time, end_time,
:param time_fmt: :param time_fmt:
:return: :return:
""" """
if time_fmt == "%%Y-%%m-%%d":
p_field = "avg(p)"
else:
p_field = "sum(p)"
sql = f""" sql = f"""
select sum(p) p ,count(*) p_count,DATE_FORMAT(create_time, select {p_field} p ,count(*) p_count,DATE_FORMAT(create_time,
"{time_fmt}") as cal_time "{time_fmt}") as cal_time
from company_day_ahead_predict from company_day_ahead_predict
where cid in %s and create_time >= %s and create_time <= %s where cid in %s and create_time >= %s and create_time <= %s
......
...@@ -37,22 +37,19 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots): ...@@ -37,22 +37,19 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
for slot in slots: for slot in slots:
if slot in real_data: if slot in real_data:
p = real_data[slot]["p"] p = real_data[slot]["p"]
kwh = real_data[slot]["kwh"]
if slot > now_time: if slot > now_time:
value = "" value, kwh = "", ""
elif p in [0, 0.0]: elif p in [0, 0.0]:
value = 0.0 value, kwh = 0.0, 0.0
elif p: elif p:
value = round(p, 2) value = round(p, 2)
kwh = round(kwh, 2)
else: else:
value = "" value, kwh = "", ""
else: else:
value = "" value, kwh = "", ""
real_list.append(value) real_list.append(value)
if value or value == 0.0:
p_count = real_data[slot]["p_count"]
kwh = round(value * 0.25 * p_count, 2)
else:
kwh = ""
real_power_list.append(kwh) real_power_list.append(kwh)
# 2,获取预测数据 # 2,获取预测数据
......
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