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
ebaa57cd
Commit
ebaa57cd
authored
May 30, 2023
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove es 2023-5-30
parent
1becd439
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
301 deletions
+7
-301
alarm_static_pds.py
..._api/modules/alarm_manager/procedures/alarm_static_pds.py
+3
-235
alarm_static_service.py
...api/modules/alarm_manager/service/alarm_static_service.py
+4
-5
alarm_static.py
unify_api/modules/alarm_manager/views/alarm_static.py
+0
-61
No files found.
unify_api/modules/alarm_manager/procedures/alarm_static_pds.py
View file @
ebaa57cd
This diff is collapsed.
Click to expand it.
unify_api/modules/alarm_manager/service/alarm_static_service.py
View file @
ebaa57cd
...
...
@@ -8,8 +8,8 @@ from unify_api.modules.alarm_manager.dao.list_static_dao import \
sdu_alarm_importance_dao
,
sdu_alarm_statistics_dao
,
\
sdu_alarm_behavior_dao
,
sdu_alarm_limit_type_dao
from
unify_api.modules.alarm_manager.procedures.alarm_static_pds
import
\
new_alarm_content_info
,
risk_distribution
,
zdu_summary_info
,
\
new_alarm_content_info_new15
,
risk_distribution_new15
,
\
risk_distribution
,
zdu_summary_info
,
\
sdu_alarm_content_info
,
risk_distribution_new15
,
\
alarm_content_time_distribution_pds
from
unify_api.modules.common.dao.common_dao
import
points_by_cid
,
\
monitor_point_join
,
points_monitor_by_cid
...
...
@@ -22,7 +22,7 @@ from unify_api.modules.home_page.procedures.security_info_pds import \
alarm_count_info_new15
from
unify_api.utils.common_utils
import
round_1
,
division_two
from
unify_api.modules.alarm_manager.dao.list_alarm_dao
import
\
zdu_alarm_sort_dao
,
alarm_content_time_distribution_dao
,
zdu_summary_dao
zdu_alarm_sort_dao
,
zdu_summary_dao
async
def
sdu_alarm_statistics_service
(
cids
,
start
,
end
,
product
):
...
...
@@ -33,8 +33,7 @@ async def sdu_alarm_statistics_service(cids, start, end, product):
raise
ParamException
(
message
=
f
"{cids}没有points"
)
point_id_list
=
[
i
[
"pid"
]
for
i
in
points
]
# 1.调用函数获取报警统计信息
alarm_info_map
=
await
new_alarm_content_info_new15
(
cids
,
start
,
end
,
points
)
alarm_info_map
=
await
sdu_alarm_content_info
(
cids
,
start
,
end
,
points
)
ele_overload
,
illegal_ele_app
,
power_quality
,
illegal_app_dic
,
\
total_alarm_cnt
,
alarm_points_cnt
=
(
alarm_info_map
[
"ele_overload"
],
...
...
unify_api/modules/alarm_manager/views/alarm_static.py
View file @
ebaa57cd
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
from
pot_libs.sanic_api
import
summary
from
unify_api.modules.alarm_manager.components.alarm_static_cps
import
\
SduAlarmReq
,
SduAlarmResp
,
ContentName
,
RiskCount
,
SasReq
,
SassReq
,
\
SassResp
,
AppReq
,
AppResp
,
SisReq
,
SisResp
,
SiasReq
,
SiasResp
,
SebReq
,
\
SebResp
,
SiarResp
,
ZsResp
,
ZasReq
,
ZasResp
from
unify_api.modules.alarm_manager.procedures.alarm_static_pds
import
\
alarm_content_info
,
risk_distribution
from
unify_api.modules.alarm_manager.service.alarm_static_service
import
\
sdu_alarm_statistics_service
,
sdu_electric_behave_service
,
\
zdu_level_distribution_service
,
\
...
...
@@ -19,64 +16,6 @@ from unify_api.modules.home_page.procedures.count_info_pds import \
from
unify_api.utils.time_format
import
last30_day_range
@
summary
(
"报警统计"
)
async
def
post_alarm_statistics
(
req
,
body
:
SduAlarmReq
)
->
SduAlarmResp
:
"""目前用于 识电u->报警统计"""
product
=
body
.
product
cid
=
body
.
cid
start
=
body
.
start
end
=
body
.
end
# 获取point信息
sql_point
=
"SELECT pid, name FROM point WHERE cid=
%
s"
async
with
MysqlUtil
()
as
conn
:
points
=
await
conn
.
fetchall
(
sql_point
,
args
=
(
cid
,))
if
not
points
:
return
SduAlarmResp
()
point_id_list
=
[
i
[
"pid"
]
for
i
in
points
]
# 1.调用函数获取报警统计信息
alarm_info_map
=
await
alarm_content_info
(
cid
,
start
,
end
,
points
)
if
not
alarm_info_map
:
return
SduAlarmResp
()
high_power_app
,
ele_overload
,
illegal_ele_app
,
power_quality
,
\
ele_car_battery
,
point_dic
,
total_alarm_cnt
=
(
alarm_info_map
[
"high_power_app"
],
alarm_info_map
[
"ele_overload"
],
alarm_info_map
[
"illegal_ele_app"
],
alarm_info_map
[
"power_quality"
],
alarm_info_map
[
"ele_car_battery"
],
alarm_info_map
[
"point_dic"
],
alarm_info_map
[
"total_alarm_cnt"
]
)
# point_dic排序
point_list
=
[]
for
key
,
val
in
point_dic
.
items
():
point_list
.
append
({
"name"
:
key
,
"value"
:
val
})
point_list
.
sort
(
key
=
lambda
x
:
x
[
"value"
],
reverse
=
True
)
# 报警类型总数,用于求比例
cn
=
ContentName
(
ele_overload
=
sum
(
ele_overload
[
"value"
]),
high_power_app
=
sum
(
high_power_app
[
"value"
]),
illegal_ele_app
=
sum
(
illegal_ele_app
[
"value"
]),
power_quality
=
sum
(
power_quality
[
"value"
]),
ele_car_battery
=
sum
(
ele_car_battery
[
"value"
])
)
# 2.计算风险分布
# 其中当前时段为发生过I级报警为风险用户,其余为安全用户
security_user
,
risk_user
=
await
risk_distribution
(
start
,
end
,
point_id_list
)
rc
=
RiskCount
(
security_user
=
security_user
,
risk_user
=
risk_user
)
return
SduAlarmResp
(
total_alarm_cnt
=
total_alarm_cnt
,
high_power_app
=
high_power_app
,
ele_overload
=
ele_overload
,
illegal_ele_app
=
illegal_ele_app
,
power_quality
=
power_quality
,
ele_car_battery
=
ele_car_battery
,
alarm_ranking
=
point_list
,
content_distribution
=
cn
,
risk_distribution
=
rc
)
@
summary
(
"报警统计-识电u"
)
async
def
post_sdu_alarm_statistics
(
req
,
body
:
SduAlarmReq
)
->
SduAlarmResp
:
"""目前用于 识电u->报警统计"""
...
...
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