Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
U
unify_api2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chaonan
unify_api2
Commits
5c1c0772
Commit
5c1c0772
authored
Jul 05, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
3e5aea6a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
syncretize_energy_services.py
...modules/elec_charge/service/syncretize_energy_services.py
+21
-14
No files found.
unify_api/modules/elec_charge/service/syncretize_energy_services.py
View file @
5c1c0772
...
...
@@ -43,7 +43,7 @@ async def pv_evaluate_service(cid, start, end):
elif
(
pendulum_end
-
pendulum_start
)
.
in_months
()
>
12
:
return
success_res
(
code
=
4008
,
msg
=
"日期最多选择12个月"
)
else
:
p_datas
=
await
load_compy_power
(
cid
,
f
"{start}-01"
,
f
"{end}-{day_num}"
)
if
not
p_datas
:
...
...
@@ -65,10 +65,10 @@ async def pv_evaluate_service(cid, start, end):
kwh_slots
[
flag
]
.
append
(
num
)
num
=
data
[
"kwh"
]
flag
=
create_time
[
11
:
13
]
for
key
,
value
in
kwh_slots
.
items
():
kwh_slots
[
key
]
=
round
(
sum
(
value
)
/
len
(
value
),
2
)
if
value
else
""
# 获取峰时段
elec_price
=
await
get_elec_price_dao
(
cid
)
if
not
elec_price
:
...
...
@@ -110,7 +110,8 @@ async def pv_evaluate_compute_service(download=None, url=None, **body):
invest_capacity
=
total_capacity
*
body
.
get
(
"capacity_per_meter"
)
/
1000
if
not
invest_capacity
:
return
success_res
(
code
=
4008
,
msg
=
"场地面积/面积折算系数/单位面积容量不能为0"
)
return
success_res
(
code
=
4008
,
msg
=
"场地面积/面积折算系数/单位面积容量不能为0"
)
except
:
return
success_res
(
code
=
4008
,
msg
=
"工厂容器参数有误"
)
if
(
pendulum_end
-
pendulum_start
)
.
in_months
()
<
1
:
...
...
@@ -169,7 +170,7 @@ async def pv_evaluate_compute_service(download=None, url=None, **body):
"other_year_decay_rate"
:
0.008
,
# 4-25年衰减率
"annual_sunshine_hours"
:
annual_sunshine_hours
# 年峰值日照小数数
}
price
=
{
"rmb_per_wp"
:
body
.
get
(
"rmb_per_w"
),
# 建设单价
"maintenance_per_wp"
:
body
.
get
(
'maintenance_per_wp'
),
# 运维单价
...
...
@@ -254,7 +255,7 @@ async def ess_evaluate_service(cid, start, end, work_day):
else
:
elec_list
=
[
i
for
i
in
re
.
findall
(
"p*"
,
elec
[
"quarters"
])
if
i
]
rule
=
2
if
len
(
elec_list
)
>
1
else
1
p_datas
=
await
load_compy_power
(
cid
,
f
"{start}-01"
,
f
"{end}-{day_num}"
)
if
not
p_datas
:
...
...
@@ -349,7 +350,7 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
day_num
=
pendulum_end
.
days_in_month
except
:
return
success_res
(
code
=
4008
,
msg
=
"日期输入错误"
)
if
(
pendulum_end
-
pendulum_start
)
.
in_months
()
<
1
:
return
success_res
(
code
=
4008
,
msg
=
"日期最少选择2个月"
)
elif
(
pendulum_end
-
pendulum_start
)
.
in_months
()
>
12
:
...
...
@@ -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_price = {key: ";".join(value) for key, value in elec_prices.items() if value}
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
=
"该厂还未设置电价"
)
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):
max_demand_list
=
[
json
.
loads
(
demand
[
"has_space"
])
for
demand
in
max_demand
if
demand
[
"has_space"
]]
for
demand
in
max_demand_list
:
if
len
(
demand
)
==
0
:
continue
if
demand
[
0
]
and
max_demand_flag
is
False
:
max_demand_flag
=
True
max_demand_pmax
+=
demand
[
1
]
...
...
@@ -388,9 +392,9 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
p_slots
=
{
"
%02
d:
%02
d:00"
%
(
i
,
j
):
[]
for
i
in
range
(
24
)
for
j
in
range
(
0
,
60
,
15
)}
for
data
in
datas
:
create_time
=
data
[
"create_time"
]
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
# 1全部 2工作日 3非工作日
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
[
"p"
]:
p_slots
[
create_time
[
11
:
19
]]
.
append
(
...
...
@@ -457,7 +461,7 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
# "invest_income_rate": (15, 12, 10, 8, 6), #投资收益率
"loop_time"
:
5000
# 循环次数
}
obj
=
EssEvaluateTool
(
ess_system
,
price
,
max_demand_var
,
df_curve
)
obj
.
output
()
# 测算表
...
...
@@ -479,7 +483,7 @@ async def ess_evaluate_compute_service(download=None, url=None, **body):
load_bat_curve
=
curve
[
"load_bat_curve"
]
.
values
.
tolist
(),
)
ess_compute_table
=
evaluate_table
.
to_dict
(
"records"
)
return
EssEvaluateComputeResp
(
evaluate_table
=
opt_curve
,
ess_compute_table
=
ess_compute_table
,
...
...
@@ -531,7 +535,8 @@ async def electrovalence_setting_service(cid, price_md, price_tc, std_cos,
if
now_time
in
t
.
keys
():
print
(
now_time
)
print
(
t
)
return
success_res
(
code
=
400
,
msg
=
"电价配置信息有误,存在重叠时间"
)
return
success_res
(
code
=
400
,
msg
=
"电价配置信息有误,存在重叠时间"
)
t
[
now_time
]
=
elec
[
"name"
]
# 结束时间的分钟数不是0
elif
index
==
(
fina
-
1
)
and
end
[
1
]
!=
"00"
:
...
...
@@ -540,7 +545,8 @@ async def electrovalence_setting_service(cid, price_md, price_tc, std_cos,
if
now_time
in
t
.
keys
():
print
(
now_time
)
print
(
t
)
return
success_res
(
code
=
400
,
msg
=
"电价配置信息有误,存在重叠时间"
)
return
success_res
(
code
=
400
,
msg
=
"电价配置信息有误,存在重叠时间"
)
t
[
now_time
]
=
elec
[
"name"
]
else
:
for
j
in
range
(
0
,
60
,
15
):
...
...
@@ -548,7 +554,8 @@ async def electrovalence_setting_service(cid, price_md, price_tc, std_cos,
if
now_time
in
t
.
keys
():
print
(
now_time
)
print
(
t
)
return
success_res
(
code
=
400
,
msg
=
"电价配置信息有误,存在重叠时间"
)
return
success_res
(
code
=
400
,
msg
=
"电价配置信息有误,存在重叠时间"
)
t
[
now_time
]
=
elec
[
"name"
]
if
len
(
t
.
keys
())
!=
24
*
4
:
return
success_res
(
code
=
400
,
msg
=
"电价配置信息有误,缺少时间段"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment