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
21b257c1
Commit
21b257c1
authored
Jul 03, 2023
by
lcn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
d2c161bf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
72 deletions
+76
-72
list_point.py
unify_api/modules/common/views/list_point.py
+19
-17
electric_dao.py
unify_api/modules/electric/dao/electric_dao.py
+2
-3
count_info_pds.py
unify_api/modules/home_page/procedures/count_info_pds.py
+55
-52
No files found.
unify_api/modules/common/views/list_point.py
View file @
21b257c1
...
@@ -23,39 +23,41 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
...
@@ -23,39 +23,41 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
list_point
=
[]
list_point
=
[]
points
=
{}
points
=
{}
groups
=
{}
groups
=
{}
sql
=
"SELECT p.pid,p.mtid, p.name, p.add_to_company FROM point p "
\
"left join monitor m on p.mtid = m.mtid "
\
"left join monitor_reuse mr on p.mtid = mr.mtid "
\
"WHERE m.demolished = 0 and (p.cid=
%
s or mr.cid =
%
s) "
# 查询属于当前工厂下的监测点 + 其他工厂但是被复用到当前工厂的监测点
# 查询属于当前工厂下的监测点 + 其他工厂但是被复用到当前工厂的监测点
if
not
is_power_equipment
:
if
is_power_equipment
:
sql
=
"SELECT p.pid,p.mtid, p.name, p.add_to_company FROM point p "
\
"left join monitor_reuse m on p.mtid = m.mtid "
\
"WHERE p.cid=
%
s or m.cid =
%
s"
else
:
# 动力设备
# 动力设备
sql
=
"SELECT p.pid,p.mtid, p.name, p.add_to_company FROM point p "
\
sql
+=
" and m.is_power_equipment = 1 "
"left join monitor m on p.mtid = m.mtid "
\
"left join monitor_reuse mr on p.mtid = mr.mtid "
\
"WHERE m.demolished = 0 and m.is_power_equipment = 1 and ("
\
"p.cid=
%
s or mr.cid =
%
s)"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
result
=
await
conn
.
fetchall
(
sql
,
args
=
(
cid
,
cid
))
result
=
await
conn
.
fetchall
(
sql
,
args
=
(
cid
,
cid
))
if
not
result
:
return
ListPointResponse
(
points
=
list_point
,
inlines
=
[],
power_show_all
=
0
)
# 去调拆表的POINT
# 去调拆表的POINT
point_ids
=
[
point
[
"pid"
]
for
point
in
result
]
point_ids
=
[
point
[
"pid"
]
for
point
in
result
]
point_mid_map
,
point_count
=
await
point_to_mid
(
point_ids
)
point_mid_map
,
point_count
=
await
point_to_mid
(
point_ids
)
result
=
[
point
for
point
in
result
if
point
[
"pid"
]
in
point_mid_map
]
result
=
[
point
for
point
in
result
if
point
[
"pid"
]
in
point_mid_map
]
for
res
in
result
:
for
res
in
result
:
pid
=
res
.
get
(
"pid"
)
pid
=
res
.
get
(
"pid"
)
points
[
pid
]
=
res
points
[
pid
]
=
res
# 获取相应的mtid
# 获取相应的mtid
point_map_mtids
=
[
point
[
"mtid"
]
for
point
in
result
if
point_map_mtids
=
[
point
[
"mtid"
]
for
point
in
result
if
point
[
'pid'
]
in
point_mid_map
]
point
[
'pid'
]
in
point_mid_map
]
# 根据pid获取mtd
# 根据pid获取mtd
sql
=
"SELECT ln.lid, mr.`name` `group`, ln.item FROM location ln LEFT JOIN"
\
sql
=
"SELECT ln.lid, mr.`name` `group`, ln.item FROM location ln LEFT JOIN"
\
" monitor mr on ln.mtid = mr.mtid WHERE ( ln.cid=
%
s or ln.mtid in "
\
" monitor mr on ln.mtid = mr.mtid WHERE ( ln.cid=
%
s or ln.mtid in "
\
"
%
s ) and ln.`ad_type` in
%
s"
"
%
s ) and ln.`ad_type` in
%
s"
try
:
try
:
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
result
=
await
conn
.
fetchall
(
sql
,
args
=
(
result
=
await
conn
.
fetchall
(
sql
,
args
=
(
...
@@ -68,7 +70,7 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
...
@@ -68,7 +70,7 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
log
.
exception
(
e
)
return
ListPointResponse
()
.
db_error
()
return
ListPointResponse
()
.
db_error
()
for
pid
,
point_info
in
points
.
items
():
for
pid
,
point_info
in
points
.
items
():
name
=
point_info
.
get
(
"name"
)
name
=
point_info
.
get
(
"name"
)
add_to_company
=
point_info
[
"add_to_company"
]
add_to_company
=
point_info
[
"add_to_company"
]
...
@@ -80,7 +82,7 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
...
@@ -80,7 +82,7 @@ async def post_list_point(req, body: ListPointRequest) -> ListPointResponse:
comm_point
=
CommonPoint
(
name
=
name
,
point_id
=
pid
,
locations
=
locations
,
comm_point
=
CommonPoint
(
name
=
name
,
point_id
=
pid
,
locations
=
locations
,
add_to_company
=
add_to_company
)
add_to_company
=
add_to_company
)
list_point
.
append
(
comm_point
)
list_point
.
append
(
comm_point
)
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
sql
=
"SELECT inlid, `name` FROM inline WHERE cid=
%
s"
sql
=
"SELECT inlid, `name` FROM inline WHERE cid=
%
s"
inlines
=
await
conn
.
fetchall
(
sql
,
args
=
(
cid
,))
inlines
=
await
conn
.
fetchall
(
sql
,
args
=
(
cid
,))
...
...
unify_api/modules/electric/dao/electric_dao.py
View file @
21b257c1
...
@@ -75,12 +75,11 @@ async def get_elec_mtid_sid_by_cid(cid):
...
@@ -75,12 +75,11 @@ async def get_elec_mtid_sid_by_cid(cid):
async
def
load_add_to_compy_ids
(
cid
):
async
def
load_add_to_compy_ids
(
cid
):
if
not
isinstance
(
cid
,
(
list
,
tuple
)):
symbol
=
"in"
if
isinstance
(
cid
,
(
list
,
tuple
))
else
"="
cid
=
[
cid
]
db
=
SETTING
.
mysql_db
db
=
SETTING
.
mysql_db
sql
=
f
"SELECT monitor.mtid, monitor.sid FROM {db}.monitor "
\
sql
=
f
"SELECT monitor.mtid, monitor.sid FROM {db}.monitor "
\
f
"INNER JOIN {db}.point ON point.mtid=monitor.mtid "
\
f
"INNER JOIN {db}.point ON point.mtid=monitor.mtid "
\
f
"WHERE monitor.cid
in
%
s AND point.add_to_company=1 "
\
f
"WHERE monitor.cid
{symbol}
%
s AND point.add_to_company=1 "
\
f
"AND monitor.demolished=0;"
f
"AND monitor.demolished=0;"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
ids
=
await
conn
.
fetchall
(
sql
,
(
cid
,))
ids
=
await
conn
.
fetchall
(
sql
,
(
cid
,))
...
...
unify_api/modules/home_page/procedures/count_info_pds.py
View file @
21b257c1
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