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
354b291f
Commit
354b291f
authored
Jun 09, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
a2e7dd6a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
pttl_max.py
unify_api/modules/common/procedures/pttl_max.py
+7
-12
No files found.
unify_api/modules/common/procedures/pttl_max.py
View file @
354b291f
...
...
@@ -27,17 +27,12 @@ async def load_pttl_max(cid, start, end, point_id=None, inline_id=None):
# index = INDEX[date_type]
if
date_type
==
"day"
:
table_name
=
"point_15min_electric"
time_format
=
"
%%
Y-
%%
m-
%%
d
%%
H:00:00"
elif
date_type
==
"month"
:
table_name
=
"point_15min_electric"
time_format
=
"
%%
Y-
%%
m-
%%
d"
else
:
table_name
=
"point_1day_electric"
time_format
=
"
%%
Y-
%%
m"
sum_sql
=
f
"SELECT DATE_FORMAT(create_time, '{time_format}') time_date, "
\
f
"sum(pttl_max) pttl_max_sum FROM {table_name} WHERE "
\
sum_sql
=
f
"SELECT create_time, sum(pttl_max) pttl_max_sum "
\
f
"FROM {table_name} WHERE "
\
f
"pid in
%
s and create_time BETWEEN '{start}' and '{end}' "
\
f
"GROUP BY
time_date ORDER BY time_dat
e"
f
"GROUP BY
create_time ORDER BY create_tim
e"
async
with
MysqlUtil
()
as
conn
:
datas
=
await
conn
.
fetchall
(
sql
=
sum_sql
,
args
=
(
point_list
,))
# 最大需量
...
...
@@ -48,15 +43,15 @@ async def load_pttl_max(cid, start, end, point_id=None, inline_id=None):
mdp_max_value
=
data
[
"pttl_max_sum"
]
if
mdp_max_value
and
mdp_max_value
>
max_val
:
max_val
=
mdp_max_value
max_val_time
=
data
[
"
time_dat
e"
]
max_val_time
=
data
[
"
create_tim
e"
]
# 根据时间范围, 返回不同时间格式
if
max_val_time
:
if
date_type
==
"day"
:
max_val_time
=
str
(
max_val_time
)[
11
:
16
]
max_val_time
=
max_val_time
.
strftime
(
"
%
H:00"
)
elif
date_type
==
"month"
:
max_val_time
=
str
(
max_val_time
)[
5
:
10
]
max_val_time
=
max_val_time
.
strftime
(
"
%
m-
%
d"
)
else
:
max_val_time
=
str
(
max_val_time
)[:
7
]
max_val_time
=
max_val_time
.
strftime
(
"
%
Y-
%
m"
)
return
max_val
,
max_val_time
...
...
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