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