aio_elin 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aio/base/toolkit/word_wps.rb +494 -490
- data/lib/modules/output/style/summary_report.rb +570 -552
- metadata +1 -1
@@ -3,562 +3,580 @@
|
|
3
3
|
require "aio/core"
|
4
4
|
|
5
5
|
class Aio::Module::OutputStyle::SummaryReport < Aio::Module::OutputStyle
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
6
|
+
include Aio::Module
|
7
|
+
include Aio::Device
|
8
|
+
include Aio::Base::Toolkit::WordWps
|
9
|
+
include Aio::Base::Toolkit::ExcelWps
|
10
|
+
include Aio::Ui::Verbose
|
11
|
+
|
12
|
+
PlaceHolder = "###"
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
super({
|
16
|
+
:author => "Elin",
|
17
|
+
:description => "输出巡检简要报告, 以WPS运行",
|
18
|
+
:file_suffix => "doc",
|
19
19
|
:platform => ['windows']
|
20
20
|
})
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
21
|
+
|
22
|
+
# 附带信息
|
23
|
+
@info = {
|
24
|
+
:resource_file => File.join(::BaseFile, "aio", "resource"),
|
25
|
+
:client => nil,
|
26
|
+
:time => ::Time.now.to_s.split(' ')[0],
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def info_client=(e)
|
31
|
+
@info[:client] = e
|
32
|
+
end
|
33
|
+
|
34
|
+
def info_time=(e)
|
35
|
+
@info[:time] = e
|
36
|
+
end
|
37
|
+
|
38
|
+
def info
|
39
|
+
@info
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def generate
|
44
|
+
|
45
|
+
word = Word.new
|
46
|
+
#word.show
|
47
|
+
word.display_alerts = false
|
48
|
+
@doc = word.init_document
|
49
|
+
@text = @doc.add_text
|
50
|
+
|
51
|
+
# 创建风格
|
52
|
+
create_style
|
53
|
+
|
54
|
+
device_manager.devices.each_pair do |device_name, klass|
|
55
|
+
#puts "summary_report"
|
56
|
+
#pp device_name
|
57
|
+
#pp klass.warning_klass
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# 标号
|
62
|
+
@mark = [0, 0, 0]
|
63
|
+
|
64
|
+
# 按流程算法运行
|
65
|
+
process(info)
|
66
|
+
|
67
|
+
# 保存
|
68
|
+
word.display_alerts = true
|
69
|
+
|
70
|
+
begin
|
71
|
+
word.save(output_file.to_s)
|
72
|
+
rescue Exception => e
|
73
|
+
e.message
|
74
|
+
ensure
|
75
|
+
#word.close
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# 创建风格
|
80
|
+
def create_style
|
81
|
+
|
82
|
+
# 用于目录的标题
|
83
|
+
@doc.create_style_self("Contents") do |sty|
|
84
|
+
sty.font.size = 20
|
85
|
+
sty.font.NameFarEast = "黑体"
|
86
|
+
sty.font.NameAscii = "Book Antiqua"
|
87
|
+
sty.font.NameOther = "Book Antiqua"
|
88
|
+
sty.font.bold = true
|
89
|
+
# 段落间距
|
90
|
+
sty.ParagraphFormat.Alignment = 2 # 文本右对齐
|
91
|
+
sty.ParagraphFormat.LineUnitBefore = 3 #
|
92
|
+
sty.ParagraphFormat.LineUnitAfter = 2
|
93
|
+
sty.NextParagraphStyle = "正文"
|
94
|
+
# 段落控制
|
95
|
+
sty.ParagraphFormat.WidowControl = true
|
96
|
+
sty.ParagraphFormat.KeepWithNext = true
|
97
|
+
sty.ParagraphFormat.PageBreakBefore = true
|
98
|
+
# 边框
|
99
|
+
sty.ParagraphFormat.Borders(-1).LineStyle = 0
|
100
|
+
sty.ParagraphFormat.Borders(-2).LineStyle = 0
|
101
|
+
sty.ParagraphFormat.Borders(-4).LineStyle = 0
|
102
|
+
bottom = sty.ParagraphFormat.Borders(-3)
|
103
|
+
bottom.LineStyle = 1
|
104
|
+
bottom.LineWidth = 12
|
105
|
+
bottom.Color = 0
|
106
|
+
end
|
107
|
+
|
108
|
+
# 一级标题
|
109
|
+
@doc.create_style_self("font_chapter_name1") do |sty|
|
110
|
+
sty.BaseStyle = "Contents"
|
111
|
+
sty.ParagraphFormat.OutlineLevel = 1
|
112
|
+
sty.NextParagraphStyle = "正文"
|
113
|
+
end
|
114
|
+
|
115
|
+
# 一级标题标号
|
116
|
+
@doc.create_style_self("font_chapter_num1") do |sty|
|
117
|
+
sty.BaseStyle = "Contents"
|
118
|
+
sty.font.size = 72
|
119
|
+
sty.ParagraphFormat.LineUnitBefore = 0.5
|
120
|
+
sty.ParagraphFormat.LineUnitAfter = 0.5
|
121
|
+
sty.ParagraphFormat.OutlineLevel = 1
|
122
|
+
sty.NextParagraphStyle = "font_chapter_name1"
|
123
|
+
end
|
124
|
+
|
125
|
+
# 二级标题
|
126
|
+
@doc.create_style_self("font_section_name1") do |sty|
|
127
|
+
sty.BaseStyle = "正文"
|
128
|
+
sty.font.bold = true
|
129
|
+
sty.font.size = 18
|
130
|
+
sty.ParagraphFormat.LineUnitBefore = 1
|
131
|
+
sty.ParagraphFormat.LineUnitAfter = 1
|
132
|
+
sty.ParagraphFormat.OutlineLevel = 2
|
133
|
+
sty.NextParagraphStyle = "正文"
|
134
|
+
end
|
135
|
+
|
136
|
+
# 二级标题标号
|
137
|
+
@doc.create_style_self("font_section_num1") do |sty|
|
138
|
+
sty.BaseStyle = "font_section_name1"
|
139
|
+
sty.NextParagraphStyle = "font_section_name1"
|
140
|
+
end
|
141
|
+
|
142
|
+
@doc.create_style_self("font_level3_name1") do |sty|
|
143
|
+
sty.BaseStyle = "正文"
|
144
|
+
sty.font.bold = true
|
145
|
+
sty.font.size = 18
|
146
|
+
sty.ParagraphFormat.LineUnitBefore = 1
|
147
|
+
sty.ParagraphFormat.LineUnitAfter = 1
|
148
|
+
sty.ParagraphFormat.OutlineLevel = 3
|
149
|
+
sty.NextParagraphStyle = "正文"
|
150
|
+
end
|
151
|
+
|
152
|
+
@doc.create_style_self("font_level3_num1") do |sty|
|
153
|
+
sty.BaseStyle = "font_level3_name1"
|
154
|
+
sty.NextParagraphStyle = "font_level3_name1"
|
155
|
+
end
|
156
|
+
|
157
|
+
# 要点
|
158
|
+
@doc.create_style_self("importance") do |sty|
|
159
|
+
sty.BaseStyle = "正文"
|
160
|
+
sty.font.bold = true
|
161
|
+
sty.font.size = 18
|
162
|
+
sty.ParagraphFormat.LineUnitBefore = 1
|
163
|
+
sty.ParagraphFormat.LineUnitAfter = 1
|
164
|
+
sty.NextParagraphStyle = "正文"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# 主体流程控制
|
169
|
+
def process(info)
|
170
|
+
generate_cover(info)
|
171
|
+
generate_catalog(info)
|
172
|
+
generate_introduction(info)
|
173
|
+
|
174
|
+
generate_summary(info)
|
175
|
+
generate_summarize(info)
|
176
|
+
update_catalog
|
177
|
+
end
|
178
|
+
|
179
|
+
# 创建封面
|
180
|
+
def generate_cover(info)
|
181
|
+
@text.add_head_image(File.join(info[:resource_file], "cover_picture.png"))
|
182
|
+
@text.style = "正文"
|
183
|
+
@text.entry
|
184
|
+
@text.entry
|
185
|
+
@text.entry
|
186
|
+
|
187
|
+
@text.font.size = 16
|
188
|
+
@text.center
|
189
|
+
@text.section { "数据通信网络高级巡检报告" }
|
190
|
+
@text.entry
|
191
|
+
@text.entry
|
192
|
+
|
193
|
+
client = info[:client]
|
194
|
+
time = info[:time]
|
195
|
+
@text.font.Size = 15
|
196
|
+
@text.section { "客户名称:#{client}" }
|
197
|
+
@text.section { "巡检时间:#{time}" }
|
198
|
+
|
199
|
+
@text.add_table(1,1) { |tbl| }
|
187
200
|
=begin
|
188
|
-
|
189
|
-
|
190
|
-
|
201
|
+
@text.entry
|
202
|
+
@text.entry
|
203
|
+
@text.entry
|
191
204
|
|
192
|
-
|
193
|
-
|
194
|
-
|
205
|
+
@text.left
|
206
|
+
@text.font.bold = true
|
207
|
+
@text.add_image(File.join(info[:resource_file], "logo.png"))
|
195
208
|
=end
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
###
|
235
|
-
#
|
236
|
-
# 巡检概要报告
|
237
|
-
#
|
238
|
-
###
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
209
|
+
end
|
210
|
+
|
211
|
+
# 生成目录
|
212
|
+
def generate_catalog(info)
|
213
|
+
@text.section("Contents") { "目 录" }
|
214
|
+
@doc.create_catalog
|
215
|
+
@text.page_break
|
216
|
+
end
|
217
|
+
|
218
|
+
# 生成前言
|
219
|
+
def generate_introduction(info)
|
220
|
+
@text.section("font_chapter_name1") { "前言" }
|
221
|
+
@text.section("font_section_name1") { "概述" }
|
222
|
+
@text.puts "根据#{info[:client]}的运行维护需要,公司对其网络设备进行了巡检。本文档提供了本次巡检所有设备的检查明细信息及汇总信息,针对检查中发现的设备在运行过程中存在的故障隐患和风险提出了相关建议,并对网络整体的健康程度进行了评估。"
|
223
|
+
@text.entry
|
224
|
+
@text.puts "通过本文档,您可以及时了解网络设备的健康状况,清除设备故障隐患,指导技术人员完成对网络的改造优化,提高网络的可用性,保障业务可靠运行。"
|
225
|
+
|
226
|
+
@text.section("font_section_name1") { "读者对象" }
|
227
|
+
@text.puts "本项目相关的网络运行维护主管、技术工程师、系统集成商工程师等。"
|
228
|
+
|
229
|
+
@text.page_break
|
230
|
+
@text.entry
|
231
|
+
@text.section("importance") { "尊敬的_______________________ :" }
|
232
|
+
@text.puts "感谢您选择我们的产品和服务!为了提高网络的可用性,保障网络的稳定运行,我们于#{info[:time]}对贵单位网络设备进行了巡检服务。现将本次服务的情况向您汇报如下,并请您对我们的工作给予评价。"
|
233
|
+
@text.entry
|
234
|
+
@text.puts "感谢您和您的团队在本次服务过程中给我们的配合和支持!"
|
235
|
+
@text.entry
|
236
|
+
@text.entry
|
237
|
+
@text.entry
|
238
|
+
@text.entry
|
239
|
+
@text.entry
|
240
|
+
@text.entry
|
241
|
+
@text.entry
|
242
|
+
@text.puts "本次巡检负责人:"
|
243
|
+
@text.puts "联系电话:"
|
244
|
+
@text.puts "联系邮箱:"
|
245
|
+
end
|
246
|
+
|
247
|
+
###
|
248
|
+
#
|
249
|
+
# 巡检概要报告
|
250
|
+
#
|
251
|
+
###
|
252
|
+
# 流程控制
|
253
|
+
def generate_summary(info)
|
254
|
+
add_title_1("巡检概要报告")
|
255
|
+
generate_summary_overview(info)
|
256
|
+
generate_summary_device_type(info)
|
257
|
+
generate_summary_warning_device_top10(info)
|
258
|
+
generate_summary_level(info)
|
259
|
+
generate_summary_problem(info)
|
260
|
+
generate_summary_major_problem(info)
|
261
|
+
end
|
262
|
+
|
263
|
+
# 概述
|
264
|
+
def generate_summary_overview(info)
|
265
|
+
add_title_2("概述")
|
266
|
+
tmp = "本次巡检共巡检设备#{device_manager.devices_number}台," +
|
267
|
+
"发现问题#{warning_summarize.total_number}个。" +
|
268
|
+
"其中严重问题#{warning_summarize.serious_number}个," +
|
269
|
+
"一般问题#{warning_summarize.ordinary_number}个。"
|
270
|
+
@text.puts tmp
|
271
|
+
end
|
272
|
+
|
273
|
+
# 巡检设备类型
|
274
|
+
def generate_summary_device_type(info)
|
275
|
+
add_title_2("巡检设备类型")
|
276
|
+
@text.puts "下图表示本次巡检各类型设备所占的比例: "
|
277
|
+
|
278
|
+
# 生成table数据目录
|
279
|
+
type_info = device_manager.device_type_classify.to_a
|
280
|
+
tbl = []
|
281
|
+
type_info.size.times do |i|
|
282
|
+
# 将Hash 变成数组后,按照indent输出
|
283
|
+
tbl << [ type_info[i][0], type_info[i][1].size.to_s ]
|
284
|
+
end
|
285
|
+
|
286
|
+
# 生成图表
|
287
|
+
@text.chart(tbl) do |chart|
|
288
|
+
chart.type = chart.class::Pie
|
289
|
+
chart.style = 251
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
# 发现问题数TOP20的设备
|
294
|
+
def generate_summary_warning_device_top10(info)
|
295
|
+
add_title_2("发现问题数TOP10的设备")
|
296
|
+
@text.puts "本次巡检发现问题数排名前10的设备,如下图所示: "
|
297
|
+
|
298
|
+
tbl = [["", "serious", "ordinary", "compare"]]
|
299
|
+
|
300
|
+
type_warning_info = warning_summarize.device_warning_sort
|
301
|
+
n = 0
|
302
|
+
type_warning_info.each do |dev|
|
303
|
+
n += 1
|
304
|
+
next unless dev[1].total_number > 0
|
305
|
+
break if n > 10
|
306
|
+
tbl << [ dev[0],
|
307
|
+
dev[1].serious_number,
|
308
|
+
dev[1].ordinary_number,
|
309
|
+
dev[1].compare_number ]
|
310
|
+
end
|
311
|
+
|
312
|
+
@text.chart(tbl) do |chart|
|
313
|
+
chart.type = chart.class::ColumnStacked
|
314
|
+
chart.style = 251
|
315
|
+
chart.series_name = false
|
316
|
+
chart.category_name = false
|
317
|
+
chart.value = false
|
318
|
+
chart.axes_unit(1)
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
# 按问题级别展现
|
323
|
+
def generate_summary_level(info)
|
324
|
+
|
325
|
+
# 当没有内容的时候,返回
|
326
|
+
return if warning_summarize.total_number.zero?
|
327
|
+
|
328
|
+
add_title_2("按问题级别展现")
|
329
|
+
@text.puts "本次巡检发现的问题级别分布情况,如下图所示: "
|
330
|
+
tbl = []
|
331
|
+
if warning_summarize.has_serious?
|
332
|
+
tbl << ["serious", warning_summarize.serious_number]
|
333
|
+
end
|
334
|
+
|
335
|
+
if warning_summarize.has_ordinary?
|
336
|
+
tbl << ["ordinary", warning_summarize.ordinary_number]
|
337
|
+
end
|
338
|
+
|
339
|
+
if warning_summarize.has_compare?
|
340
|
+
tbl << ["compare", warning_summarize.compare_number]
|
341
|
+
end
|
342
|
+
|
343
|
+
@text.chart(tbl) do |chart|
|
344
|
+
chart.type = chart.class::Pie
|
345
|
+
chart.style = 251
|
346
|
+
end
|
347
|
+
|
348
|
+
#------
|
349
|
+
@text.entry
|
350
|
+
@text.puts "1、本次巡检发现的严重问题数最多的5台设备,如下图所示:"
|
351
|
+
tbl = warning_summarize.device_serious_sort
|
352
|
+
# 只保留5个
|
353
|
+
n = 0
|
354
|
+
tbl.delete_if { |x| n += 1 ;n > 5 }
|
355
|
+
tbl.insert(0, ["", "数量"])
|
356
|
+
@text.chart(tbl) do |chart|
|
357
|
+
chart.type = chart.class::ColumnClustered
|
358
|
+
chart.style = 251
|
359
|
+
chart.series_name = false
|
360
|
+
chart.category_name = false
|
361
|
+
chart.value = false
|
362
|
+
chart.axes_unit(1)
|
363
|
+
end
|
364
|
+
|
365
|
+
#------
|
366
|
+
@text.entry
|
367
|
+
@text.puts "2、本次巡检发现的一般问题数最多的5台设备,如下图所示:"
|
368
|
+
tbl = warning_summarize.device_ordinary_sort
|
369
|
+
# 只保留5个
|
370
|
+
n = 0
|
371
|
+
tbl.delete_if { |x| n += 1 ;n > 5 }
|
372
|
+
tbl.insert(0, ["", "数量"])
|
373
|
+
@text.chart(tbl) do |chart|
|
374
|
+
chart.type = chart.class::ColumnClustered
|
375
|
+
chart.style = 251
|
376
|
+
chart.series_name = false
|
377
|
+
chart.category_name = false
|
378
|
+
chart.value = false
|
379
|
+
chart.axes_unit(1)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
# 按问题发生频率展现
|
384
|
+
def generate_summary_problem(info)
|
385
|
+
add_title_2("按问题发生频率展现")
|
386
|
+
@text.puts "本次巡检发现的发生频率最多的5类问题,如下图所示:"
|
387
|
+
tbl = warning_summarize.problem_frequency
|
388
|
+
n = 0
|
389
|
+
tbl.delete_if { |x| n += 1 ;n > 5 }
|
390
|
+
tbl.insert(0, ["", "数量"])
|
391
|
+
@text.chart(tbl) do |chart|
|
392
|
+
chart.type = chart.class::BarClustered
|
393
|
+
chart.style = 251
|
394
|
+
chart.series_name = false
|
395
|
+
chart.category_name = false
|
396
|
+
chart.value = false
|
397
|
+
chart.axes_unit(1)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
# 主要问题分析及说明
|
402
|
+
def generate_summary_major_problem(info)
|
403
|
+
return if warning_summarize.total_number.zero?
|
404
|
+
add_title_2("主要问题分析及说明")
|
405
|
+
@text.puts "本章节将详细介绍巡检过程中发生的所有严重问题,及发生频率最高的3类一般和提示问题。"
|
406
|
+
|
407
|
+
#------
|
408
|
+
warning_summarize.summary[:serious].each_pair do |cs, dev_info|
|
409
|
+
desc_klass = warning_summarize.get_desc(cs)
|
410
|
+
add_title_3(desc_klass.title)
|
411
|
+
level(:serious)
|
412
|
+
@text.puts desc_klass.to_s + "不符合该规则的设备共#{dev_info.size}台,明细如下:"
|
413
|
+
add_device_table(dev_info)
|
414
|
+
end
|
415
|
+
|
416
|
+
#------
|
417
|
+
warning_summarize.summary[:ordinary].each_pair do |cs, dev_info|
|
418
|
+
desc_klass = warning_summarize.get_desc(cs)
|
419
|
+
add_title_3(desc_klass.title)
|
420
|
+
level(:ordinary)
|
421
|
+
@text.puts desc_klass.to_s + "不符合该规则的设备共#{dev_info.size}台,明细如下:"
|
422
|
+
add_device_table(dev_info)
|
423
|
+
end
|
424
|
+
|
425
|
+
end
|
426
|
+
|
427
|
+
# 打印级别
|
428
|
+
def level(sym)
|
429
|
+
res = ""
|
430
|
+
case sym
|
431
|
+
when :serious
|
432
|
+
res = "级别: 严重"
|
433
|
+
when :ordinary
|
434
|
+
res = "级别: 一般"
|
435
|
+
end
|
436
|
+
|
437
|
+
@text.style = "importance"
|
438
|
+
@text.size = 12
|
439
|
+
@text.puts res
|
440
|
+
end
|
441
|
+
|
442
|
+
# 添加按照设备标明的表格
|
443
|
+
def add_device_table(dev_info)
|
444
|
+
tbl = [ ["序号", "名称", "型号", "IP"] ]
|
445
|
+
n = 1
|
446
|
+
dev_info.each_pair do |name, klass_info|
|
447
|
+
klass = klass_info[:klass]
|
448
|
+
tbl << [n, name,
|
449
|
+
klass.device_info[:device_model],
|
450
|
+
klass.get_manager_ip ]
|
451
|
+
n += 1
|
452
|
+
end
|
453
|
+
@text.size = 10
|
454
|
+
@text.add_table_by_value(tbl) do |table|
|
455
|
+
table.center
|
456
|
+
table.border_line
|
457
|
+
table.set_columns_width(1, 44)
|
458
|
+
table.set_columns_width(2, 143)
|
459
|
+
table.set_columns_width(3, 143)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
|
464
|
+
# 总结流程控制
|
465
|
+
def generate_summarize(info)
|
466
|
+
@text.page_break
|
467
|
+
generate_machine_room(info)
|
468
|
+
generate_inspection(info)
|
469
|
+
generate_offer(info)
|
470
|
+
generate_appraise(info)
|
471
|
+
end
|
472
|
+
|
473
|
+
# 机房环境检查结果
|
474
|
+
def generate_machine_room(info)
|
475
|
+
add_title_2("机房环境检查结果")
|
476
|
+
@text.add_table(1,1) do |tbl|
|
477
|
+
tbl.height = 100
|
478
|
+
tbl.border_line
|
479
|
+
end
|
480
|
+
|
481
|
+
end
|
482
|
+
|
483
|
+
# 巡检结论
|
484
|
+
def generate_inspection(info)
|
485
|
+
add_title_2("巡检结论")
|
486
|
+
@text.add_table(1,1) do |tbl|
|
487
|
+
tbl.height = 100
|
488
|
+
tbl.border_line
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
# 运行维护建议
|
493
|
+
def generate_offer(info)
|
494
|
+
add_title_2("运行维护建议")
|
495
|
+
@text.add_table(1,1) do |tbl|
|
496
|
+
tbl.height = 100
|
497
|
+
tbl.border_line
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
# 您对本次巡检情况的评价
|
502
|
+
def generate_appraise(info)
|
503
|
+
add_title_2("您对本次巡检情况的评价")
|
504
|
+
@text.add_table(1,1) do |tbl|
|
505
|
+
tbl.height = 100
|
506
|
+
tbl.border_line
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
private
|
511
|
+
###
|
512
|
+
#
|
513
|
+
# 本地方法
|
514
|
+
#
|
515
|
+
###
|
516
|
+
# 更新目录
|
517
|
+
def update_catalog
|
518
|
+
@doc.update_catalog
|
519
|
+
end
|
520
|
+
|
521
|
+
# 1级标题
|
522
|
+
def add_title_1(str)
|
523
|
+
@mark[0] += 1
|
524
|
+
@mark[1] = 0
|
525
|
+
@mark[2] = 0
|
526
|
+
mk = @mark[0].to_s
|
527
|
+
@text.style = "font_chapter_name1"
|
528
|
+
@text.print join(mk, str)
|
529
|
+
modify_num(mk, "font_chapter_num1")
|
530
|
+
@text.entry
|
531
|
+
end
|
532
|
+
|
533
|
+
# 2级标题
|
534
|
+
def add_title_2(str)
|
535
|
+
@mark[1] += 1
|
536
|
+
@mark[2] = 0
|
537
|
+
mk = [@mark[0], @mark[1]].join(".")
|
538
|
+
@text.style = "font_section_name1"
|
539
|
+
@text.print join(mk, str)
|
540
|
+
modify_num(mk, "font_section_num1")
|
541
|
+
@text.entry
|
542
|
+
end
|
543
|
+
|
544
|
+
# 3级标题
|
545
|
+
def add_title_3(str)
|
546
|
+
@mark[2] += 1
|
547
|
+
mk = [@mark[0], @mark[1], @mark[2]].join(".")
|
548
|
+
@text.style = "font_level3_name1"
|
549
|
+
@text.print join(mk, str)
|
550
|
+
modify_num(mk, "font_level3_num1")
|
551
|
+
@text.entry
|
552
|
+
end
|
553
|
+
|
554
|
+
# 合并,以空格分开
|
555
|
+
def join(*arg)
|
556
|
+
arg.join(" ")
|
557
|
+
end
|
558
|
+
|
559
|
+
# 修改标题数字
|
560
|
+
def modify_num(num, sty)
|
561
|
+
@doc.home_key
|
562
|
+
@doc.move_right(num.size, 1)
|
563
|
+
@text.now.Style = @doc.doc_work.Styles(sty)
|
564
|
+
#@text.now.ParagraphFormat.LineUnitBefore = 0.1
|
565
|
+
@doc.end_key
|
566
|
+
end
|
567
|
+
|
568
|
+
# 添加占位符
|
569
|
+
def add_holder(str)
|
570
|
+
PlaceHolder + " " + str
|
571
|
+
end
|
572
|
+
|
573
|
+
def replace_holder(str, style)
|
574
|
+
@text.replace(PlaceHolder, str.to_s, style)
|
575
|
+
end
|
576
|
+
|
577
|
+
# 警告信息汇总类
|
578
|
+
def warning_summarize
|
579
|
+
device_manager.warning_summarize
|
580
|
+
end
|
563
581
|
|
564
582
|
end
|