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
1c7a8f73
Commit
1c7a8f73
authored
Jul 04, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
9e008873
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
14 deletions
+21
-14
linkage_control.py
unify_api/modules/linkage_control/views/linkage_control.py
+17
-14
scope_analyse_service.py
...pi/modules/scope_analyse/service/scope_analyse_service.py
+4
-0
No files found.
unify_api/modules/linkage_control/views/linkage_control.py
View file @
1c7a8f73
...
...
@@ -21,7 +21,8 @@ async def post_linkage_location(req, body: LinLocationReq) -> LinLocationResp:
"""联动控制,工厂所有开关监测点,group+item"""
cid
=
body
.
cid
# 1. 根据cid查出所有(location.group)
sql
=
"select * from location where cid =
%
s and ad_type =
%
s"
sql
=
"select l.*,m.name from location l left join monitor m on "
\
"l.mtid = m.mtid where l.cid =
%
s and l.ad_type =
%
s"
async
with
MysqlUtil
()
as
conn
:
loc_info
=
await
conn
.
fetchall
(
sql
=
sql
,
args
=
(
cid
,
"switch"
))
if
not
loc_info
:
...
...
@@ -50,9 +51,9 @@ async def post_linkage_location(req, body: LinLocationReq) -> LinLocationResp:
ll
=
LinkageLocation
()
ll
.
location_id
=
info
.
get
(
"id"
)
if
info
.
get
(
"item"
)
==
"default"
:
ll
.
name
=
info
.
get
(
"
group
"
)
ll
.
name
=
info
.
get
(
"
name
"
)
else
:
ll
.
name
=
info
.
get
(
"
group
"
)
+
"_"
+
info
.
get
(
"item"
)
ll
.
name
=
info
.
get
(
"
name
"
)
+
"_"
+
info
.
get
(
"item"
)
# 开关状态
val
=
await
RedisUtils
()
.
hget
(
ADIO_KEY
,
info
.
get
(
"id"
))
try
:
...
...
@@ -150,7 +151,7 @@ async def post_switch_record_list(req,
sql
=
"select lid from location where cid=
%
s"
locations
=
await
conn
.
fetchall
(
sql
,
args
=
(
cid
,))
location_list
=
[
l
[
"lid"
]
for
l
in
locations
]
if
not
location_list
:
return
SwitchRecordResp
(
total
=
0
,
rows
=
[])
page_num
=
body
.
page_num
...
...
@@ -160,16 +161,18 @@ async def post_switch_record_list(req,
end
=
body
.
end
# 1.查询联动控制记录表
sql_total
=
"SELECT count(*) from linkage_control_operation_record "
\
"where l
ocation_
id in
%
s"
"where lid in
%
s"
total_args
=
(
tuple
(
location_list
),)
if
start
and
end
:
sql_total
=
"SELECT count(*) from linkage_control_operation_record "
\
"where l
ocation_
id in
%
s and time >=
%
s and time <=
%
s"
"where lid in
%
s and time >=
%
s and time <=
%
s"
total_args
=
(
tuple
(
location_list
),
start
,
end
)
base_sql
=
"select lr.`time`,lr.`type`,lr.`action`,lr.location_id, "
\
"location.`ad_type` group,location.item, lr.user_id "
\
"from linkage_control_operation_record lr left join location "
\
"on lr.location_id = location.id where location_id in
%
s "
base_sql
=
"select lr.`time`,lr.`type`,lr.`action`,lr.lid, "
\
"location.`ad_type`,location.item, lr.user_id,m.name "
\
"from linkage_control_operation_record lr "
\
"left join location on lr.lid = location.lid "
\
"left join monitor m on location.mtid=m.mtid "
\
"where lr.lid in
%
s "
if
is_wechat
==
1
:
# 小程序端
sql
=
base_sql
+
"order by `time` desc limit 0, 20"
args
=
(
tuple
(
location_list
),)
...
...
@@ -183,7 +186,7 @@ async def post_switch_record_list(req,
"order by `time` desc limit
%
s,
%
s"
args
=
(
tuple
(
location_list
),
start
,
end
,
(
page_num
-
1
)
*
page_record_num
,
page_record_num
)
async
with
MysqlUtil
()
as
conn
:
total_res
=
await
conn
.
fetch_value
(
sql_total
,
args
=
total_args
)
db_result
=
await
conn
.
fetchall
(
sql
,
args
=
args
)
...
...
@@ -194,9 +197,9 @@ async def post_switch_record_list(req,
for
info
in
db_result
:
# location名
if
info
.
get
(
"item"
)
==
"default"
:
location
=
info
.
get
(
"
group
"
)
location
=
info
.
get
(
"
name
"
)
else
:
location
=
info
.
get
(
"
group
"
)
+
'_'
+
info
.
get
(
"item"
)
location
=
info
.
get
(
"
name
"
)
+
'_'
+
info
.
get
(
"item"
)
# 操作人
if
info
.
get
(
"user_id"
):
op_sql
=
"select name from linkage_control_authority "
\
...
...
@@ -216,7 +219,7 @@ async def post_switch_record_list(req,
sr
.
user
=
op_name
# 操作人
record_info
.
append
(
sr
)
return
SwitchRecordResp
(
total
=
total_res
if
total_res
<
10000
else
10000
,
total
=
total_res
,
rows
=
record_info
)
...
...
unify_api/modules/scope_analyse/service/scope_analyse_service.py
View file @
1c7a8f73
...
...
@@ -90,6 +90,10 @@ async def scope_analyse_service(pid, create_time):
for
k
,
v
in
context
.
items
():
context
[
k
]
=
[
value
if
not
math
.
isnan
(
value
)
else
''
for
value
in
v
]
if
"lc"
in
context
:
del
context
[
"lc"
]
if
"pttl"
in
context
:
del
context
[
"pttl"
]
except
Exception
as
e
:
log
.
error
(
f
"录波地址无效 url:{data['url']} message:{str(e)}"
)
return
success_res
(
code
=
RET
.
not_data
,
msg
=
"录波地址有误"
)
...
...
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