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
41a6142d
Commit
41a6142d
authored
May 15, 2023
by
wang.wenrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备管理复用cid逻辑
parent
c473ef7a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
14 deletions
+27
-14
hardware_pds.py
unify_api/modules/product_info/procedures/hardware_pds.py
+27
-14
No files found.
unify_api/modules/product_info/procedures/hardware_pds.py
View file @
41a6142d
...
...
@@ -28,9 +28,12 @@ async def get_user_hardware_info(company_id, page_num, page_size):
# 1. 获取总的point数量
async
with
MysqlUtil
()
as
conn
:
point_sql_tmp
=
"select p.pid, p.name, p.create_time, p.update_time "
\
"from point p inner JOIN monitor c "
\
"on p.mtid = c.mtid where p.cid=
%
s and c.demolished=0"
points_tmp
=
await
conn
.
fetchall
(
sql
=
point_sql_tmp
,
args
=
(
company_id
,))
"from monitor c "
\
"left join point p on p.mtid = c.mtid "
\
"left join monitor_reuse m on m.mtid = c.mtid "
\
"where c.demolished=0 "
\
"and (p.cid =
%
s or m.cid =
%
s) "
points_tmp
=
await
conn
.
fetchall
(
sql
=
point_sql_tmp
,
args
=
(
company_id
,
company_id
))
point_ids_tmp
=
[
point
[
"pid"
]
for
point
in
points_tmp
]
# 拆表
point_mid_map_tmp
,
point_count
=
await
point_to_mid
(
point_ids_tmp
)
...
...
@@ -39,7 +42,7 @@ async def get_user_hardware_info(company_id, page_num, page_size):
offset
=
(
page_num
-
1
)
*
page_size
async
with
MysqlUtil
()
as
conn
:
point_sql
=
"select pid, name, create_time, update_time, position "
\
"from point where cid =
%
s
and
pid in
%
s "
\
"from point where cid =
%
s
or
pid in
%
s "
\
"limit
%
s offset
%
s"
points
=
await
conn
.
fetchall
(
sql
=
point_sql
,
args
=
(
company_id
,
tuple
(
point_id_tmp
),
page_size
,
offset
))
point_ids
=
[
point
[
"pid"
]
for
point
in
points
]
...
...
@@ -149,6 +152,10 @@ async def get_user_hardware_info(company_id, page_num, page_size):
data
[
"inline_capacity"
]
=
meter_param
[
"tc"
]
if
not
check_value_is_null
(
meter_param
[
"vc"
]):
data
[
"rated_voltage"
]
=
meter_param
[
"vc"
]
if
not
check_value_is_null
(
meter_param
[
"bureau_number"
]):
data
[
"belong_number"
]
=
meter_param
[
"bureau_number"
]
if
not
check_value_is_null
(
meter_param
[
"td_type"
]):
data
[
"device_type"
]
=
meter_param
[
"td_type"
]
datas
.
append
(
data
)
return
{
...
...
@@ -211,17 +218,22 @@ async def hardware_statistics(company_id):
#
# point_count = point_count_map["point_count"]
async
with
MysqlUtil
()
as
conn
:
point_sql
=
"select p.pid from point p inner JOIN monitor c "
\
"on p.mtid = c.mtid where p.cid =
%
s and "
\
"c.demolished=0"
points
=
await
conn
.
fetchall
(
sql
=
point_sql
,
args
=
(
company_id
,))
point_sql
=
"select p.pid from point p "
\
"left JOIN monitor c on p.mtid = c.mtid "
\
"left join monitor_reuse m on c.mtid = m.mtid "
\
"where c.demolished=0 and "
\
"(p.cid_belongedto =
%
s or m.cid=
%
s)"
points
=
await
conn
.
fetchall
(
sql
=
point_sql
,
args
=
(
company_id
,
company_id
))
point_ids
=
[
point
[
"pid"
]
for
point
in
points
]
mid_info
,
point_count
=
await
point_to_mid
(
point_ids
)
async
with
MysqlUtil
()
as
conn
:
inline_sql
=
"select count(*) as inline_count from inline where "
\
"cid =
%
s"
inline_count_map
=
await
conn
.
fetchone
(
sql
=
inline_sql
,
args
=
(
company_id
,))
"cid_belongedto =
%
s"
inline_count_map
=
await
conn
.
fetchone
(
sql
=
inline_sql
,
args
=
(
company_id
,))
inline_count
=
inline_count_map
[
"inline_count"
]
async
with
MysqlUtil
()
as
conn
:
...
...
@@ -229,12 +241,13 @@ async def hardware_statistics(company_id):
create_time_map
=
await
conn
.
fetchone
(
sql
=
time_sql
,
args
=
(
company_id
,))
create_time_timestamp
=
create_time_map
[
"create_time"
]
start_time
=
datetime
.
strftime
(
datetime
.
fromtimestamp
(
create_time_timestamp
),
"
%
Y-
%
m-
%
d
%
H:
%
M"
)
start_time
=
datetime
.
strftime
(
datetime
.
fromtimestamp
(
create_time_timestamp
),
"
%
Y-
%
m-
%
d
%
H:
%
M"
)
# power_capacity供电容量字段计算错误,改为inline表的tc_runtime字段相加
async
with
MysqlUtil
()
as
conn
:
capacity_sql
=
"select tc_runtime from inline where cid =
%
s"
capacity_list
=
await
conn
.
fetchall
(
sql
=
capacity_sql
,
args
=
(
company_id
,))
capacity_sql
=
"select tc_runtime from inline where cid_belongedto =
%
s"
capacity_list
=
await
conn
.
fetchall
(
sql
=
capacity_sql
,
args
=
(
company_id
,))
power_capacity
=
0
for
capacity
in
capacity_list
:
if
capacity
and
capacity
.
get
(
"tc_runtime"
):
...
...
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