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
9109ff15
Commit
9109ff15
authored
Jun 04, 2024
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hardware alarm set support mult lang 2024-06-04
parent
6f878baf
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
119 deletions
+156
-119
constants.py
unify_api/constants.py
+4
-2
alarm_setting.py
unify_api/modules/alarm_manager/views/alarm_setting.py
+22
-7
count_info_pds.py
unify_api/modules/home_page/procedures/count_info_pds.py
+72
-56
count_info.py
unify_api/modules/home_page/views/count_info.py
+26
-38
hardware_pds.py
unify_api/modules/product_info/procedures/hardware_pds.py
+22
-7
hardware_info.py
unify_api/modules/product_info/views/hardware_info.py
+10
-9
No files found.
unify_api/constants.py
View file @
9109ff15
...
@@ -733,14 +733,16 @@ PHASE_LINE_LANG = {
...
@@ -733,14 +733,16 @@ PHASE_LINE_LANG = {
"en_US"
:
"Phase B"
,
"en_US"
:
"Phase B"
,
"de_DE"
:
"Phase B"
"de_DE"
:
"Phase B"
},
},
"C相"
:
{
"C相"
:
{
"en_US"
:
"Phase C"
,
"en_US"
:
"Phase C"
,
"de_DE"
:
"Phase C"
"de_DE"
:
"Phase C"
},
},
"N线"
:
{
"N线"
:
{
"en_US"
:
"Neutral Line"
,
"en_US"
:
"Neutral Line"
,
"de_DE"
:
"N-Leitung"
"de_DE"
:
"N-Leitung"
},
},
"漏电流"
:
{
"en_US"
:
"Leakage current"
,
"de_DE"
:
"Elektrizität"
},
}
}
unify_api/modules/alarm_manager/views/alarm_setting.py
View file @
9109ff15
...
@@ -2,15 +2,12 @@
...
@@ -2,15 +2,12 @@
#
#
# Author:jing
# Author:jing
# Date: 2020/7/9
# Date: 2020/7/9
import
json
from
pot_libs.aiohttp_util.aiohttp_utils
import
AioHttpUtils
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
pot_libs.common.components.responses
import
Success
from
pot_libs.common.components.responses
import
Success
from
pot_libs.sanic_api
import
summary
,
examples
from
pot_libs.sanic_api
import
summary
,
examples
from
pot_libs.logger
import
log
from
pot_libs.logger
import
log
from
pot_libs.settings
import
SETTING
from
pot_libs.settings
import
SETTING
from
pot_libs.utils.exc_util
import
BusinessException
from
unify_api.constants
import
EVENT_TYPE_SYNC_DEVICE
,
RESIDUAL_CURRENT_OP
from
unify_api.constants
import
EVENT_TYPE_SYNC_DEVICE
,
RESIDUAL_CURRENT_OP
from
unify_api.modules.alarm_manager.components.alarm_setting
import
(
from
unify_api.modules.alarm_manager.components.alarm_setting
import
(
AlarmSettingUpdate
,
AlarmSettingUpdate
,
...
@@ -21,6 +18,9 @@ from unify_api.modules.alarm_manager.components.alarm_setting import (
...
@@ -21,6 +18,9 @@ from unify_api.modules.alarm_manager.components.alarm_setting import (
)
)
from
unify_api.modules.alarm_manager.service.alarm_setting_service
import
\
from
unify_api.modules.alarm_manager.service.alarm_setting_service
import
\
post_update_alarm_emq_service
post_update_alarm_emq_service
from
unify_api.modules.common.dao.common_dao
import
load_user_lang
from
unify_api.modules.common.procedures.multi_lang
import
load_e_type_name
from
unify_api.constants
import
PHASE_LINE_LANG
@
summary
(
'获取某监测点告警设置列表'
)
@
summary
(
'获取某监测点告警设置列表'
)
...
@@ -30,6 +30,7 @@ async def post_point_alarm_setting(req, body: PointAlarmSettingRequest) \
...
@@ -30,6 +30,7 @@ async def post_point_alarm_setting(req, body: PointAlarmSettingRequest) \
point_id
=
body
.
point_id
point_id
=
body
.
point_id
location_ids
=
body
.
location_ids
location_ids
=
body
.
location_ids
enable
=
body
.
enable
enable
=
body
.
enable
user_id
=
req
.
ctx
.
user_id
point_alarm_settings
=
[]
point_alarm_settings
=
[]
location_alarm_settings
=
[]
location_alarm_settings
=
[]
if
enable
in
(
0
,
1
):
if
enable
in
(
0
,
1
):
...
@@ -67,11 +68,18 @@ async def post_point_alarm_setting(req, body: PointAlarmSettingRequest) \
...
@@ -67,11 +68,18 @@ async def post_point_alarm_setting(req, body: PointAlarmSettingRequest) \
point_id
,))
if
point_id
else
{}
point_id
,))
if
point_id
else
{}
res_location
=
await
conn
.
fetchall
(
sql_location
,
args
=
(
res_location
=
await
conn
.
fetchall
(
sql_location
,
args
=
(
tuple
(
location_ids
),))
if
location_ids
else
{}
tuple
(
location_ids
),))
if
location_ids
else
{}
lang
=
await
load_user_lang
(
user_id
)
for
res
in
res_point
:
for
res
in
res_point
:
if
lang
!=
"zh_CN"
:
etype_name
=
load_e_type_name
(
res
.
get
(
"etype"
),
lang
)
else
:
etype_name
=
res
.
get
(
"name"
)
alarm_setting
=
AlarmSetting
(
alarm_setting
=
AlarmSetting
(
id
=
res
.
get
(
"id"
),
id
=
res
.
get
(
"id"
),
type
=
res
.
get
(
"etype"
),
type
=
res
.
get
(
"etype"
),
name
=
res
.
get
(
"name"
)
,
name
=
etype_name
,
level
=
res
.
get
(
"importance"
),
level
=
res
.
get
(
"importance"
),
threshold
=
res
.
get
(
"threshold"
),
threshold
=
res
.
get
(
"threshold"
),
duration
=
res
.
get
(
"duration"
,
None
),
duration
=
res
.
get
(
"duration"
,
None
),
...
@@ -80,11 +88,18 @@ async def post_point_alarm_setting(req, body: PointAlarmSettingRequest) \
...
@@ -80,11 +88,18 @@ async def post_point_alarm_setting(req, body: PointAlarmSettingRequest) \
point_alarm_settings
.
append
(
alarm_setting
)
point_alarm_settings
.
append
(
alarm_setting
)
for
res
in
res_location
:
for
res
in
res_location
:
item
,
name
=
res
.
get
(
"item"
),
res
.
get
(
"name"
)
if
lang
!=
"zh_CN"
:
etype_name
=
load_e_type_name
(
res
.
get
(
"etype"
),
lang
)
if
item
!=
"default"
:
item_lang
=
PHASE_LINE_LANG
.
get
(
item
,
""
)
etype_name
=
f
"{item_lang}{etype_name}"
else
:
etype_name
=
f
"{item}{name}"
if
item
!=
"default"
else
name
alarm_setting
=
AlarmSetting
(
alarm_setting
=
AlarmSetting
(
id
=
res
.
get
(
"id"
),
id
=
res
.
get
(
"id"
),
type
=
res
.
get
(
"etype"
),
type
=
res
.
get
(
"etype"
),
name
=
(
res
.
get
(
"item"
)
+
res
.
get
(
"name"
))
if
res
.
get
(
name
=
etype_name
,
"item"
)
!=
"default"
else
res
.
get
(
"name"
),
level
=
res
.
get
(
"importance"
),
level
=
res
.
get
(
"importance"
),
threshold
=
res
.
get
(
"threshold"
),
threshold
=
res
.
get
(
"threshold"
),
duration
=
res
.
get
(
"duration"
,
None
),
duration
=
res
.
get
(
"duration"
,
None
),
...
@@ -94,7 +109,7 @@ async def post_point_alarm_setting(req, body: PointAlarmSettingRequest) \
...
@@ -94,7 +109,7 @@ async def post_point_alarm_setting(req, body: PointAlarmSettingRequest) \
log
.
exception
(
e
)
log
.
exception
(
e
)
return
PointAlarmSettingResponse
()
.
db_error
()
return
PointAlarmSettingResponse
()
.
db_error
()
residual_current_op
=
0
residual_current_op
=
0
user_id
=
req
.
ctx
.
user_id
if
user_id
in
RESIDUAL_CURRENT_OP
:
if
user_id
in
RESIDUAL_CURRENT_OP
:
residual_current_op
=
1
residual_current_op
=
1
return
PointAlarmSettingResponse
(
return
PointAlarmSettingResponse
(
...
...
unify_api/modules/home_page/procedures/count_info_pds.py
View file @
9109ff15
# -*- coding:utf-8 -*-
import
json
import
json
import
time
import
time
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
...
@@ -34,6 +35,10 @@ from unify_api.modules.electric_optimization.dao.power_index import (
...
@@ -34,6 +35,10 @@ from unify_api.modules.electric_optimization.dao.power_index import (
from
unify_api.utils.taos_new
import
parse_td_columns
,
get_td_table_name
,
\
from
unify_api.utils.taos_new
import
parse_td_columns
,
get_td_table_name
,
\
td3_tbl_compate
,
get_td_engine_data
td3_tbl_compate
,
get_td_engine_data
from
unify_api.utils.time_format
import
CST
from
unify_api.utils.time_format
import
CST
from
unify_api.constants
import
PHASE_LINE_LANG
from
unify_api.modules.common.dao.common_dao
import
(
load_user_lang
,
load_monitor_names
)
async
def
other_info
(
cid
):
async
def
other_info
(
cid
):
...
@@ -232,19 +237,30 @@ async def power_count_info(cid):
...
@@ -232,19 +237,30 @@ async def power_count_info(cid):
return
round_2
(
cur_load
),
round_2
(
max_30d_load
)
return
round_2
(
cur_load
),
round_2
(
max_30d_load
)
async
def
get_max_aiao_of_filed
(
cid
,
start
,
end
,
filed
=
"temperature"
):
async
def
load_aiao_max
(
user_id
,
cid
,
s_dts
,
e_dts
,
filed
):
value_max
,
location_name
,
occur_time
=
None
,
None
,
None
value_max
,
location_name
,
occur_time
=
None
,
None
,
None
sql
=
f
"SELECT a.value_max,a.value_max_time,p.name,b.item FROM "
\
sql
=
f
"SELECT a.value_max,a.value_max_time,p.name,
p.mtid,
b.item FROM "
\
f
"`location_15min_aiao` a LEFT JOIN location b on a.lid=b.lid "
\
f
"`location_15min_aiao` a LEFT JOIN location b on a.lid=b.lid "
\
f
"LEFT JOIN point p on p.mtid=a.mtid where "
\
f
"LEFT JOIN point p on p.mtid=a.mtid where "
\
f
"a.create_time BETWEEN '{s
tart}' and '{end
}' and a.cid=
%
s "
\
f
"a.create_time BETWEEN '{s
_dts}' and '{e_dts
}' and a.cid=
%
s "
\
f
" and a.ad_type=
%
s order by a.value_max desc limit 1"
f
" and a.ad_type=
%
s order by a.value_max desc limit 1"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
datas
=
await
conn
.
fetchone
(
sql
,
args
=
(
cid
,
filed
))
datas
=
await
conn
.
fetchone
(
sql
,
args
=
(
cid
,
filed
))
if
datas
:
if
datas
:
lang
=
await
load_user_lang
(
user_id
)
mtid
=
datas
[
"mtid"
]
if
lang
!=
"zh_CN"
:
mtr_names
=
await
load_monitor_names
([
mtid
],
lang
)
mtr_name
=
mtr_names
[
mtid
]
else
:
mtr_name
=
datas
[
"name"
]
value_max
=
round
(
datas
[
"value_max"
],
2
)
value_max
=
round
(
datas
[
"value_max"
],
2
)
item_name
=
'漏电流'
if
datas
[
'item'
]
==
'default'
else
datas
[
'item'
]
item_name
=
"漏电流"
if
datas
[
'item'
]
==
'default'
else
datas
[
'item'
]
location_name
=
f
"{datas['name']}_{item_name}"
if
lang
!=
"zh_CN"
:
item_name
=
PHASE_LINE_LANG
.
get
(
datas
[
"item"
],
""
)
location_name
=
f
"{mtr_name}_{item_name}"
occur_time
=
datas
.
get
(
"value_max_time"
)
occur_time
=
datas
.
get
(
"value_max_time"
)
occur_time
=
str
(
occur_time
)
if
occur_time
else
None
occur_time
=
str
(
occur_time
)
if
occur_time
else
None
return
MaxResidualCurrent
(
return
MaxResidualCurrent
(
...
...
unify_api/modules/home_page/views/count_info.py
View file @
9109ff15
import
time
# -*- coding:utf-8 -*-
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
aioredis
import
RedisError
from
aioredis
import
RedisError
...
@@ -19,7 +19,7 @@ from unify_api.modules.home_page.components.count_info_proxy_cps import \
...
@@ -19,7 +19,7 @@ from unify_api.modules.home_page.components.count_info_proxy_cps import \
CountInfoProxyResp
,
IycResp
,
IycmResp
,
RtrResp
,
CmResp
,
ApcResp
,
AsiResp
,
\
CountInfoProxyResp
,
IycResp
,
IycmResp
,
RtrResp
,
CmResp
,
ApcResp
,
AsiResp
,
\
HsiResp
,
AiiResp
HsiResp
,
AiiResp
from
unify_api.modules.home_page.procedures.count_info_pds
import
(
from
unify_api.modules.home_page.procedures.count_info_pds
import
(
get_max_aiao_of_filed
,
normal_rate_of_location
,
load_aiao_max
,
normal_rate_of_location
,
other_info
,
other_info
,
power_count_info
,
power_count_info
,
electric_use_info
,
electric_use_info
,
...
@@ -27,71 +27,59 @@ from unify_api.modules.home_page.procedures.count_info_pds import (
...
@@ -27,71 +27,59 @@ from unify_api.modules.home_page.procedures.count_info_pds import (
cal_power_factor
,
cal_power_factor
,
optimization_count_info
,
optimization_count_info_new
optimization_count_info
,
optimization_count_info_new
)
)
from
unify_api.modules.home_page.service.count_info_service
import
\
from
unify_api.modules.home_page.service.count_info_service
import
(
post_zd_info_factory_service
,
risk_cost_service
,
info_yang_chen_service
,
\
post_zd_info_factory_service
,
risk_cost_service
,
rank_type_ranking_service
,
info_yang_chen_map_service
,
rank_type_ranking_service
,
\
condition_monitor_service
,
alarm_price_costtl_service
,
condition_monitor_service
,
alarm_price_costtl_service
,
\
alarm_safe_index_service
,
all_index_info_service
alarm_safe_index_service
,
all_index_info_service
)
from
unify_api.modules.users.procedures.jwt_user
import
jwt_user
@
summary
(
"获取首页统计信息"
)
@
summary
(
"获取首页统计信息"
)
async
def
post_count_info
(
request
,
body
:
CountInfoReq
)
->
CountInfoResp
:
async
def
post_count_info
(
request
,
body
:
CountInfoReq
)
->
CountInfoResp
:
# 1. 获取company_id
# 1. 获取company_id
company_id
=
body
.
cid
cid
=
body
.
cid
# now_tt = time.time()
user_id
=
jwt_user
(
request
)
# start_dt = datetime.now() - timedelta(30)
e_dts
=
str
(
datetime
.
now
())
# start_tt = datetime_to_timestamp(
s_dts
=
str
(
datetime
.
now
()
-
timedelta
(
30
))
# datetime(start_dt.year, start_dt.month, start_dt.day))
now_tt
=
str
(
datetime
.
now
())
start_tt
=
str
(
datetime
.
now
()
-
timedelta
(
30
))
try
:
try
:
field
=
"residual_current"
max_residual_current
=
await
get_max_aiao_of_filed
(
company_id
,
max_rc
=
await
load_aiao_max
(
user_id
,
cid
,
s_dts
,
e_dts
,
field
)
start_tt
,
now_tt
,
field
=
"temperature"
"residual_current"
)
max_temp
=
await
load_aiao_max
(
user_id
,
cid
,
s_dts
,
e_dts
,
field
)
max_temperature
=
await
get_max_aiao_of_filed
(
company_id
,
start_tt
,
now_tt
,
"temperature"
)
# 温度和漏电流实时达标率
# 温度和漏电流实时达标率
# temperature_qr, residual_current_qr = await normal_rate_of_location(
temp_qr
,
rc_qr
=
await
normal_rate_of_location
(
cid
)
# company_id)
temperature_qr
,
residual_current_qr
=
await
\
normal_rate_of_location
(
company_id
)
# 今日报警数和累计安全运行天数
# 今日报警数和累计安全运行天数
# today_alarm_count, safe_run_days, alarm_count = await other_info(
today_alarm_count
,
safe_run_days
,
alarm_count
=
await
other_info
(
cid
)
# company_id)
today_alarm_count
,
safe_run_days
,
alarm_count
=
await
other_info
(
company_id
)
# 实时负荷和近30日最高负荷
# 实时负荷和近30日最高负荷
current_load
,
max_30d_load
=
await
power_count_info
(
c
ompany_
id
)
current_load
,
max_30d_load
=
await
power_count_info
(
cid
)
# 用电安全指数, 报警分, 近30天报警1,2,3级数目
# 用电安全指数, 报警分, 近30天报警1,2,3级数目
# electric_info = await electric_use_info(company_id)
electric_info
=
await
electric_use_info
(
cid
)
electric_info
=
await
electric_use_info
(
company_id
)
# 昨日平均电价, 上月平均电价
# 昨日平均电价, 上月平均电价
yestoday_price
,
last_month_price
=
await
power_charge_price
(
yestoday_price
,
last_month_price
=
await
power_charge_price
(
cid
)
company_id
)
# 实时功率因数, 上月功率因数
# 实时功率因数, 上月功率因数
# cos_ttl, last_month_cos = await power_factor(company_id)
cos_ttl
,
last_month_cos
=
await
cal_power_factor
(
cid
)
cos_ttl
,
last_month_cos
=
await
cal_power_factor
(
company_id
)
# 其实异常捕获这个东西最好是在框架内部做一次就够了
# 其实异常捕获这个东西最好是在框架内部做一次就够了
except
(
ElasticsearchException
,
MySQLError
,
RedisError
)
as
e
:
except
(
ElasticsearchException
,
MySQLError
,
RedisError
)
as
e
:
log
.
exception
(
e
)
log
.
exception
(
e
)
return
CountInfoResp
()
.
db_error
()
return
CountInfoResp
()
.
db_error
()
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
e
)
log
.
exception
(
e
)
return
CountInfoResp
()
.
server_error
()
return
CountInfoResp
()
.
server_error
()
return
CountInfoResp
(
return
CountInfoResp
(
max_residual_current
=
max_r
esidual_current
,
max_residual_current
=
max_r
c
,
max_temperature
=
max_temp
erature
,
max_temperature
=
max_temp
,
temperature_qr
=
temp
erature
_qr
,
temperature_qr
=
temp_qr
,
residual_current_qr
=
r
esidual_current
_qr
,
residual_current_qr
=
r
c
_qr
,
today_alarm_count
=
today_alarm_count
,
today_alarm_count
=
today_alarm_count
,
safe_run_days
=
safe_run_days
,
safe_run_days
=
safe_run_days
,
current_load
=
current_load
,
current_load
=
current_load
,
...
...
unify_api/modules/product_info/procedures/hardware_pds.py
View file @
9109ff15
# -*- coding:utf-8 -*-
from
collections
import
defaultdict
from
collections
import
defaultdict
from
datetime
import
datetime
from
datetime
import
datetime
from
pot_libs.logger
import
log
from
pot_libs.logger
import
log
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
unify_api.modules.common.procedures.points
import
point_to_mid
from
unify_api.modules.common.procedures.points
import
point_to_mid
from
unify_api.modules.common.dao.common_dao
import
(
load_user_lang
,
load_monitor_names
)
async
def
get_company
(
company_id
):
async
def
get_company
(
company_id
):
...
@@ -164,19 +168,28 @@ async def get_user_hardware_info(cid, page_num, page_size):
...
@@ -164,19 +168,28 @@ async def get_user_hardware_info(cid, page_num, page_size):
}
}
async
def
get_user_hardware_info_new15
(
company_id
,
page_num
,
page_size
):
async
def
load_hardware_info
(
cid
,
pg
,
pg_size
,
user_id
):
sql
=
"SELECT p.*,
m.s
id FROM `point` p left join monitor m "
\
sql
=
"SELECT p.*,
m.sid, m.mt
id FROM `point` p left join monitor m "
\
"on p.mtid=m.mtid where m.demolished=0 and p.cid=
%
s "
\
"on p.mtid=m.mtid where m.demolished=0 and p.cid=
%
s "
\
"ORDER BY p.create_time desc"
"ORDER BY p.create_time desc"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
datas
=
await
conn
.
fetchall
(
sql
=
sql
,
args
=
(
c
ompany_
id
,))
datas
=
await
conn
.
fetchall
(
sql
=
sql
,
args
=
(
cid
,))
results
=
[]
results
=
[]
if
p
age_num
>
0
and
page
_size
>
0
:
if
p
g
>
0
and
pg
_size
>
0
:
start
=
(
p
age_num
-
1
)
*
page
_size
start
=
(
p
g
-
1
)
*
pg
_size
end
=
p
age_num
*
page
_size
end
=
p
g
*
pg
_size
else
:
else
:
start
,
end
=
0
,
10
start
,
end
=
0
,
10
lang
=
await
load_user_lang
(
user_id
)
if
lang
!=
"zh_CN"
:
mtids
=
[
r
[
"mtid"
]
for
r
in
datas
]
mtr_names
=
await
load_monitor_names
(
mtids
,
lang
)
else
:
mtr_names
=
{}
for
data
in
datas
:
for
data
in
datas
:
mtid
=
data
[
"mtid"
]
high_or_low_side
=
"高压侧"
if
data
[
"voltage_side"
]
==
1
else
"低压侧"
high_or_low_side
=
"高压侧"
if
data
[
"voltage_side"
]
==
1
else
"低压侧"
start_time
=
datetime
.
strftime
(
start_time
=
datetime
.
strftime
(
datetime
.
fromtimestamp
(
data
[
"create_time"
]),
"
%
Y-
%
m-
%
d
%
H:
%
M"
datetime
.
fromtimestamp
(
data
[
"create_time"
]),
"
%
Y-
%
m-
%
d
%
H:
%
M"
...
@@ -185,8 +198,10 @@ async def get_user_hardware_info_new15(company_id, page_num, page_size):
...
@@ -185,8 +198,10 @@ async def get_user_hardware_info_new15(company_id, page_num, page_size):
datetime
.
fromtimestamp
(
data
[
"update_time"
]),
"
%
Y-
%
m-
%
d
%
H:
%
M"
datetime
.
fromtimestamp
(
data
[
"update_time"
]),
"
%
Y-
%
m-
%
d
%
H:
%
M"
)
)
wiring_type
=
"两表法"
if
data
[
"ctnum"
]
==
2
else
"三表法"
wiring_type
=
"两表法"
if
data
[
"ctnum"
]
==
2
else
"三表法"
name
=
data
.
get
(
"name"
)
or
''
mtr_name
=
name
if
lang
==
"zh_CN"
else
mtr_names
.
get
(
mtid
,
""
)
results
.
append
({
results
.
append
({
"installed_location"
:
data
.
get
(
"name"
)
or
''
,
"installed_location"
:
mtr_name
,
"device_number"
:
data
.
get
(
"sid"
)
or
''
,
"device_number"
:
data
.
get
(
"sid"
)
or
''
,
"device_type"
:
data
.
get
(
"device_type"
)
or
''
,
"device_type"
:
data
.
get
(
"device_type"
)
or
''
,
"start_time"
:
start_time
,
"start_time"
:
start_time
,
...
...
unify_api/modules/product_info/views/hardware_info.py
View file @
9109ff15
# -*- coding:utf-8 -*-
from
pot_libs.sanic_api
import
summary
from
pot_libs.sanic_api
import
summary
from
unify_api.modules.product_info.components.hardware_cps
import
(
from
unify_api.modules.product_info.components.hardware_cps
import
(
HardwareInfoRespList
,
HardwareInfoReq
,
HardwareInfoCountResp
,
HardwareInfoRespList
,
HardwareInfoReq
,
HardwareInfoCountResp
,
...
@@ -5,30 +6,30 @@ from unify_api.modules.product_info.components.hardware_cps import (
...
@@ -5,30 +6,30 @@ from unify_api.modules.product_info.components.hardware_cps import (
HardwareInfoManResq
,
HardwareInfoListReq
,
HardwareInfoListResq
HardwareInfoManResq
,
HardwareInfoListReq
,
HardwareInfoListResq
)
)
from
unify_api.modules.product_info.procedures.hardware_pds
import
(
from
unify_api.modules.product_info.procedures.hardware_pds
import
(
company_available
,
get_user_hardware_info_new15
,
hardware_statistics
company_available
,
load_hardware_info
,
hardware_statistics
)
)
from
pot_libs.logger
import
log
from
pot_libs.logger
import
log
from
unify_api.modules.product_info.service.hardware_info
import
\
from
unify_api.modules.product_info.service.hardware_info
import
\
hardware_info_sdu_service
,
hardware_list_sdu_service
,
\
hardware_info_sdu_service
,
hardware_list_sdu_service
,
\
hardware_info_management_service
,
hardware_info_list_manage_service
hardware_info_management_service
,
hardware_info_list_manage_service
from
unify_api.modules.common.procedures.cids
import
get_cids
,
get_proxy_cids
from
unify_api.modules.common.procedures.cids
import
get_cids
,
get_proxy_cids
from
unify_api.modules.users.procedures.jwt_user
import
jwt_user
@
summary
(
"获取硬件信息"
)
@
summary
(
"获取硬件信息"
)
async
def
post_hardware_info_list
(
request
,
async
def
post_hardware_info_list
(
request
,
body
:
HardwareInfoReq
)
->
HardwareInfoRespList
:
body
:
HardwareInfoReq
)
->
HardwareInfoRespList
:
c
ompany_
id
=
body
.
cid
cid
=
body
.
cid
p
age_size
,
page_num
=
body
.
page_size
,
body
.
page_num
p
g_size
,
pg
=
body
.
page_size
,
body
.
page_num
log
.
info
(
log
.
info
(
f
"post_hardware_info c
ompany_id={company_id}, page_size={page_size}, page_num={page_num
}"
f
"post_hardware_info c
id={cid}, page_size={pg_size}, page_num={pg
}"
)
)
comp_available
=
await
company_available
(
c
ompany_
id
)
comp_available
=
await
company_available
(
cid
)
if
not
comp_available
:
if
not
comp_available
:
return
HardwareInfoRespList
.
user_error
()
return
HardwareInfoRespList
.
user_error
()
# page_map = await get_user_hardware_info(company_id, page_num, page_size)
user_id
=
jwt_user
(
request
)
page_map
=
await
get_user_hardware_info_new15
(
company_id
,
page_num
,
page_map
=
await
load_hardware_info
(
cid
,
pg
,
pg_size
,
user_id
)
page_size
)
return
HardwareInfoRespList
(
rows
=
page_map
[
"rows"
],
total
=
page_map
[
"total"
])
return
HardwareInfoRespList
(
rows
=
page_map
[
"rows"
],
total
=
page_map
[
"total"
])
...
...
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