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
9b02f7be
Commit
9b02f7be
authored
Aug 22, 2022
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug
parent
81c24bd9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
54 deletions
+90
-54
location_temp_rcurrent.py
...y_api/modules/common/procedures/location_temp_rcurrent.py
+2
-0
syncretize_energy_es_dao.py
...y_api/modules/elec_charge/dao/syncretize_energy_es_dao.py
+28
-0
syncretize_energy_services.py
...modules/elec_charge/service/syncretize_energy_services.py
+60
-54
No files found.
unify_api/modules/common/procedures/location_temp_rcurrent.py
View file @
9b02f7be
...
@@ -156,6 +156,8 @@ async def location_stats_statics_new15(table_name, cid, start, end):
...
@@ -156,6 +156,8 @@ async def location_stats_statics_new15(table_name, cid, start, end):
location_map
=
{}
location_map
=
{}
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
locations
=
await
conn
.
fetchall
(
sql
,
args
=
(
cid
,
))
locations
=
await
conn
.
fetchall
(
sql
,
args
=
(
cid
,
))
if
not
locations
:
return
location_map
for
loca
in
locations
:
for
loca
in
locations
:
location_map
[
loca
[
"lid"
]]
=
loca
location_map
[
loca
[
"lid"
]]
=
loca
datas_sql
=
f
"SELECT * from {table_name} where lid in
%
s and create_time"
\
datas_sql
=
f
"SELECT * from {table_name} where lid in
%
s and create_time"
\
...
...
unify_api/modules/elec_charge/dao/syncretize_energy_es_dao.py
View file @
9b02f7be
from
pot_libs.es_util.es_utils
import
EsUtil
from
pot_libs.es_util.es_utils
import
EsUtil
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
pot_libs.utils.pendulum_wrapper
import
my_pendulum
from
pot_libs.utils.pendulum_wrapper
import
my_pendulum
from
unify_api.utils.time_format
import
get_start_end_by_tz_time_new
def
convert_es_str
(
str1
:
object
)
->
object
:
def
convert_es_str
(
str1
:
object
)
->
object
:
...
@@ -64,6 +66,20 @@ async def query_search_kwh_p(cid, start, end, interval):
...
@@ -64,6 +66,20 @@ async def query_search_kwh_p(cid, start, end, interval):
return
es_re
[
"aggregations"
][
"quarter_time"
][
"buckets"
]
return
es_re
[
"aggregations"
][
"quarter_time"
][
"buckets"
]
async
def
query_search_kwh_p_new15
(
cid
,
start
,
end
):
start
,
_
=
get_start_end_by_tz_time_new
(
start
)
_
,
end
=
get_start_end_by_tz_time_new
(
end
)
sql
=
f
"""
select p,kwh,create_time from company_15min_power
where cid =
%
s and create_time BETWEEN
%
s and
%
s
order by create_time asc
"""
async
with
MysqlUtil
()
as
conn
:
datas
=
await
conn
.
fetchall
(
sql
=
sql
,
args
=
(
cid
,
start
,
end
))
return
datas
async
def
query_spfv_price
(
cid
,
start
,
end
):
async
def
query_spfv_price
(
cid
,
start
,
end
):
query_body
=
{
query_body
=
{
"query"
:
{
"query"
:
{
...
@@ -103,3 +119,15 @@ async def query_spfv_price(cid, start, end):
...
@@ -103,3 +119,15 @@ async def query_spfv_price(cid, start, end):
es_re
=
await
es
.
search_origin
(
body
=
query_body
,
es_re
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
"poweriot_company_15min_power"
)
index
=
"poweriot_company_15min_power"
)
return
es_re
[
"aggregations"
][
"charge"
][
"avg"
],
es_re
[
"aggregations"
][
"kwh"
][
"avg"
]
return
es_re
[
"aggregations"
][
"charge"
][
"avg"
],
es_re
[
"aggregations"
][
"kwh"
][
"avg"
]
async
def
query_spfv_price_new15
(
cid
,
start
,
end
):
start
,
_
=
get_start_end_by_tz_time_new
(
start
)
_
,
end
=
get_start_end_by_tz_time_new
(
end
)
sql
=
f
"""
select avg(charge) charge,avg(kwh) kwh from company_15min_power
where cid =
%
s and create_time BETWEEN
%
s and
%
s
"""
async
with
MysqlUtil
()
as
conn
:
data
=
await
conn
.
fetchone
(
sql
=
sql
,
args
=
(
cid
,
start
,
end
))
return
data
.
get
(
'charge'
,
0
),
data
.
get
(
'kwh'
,
0
)
unify_api/modules/elec_charge/service/syncretize_energy_services.py
View file @
9b02f7be
This diff is collapsed.
Click to expand it.
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