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
c21ef2cd
Commit
c21ef2cd
authored
Apr 24, 2023
by
wang.wenrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
equipment-details-mysql
parent
14562472
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
62 deletions
+68
-62
common_dao.py
unify_api/modules/common/dao/common_dao.py
+4
-4
electric_util.py
unify_api/modules/electric/procedures/electric_util.py
+7
-18
equipment_operations_pds.py
...i/modules/zhiwei_u/procedures/equipment_operations_pds.py
+54
-37
equipment_operations_service.py
.../modules/zhiwei_u/service/equipment_operations_service.py
+3
-3
No files found.
unify_api/modules/common/dao/common_dao.py
View file @
c21ef2cd
...
...
@@ -126,12 +126,12 @@ async def monitor_point_storey_join_in(cid, page_num, page_size):
return
monitor_point_storey_list
async
def
meter_param_by_mid
(
mid
):
async
def
meter_param_by_mid
(
m
t
id
):
"""根据mid查询meter, 参数固定不要再增加"""
sql
=
"select ctr,ptr,ctnum,vc,tc,imax from
meter_param_record
"
\
"where m
id=
%
s order by start
_time desc limit 1"
sql
=
"select ctr,ptr,ctnum,vc,tc,imax from
point
"
\
"where m
tid=
%
s order by create
_time desc limit 1"
async
with
MysqlUtil
()
as
conn
:
meter_param_dic
=
await
conn
.
fetchone
(
sql
,
args
=
(
mid
,))
meter_param_dic
=
await
conn
.
fetchone
(
sql
,
args
=
(
m
t
id
,))
return
meter_param_dic
...
...
unify_api/modules/electric/procedures/electric_util.py
View file @
c21ef2cd
...
...
@@ -13,33 +13,22 @@ async def get_wiring_type(point_id):
:return: ctnum, mid
"""
ctnum
=
None
mid
=
None
m
t
id
=
None
if
not
point_id
:
log
.
error
(
"para error point_id:
%
s exception"
%
point_id
)
return
ctnum
,
mid
return
ctnum
,
m
t
id
# 根据point_id去change_meter_record查询最新的mid
sql
=
"SELECT mid FROM change_meter_record WHERE pid=
%
s "
\
"ORDER BY start_time DESC LIMIT 1"
sql
=
"SELECT mtid FROM point WHERE pid=
%
s "
async
with
MysqlUtil
()
as
conn
:
result
=
await
conn
.
fetchone
(
sql
,
args
=
(
point_id
,))
if
result
:
m
id
=
result
.
get
(
"m
id"
)
m
tid
=
result
.
get
(
"mt
id"
)
if
not
mid
:
return
ctnum
,
mid
# 2. 根据mid去meter_param_record查最新ctnum
sql
=
"SELECT ctnum FROM meter_param_record WHERE mid=
%
s "
\
"ORDER BY start_time DESC LIMIT 1"
async
with
MysqlUtil
()
as
conn
:
result
=
await
conn
.
fetchone
(
sql
,
args
=
(
mid
,))
if
result
:
ctnum
=
result
.
get
(
"ctnum"
)
return
ctnum
,
mid
if
not
mtid
:
return
ctnum
,
mtid
return
ctnum
,
mtid
async
def
get_wiring_type_new15
(
pid
):
...
...
unify_api/modules/zhiwei_u/procedures/equipment_operations_pds.py
View file @
c21ef2cd
...
...
@@ -10,42 +10,59 @@ from unify_api.constants import EVENT_TYPE_UNIT_MAP
async
def
alarm_setting_pds
(
pid
,
locations
):
"""获取报警设置"""
sql_point
=
"SELECT alarm_setting.id, alarm_setting.type, "
\
"event_type.name, event_type.importance, "
\
"threshold, duration, alarm_setting.enable "
\
"FROM alarm_setting INNER JOIN event_type "
\
"ON alarm_setting.`type`=event_type.`id` "
\
"WHERE point_id=
%
s"
sql_location
=
"SELECT location.item, "
\
"location.type as location_type, "
\
"alarm_setting.id, alarm_setting.type, "
\
"event_type.name, event_type.importance, "
\
"threshold, duration, alarm_setting.enable "
\
"FROM alarm_setting INNER JOIN event_type "
\
"ON alarm_setting.`type`=event_type.`id` "
\
"INNER JOIN location "
\
"on location.id=alarm_setting.location_id "
\
"WHERE location_id IN
%
s"
sql_point
=
f
"""
SELECT
sd.id,
sd.etype,
et.`NAME`,
sd.threshold,
sd.duration,
sd.importance,
sd.`enable`
FROM
soe_config_record sd
INNER JOIN event_type et ON sd.etype = et.e_type
WHERE
sd.pid =
%
s
"""
sql_location
=
"""
SELECT
ln.item,
ln.ad_type AS location_ytpe,
sd.id,
sd.etype,
et.`name`,
sd.importance,
sd.threshold,
sd.duration,
sd.`enable`
FROM
soe_config_record sd
INNER JOIN event_type et ON sd.etype = et.e_type
INNER JOIN location ln ON ln.lid = sd.lid
WHERE
sd.lid IN
%
s
"""
async
with
MysqlUtil
()
as
conn
:
res_point
=
await
conn
.
fetchall
(
sql_point
,
args
=
(
pid
,))
if
pid
else
{}
res_point
=
await
conn
.
fetchall
(
sql_point
,
args
=
(
pid
,))
if
pid
else
{}
res_location
=
await
conn
.
fetchall
(
sql_location
,
args
=
(
tuple
(
locations
)
,)
)
if
locations
else
{}
tuple
(
locations
)
),
)
if
locations
else
{}
alarm_list
=
[]
for
res
in
res_point
:
name
=
res
.
get
(
"name"
)
id_
=
res
.
get
(
"id"
)
threshold
=
res
.
get
(
"threshold"
)
duration
=
res
.
get
(
"duration"
)
enable
=
res
.
get
(
"enable"
)
event_type
=
res
.
get
(
"type"
)
name
=
res
.
get
(
"name"
,
""
)
id_
=
res
.
get
(
"id"
,
""
)
threshold
=
res
.
get
(
"threshold"
,
""
)
duration
=
res
.
get
(
"duration"
,
""
)
enable
=
res
.
get
(
"enable"
,
""
)
event_type
=
res
.
get
(
"type"
,
""
)
p_dic
=
{
"id"
:
id_
,
"type"
:
name
if
name
is
not
None
else
""
,
"threshold"
:
threshold
if
threshold
is
not
None
else
""
,
"duration"
:
duration
if
duration
is
not
None
else
""
,
"enable"
:
enable
if
enable
is
not
None
else
""
,
"type"
:
name
,
"threshold"
:
threshold
,
"duration"
:
duration
,
"enable"
:
enable
,
"unit"
:
EVENT_TYPE_UNIT_MAP
[
event_type
]
}
alarm_list
.
append
(
p_dic
)
...
...
@@ -53,16 +70,16 @@ async def alarm_setting_pds(pid, locations):
name
=
(
res
.
get
(
"item"
)
+
res
.
get
(
"name"
))
if
res
.
get
(
"item"
)
!=
"default"
else
res
.
get
(
"name"
),
id_
=
res
.
get
(
"id"
)
threshold
=
res
.
get
(
"threshold"
)
duration
=
res
.
get
(
"duration"
)
enable
=
res
.
get
(
"enable"
)
event_type
=
res
.
get
(
"type"
)
threshold
=
res
.
get
(
"threshold"
,
""
)
duration
=
res
.
get
(
"duration"
,
""
)
enable
=
res
.
get
(
"enable"
,
""
)
event_type
=
res
.
get
(
"type"
,
""
)
lo_dic
=
{
"id"
:
id_
,
"type"
:
name
if
name
is
not
None
else
""
,
"threshold"
:
threshold
if
threshold
is
not
None
else
""
,
"duration"
:
duration
if
duration
is
not
None
else
""
,
"enable"
:
enable
if
enable
is
not
None
else
""
,
"type"
:
name
,
"threshold"
:
threshold
,
"duration"
:
duration
,
"enable"
:
enable
,
"unit"
:
EVENT_TYPE_UNIT_MAP
[
event_type
]
}
alarm_list
.
append
(
lo_dic
)
...
...
unify_api/modules/zhiwei_u/service/equipment_operations_service.py
View file @
c21ef2cd
...
...
@@ -139,10 +139,10 @@ async def equipment_details_mysql_service(sid, mtid):
alarm_list
=
await
alarm_setting_pds
(
point_id
,
locations
)
# 2. 额定电压, 额定电流
ct
,
pt
,
rated_voltage
,
rated_current
=
""
,
""
,
""
,
""
ctnum
,
mid
=
await
get_wiring_type
(
point_id
)
ctnum
,
m
t
id
=
await
get_wiring_type
(
point_id
)
# 装置已安装逻辑:有mid且ptr、ctr有值
if
mid
:
meter_param_dic
=
await
meter_param_by_mid
(
mid
)
if
m
t
id
:
meter_param_dic
=
await
meter_param_by_mid
(
m
t
id
)
if
meter_param_dic
:
ct
=
meter_param_dic
.
get
(
"ctr"
)
ct
=
ct
if
ct
is
not
None
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