|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use yii\bootstrap\ActiveForm; |
|
4
|
|
|
use yii\grid\GridView; |
|
5
|
|
|
|
|
6
|
|
|
$this->title = '队列统计'; |
|
7
|
|
|
$this->params['breadcrumbs'][] = $this->title; |
|
8
|
|
|
/* @var $dataProvider \yii\data\ActiveDataProvider */ |
|
9
|
|
|
/* @var $queue \graychen\yii2\queue\backend\models\RedisQueue */ |
|
10
|
|
|
?> |
|
11
|
|
|
<div class="appointment-order-index"> |
|
12
|
|
|
<?php $form = ActiveForm::begin([ |
|
13
|
|
|
'fieldConfig' => [ |
|
14
|
|
|
'template' => "{label}<div class=\"col-lg-3\">{input}</div>", |
|
15
|
|
|
'labelOptions' => ['class' => 'col-lg-3 control-label'], |
|
16
|
|
|
] |
|
17
|
|
|
]); ?> |
|
18
|
|
|
|
|
19
|
|
|
<ul class="nav nav-pills" role="tablist"> |
|
20
|
|
|
<button type="button" class="btn btn-primary btn-lg">总数(total):<span class="badge"><?= $queue->total ?></span> |
|
21
|
|
|
</button> |
|
22
|
|
|
<button type="button" class="btn btn-success btn-lg">完成(done):<span class="badge"><?= $queue->done ?></span> |
|
23
|
|
|
</button> |
|
24
|
|
|
</ul> |
|
25
|
|
|
<div class="btn-group" role="group" aria-label="..."> |
|
26
|
|
|
<button type="button" class="btn btn-danger">等待(waiting):<span class="badge"><?= $queue->waiting ?></span> |
|
27
|
|
|
</button> |
|
28
|
|
|
<button type="button" class="btn btn-warning">延迟(delayed):<span class="badge"><?= $queue->delayed ?></span> |
|
29
|
|
|
</button> |
|
30
|
|
|
<button type="button" class="btn btn-default">保留(reserved):<span class="badge"><?= $queue->reserved ?></span> |
|
31
|
|
|
</button> |
|
32
|
|
|
</div> |
|
33
|
|
|
<h2 class="page-title">队列信息</h2> |
|
34
|
|
|
<div id="w1" class="grid-view"> |
|
35
|
|
|
<table class="table table-striped table-bordered"> |
|
36
|
|
|
<thead> |
|
37
|
|
|
<tr> |
|
38
|
|
|
<th>队列ID</th> |
|
39
|
|
|
<th>队列地址</th> |
|
40
|
|
|
<th>队列名字</th> |
|
41
|
|
|
<th>队列位数</th> |
|
42
|
|
|
<th>运行时间</th> |
|
43
|
|
|
</thead> |
|
44
|
|
|
<tbody> |
|
45
|
|
|
<?php foreach ($queue->getWorkInfo() as $key => $value) { |
|
46
|
|
|
?> |
|
47
|
|
|
<tr> |
|
48
|
|
|
<td> |
|
49
|
|
|
<?= $value['id'] ?> |
|
50
|
|
|
</td> |
|
51
|
|
|
<td> |
|
52
|
|
|
<?= $value['addr'] ?> |
|
53
|
|
|
</td> |
|
54
|
|
|
<td> |
|
55
|
|
|
<?= $value['name'] ?> |
|
56
|
|
|
</td> |
|
57
|
|
|
<td> |
|
58
|
|
|
<?= $value['fd'] ?> |
|
59
|
|
|
</td> |
|
60
|
|
|
<td> |
|
61
|
|
|
<?= $value['age'] ?> |
|
62
|
|
|
</td> |
|
63
|
|
|
</tr> |
|
64
|
|
|
<?php |
|
65
|
|
|
} |
|
66
|
|
|
?> |
|
67
|
|
|
</tbody> |
|
68
|
|
|
</table> |
|
69
|
|
|
</div> |
|
70
|
|
|
<h2 class="page-title">队列详情</h2> |
|
71
|
|
|
<?= GridView::widget([ |
|
72
|
|
|
'dataProvider' => $dataProvider, |
|
73
|
|
|
'columns' => [ |
|
74
|
|
|
['class' => 'yii\grid\SerialColumn'], |
|
75
|
|
|
'catalog', |
|
76
|
|
|
'name', |
|
77
|
|
|
[ |
|
78
|
|
|
'attribute' => 'status', |
|
79
|
|
|
'value' => function ($model) { |
|
80
|
|
|
switch ($status = $model->getStatus($model->queue_id)) { |
|
|
|
|
|
|
81
|
|
|
case 0: |
|
82
|
|
|
return "等待中"; |
|
83
|
|
|
break; |
|
|
|
|
|
|
84
|
|
|
case 1: |
|
85
|
|
|
return "成功"; |
|
86
|
|
|
break; |
|
|
|
|
|
|
87
|
|
|
case 2: |
|
88
|
|
|
return "正在执行"; |
|
89
|
|
|
break; |
|
|
|
|
|
|
90
|
|
|
case -1: |
|
91
|
|
|
return "失败"; |
|
92
|
|
|
break; |
|
|
|
|
|
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
], |
|
96
|
|
|
[ |
|
97
|
|
|
'attribute' => 'created_at', |
|
98
|
|
|
'value' => function ($model) { |
|
99
|
|
|
return date("Y-m-d H:i:s", $model->created_at); |
|
100
|
|
|
} |
|
101
|
|
|
], |
|
102
|
|
|
[ |
|
103
|
|
|
'attribute' => 'exec_time', |
|
104
|
|
|
'value' => function ($model) { |
|
105
|
|
|
return date("Y-m-d H:i:s", $model->exec_time); |
|
106
|
|
|
} |
|
107
|
|
|
], |
|
108
|
|
|
['class' => 'yii\grid\ActionColumn', |
|
109
|
|
|
'template' => '{view}' |
|
110
|
|
|
] |
|
111
|
|
|
], |
|
112
|
|
|
]); ?> |
|
113
|
|
|
|
|
114
|
|
|
<?php ActiveForm::end(); ?> |
|
115
|
|
|
|
|
116
|
|
|
|
|
117
|
|
|
</div> |
|
118
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.