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
9e9cc857
Commit
9e9cc857
authored
Apr 12, 2023
by
wang.wenrong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wwr' into 'develop'
anshiU See merge request
!12
parents
153e0c79
6c602d2a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
22 deletions
+32
-22
fine_monitor_pds.py
unify_api/modules/anshiu/procedures/fine_monitor_pds.py
+4
-4
fine_monitor_serv.py
unify_api/modules/anshiu/service/fine_monitor_serv.py
+1
-1
points.py
unify_api/modules/common/procedures/points.py
+3
-3
hardware_pds.py
unify_api/modules/product_info/procedures/hardware_pds.py
+24
-14
No files found.
unify_api/modules/anshiu/procedures/fine_monitor_pds.py
View file @
9e9cc857
...
@@ -9,9 +9,9 @@ async def get_location_by_ids(location_ids):
...
@@ -9,9 +9,9 @@ async def get_location_by_ids(location_ids):
根据location_id获取各项温度信息
根据location_id获取各项温度信息
'''
'''
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
sql
=
"select
id,item,type from location where
id in
%
s"
sql
=
"select
lid,item,ad_type from location where l
id in
%
s"
result
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
location_ids
),))
result
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
location_ids
),))
location_info
=
{
res
.
get
(
'id'
):
res
for
res
in
result
}
location_info
=
{
res
.
get
(
'
l
id'
):
res
for
res
in
result
}
return
location_info
return
location_info
...
@@ -21,8 +21,8 @@ async def get_threshold_by_location(location_ids, type='overResidualCurrent',
...
@@ -21,8 +21,8 @@ async def get_threshold_by_location(location_ids, type='overResidualCurrent',
根据location_id获取阈值
根据location_id获取阈值
'''
'''
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
sql
=
"select threshold from
alarm_setting where location_
id in
%
s "
\
sql
=
"select threshold from
soe_config_record where l
id in
%
s "
\
"and type =
%
s limit 1 "
"and
e
type =
%
s limit 1 "
settings
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
location_ids
),
type
))
settings
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
location_ids
),
type
))
if
settings
:
if
settings
:
return
settings
[
0
][
"threshold"
]
return
settings
[
0
][
"threshold"
]
...
...
unify_api/modules/anshiu/service/fine_monitor_serv.py
View file @
9e9cc857
...
@@ -25,7 +25,7 @@ async def get_adio_chart_data(location_group, location_info,
...
@@ -25,7 +25,7 @@ async def get_adio_chart_data(location_group, location_info,
start_timestamp
,
start_timestamp
,
end_timestamp
,
intervel
,
slots
):
end_timestamp
,
intervel
,
slots
):
'''
'''
获取环境(温度与漏电流)的曲线数据
获取环境(温度与漏电流)的曲线数据
todo:es获取liudianliu
'''
'''
# 工况标准,取其中一个漏电流阈值
# 工况标准,取其中一个漏电流阈值
...
...
unify_api/modules/common/procedures/points.py
View file @
9e9cc857
...
@@ -155,12 +155,12 @@ async def list_point(cid):
...
@@ -155,12 +155,12 @@ async def list_point(cid):
async
def
point_to_mid
(
points
):
async
def
point_to_mid
(
points
):
"""获取所有poin_id和mid对应关系"""
"""获取所有poin_id和mid对应关系"""
sql
=
"SELECT pid, m
id FROM change_meter_record
WHERE pid IN
%
s "
\
sql
=
"SELECT pid, m
tid FROM point
WHERE pid IN
%
s "
\
"order by pid,
start
_time"
"order by pid,
create
_time"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
change_meter_records
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
points
),))
change_meter_records
=
await
conn
.
fetchall
(
sql
,
args
=
(
tuple
(
points
),))
point_mid_map
=
{
point_mid_map
=
{
i
[
"pid"
]:
i
[
"mid"
]
for
i
in
change_meter_records
i
[
"pid"
]:
i
[
"m
t
id"
]
for
i
in
change_meter_records
}
}
point_mid
=
dict
(
filter
(
lambda
x
:
x
[
1
]
is
not
None
,
point_mid_map
.
items
()))
point_mid
=
dict
(
filter
(
lambda
x
:
x
[
1
]
is
not
None
,
point_mid_map
.
items
()))
return
point_mid
,
len
(
point_mid
)
return
point_mid
,
len
(
point_mid
)
...
...
unify_api/modules/product_info/procedures/hardware_pds.py
View file @
9e9cc857
...
@@ -49,7 +49,7 @@ async def get_user_hardware_info(company_id, page_num, page_size):
...
@@ -49,7 +49,7 @@ async def get_user_hardware_info(company_id, page_num, page_size):
points
=
[
point
for
point
in
points
if
point
[
"pid"
]
in
point_mid_map
]
points
=
[
point
for
point
in
points
if
point
[
"pid"
]
in
point_mid_map
]
meter_change_sql
=
(
meter_change_sql
=
(
"select pid, m
id from `change_meter_record` where pid in
%
s order by pid, start
_time"
"select pid, m
tid from `point` where pid in
%
s order by pid, create
_time"
)
)
meter_changes
=
[]
meter_changes
=
[]
if
point_ids
:
if
point_ids
:
...
@@ -59,21 +59,35 @@ async def get_user_hardware_info(company_id, page_num, page_size):
...
@@ -59,21 +59,35 @@ async def get_user_hardware_info(company_id, page_num, page_size):
for
i
in
meter_changes
:
for
i
in
meter_changes
:
point_meter_map
[
i
[
"pid"
]]
=
i
point_meter_map
[
i
[
"pid"
]]
=
i
meter_ids
=
[
i
[
"mid"
]
for
i
in
point_meter_map
.
values
()]
meter_ids
=
[
i
[
"m
t
id"
]
for
i
in
point_meter_map
.
values
()]
meters
,
meter_param_records
=
[],
[]
meters
,
meter_param_records
=
[],
[]
if
meter_ids
:
if
meter_ids
:
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
meter_sql
=
"select m
id, sid from `meter` where m
id in
%
s"
meter_sql
=
"select m
tid, sid from `monitor` where mt
id in
%
s"
meters
=
await
conn
.
fetchall
(
meter_sql
,
args
=
(
tuple
(
meter_ids
),))
meters
=
await
conn
.
fetchall
(
meter_sql
,
args
=
(
tuple
(
meter_ids
),))
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
meter_param_record_sql
=
"select mid, ptr, ctr, ctnum, voltage_side, vc, tc, bureau_number, td_type from `meter_param_record` where mid in
%
s order by mid, start_time"
meter_param_record_sql
=
"""SELECT
mtid,
ptr,
ctr,
ctnum,
voltage_side,
vc,
tc
FROM
`point`
WHERE
mtid IN
%
s
ORDER BY
mtid,
create_time"""
meter_param_records
=
await
conn
.
fetchall
(
meter_param_records
=
await
conn
.
fetchall
(
meter_param_record_sql
,
args
=
(
tuple
(
meter_ids
),)
meter_param_record_sql
,
args
=
(
tuple
(
meter_ids
),)
)
)
meter_map
=
{
m
[
"mid"
]:
m
for
m
in
meters
}
meter_map
=
{
m
[
"m
t
id"
]:
m
for
m
in
meters
}
meterparam_map
=
{
m
[
"mid"
]:
m
for
m
in
meter_param_records
}
meterparam_map
=
{
m
[
"m
t
id"
]:
m
for
m
in
meter_param_records
}
log
.
info
(
"meter_ids = {}"
.
format
(
meter_ids
))
log
.
info
(
"meter_ids = {}"
.
format
(
meter_ids
))
log
.
info
(
"meter_map = {}"
.
format
(
meter_map
))
log
.
info
(
"meter_map = {}"
.
format
(
meter_map
))
...
@@ -81,14 +95,14 @@ async def get_user_hardware_info(company_id, page_num, page_size):
...
@@ -81,14 +95,14 @@ async def get_user_hardware_info(company_id, page_num, page_size):
# 组装point_id和meter_param的对应关系
# 组装point_id和meter_param的对应关系
point_meterparam_map
=
defaultdict
(
dict
)
point_meterparam_map
=
defaultdict
(
dict
)
for
point_id
,
meter_change
in
point_meter_map
.
items
():
for
point_id
,
meter_change
in
point_meter_map
.
items
():
if
meter_change
[
"mid"
]
not
in
meterparam_map
:
if
meter_change
[
"m
t
id"
]
not
in
meterparam_map
:
log
.
warn
(
f
"m
id={meter_change['m
id']}沒有meter_param_records"
)
log
.
warn
(
f
"m
tid={meter_change['mt
id']}沒有meter_param_records"
)
continue
continue
point_meterparam_map
[
point_id
]
=
meterparam_map
[
meter_change
[
"mid"
]]
point_meterparam_map
[
point_id
]
=
meterparam_map
[
meter_change
[
"m
t
id"
]]
# 组装pid和meter的对应关系
# 组装pid和meter的对应关系
for
point_id
,
meter_change
in
point_meter_map
.
items
():
for
point_id
,
meter_change
in
point_meter_map
.
items
():
point_meter_map
[
point_id
]
=
meter_map
[
meter_change
[
"m
id"
]]
if
meter_change
[
"m
id"
]
else
{}
point_meter_map
[
point_id
]
=
meter_map
[
meter_change
[
"m
tid"
]]
if
meter_change
[
"mt
id"
]
else
{}
datas
=
[]
datas
=
[]
for
point
in
points
:
for
point
in
points
:
...
@@ -135,10 +149,6 @@ async def get_user_hardware_info(company_id, page_num, page_size):
...
@@ -135,10 +149,6 @@ async def get_user_hardware_info(company_id, page_num, page_size):
data
[
"inline_capacity"
]
=
meter_param
[
"tc"
]
data
[
"inline_capacity"
]
=
meter_param
[
"tc"
]
if
not
check_value_is_null
(
meter_param
[
"vc"
]):
if
not
check_value_is_null
(
meter_param
[
"vc"
]):
data
[
"rated_voltage"
]
=
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
)
datas
.
append
(
data
)
return
{
return
{
...
...
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