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
2bd87ca5
Commit
2bd87ca5
authored
Jul 19, 2023
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
longgang data 2023-7-19
parent
4100febc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
306 additions
and
194 deletions
+306
-194
select_company_cps.py
unify_api/modules/common/components/select_company_cps.py
+1
-1
common_dao.py
unify_api/modules/common/dao/common_dao.py
+12
-12
open_data_cps.py
unify_api/modules/shidianu/components/open_data_cps.py
+59
-3
open_data_dao.py
unify_api/modules/shidianu/dao/open_data_dao.py
+26
-45
open_data_service.py
unify_api/modules/shidianu/service/open_data_service.py
+80
-117
open_data.py
unify_api/modules/shidianu/views/open_data.py
+128
-16
No files found.
unify_api/modules/common/components/select_company_cps.py
View file @
2bd87ca5
...
@@ -29,7 +29,7 @@ class CompanyResponse(Model, DbErr):
...
@@ -29,7 +29,7 @@ class CompanyResponse(Model, DbErr):
@
dataclass
@
dataclass
class
CmReq
(
Model
):
class
CmReq
(
Model
):
cid
:
int
=
Int
(
"公司id"
)
.
eg
(
66
)
cid
:
int
=
Opt
(
Int
(
"公司id"
)
.
eg
(
66
)
)
@
dataclass
@
dataclass
...
...
unify_api/modules/common/dao/common_dao.py
View file @
2bd87ca5
...
@@ -103,19 +103,19 @@ async def item_by_mitd_dao(mtids):
...
@@ -103,19 +103,19 @@ async def item_by_mitd_dao(mtids):
return
datas
return
datas
async
def
monitor_point_storey_join_in
(
cid
,
page_num
,
page
_size
):
async
def
load_compy_storey_points
(
cid
,
pg_num
,
pg
_size
):
"""monitor和point和storey联合查询, 分页"""
"""monitor和point和storey联合查询, 分页"""
sql
=
"SELECT monitor.cid,
c.address,point.name,
point.create_time, "
\
sql
=
"SELECT monitor.cid,
c.address, point.name,
point.create_time, "
\
"monitor.sid,
srm.room_name, srm.storey_name, monitor.longitud
e, "
\
"monitor.sid,
monitor.meter_no, srm.room_name, srm.storey_nam
e, "
\
"
point.mtid,monitor.latitude,point.pid FROM monitor
"
\
"
monitor.longitude, point.mtid, monitor.latitude, point.pid
"
\
"
inner join point on monitor.mtid = point.mtid inner join
"
\
"
FROM monitor
"
\
"
storey_room_map srm on point.pid = srm.point_id left join
"
\
"
inner join point on monitor.mtid = point.mtid
"
\
"
company c on c.cid = monitor.cid WHERE monitor.cid in
%
s
"
\
"
inner join storey_room_map srm on point.pid = srm.point_id
"
\
"
and monitor.demolished = 0 order by point.pid limit
%
s,
%
s"
"
left join company c on c.cid = monitor.cid "
\
async
with
MysqlUtil
()
as
conn
:
"WHERE monitor.cid in
%
s and monitor.demolished = 0 "
\
monitor_point_storey_list
=
await
conn
.
fetchall
(
sql
,
args
=
(
"order by point.pid limit
%
s,
%
s"
cid
,
(
page_num
-
1
)
*
page_size
,
page_size
))
async
with
MysqlUtil
()
as
conn
:
return
monitor_point_storey_list
return
await
conn
.
fetchall
(
sql
,
(
cid
,
(
pg_num
-
1
)
*
pg_size
,
pg_size
))
async
def
meter_param_by_mid
(
mtid
):
async
def
meter_param_by_mid
(
mtid
):
...
...
unify_api/modules/shidianu/components/open_data_cps.py
View file @
2bd87ca5
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
pot_libs.sanic_api
import
Model
from
pot_libs.sanic_api
import
Model
from
pot_libs.sanic_api.column
import
Float
,
Str
,
List
,
Int
,
Dict
,
Opt
from
pot_libs.sanic_api.column
import
Float
,
Str
,
List
,
Int
,
Dict
,
Opt
from
pot_libs.common.components.fields
import
Cid
@
dataclass
@
dataclass
class
BasicInfoReq
(
Model
):
class
BasicInfoReq
(
Model
):
# cid: int = Int("工厂id").eg(78)
# cid: int = Opt(Int("工厂id").eg(78))
page_size
:
int
=
Opt
(
Int
(
"页面大小"
)
.
eg
(
10
))
page_size
:
int
=
Opt
(
Int
(
"页面大小"
)
.
eg
(
10
))
page_num
:
int
=
Opt
(
Int
(
"当前页面"
)
.
eg
(
1
))
page_num
:
int
=
Opt
(
Int
(
"当前页面"
)
.
eg
(
1
))
...
@@ -46,3 +44,61 @@ class SupplementReq(Model):
...
@@ -46,3 +44,61 @@ class SupplementReq(Model):
start
:
str
=
Str
(
"开始时间"
)
.
eg
(
"2021-12-29 00:00:00"
)
start
:
str
=
Str
(
"开始时间"
)
.
eg
(
"2021-12-29 00:00:00"
)
end
:
str
=
Str
(
"开始时间"
)
.
eg
(
"2021-12-29 06:00:00"
)
end
:
str
=
Str
(
"开始时间"
)
.
eg
(
"2021-12-29 06:00:00"
)
type
:
str
=
Str
(
"类型"
)
.
eg
(
"appliance or electric"
)
type
:
str
=
Str
(
"类型"
)
.
eg
(
"appliance or electric"
)
@
dataclass
class
RiskCount
(
Model
):
security_user
:
int
=
Opt
(
Int
(
"安全用户"
)
.
eg
(
10
))
risk_user
:
int
=
Opt
(
Int
(
"风险用户"
)
.
eg
(
2
))
@
dataclass
class
ContentName
(
Model
):
ele_overload
:
int
=
Opt
(
Int
(
"用电超载"
)
.
eg
(
10
))
high_power_app
:
int
=
Opt
(
Int
(
"大功率电器"
)
.
eg
(
2
))
illegal_ele_app
:
int
=
Opt
(
Int
(
"违规电器"
)
.
eg
(
2
))
power_quality
:
int
=
Opt
(
Int
(
"电能质量"
)
.
eg
(
2
))
ele_car_battery
:
int
=
Opt
(
Int
(
"电能质量"
)
.
eg
(
2
))
@
dataclass
class
HomeDataResp
(
Model
):
risk_distribution
:
RiskCount
=
Opt
(
RiskCount
)
content_distribution
:
ContentName
=
Opt
(
ContentName
)
electric_use_score
:
float
=
Opt
(
Float
(
"用电安全指数"
)
.
eg
(
90.3
))
total_tenant
:
int
=
Opt
(
Int
(
"接入住户"
)
.
eg
(
20
))
online_rate
:
float
=
Opt
(
Float
(
"在线率"
)
.
eg
(
0.8
))
safe_day
:
float
=
Opt
(
Float
(
"平均安全运行"
)
.
eg
(
11.1
))
total_power
:
float
=
Opt
(
Float
(
"累计监测用电"
)
.
eg
(
96000
))
total_alarm
:
int
=
Opt
(
Int
(
"累计报警次数"
)
.
eg
(
5
))
@
dataclass
class
HomeLstAlarmReq
(
Model
):
cid
:
Opt
(
Cid
)
importance
:
list
=
Opt
(
List
(
"报警等级,默认:[1, 2, 3]"
)
.
eg
([
1
,
2
,
3
]))
page_size
:
int
=
Opt
(
Int
(
"每页记录数"
)
.
eg
(
10
))
page_num
:
int
=
Opt
(
Int
(
"当前页码"
)
.
eg
(
1
))
start
:
str
=
Opt
(
Str
(
"开始时间"
)
.
eg
(
"2021-02-01 00:00:00"
))
end
:
str
=
Opt
(
Str
(
"结束时间"
)
.
eg
(
"2021-02-28 23:59:59"
))
@
dataclass
class
HomeAlarmStatsReq
(
Model
):
cid
:
Opt
(
Cid
)
importance
:
list
=
Opt
(
List
(
"报警等级,默认:[1, 2, 3]"
)
.
eg
([
1
,
2
,
3
]))
page_size
:
int
=
Opt
(
Int
(
"每页记录数"
)
.
eg
(
10
))
page_num
:
int
=
Opt
(
Int
(
"当前页码"
)
.
eg
(
1
))
start
:
str
=
Opt
(
Str
(
"开始时间"
)
.
eg
(
"2021-02-01 00:00:00"
))
end
:
str
=
Opt
(
Str
(
"结束时间"
)
.
eg
(
"2021-02-28 23:59:59"
))
@
dataclass
class
HomeAlarmStatsResp
(
Model
):
ele_overload
:
dict
=
Dict
(
"线路过载"
)
.
eg
(
{
"slots"
:
[
"00-01"
,
"00-02"
,
"00-03"
],
"value"
:
[
1
,
2
,
3
]})
illegal_ele_app
:
dict
=
Dict
(
"违规电器"
)
.
eg
(
{
"slots"
:
[
"00-01"
,
"00-02"
,
"00-03"
],
"value"
:
[
1
,
2
,
3
]})
power_quality
:
dict
=
Dict
(
"电能质量"
)
.
eg
(
{
"slots"
:
[
"00-01"
,
"00-02"
,
"00-03"
],
"value"
:
[
1
,
2
,
3
]})
unify_api/modules/shidianu/dao/open_data_dao.py
View file @
2bd87ca5
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
pot_libs.es_util.es_utils
import
EsUtil
from
unify_api.constants
import
SDU_ALARM_LIST
from
unify_api.constants
import
POINT_1MIN_EVENT
,
SDU_ALARM_LIST
import
pendulum
from
unify_api.utils.time_format
import
CST
async
def
get_user_product_auth
(
user_id
):
async
def
get_user_product_auth
(
user_id
):
sql
=
"SELECT * from user_product_auth where user_id=
%
s and product=4"
sql
=
"SELECT * from user_product_auth where user_id=
%
s and product=4"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
user_info
=
await
conn
.
fetchone
(
sql
,
args
=
(
user_id
,))
return
await
conn
.
fetchone
(
sql
,
args
=
(
user_id
,))
return
user_info
async
def
get_basic_info_by_mtid
(
mtid
,
cid
):
async
def
get_basic_info_by_mtid
(
mtid
,
cid
):
...
@@ -16,8 +16,7 @@ async def get_basic_info_by_mtid(mtid, cid):
...
@@ -16,8 +16,7 @@ async def get_basic_info_by_mtid(mtid, cid):
"on p.pid=s.point_id LEFT JOIN monitor m on m.mtid=p.mtid "
\
"on p.pid=s.point_id LEFT JOIN monitor m on m.mtid=p.mtid "
\
"where m.mtid=
%
s and m.demolished=0 and s.cid =
%
s"
"where m.mtid=
%
s and m.demolished=0 and s.cid =
%
s"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
info
=
await
conn
.
fetchone
(
sql
,
args
=
(
mtid
,
cid
))
return
await
conn
.
fetchone
(
sql
,
args
=
(
mtid
,
cid
))
return
info
async
def
monitor_point_company
(
cids
):
async
def
monitor_point_company
(
cids
):
...
@@ -26,45 +25,27 @@ async def monitor_point_company(cids):
...
@@ -26,45 +25,27 @@ async def monitor_point_company(cids):
"on c.cid=m.cid INNER JOIN point p on m.mtid=p.mtid "
\
"on c.cid=m.cid INNER JOIN point p on m.mtid=p.mtid "
\
"INNER JOIN storey_room_map s on s.point_id=p.pid where c.cid in
%
s"
"INNER JOIN storey_room_map s on s.point_id=p.pid where c.cid in
%
s"
async
with
MysqlUtil
()
as
conn
:
async
with
MysqlUtil
()
as
conn
:
datas
=
await
conn
.
fetchall
(
sql
,
args
=
(
cids
,
))
return
await
conn
.
fetchall
(
sql
,
args
=
(
cids
,))
return
datas
async
def
result_longgang_by_cid
(
cids
,
page_num
,
page_size
,
importance
):
async
def
load_lg_sdu_events
(
cid
,
pg_num
,
pg_size
,
importance
):
alarm_list
=
SDU_ALARM_LIST
cond_lst
=
[
f
"cid={cid}"
,
f
"event_type in {tuple(SDU_ALARM_LIST)}"
]
if
len
(
importance
)
>
0
:
importance
=
str
(
tuple
(
importance
))
.
replace
(
',)'
,
')'
)
cond_lst
.
append
(
f
"importance in {importance}"
)
query_body
=
{
time_format
=
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
"from"
:
(
page_num
-
1
)
*
page_size
,
end_date
=
str
(
pendulum
.
now
(
tz
=
CST
)
.
strftime
(
time_format
))
"size"
:
page_size
,
cond_lst
.
append
(
f
"event_datetime < '{end_date}'"
)
"query"
:
{
cond_str
=
" AND "
.
join
(
cond_lst
)
"bool"
:
{
async
with
MysqlUtil
()
as
conn
:
"must"
:
[
sql
=
f
"select count(*) cnt from point_1min_event WHERE {cond_str};"
{
total
=
await
conn
.
fetchone
(
sql
)
"terms"
:
{
total_count
=
total
.
get
(
"cnt"
,
0
)
"cid"
:
cids
if
total_count
<=
0
:
}
return
0
,
[]
},
{
sql
=
f
"select * from point_1min_event WHERE {cond_str} "
\
"terms"
:
{
f
"order by event_datetime desc limit
%
s,
%
s;"
"type.keyword"
:
alarm_list
data
=
await
conn
.
fetchall
(
sql
,
args
=
((
pg_num
-
1
)
*
pg_size
,
pg_size
))
}
return
total_count
,
data
},
{
"terms"
:
{
"importance"
:
importance
}
}
]
}
},
"sort"
:
[
{
"datetime"
:
{
"order"
:
"desc"
}
}
]
}
async
with
EsUtil
()
as
es
:
es_re
=
await
es
.
search_origin
(
body
=
query_body
,
index
=
POINT_1MIN_EVENT
)
return
es_re
unify_api/modules/shidianu/service/open_data_service.py
View file @
2bd87ca5
This diff is collapsed.
Click to expand it.
unify_api/modules/shidianu/views/open_data.py
View file @
2bd87ca5
import
random
from
pot_libs.sanic_api
import
summary
from
pot_libs.sanic_api
import
summary
from
unify_api.modules.shidianu.components.open_data_cps
import
(
from
unify_api.modules.shidianu.components.open_data_cps
import
(
BasicInfoReq
,
BasicInfoResp
,
StbDataReq
,
StbDataResp
,
SupplementReq
BasicInfoReq
,
BasicInfoResp
,
StbDataReq
,
StbDataResp
,
SupplementReq
,
HomeDataResp
,
HomeLstAlarmReq
,
HomeAlarmStatsReq
,
HomeAlarmStatsResp
)
)
from
unify_api.modules.alarm_manager.components.list_alarm
import
\
from
unify_api.modules.alarm_manager.components.list_alarm
import
\
ListAlarmResponse
ListAlarmResponse
from
unify_api.modules.shidianu.service.open_data_service
import
\
from
unify_api.modules.shidianu.service.open_data_service
import
(
basic_info_longgang_service
,
stb_data_longgang_service
,
\
basic_info_longgang_service
,
stb_data_longgang_service
,
supplement_data_service
,
result_longgang_service
supplement_data_service
,
result_longgang_service
)
from
pot_libs.settings
import
SETTING
from
unify_api.utils.time_format
import
last30_day_range
from
unify_api.modules.common.dao.common_dao
import
monitor_by_cid
from
unify_api.modules.home_page.service.count_info_service
import
safe_run_sdu
from
unify_api.modules.common.procedures.power_cps
import
power_use_count
from
unify_api.modules.common.procedures.alarm_cps
import
alarm_count_sdu_new
from
unify_api.modules.shidianu.service.open_data_service
import
get_power
from
unify_api.modules.common.components.select_company_cps
import
CmReq
from
pot_libs.common.components.responses
import
success_res
from
unify_api.modules.alarm_manager.service.alarm_static_service
import
(
sdu_alarm_statistics_service
)
from
unify_api.modules.home_page.procedures.count_info_pds
import
(
electric_use_info_sdu
)
from
unify_api.modules.common.dao.common_dao
import
storey_by_cid
from
unify_api.modules.alarm_manager.service.list_alarm_service
import
\
new_list_alarm_service
# 数据对外开放接口
# 数据对外开放接口
@
summary
(
"获取装置列表"
)
@
summary
(
"获取装置列表"
)
async
def
post_basic_info_longgang
2
(
req
,
body
:
BasicInfoReq
)
->
BasicInfoResp
:
async
def
post_basic_info_longgang
(
req
,
body
:
BasicInfoReq
)
->
BasicInfoResp
:
user_id
=
req
.
ctx
.
user_id
user_id
=
req
.
ctx
.
user_id
# user_id = 10086
# user_id = 10086
page_size
=
body
.
page_size
or
10
page_size
=
body
.
page_size
or
10
...
@@ -20,7 +41,7 @@ async def post_basic_info_longgang2(req, body: BasicInfoReq) -> BasicInfoResp:
...
@@ -20,7 +41,7 @@ async def post_basic_info_longgang2(req, body: BasicInfoReq) -> BasicInfoResp:
@
summary
(
"查询数据"
)
@
summary
(
"查询数据"
)
async
def
post_stb_data_longgang
2
(
req
,
body
:
StbDataReq
)
->
StbDataResp
:
async
def
post_stb_data_longgang
(
req
,
body
:
StbDataReq
)
->
StbDataResp
:
user_id
=
req
.
ctx
.
user_id
user_id
=
req
.
ctx
.
user_id
# user_id = 10086
# user_id = 10086
# cid = body.cid
# cid = body.cid
...
@@ -29,27 +50,25 @@ async def post_stb_data_longgang2(req, body: StbDataReq) -> StbDataResp:
...
@@ -29,27 +50,25 @@ async def post_stb_data_longgang2(req, body: StbDataReq) -> StbDataResp:
@
summary
(
"获取告警结果"
)
@
summary
(
"获取告警结果"
)
async
def
post_alarm_result_longgang
2
(
req
,
body
:
BasicInfoReq
)
->
\
async
def
post_alarm_result_longgang
(
req
,
body
:
BasicInfoReq
)
->
\
ListAlarmResponse
:
ListAlarmResponse
:
user_id
=
req
.
ctx
.
user_id
user_id
=
req
.
ctx
.
user_id
# user_id = 10086
# user_id = 10086
p
age
_size
=
body
.
page_size
or
10
p
g
_size
=
body
.
page_size
or
10
p
age
_num
=
body
.
page_num
or
1
p
g
_num
=
body
.
page_num
or
1
importance
=
[
2
,
3
]
importance
=
[
2
,
3
]
return
await
result_longgang_service
(
user_id
,
importance
,
page_size
,
return
await
result_longgang_service
(
user_id
,
importance
,
pg_size
,
pg_num
)
page_num
)
@
summary
(
"获取分析结果"
)
@
summary
(
"获取分析结果"
)
async
def
post_analyse_result_longgang
2
(
req
,
body
:
BasicInfoReq
)
->
\
async
def
post_analyse_result_longgang
(
req
,
body
:
BasicInfoReq
)
->
\
ListAlarmResponse
:
ListAlarmResponse
:
user_id
=
req
.
ctx
.
user_id
user_id
=
req
.
ctx
.
user_id
# user_id = 10086
# user_id = 10086
p
age
_size
=
body
.
page_size
or
10
p
g
_size
=
body
.
page_size
or
10
p
age
_num
=
body
.
page_num
or
1
p
g
_num
=
body
.
page_num
or
1
importance
=
[
1
]
importance
=
[
1
]
return
await
result_longgang_service
(
user_id
,
importance
,
page_size
,
return
await
result_longgang_service
(
user_id
,
importance
,
pg_size
,
pg_num
)
page_num
)
@
summary
(
"补充数据"
)
@
summary
(
"补充数据"
)
...
@@ -60,4 +79,97 @@ async def post_supplement_data(req, body: SupplementReq) -> StbDataResp:
...
@@ -60,4 +79,97 @@ async def post_supplement_data(req, body: SupplementReq) -> StbDataResp:
start
=
body
.
start
start
=
body
.
start
end
=
body
.
end
end
=
body
.
end
type
=
body
.
type
type
=
body
.
type
return
await
supplement_data_service
(
user_id
,
cid
,
start
,
end
,
type
)
return
await
supplement_data_service
(
user_id
,
cid
,
start
,
end
,
type
)
\ No newline at end of file
@
summary
(
"首页信息"
)
async
def
post_home_page_data
(
req
,
body
:
CmReq
)
->
HomeDataResp
:
user_id
=
req
.
ctx
.
user_id
cid
=
223
cids
=
[
223
]
is_auth
=
await
get_power
(
user_id
,
cids
)
if
not
is_auth
and
not
SETTING
.
debug_mode
:
return
success_res
(
code
=
4001
,
msg
=
"您没有权限访问"
)
start
,
end
=
last30_day_range
()
product
=
4
# 安全和报警统计
res
=
await
sdu_alarm_statistics_service
([
cid
],
start
,
end
,
product
)
# 安全指数
alarm_res
=
await
electric_use_info_sdu
(
cid
)
electric_use_score
=
round
(
alarm_res
.
electric_use_score
)
# 1. 接入住户,从monitor表取,解决拆除逻辑
monitor_list
=
await
monitor_by_cid
(
cid
)
total_tenant
=
len
(
monitor_list
)
# 2. 安全运行天数: 以天计,当工厂某天I级、II级报警总数小于总户数*5%时,即为安全运行,
# 展示自接入累加安全运行天数
safe_day
=
await
safe_run_sdu
(
cid
,
total_tenant
)
# 3. 在线率
online_rate
=
88
+
random
.
choice
([
1
,
1.5
,
2
,
2.5
,
3
,
3.5
,
4
])
# 4.累计用电
total_power
=
await
power_use_count
(
cids
)
# 5. 累计报警
total_alarm
=
await
alarm_count_sdu_new
(
cids
)
return
HomeDataResp
(
risk_distribution
=
res
.
risk_distribution
,
content_distribution
=
res
.
content_distribution
,
electric_use_score
=
electric_use_score
,
total_tenant
=
total_tenant
,
online_rate
=
online_rate
,
safe_day
=
safe_day
,
total_power
=
total_power
,
total_alarm
=
total_alarm
,
)
@
summary
(
"首页-最近报警"
)
async
def
post_home_page_lst_alarm
(
req
,
body
:
HomeLstAlarmReq
)
->
\
ListAlarmResponse
:
user_id
=
req
.
ctx
.
user_id
# cid = body.cid
cid
=
223
is_auth
=
await
get_power
(
user_id
,
[
cid
])
if
not
is_auth
and
not
SETTING
.
debug_mode
:
return
success_res
(
code
=
4001
,
msg
=
"您没有权限访问"
)
importance
=
body
.
importance
page_size
=
body
.
page_size
page_num
=
body
.
page_num
start
=
body
.
start
end
=
body
.
end
product
=
4
point_ids
=
None
storeys
=
await
storey_by_cid
(
cid
)
storey_ids
=
[
item
[
"storey_id"
]
for
item
in
storeys
]
return
await
new_list_alarm_service
(
cid
,
storey_ids
,
page_num
,
page_size
,
start
,
end
,
product
,
importance
,
point_ids
)
@
summary
(
"首页-运行趋势"
)
async
def
post_home_page_alarm_stats
(
req
,
body
:
HomeAlarmStatsReq
)
->
\
HomeAlarmStatsResp
:
user_id
=
req
.
ctx
.
user_id
# cid = body.cid
cid
=
223
is_auth
=
await
get_power
(
user_id
,
[
cid
])
if
not
is_auth
and
not
SETTING
.
debug_mode
:
return
success_res
(
code
=
4001
,
msg
=
"您没有权限访问"
)
# 1. 获取参数
start
=
body
.
start
end
=
body
.
end
product
=
4
sr
=
await
sdu_alarm_statistics_service
([
cid
],
start
,
end
,
product
)
return
HomeAlarmStatsResp
(
ele_overload
=
sr
.
ele_overload
,
illegal_ele_app
=
sr
.
illegal_ele_app
,
power_quality
=
sr
.
power_quality
)
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