Inspection.php
3.1 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
<?php
/**
* Created by PhpStorm.
* User: yrf
* Date: 2022/4/3
* Time: 9:24
* ResvRaninDate
* 水库安全运行监测大屏接口
*
*/
namespace app\api\controller\safeoperation;
use app\common\controller\Api;
use fast\Tree;
use think\Db;
use think\Request;
class Inspection extends Api
{
protected $id;
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
$this->id = $this->request->param('id');
// var_dump($this->id);die;
parent::_initialize();
}
/**
* 水库实时坝体位移报告
* @var
*/
public function Displacement()
{
//位移表模型
$model = new \app\admin\model\reservoir\dam\Displacement;
$data = collection($model->where('reservoir_id', $this->id)
->field('vertical,horizontal,horizontalY,from_unixtime(createtime,"%m-%d %H:%i") as createtime')
->order('id desc')
->limit(20)
->select())->toArray();
$return_data = [];
if (!empty($data)) {
foreach ($data as $k => $v) {
unset($v['status_text']);
unset($v['warning_text']);
$return_data[$k] = array_values($v);
}
}
$this->success('请求成功', $return_data);
}
public function Reservoirname()
{
$name = Db::name('reservoir_list')
->where('id', $this->id)
->field('id,name,rain_bg_image')
->find();
if ($name) {
if (!empty($name['rain_bg_image'])) {
$name['rain_bg_image'] = full_image($name['rain_bg_image']);
$name['rain_bg_image'] = [$name['rain_bg_image']];
} else {
$name['rain_bg_image'] = [];
}
}
$this->success('请求成功', $name);
}
public function getgnss()
{
$model = new \app\admin\model\reservoir\dam\Displacement;
$time = $model->where('reservoir_id', $this->id)
->field('from_unixtime(createtime,"%Y-%m-%d ") as createtime')
->order('createtime desc')
->find()['createtime'];
$x = [];
$y = [];
$z = [];
$xtime = [];
for ($i = 0; $i < 5; $i++) {
$time1 = date('Y-m-d', strtotime("$time - $i day"));
$dataxyz = $model->where('reservoir_id', $this->id)
->where('createtime', 'between time', [$time1, $time])
->field('vertical,horizontal,horizontalY,from_unixtime(createtime,"%m-%d %h:%i") as createtime')
->order('createtime desc')
->find();
$x[] = $dataxyz['horizontal'];
$y[] = $dataxyz['horizontalY'];
$z[] = $dataxyz['vertical'];
$xtime[] = date('m-d', strtotime("$time - $i day"));
$time = date('Y-m-d', strtotime("$time - 1 day"));
}
$data = [
'x' => $x,
'y' => $y,
'z' => $z,
'time' => $xtime
];
$this->success('', $data);
}
}