Commit 5c1c0772 authored by lcn's avatar lcn

bug修复

parent 3e5aea6a
...@@ -43,7 +43,7 @@ async def pv_evaluate_service(cid, start, end): ...@@ -43,7 +43,7 @@ async def pv_evaluate_service(cid, start, end):
elif (pendulum_end - pendulum_start).in_months() > 12: elif (pendulum_end - pendulum_start).in_months() > 12:
return success_res(code=4008, msg="日期最多选择12个月") return success_res(code=4008, msg="日期最多选择12个月")
else: else:
p_datas = await load_compy_power(cid, f"{start}-01", p_datas = await load_compy_power(cid, f"{start}-01",
f"{end}-{day_num}") f"{end}-{day_num}")
if not p_datas: if not p_datas:
...@@ -65,10 +65,10 @@ async def pv_evaluate_service(cid, start, end): ...@@ -65,10 +65,10 @@ async def pv_evaluate_service(cid, start, end):
kwh_slots[flag].append(num) kwh_slots[flag].append(num)
num = data["kwh"] num = data["kwh"]
flag = create_time[11:13] flag = create_time[11:13]
for key, value in kwh_slots.items(): for key, value in kwh_slots.items():
kwh_slots[key] = round(sum(value) / len(value), 2) if value else "" kwh_slots[key] = round(sum(value) / len(value), 2) if value else ""
# 获取峰时段 # 获取峰时段
elec_price = await get_elec_price_dao(cid) elec_price = await get_elec_price_dao(cid)
if not elec_price: if not elec_price:
...@@ -110,7 +110,8 @@ async def pv_evaluate_compute_service(download=None, url=None, **body): ...@@ -110,7 +110,8 @@ async def pv_evaluate_compute_service(download=None, url=None, **body):
invest_capacity = total_capacity * body.get( invest_capacity = total_capacity * body.get(
"capacity_per_meter") / 1000 "capacity_per_meter") / 1000
if not invest_capacity: if not invest_capacity:
return success_res(code=4008, msg="场地面积/面积折算系数/单位面积容量不能为0") return success_res(code=4008,
msg="场地面积/面积折算系数/单位面积容量不能为0")
except: except:
return success_res(code=4008, msg="工厂容器参数有误") return success_res(code=4008, msg="工厂容器参数有误")
if (pendulum_end - pendulum_start).in_months() < 1: if (pendulum_end - pendulum_start).in_months() < 1:
...@@ -169,7 +170,7 @@ async def pv_evaluate_compute_service(download=None, url=None, **body): ...@@ -169,7 +170,7 @@ async def pv_evaluate_compute_service(download=None, url=None, **body):
"other_year_decay_rate": 0.008, # 4-25年衰减率 "other_year_decay_rate": 0.008, # 4-25年衰减率
"annual_sunshine_hours": annual_sunshine_hours # 年峰值日照小数数 "annual_sunshine_hours": annual_sunshine_hours # 年峰值日照小数数
} }
price = { price = {
"rmb_per_wp": body.get("rmb_per_w"), # 建设单价 "rmb_per_wp": body.get("rmb_per_w"), # 建设单价
"maintenance_per_wp": body.get('maintenance_per_wp'), # 运维单价 "maintenance_per_wp": body.get('maintenance_per_wp'), # 运维单价
...@@ -254,7 +255,7 @@ async def ess_evaluate_service(cid, start, end, work_day): ...@@ -254,7 +255,7 @@ async def ess_evaluate_service(cid, start, end, work_day):
else: else:
elec_list = [i for i in re.findall("p*", elec["quarters"]) if i] elec_list = [i for i in re.findall("p*", elec["quarters"]) if i]
rule = 2 if len(elec_list) > 1 else 1 rule = 2 if len(elec_list) > 1 else 1
p_datas = await load_compy_power(cid, f"{start}-01", p_datas = await load_compy_power(cid, f"{start}-01",
f"{end}-{day_num}") f"{end}-{day_num}")
if not p_datas: if not p_datas:
...@@ -349,7 +350,7 @@ async def ess_evaluate_compute_service(download=None, url=None, **body): ...@@ -349,7 +350,7 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
day_num = pendulum_end.days_in_month day_num = pendulum_end.days_in_month
except: except:
return success_res(code=4008, msg="日期输入错误") return success_res(code=4008, msg="日期输入错误")
if (pendulum_end - pendulum_start).in_months() < 1: if (pendulum_end - pendulum_start).in_months() < 1:
return success_res(code=4008, msg="日期最少选择2个月") return success_res(code=4008, msg="日期最少选择2个月")
elif (pendulum_end - pendulum_start).in_months() > 12: elif (pendulum_end - pendulum_start).in_months() > 12:
...@@ -359,7 +360,8 @@ async def ess_evaluate_compute_service(download=None, url=None, **body): ...@@ -359,7 +360,8 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
elec_prices = await get_elec_price_dao(body.get("cid")) elec_prices = await get_elec_price_dao(body.get("cid"))
# elec_price = {key: ";".join(value) for key, value in elec_prices.items() if value} # elec_price = {key: ";".join(value) for key, value in elec_prices.items() if value}
if not elec_prices: if not elec_prices:
log.error(f"该厂还未设置电价, cid:{body.get('cid')}, table:price_policy") log.error(
f"该厂还未设置电价, cid:{body.get('cid')}, table:price_policy")
return success_res(code=4008, msg="该厂还未设置电价") return success_res(code=4008, msg="该厂还未设置电价")
section_time_range = get_section_time_range(elec_prices["quarters"]) section_time_range = get_section_time_range(elec_prices["quarters"])
# 获取工厂容量 # 获取工厂容量
...@@ -375,6 +377,8 @@ async def ess_evaluate_compute_service(download=None, url=None, **body): ...@@ -375,6 +377,8 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
max_demand_list = [json.loads(demand["has_space"]) max_demand_list = [json.loads(demand["has_space"])
for demand in max_demand if demand["has_space"]] for demand in max_demand if demand["has_space"]]
for demand in max_demand_list: for demand in max_demand_list:
if len(demand) == 0:
continue
if demand[0] and max_demand_flag is False: if demand[0] and max_demand_flag is False:
max_demand_flag = True max_demand_flag = True
max_demand_pmax += demand[1] max_demand_pmax += demand[1]
...@@ -388,9 +392,9 @@ async def ess_evaluate_compute_service(download=None, url=None, **body): ...@@ -388,9 +392,9 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
p_slots = {"%02d:%02d:00" % (i, j): [] for i in range(24) for j in p_slots = {"%02d:%02d:00" % (i, j): [] for i in range(24) for j in
range(0, 60, 15)} range(0, 60, 15)}
for data in datas: for data in datas:
create_time = data["create_time"].strftime("%Y-%m-%d %H:%M:%S")
# 1全部 2工作日 3非工作日 # 1全部 2工作日 3非工作日
if body.get("work_day") == "2": if body.get("work_day") == "2":
create_time = data["create_time"].strftime("%Y-%m-%d %H:%M:%S")
if ChineseCalendar(create_time[:10]).is_workday() and data[ if ChineseCalendar(create_time[:10]).is_workday() and data[
"p"]: "p"]:
p_slots[create_time[11:19]].append( p_slots[create_time[11:19]].append(
...@@ -457,7 +461,7 @@ async def ess_evaluate_compute_service(download=None, url=None, **body): ...@@ -457,7 +461,7 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
# "invest_income_rate": (15, 12, 10, 8, 6), #投资收益率 # "invest_income_rate": (15, 12, 10, 8, 6), #投资收益率
"loop_time": 5000 # 循环次数 "loop_time": 5000 # 循环次数
} }
obj = EssEvaluateTool(ess_system, price, max_demand_var, df_curve) obj = EssEvaluateTool(ess_system, price, max_demand_var, df_curve)
obj.output() obj.output()
# 测算表 # 测算表
...@@ -479,7 +483,7 @@ async def ess_evaluate_compute_service(download=None, url=None, **body): ...@@ -479,7 +483,7 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
load_bat_curve=curve["load_bat_curve"].values.tolist(), load_bat_curve=curve["load_bat_curve"].values.tolist(),
) )
ess_compute_table = evaluate_table.to_dict("records") ess_compute_table = evaluate_table.to_dict("records")
return EssEvaluateComputeResp( return EssEvaluateComputeResp(
evaluate_table=opt_curve, evaluate_table=opt_curve,
ess_compute_table=ess_compute_table, ess_compute_table=ess_compute_table,
...@@ -531,7 +535,8 @@ async def electrovalence_setting_service(cid, price_md, price_tc, std_cos, ...@@ -531,7 +535,8 @@ async def electrovalence_setting_service(cid, price_md, price_tc, std_cos,
if now_time in t.keys(): if now_time in t.keys():
print(now_time) print(now_time)
print(t) print(t)
return success_res(code=400, msg="电价配置信息有误,存在重叠时间") return success_res(code=400,
msg="电价配置信息有误,存在重叠时间")
t[now_time] = elec["name"] t[now_time] = elec["name"]
# 结束时间的分钟数不是0 # 结束时间的分钟数不是0
elif index == (fina - 1) and end[1] != "00": elif index == (fina - 1) and end[1] != "00":
...@@ -540,7 +545,8 @@ async def electrovalence_setting_service(cid, price_md, price_tc, std_cos, ...@@ -540,7 +545,8 @@ async def electrovalence_setting_service(cid, price_md, price_tc, std_cos,
if now_time in t.keys(): if now_time in t.keys():
print(now_time) print(now_time)
print(t) print(t)
return success_res(code=400, msg="电价配置信息有误,存在重叠时间") return success_res(code=400,
msg="电价配置信息有误,存在重叠时间")
t[now_time] = elec["name"] t[now_time] = elec["name"]
else: else:
for j in range(0, 60, 15): for j in range(0, 60, 15):
...@@ -548,7 +554,8 @@ async def electrovalence_setting_service(cid, price_md, price_tc, std_cos, ...@@ -548,7 +554,8 @@ async def electrovalence_setting_service(cid, price_md, price_tc, std_cos,
if now_time in t.keys(): if now_time in t.keys():
print(now_time) print(now_time)
print(t) print(t)
return success_res(code=400, msg="电价配置信息有误,存在重叠时间") return success_res(code=400,
msg="电价配置信息有误,存在重叠时间")
t[now_time] = elec["name"] t[now_time] = elec["name"]
if len(t.keys()) != 24 * 4: if len(t.keys()) != 24 * 4:
return success_res(code=400, msg="电价配置信息有误,缺少时间段") return success_res(code=400, msg="电价配置信息有误,缺少时间段")
......
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