Project.php
7.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
187
188
189
190
191
192
193
194
195
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
<?php
namespace app\api\controller\v7\screen;
use app\common\controller\Api;
use think\Db;
/**
* 工程运行监测
* Class Project
* @package app\api\controller\v7\screen
*/
class Project extends Api
{
public $noNeedLogin = ['*'];
public $noNeedRight = ['*'];
protected $projectStatusList = [
1 => '待开始',
2 => '进行中',
3 => '完成',
];
protected $warningStatusList = [
1 => '待处理',
2 => '处理中',
3 => '处理完成',
];
protected $warningTypesList = [
1 => '管道腐蚀',
2 => '管道裂口',
3 => '管道变形',
];
public function _initialize()
{
parent::_initialize();
}
//工程运行事项任务
public function mission(){
$list = Db::name('pipes_project')->select();
foreach ($list as &$item){
$item['createtime'] = date('Y-m-d', $item['createtime']);
$item['status_text'] = $this->projectStatusList[$item['status']];
}
$this->success('成功', $list);
}
//实时管道监测
public function monitor(){
$result = [
[
'images' => full_image_kevin('/uploads/20231224/FoN06J19nMnSf0KXoPQYMLkK8MbH.jpg'),
],
[
'images' => full_image_kevin('/uploads/20231224/FoN06J19nMnSf0KXoPQYMLkK8MbH.jpg'),
],
[
'images' => full_image_kevin('/uploads/20231224/FoN06J19nMnSf0KXoPQYMLkK8MbH.jpg'),
],
[
'images' => full_image_kevin('/uploads/20231224/FoN06J19nMnSf0KXoPQYMLkK8MbH.jpg'),
],
[
'images' => full_image_kevin('/uploads/20231224/FoN06J19nMnSf0KXoPQYMLkK8MbH.jpg'),
],
[
'images' => full_image_kevin('/uploads/20231224/FoN06J19nMnSf0KXoPQYMLkK8MbH.jpg'),
]
];
$this->success('成功', $result);
}
//输水管道监测
public function trans(){
$list = Db::name('pipes_transmission')->select();
$status1 = 0;
$status2 = 0;
$status3 = 0;
$status4 = 0;
$types1 = 0;
$types2 = 0;
$types3 = 0;
foreach ($list as $item){
switch (intval($item['status'])){
case 1:
$status1++;
break;
case 2:
$status2++;
break;
case 3:
$status3++;
break;
case 4:
$status4++;
break;
}
switch (intval($item['types'])){
case 1:
$types1++;
break;
case 2:
$types2++;
break;
case 3:
$types3++;
break;
}
}
$result = [
'total' => count($list),
'status_1' => $status1,
'status_2' => $status2,
'status_3' => $status3,
'status_4' => $status4,
'types_1' => $types1,
'types_2' => $types2,
'types_3' => $types3,
];
$this->success('成功', $result);
}
//坝体安全监测
public function dam(){
$list = Db::name('pipes_dam')->select();
$result = [
[
'title' => '设备一',
'displacement_x' => '0.2',
'displacement_y' => '0.2',
'displacement_z' => '0.2',
'status' => 1,
'status_text' => '正常',
'normal_num' => 10,
'total_num' => 10,
],
[
'title' => '设备二',
'displacement_x' => '0.2',
'displacement_y' => '0.2',
'displacement_z' => '0.2',
'status' => 2,
'status_text' => '预警',
'normal_num' => 5,
'total_num' => 10,
],
[
'title' => '设备三',
'displacement_x' => '0.2',
'displacement_y' => '0.2',
'displacement_z' => '0.2',
'status' => 2,
'status_text' => '预警',
'normal_num' => 7,
'total_num' => 10,
],
];
$result = [
'month' => $result,
'quarter' => $result,
'year' => $result,
];
$this->success('成功', $result);
}
protected $pressureTypesList = [
1 => '压力异常',
2 => '压力突变',
];
//管网漏损报警
public function warning(){
$list = Db::name('pipes_warning')->select();
foreach ($list as &$item){
$item['createtime'] = date('Y-m-d H:i', $item['createtime']);
$item['dealtime'] = date('Y-m-d H:i', $item['dealtime']);
$item['status_text'] = $this->warningStatusList[$item['status']];
$item['types_text'] = $this->warningTypesList[$item['types']];
$item['staff_info'] = Db::name('inspection_staff')->field('staff_name,mobile')->where('id',$item['staff_id'])->find();
$item['pressure_type_text'] = $this->pressureTypesList[$item['pressure_type']];
}
$result = [
'seven_statics' => [
'today' => [
'x' => [
date('H:i', strtotime("-6 hour")),
date('H:i', strtotime("-5 hour")),
date('H:i', strtotime("-4 hour")),
date('H:i', strtotime("-3 hour")),
date('H:i', strtotime("-2 hour")),
date('H:i', strtotime("-1 hour")),
date('H:i'),
],
'y' =>[
3,
4,
6,
5,
4,
3,
2,
]
],
'seven' => [
'x' => [
date('m-d', strtotime("-6 day")),
date('m-d', strtotime("-5 day")),
date('m-d', strtotime("-4 day")),
date('m-d', strtotime("-3 day")),
date('m-d', strtotime("-2 day")),
date('m-d', strtotime("-1 day")),
date('m-d'),
],
'y' =>[
3,
4,
6,
5,
4,
3,
2,
]
]
],
'today' => $list,
'seven' => $list,
];
$this->success('成功', $result);
}
//管网漏损报警详情
public function warningDetail(){
$id = $this->request->param('id');
if (empty($id)){
$this->error('id必须');
}
$list = Db::name('pipes_warning')->where('id', $id)->find();
if (!$list){
$this->error('数据不存在');
}
$list['createtime'] = date('Y-m-d H:i', $list['createtime']);
$list['dealtime'] = date('Y-m-d H:i', $list['dealtime']);
$list['status_text'] = $this->warningStatusList[$list['status']];
$list['types_text'] = $this->warningTypesList[$list['types']];
$list['staff_info'] = Db::name('inspection_staff')->field('staff_name,mobile')->where('id',$list['staff_id'])->find();
$imagesArr = explode(',',trim($list['images'],','));
foreach ($imagesArr as &$image){
$image = full_image_kevin($image);
}
unset($image);
$list['images_arr'] = $imagesArr;
$this->success('成功', $list);
}
}