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
747aba6e
Commit
747aba6e
authored
Jun 29, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
2d16cd9d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
28 deletions
+19
-28
adio_dao.py
unify_api/modules/adio/dao/adio_dao.py
+3
-2
adio_card.py
unify_api/modules/adio/service/adio_card.py
+15
-25
analysis_result_service.py
...pi/modules/shidianu/procedures/analysis_result_service.py
+1
-1
No files found.
unify_api/modules/adio/dao/adio_dao.py
View file @
747aba6e
...
...
@@ -20,9 +20,10 @@ async def get_location_dao(lids):
return
location_info
async
def
get_location_15min_dao
(
lid
,
start
,
end
):
async
def
get_location_15min_dao
(
lid
,
start
,
end
,
table_name
=
"location_15min_aiao"
):
sql
=
f
"SELECT lid,value_max,value_max_time,value_avg,value_min,"
\
f
"value_min_time FROM
`location_15min_aiao`
WHERE lid =
%
s "
\
f
"value_min_time FROM
{table_name}
WHERE lid =
%
s "
\
f
"and create_time BETWEEN '{start}' and '{end}'"
async
with
MysqlUtil
()
as
conn
:
result
=
await
conn
.
fetchall
(
sql
,
args
=
(
lid
,))
...
...
unify_api/modules/adio/service/adio_card.py
View file @
747aba6e
...
...
@@ -6,6 +6,7 @@ import aioredis
from
pot_libs.aredis_util.aredis_utils
import
RedisClient
,
RedisUtils
from
pot_libs.settings
import
SETTING
from
pot_libs.utils
import
time_format
from
unify_api
import
constants
from
unify_api.constants
import
POINT_LEVEL_MAP
from
unify_api.modules.adio.components.adio
import
AdioIndex
...
...
@@ -116,21 +117,14 @@ async def post_adio_card_service(location_list, cid):
async
def
adio_index_service
(
location_group
,
start
,
end
):
redis_data
,
redis_key
=
await
get_location_15min_redis
(
location_group
,
start
,
end
)
if
redis_data
:
datas
=
redis_data
.
get
(
"data"
)
else
:
# # load location表信息
location_info
=
await
get_location_dao
(
location_group
)
tasks
=
[
get_location_15min_service
(
location_info
,
lid
,
start
,
end
)
for
lid
in
location_group
]
adio_index_result
=
await
asyncio
.
gather
(
*
tasks
)
datas
=
list
(
adio_index_result
)
# set to redis
await
RedisUtils
()
.
setex
(
redis_key
,
60
*
7
,
json
.
dumps
({
"data"
:
datas
}))
# # load location表信息
location_info
=
await
get_location_dao
(
location_group
)
intervel
,
_
=
time_format
.
time_pick_transf
(
start
,
end
)
tasks
=
[
get_location_15min_service
(
location_info
,
lid
,
start
,
end
,
intervel
)
for
lid
in
location_group
]
adio_index_result
=
await
asyncio
.
gather
(
*
tasks
)
datas
=
list
(
adio_index_result
)
adio_indexes
=
[]
for
data
in
datas
:
adio_index
=
AdioIndex
(
**
data
)
...
...
@@ -138,18 +132,14 @@ async def adio_index_service(location_group, start, end):
return
adio_indexes
async
def
get_location_15min_redis
(
location_group
,
start
,
end
):
redis_key_data
=
json
.
dumps
(
{
"group"
:
location_group
,
"start"
:
start
,
"end"
:
end
})
redis_key
=
hashlib
.
md5
(
redis_key_data
.
encode
())
.
hexdigest
()
redis_data
=
await
RedisUtils
()
.
get
(
redis_key
)
return
json
.
loads
(
redis_data
)
if
redis_data
else
{},
redis_key
async
def
get_location_15min_service
(
location_info
,
lid
,
start
,
end
):
async
def
get_location_15min_service
(
location_info
,
lid
,
start
,
end
,
intervel
):
value_max
,
value_min
,
value_avg
=
[],
[],
[]
value_max_time
,
value_min_time
=
[],
[]
datas
=
await
get_location_15min_dao
(
lid
,
start
,
end
)
if
intervel
==
24
*
3600
:
table_name
=
"location_1day_aiao"
else
:
table_name
=
"location_15min_aiao"
datas
=
await
get_location_15min_dao
(
lid
,
start
,
end
,
table_name
)
for
data
in
datas
:
value_max
.
append
(
data
.
get
(
"value_max"
))
value_min
.
append
(
data
.
get
(
"value_min"
))
...
...
unify_api/modules/shidianu/procedures/analysis_result_service.py
View file @
747aba6e
...
...
@@ -90,7 +90,7 @@ async def alarm_behavior_curve_service(point_id, req_date, product):
behavior_illegal_app
=
[]
if
behavior_res
:
for
i
in
behavior_res
:
tmp_dic
=
{
"name"
:
i
[
"
key
"
],
"value"
:
i
[
"doc_count"
]}
tmp_dic
=
{
"name"
:
i
[
"
appliance
"
],
"value"
:
i
[
"doc_count"
]}
behavior_illegal_app
.
append
(
tmp_dic
)
behavior_illegal_app
=
sorted
(
behavior_illegal_app
,
key
=
lambda
x
:
x
[
"value"
],
reverse
=
True
)
...
...
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