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
3e5aea6a
Commit
3e5aea6a
authored
Jul 05, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
3f4da3fe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
68 deletions
+32
-68
data_es_dao.py
unify_api/modules/zhiwei_u/dao/data_es_dao.py
+3
-39
scope_operations_pds.py
...y_api/modules/zhiwei_u/procedures/scope_operations_pds.py
+29
-29
No files found.
unify_api/modules/zhiwei_u/dao/data_es_dao.py
View file @
3e5aea6a
...
...
@@ -59,6 +59,7 @@ async def get_search_scope(cid, pid, start, end):
f
"event_datetime >= '{start}' and event_datetime <='{end}' "
)
where_str
=
" and "
.
join
(
where_list
)
sql
=
f
"select * from point_1min_event where {where_str} "
\
f
"and event_mode='scope' "
\
f
"ORDER BY event_datetime desc limit 5000"
async
with
MysqlUtil
()
as
conn
:
if
cid
:
...
...
@@ -141,46 +142,9 @@ async def get_scope_pids(pids, start, end):
f
"event_datetime<={end}"
else
:
where_str
=
f
"pid in {pids}"
sql
=
f
"select * from point_1min_event where {where_str} "
\
sql
=
f
"select * from point_1min_event where {where_str} and "
\
f
"event_mode='scope' "
\
f
"ORDER BY event_datetime desc limit 5000"
async
with
MysqlUtil
()
as
conn
:
data
=
await
conn
.
fetchall
(
sql
)
return
data
async
def
query_search_scope_pids
(
pids
,
page_num
,
page_size
,
start
,
end
):
query_body
=
{
"from"
:
(
page_num
-
1
)
*
page_size
,
"size"
:
page_size
,
"query"
:
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"mode.keyword"
:
"scope"
}},
{
"terms"
:
{
"point_id"
:
pids
}}
]
}
},
"sort"
:
[
{
"datetime"
:
{
"order"
:
"desc"
}
}
]
}
if
start
and
end
:
start_es
=
convert_es_str
(
start
)
end_es
=
convert_es_str
(
end
)
query_body
[
"query"
][
"bool"
][
"must"
]
.
append
(
{
"range"
:
{
"datetime"
:
{
"gte"
:
start_es
,
"lte"
:
end_es
}
}
}
)
async
with
EsUtil
()
as
es
:
es_re
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
SCOPE_DATABASE
)
return
es_re
unify_api/modules/zhiwei_u/procedures/scope_operations_pds.py
View file @
3e5aea6a
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
async
def
get_event_info_by_event_id
(
event_id
):
"""获取报警信息"""
sql
=
f
"""
SELECT
mtid, name, pid point_id, UNIX_TIMESTAMP(event_datetime) time,
cid, message, event_datetime datetime
FROM point_1min_event
WHERE
event_id = "{event_id}"
"""
async
with
MysqlUtil
()
as
conn
:
data
=
await
conn
.
fetchone
(
sql
)
return
data
if
data
else
{}
async
def
get_scope_info_pds
(
mtid
,
create_time
):
"""获取录波报警信息"""
sql
=
f
"""
SELECT
fault_type, create_time datetime, index_loc result, url context_url
FROM point_1min_scope
WHERE mtid = "{mtid}"
AND create_time = "{create_time}"
"""
async
with
MysqlUtil
()
as
conn
:
data
=
await
conn
.
fetchone
(
sql
)
return
data
if
data
else
{}
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
async
def
get_event_info_by_event_id
(
event_id
):
"""获取报警信息"""
sql
=
f
"""
SELECT
mtid, name, pid point_id, UNIX_TIMESTAMP(event_datetime) time,
cid, message, event_datetime datetime
FROM point_1min_event
WHERE
id = "{event_id}"
"""
async
with
MysqlUtil
()
as
conn
:
data
=
await
conn
.
fetchone
(
sql
)
return
data
if
data
else
{}
async
def
get_scope_info_pds
(
mtid
,
create_time
):
"""获取录波报警信息"""
sql
=
f
"""
SELECT
fault_type, create_time datetime, index_loc result, url context_url
FROM point_1min_scope
WHERE mtid = "{mtid}"
AND create_time = "{create_time}"
"""
async
with
MysqlUtil
()
as
conn
:
data
=
await
conn
.
fetchone
(
sql
)
return
data
if
data
else
{}
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