Commit e4a663a5 authored by lcn's avatar lcn

bug修复

parent 86b3998e
...@@ -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 avg(p) p,sum(kwh) kwh, DATE_FORMAT(create_time,"{time_fmt}") select sum(p) p,count(*) p_count,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
...@@ -36,7 +36,7 @@ async def get_pred_p_dao(terms, start_time, end_time, ...@@ -36,7 +36,7 @@ async def get_pred_p_dao(terms, start_time, end_time,
:return: :return:
""" """
sql = f""" sql = f"""
select avg(p) p ,count(*) p_count,DATE_FORMAT(create_time, select sum(p) 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,19 +37,22 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots): ...@@ -37,19 +37,22 @@ 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, kwh = "", "" value = ""
elif p in [0, 0.0]: elif p in [0, 0.0]:
value, kwh = 0.0, 0.0 value = 0.0
elif p: elif p:
value = round(p, 2) value = round(p, 2)
kwh = round(kwh, 2)
else: else:
value, kwh = "", "" value = ""
else: else:
value, kwh = "", "" value = ""
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