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
8441b0f6
Commit
8441b0f6
authored
Jul 06, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
e4a663a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
load_forecast_dao.py
unify_api/modules/load_analysis/dao/load_forecast_dao.py
+6
-2
load_forecast_service.py
...pi/modules/load_analysis/service/load_forecast_service.py
+6
-9
No files found.
unify_api/modules/load_analysis/dao/load_forecast_dao.py
View file @
8441b0f6
...
@@ -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
...
...
unify_api/modules/load_analysis/service/load_forecast_service.py
View file @
8441b0f6
...
@@ -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,获取预测数据
...
...
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