Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
event-analysis
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
崔义雄
event-analysis
Commits
8e28ef98
Commit
8e28ef98
authored
May 26, 2020
by
Kerwin_Cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
预警统计导出
parent
12b0f9ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
0 deletions
+94
-0
event_analysis/urls.py
event_analysis/urls.py
+2
-0
event_analysis/views.py
event_analysis/views.py
+59
-0
templates/event_analysis/alarm_count.html
templates/event_analysis/alarm_count.html
+33
-0
No files found.
event_analysis/urls.py
View file @
8e28ef98
...
...
@@ -42,4 +42,6 @@ urlpatterns = [
url
(
r'^monitor_excel/$'
,
monitor_excel
),
url
(
r'^system_cmdb/$'
,
system_cmdb
),
url
(
r'^download_monitor/$'
,
download_monitor
),
url
(
r'^alarm_count_out/$'
,
alarm_count_out
),
url
(
r'^download_alarm_count/$'
,
download_alarm_count
),
]
event_analysis/views.py
View file @
8e28ef98
...
...
@@ -2790,6 +2790,65 @@ def system_cmdb(request):
)
def
alarm_count_out
(
request
):
try
:
req
=
json
.
loads
(
request
.
body
)
data_list
=
[]
for
i
in
req
:
new_list
=
[]
new_list
.
append
(
i
.
get
(
u'system'
))
new_list
.
append
(
i
.
get
(
u'total'
))
new_list
.
append
(
i
.
get
(
u'bad_work'
))
new_list
.
append
(
i
.
get
(
u'main_work'
))
new_list
.
append
(
i
.
get
(
u'normal_work'
))
new_list
.
append
(
i
.
get
(
u'bad_weekend'
))
new_list
.
append
(
i
.
get
(
u'main_weekend'
))
new_list
.
append
(
i
.
get
(
u'normal_weekend'
))
data_list
.
append
(
new_list
)
workbook
=
xlwt
.
Workbook
(
encoding
=
'utf-8'
)
data_sheet
=
workbook
.
add_sheet
(
'demo'
)
row0
=
[
'系统'
,
'有效故障预警数'
,
'严重故障预警数(交易日)'
,
'主要故障预警数(交易日)'
,
'次要故障预警数(交易日)'
,
'严重故障预警数(非交易日)'
,
'主要故障预警数(非交易日)'
,
'次要故障预警数(非交易日)'
]
for
i
in
range
(
len
(
row0
)):
data_sheet
.
write
(
0
,
i
,
row0
[
i
],
set_style
(
u'宋体'
,
220
,
True
))
a
=
1
while
True
:
for
i
in
range
(
len
(
row0
)):
data_sheet
.
write
(
a
,
i
,
data_list
[
0
][
i
],
set_style
(
u'宋体'
,
220
,
False
))
data_list
.
pop
(
0
)
a
+=
1
if
len
(
data_list
)
==
0
:
break
workbook
.
save
(
u'预警统计.xls'
)
return
render_json
(
{
"result"
:
True
,
"code"
:
0
,
"message"
:
u"生成文件成功"
,
"data"
:
1
}
)
except
Exception
as
e
:
return
render_json
(
{
"result"
:
False
,
"code"
:
1
,
"message"
:
u"未知错误:
%
s"
%
e
,
"data"
:
{}
}
)
def
download_alarm_count
(
request
):
file_name
=
u'预警统计.xls'
file
=
open
(
file_name
,
'rb'
)
response
=
FileResponse
(
file
)
response
[
'Content-Type'
]
=
'application/octet-stream'
response
[
'Content-Disposition'
]
=
'attachment;filename="预警统计.xls"'
return
response
# 同步事件
def
sync
(
request
):
now_time
=
int
(
time
.
time
())
...
...
templates/event_analysis/alarm_count.html
View file @
8e28ef98
...
...
@@ -22,6 +22,10 @@
@
click=
"searchList()"
style=
"float: right;margin-right:12px"
>
查询
</el-button>
<el-button
size=
"medium"
id=
"search"
type=
"primary"
@
click=
"listOut()"
style=
"float: right;margin-right:12px"
>
导出
</el-button>
</div>
</div>
...
...
@@ -103,6 +107,35 @@
this
.
total
=
res
.
data
.
count
})
},
async
listOut
(){
console
.
log
(
!
this
.
AlarmCountData
.
length
)
if
(
!
this
.
AlarmCountData
.
length
){
vm
.
$message
(
{
type
:
'
error
'
,
message
:
"
当前搜索条件下无数据!
"
}
)
}
else
{
await
this
.
out_data
();
vm
.
$message
({
type
:
'
success
'
,
message
:
'
下载成功
'
});
this
.
download_alarm_count
();
}
},
out_data
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
post
(
'
${SITE_URL}alarm_count_out/
'
,
this
.
AlarmCountData
).
then
(
res
=>
{
if
(
res
.
data
==
1
)
{
resolve
(
'
ok
'
)}
})
})
},
download_alarm_count
(){
window
.
location
.
href
=
"
${SITE_URL}download_alarm_count
"
;
},
getUserGroup
()
{
axios
.
get
(
'
${SITE_URL}search_user_group/
'
).
then
(
res
=>
{
this
.
GroupOp
=
res
.
data
[
'
group_list
'
];
...
...
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