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
e57796df
Commit
e57796df
authored
Jul 27, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
1602e4f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
load_forecast_service.py
...pi/modules/load_analysis/service/load_forecast_service.py
+16
-12
No files found.
unify_api/modules/load_analysis/service/load_forecast_service.py
View file @
e57796df
...
@@ -23,15 +23,15 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
...
@@ -23,15 +23,15 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
time_fmt
=
"
%%
Y-
%%
m"
time_fmt
=
"
%%
Y-
%%
m"
now_time_fmt
=
"YYYY-MM"
now_time_fmt
=
"YYYY-MM"
tbl_name
=
"company_1day_power"
tbl_name
=
"company_1day_power"
now_time
=
pendulum
.
now
()
.
format
(
now_time_fmt
)
now_time
=
pendulum
.
now
()
.
format
(
now_time_fmt
)
now_month
=
pendulum
.
now
()
.
format
(
"YYYY-MM"
)
now_month
=
pendulum
.
now
()
.
format
(
"YYYY-MM"
)
# 1,获取实际数据
# 1,获取实际数据
real_result
=
await
get_kwh_p_dao
(
cids
,
s_time
,
e_time
,
tbl_name
,
time_fmt
)
real_result
=
await
get_kwh_p_dao
(
cids
,
s_time
,
e_time
,
tbl_name
,
time_fmt
)
# if not real_result:
# if not real_result:
# return [], [], [], [], [], [], [], 0, "", 0, "", 0, 0
# return [], [], [], [], [], [], [], 0, "", 0, "", 0, 0
real_data
=
{
i
[
"cal_time"
]:
i
for
i
in
real_result
}
real_data
=
{
i
[
"cal_time"
]:
i
for
i
in
real_result
}
real_list
,
real_power_list
=
[],
[]
real_list
,
real_power_list
=
[],
[]
for
slot
in
slots
:
for
slot
in
slots
:
...
@@ -51,7 +51,7 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
...
@@ -51,7 +51,7 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
value
,
kwh
=
""
,
""
value
,
kwh
=
""
,
""
real_list
.
append
(
value
)
real_list
.
append
(
value
)
real_power_list
.
append
(
kwh
)
real_power_list
.
append
(
kwh
)
# 2,获取预测数据
# 2,获取预测数据
forecast_result
=
await
get_pred_p_dao
(
cids
,
s_time
,
e_time
,
time_fmt
)
forecast_result
=
await
get_pred_p_dao
(
cids
,
s_time
,
e_time
,
time_fmt
)
# if not forecast_result:
# if not forecast_result:
...
@@ -76,7 +76,7 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
...
@@ -76,7 +76,7 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
else
:
else
:
power_value
=
""
power_value
=
""
forecast_power_list
.
append
(
power_value
)
forecast_power_list
.
append
(
power_value
)
# 3.求偏差数据
# 3.求偏差数据
deviation_list
,
deviation_power_list
=
[],
[]
# 偏差取绝对值, 最大/最小/平均偏差都是绝对值后数据
deviation_list
,
deviation_power_list
=
[],
[]
# 偏差取绝对值, 最大/最小/平均偏差都是绝对值后数据
for
num
,
value
in
enumerate
(
real_list
):
for
num
,
value
in
enumerate
(
real_list
):
...
@@ -86,7 +86,7 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
...
@@ -86,7 +86,7 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
# (预测-实际)/实际 * 100%
# (预测-实际)/实际 * 100%
deviation
=
(
forecast_list
[
num
]
-
value
)
/
value
deviation
=
(
forecast_list
[
num
]
-
value
)
/
value
deviation_list
.
append
(
abs
(
round
(
deviation
,
4
)))
deviation_list
.
append
(
abs
(
round
(
deviation
,
4
)))
for
num
,
value
in
enumerate
(
real_power_list
):
for
num
,
value
in
enumerate
(
real_power_list
):
if
not
value
or
not
forecast_power_list
[
num
]:
if
not
value
or
not
forecast_power_list
[
num
]:
deviation_power
=
""
deviation_power
=
""
...
@@ -99,10 +99,10 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
...
@@ -99,10 +99,10 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
num
==
slots
.
index
(
now_time
):
num
==
slots
.
index
(
now_time
):
deviation_power
=
""
deviation_power
=
""
deviation_power_list
.
append
(
deviation_power
)
deviation_power_list
.
append
(
deviation_power
)
# 4,求偏差统计值
# 4,求偏差统计值
deviation_list_tmp
=
[
i
for
i
in
deviation_list
if
i
!=
""
]
deviation_list_tmp
=
[
i
for
i
in
deviation_list
if
i
!=
""
]
if
deviation_list_tmp
:
if
deviation_list_tmp
:
count
,
max_deviation
,
min_deviation
,
average
,
max_index
,
min_index
=
\
count
,
max_deviation
,
min_deviation
,
average
,
max_index
,
min_index
=
\
choose_list
(
deviation_list_tmp
,
4
)
choose_list
(
deviation_list_tmp
,
4
)
...
@@ -120,19 +120,23 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
...
@@ -120,19 +120,23 @@ async def load_forecast_srv(cids, s_time, e_time, interval, slots):
else
:
else
:
max_deviation
,
max_time
,
min_deviation
,
min_time
=
0
,
""
,
0
,
""
max_deviation
,
max_time
,
min_deviation
,
min_time
=
0
,
""
,
0
,
""
avg_deviation
,
total_deviation
=
0
,
0
avg_deviation
,
total_deviation
=
0
,
0
# 重置 slots
# 重置 slots
if
interval
==
15
*
60
:
if
interval
==
15
*
60
:
for
num
,
slot
in
enumerate
(
slots
):
for
num
,
slot
in
enumerate
(
slots
):
slot
=
pendulum
.
parse
(
slot
)
.
format
(
"HH:mm"
)
slot
=
pendulum
.
parse
(
slot
)
.
format
(
"HH:mm"
)
slots
[
num
]
=
slot
slots
[
num
]
=
slot
elif
interval
==
86400
:
for
num
,
slot
in
enumerate
(
slots
):
slot
=
pendulum
.
parse
(
slot
)
.
format
(
"MM-DD"
)
slots
[
num
]
=
slot
return
ForecastResp
(
return
ForecastResp
(
pred_data
=
LoadValue
(
slots
=
slots
,
value
=
forecast_list
),
pred_data
=
LoadValue
(
slots
=
slots
,
value
=
forecast_list
),
real_data
=
LoadValue
(
slots
=
slots
,
value
=
real_list
),
real_data
=
LoadValue
(
slots
=
slots
,
value
=
real_list
),
deviation_list
=
deviation_list
,
deviation_list
=
deviation_list
,
max_deviation
=
[
max_deviation
,
max_time
],
max_deviation
=
[
max_deviation
,
max_time
],
min_deviation
=
[
min_deviation
,
min_time
],
min_deviation
=
[
min_deviation
,
min_time
],
avg_deviation
=
avg_deviation
,
avg_deviation
=
avg_deviation
,
total_deviation
=
total_deviation
,
total_deviation
=
total_deviation
,
real_power_list
=
LoadValue
(
slots
=
slots
,
value
=
real_power_list
),
real_power_list
=
LoadValue
(
slots
=
slots
,
value
=
real_power_list
),
...
...
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