Screenapi.php
4.7 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
<?php
/**
* Created by PhpStorm.
* User: pcl
* Date: 2022/5/30
* Time: 11:12
*/
namespace app\api\controller;
use think\Db;
use app\common\controller\Api;
use app\common\model\User;
/**
* 水库总大屏
* 0530新增接口
*
*/
class Screenapi extends Api
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
public function _initialize()
{
parent::_initialize();
}
/**
* 底部分类名称
*
*/
public function getCatName()
{
$arr = [
'0' => ['id' => 1, 'name' => '全部'],
'1' => ['id' => 2, 'name' => '摄像头'],
'2' => ['id' => 3, 'name' => '雨量计'],
'3' => ['id' => 4, 'name' => '北斗位移'],
'4' => ['id' => 5, 'name' => '水库'],
'5' => ['id' => 6, 'name' => '志愿者'],
'6' => ['id' => 7, 'name' => '待办'],
];
$this->success('获取成功', $arr);
}
/***
* 获得海康监控的列表
* 监控经纬度和视频地址
*/
public function gethkDecList()
{
$wh['latitude'] = ['>', '0'];
$list = Db::name('reservoir_hkws_hardware')
->alias('h')
->join('reservoir_list r', 'h.reservoir_id=r.id')
->order('h.reservoir_id', 'asc')
->where($wh)
->field('h.id,h.reservoir_id,h.name,h.type_child_name,h.indexCode,h.image,h.intercom_occupancy_userid,h.longitude,h.latitude,r.name as reservoir_name')
->select();
foreach ($list as $k => $v) {
$list[$k]['image'] = setQiniuFileUrl($v['image']);
}
$this->success('获取成功', $list);
}
/**
* 雨水情监测
* 雨量计列表
*/
public function equpTypeList()
{
$list = Db::name('reservoir_equipment')
->alias('h')
->join('reservoir_list r', 'h.reservoir_id=r.id')
->where(['type' => '5'])
->order('h.reservoir_id', 'asc')
->field('h.id,h.reservoir_id,h.name,h.status,h.longitude,h.latitude,r.name as reservoir_name')
->select();
foreach ($list as $k => $v) {
$list[$k]['longitude'] = str_replace("\r\n", "", $v['longitude']);
$list[$k]['latitude'] = str_replace("\r\n", "", $v['latitude']);
//当前降水量
$now_rainfall = Db::name('reservoir_rain_rainfall')
->where(['reservoir_id' => $v['reservoir_id']])
->order('id', 'desc')
->value('total_rainfall');
$list[$k]['now_rainfall'] = $now_rainfall ? $now_rainfall : 0;
//累计降水量
$star_time = date('Ymd', strtotime('-12 month', time()));
$wh['reservoir_id'] = ['=', $v['reservoir_id']];
$wh['daytime'] = ['>', $star_time];
$all_rainfall = Db::name('reservoir_rainfall_ctday')
->where($wh)
->sum('total_rainfall');
$list[$k]['all_rainfall'] = $all_rainfall ? $all_rainfall : 0;
//当前库水位
$water_level = Db::name('reservoir_warning_waterlevel')
->where(['reservoir_id' => $v['reservoir_id']])
->value('value');
$list[$k]['all_rainfall'] = $water_level ? $water_level : 0;
//当前库容量
$kurong = Db::name('warterdata_capacityof')
->where(['warterdata' => $water_level])
->value('CapacityOf');
$list[$k]['kurong'] = $kurong ? $kurong : 0;
}
$this->success('获取成功', $list);
}
/***
* 位移设备列表
*
*/
public function displaceList()
{
$list = Db::name('reservoir_equipment')
->alias('h')
->join('reservoir_list r', 'h.reservoir_id=r.id')
->where(['type' => '6'])
->order('h.reservoir_id', 'asc')
->field('h.id,h.reservoir_id,h.name,h.status,h.longitude,h.latitude,r.name as reservoir_name')
->select();
foreach ($list as $k => $v) {
$list[$k]['longitude'] = str_replace("\r\n", "", $v['longitude']);
$list[$k]['latitude'] = str_replace("\r\n", "", $v['latitude']);
//当前最新1条数据
$newinfo = Db::name('reservoir_dam_displacement')
->where(['reservoir_id' => $v['reservoir_id']])
->find();
$list[$k]['xx'] = $newinfo['horizontal'];
$list[$k]['yy'] = $newinfo['horizontalY'];
$list[$k]['zz'] = $newinfo['vertical'];
}
$this->success('获取成功', $list);
}
/**
* 待办列表
*/
public function noticeList()
{
}
}