|
@@ -46,7 +46,7 @@ class Equipment2 extends Api |
|
@@ -46,7 +46,7 @@ class Equipment2 extends Api |
46
|
foreach ($list as $k => $v) {
|
46
|
foreach ($list as $k => $v) {
|
47
|
|
47
|
|
48
|
$startTime = Db::name('reservoir_flow')->where(["number" => $v['deviceId'], "reservoir_id" => $v['reservoir_id']])->order('createtime desc')->value('createtime');
|
48
|
$startTime = Db::name('reservoir_flow')->where(["number" => $v['deviceId'], "reservoir_id" => $v['reservoir_id']])->order('createtime desc')->value('createtime');
|
49
|
- $startTime = $startTime ? $startTime + 1 : strtotime("2024-06-01 00:00:00");//数据是从07-14开始才有的,所以默认这个时间点
|
49
|
+ $startTime = $startTime ? $startTime + 1 : strtotime("2024-06-05 10:00:00");//数据是从07-14开始才有的,所以默认这个时间点
|
50
|
$time_arr = time_to_today_end($startTime);
|
50
|
$time_arr = time_to_today_end($startTime);
|
51
|
if (!empty($time_arr)) {
|
51
|
if (!empty($time_arr)) {
|
52
|
foreach ($time_arr as $k2 => $v2) {
|
52
|
foreach ($time_arr as $k2 => $v2) {
|
|
@@ -59,26 +59,27 @@ class Equipment2 extends Api |
|
@@ -59,26 +59,27 @@ class Equipment2 extends Api |
59
|
if (!empty($res)) {
|
59
|
if (!empty($res)) {
|
60
|
$r = json_decode($res, true);
|
60
|
$r = json_decode($res, true);
|
61
|
if (!empty($r) && $r['code'] == 0) {
|
61
|
if (!empty($r) && $r['code'] == 0) {
|
62
|
- $water_data = $r['data']['L3_SL'][$v['deviceId']];
|
|
|
63
|
- if (!empty($water_data)) {
|
|
|
64
|
- //$this->warning($v['deviceId'], $water_data);
|
|
|
65
|
- foreach ($water_data as $k3 => $v3) {
|
62
|
+ $instantaneous_data = $r['data']['L3_SL']['L3_SL_27'];
|
|
|
63
|
+ $cumulative_data = $r['data']['L3_SL']['L3_SL_60'];
|
|
|
64
|
+
|
|
|
65
|
+ if (!empty($instantaneous_data)) {
|
|
|
66
|
+ //$this->warning($v['deviceId'], $instantaneous_data);
|
|
|
67
|
+ foreach ($instantaneous_data as $k3 => $v3) {
|
66
|
$insert_data = [];
|
68
|
$insert_data = [];
|
67
|
$insert_data = [
|
69
|
$insert_data = [
|
68
|
'reservoir_id' => $v['reservoir_id'],
|
70
|
'reservoir_id' => $v['reservoir_id'],
|
69
|
- 'value' => $v3['value'],
|
71
|
+ 'instantaneous_value' =>$v3['value'],
|
|
|
72
|
+ 'cumulative_value' => $cumulative_data[$k3]['value'],
|
70
|
'createtime' => $v3['reportTime'] / 1000,
|
73
|
'createtime' => $v3['reportTime'] / 1000,
|
71
|
'updatetime' => $v3['reportTime'] / 1000,
|
74
|
'updatetime' => $v3['reportTime'] / 1000,
|
72
|
'reporttime' => $v3['reportTime'],
|
75
|
'reporttime' => $v3['reportTime'],
|
73
|
- 'number' => $v['deviceId']
|
76
|
+ 'number' => $v['apiKey']
|
74
|
];
|
77
|
];
|
75
|
$rr = Db::name('reservoir_flow')->insertGetId($insert_data);
|
78
|
$rr = Db::name('reservoir_flow')->insertGetId($insert_data);
|
76
|
-
|
|
|
77
|
if ($rr) {
|
79
|
if ($rr) {
|
78
|
$upt_succ = $upt_succ + 1;
|
80
|
$upt_succ = $upt_succ + 1;
|
79
|
}
|
81
|
}
|
80
|
}
|
82
|
}
|
81
|
-
|
|
|
82
|
}
|
83
|
}
|
83
|
}
|
84
|
}
|
84
|
}
|
85
|
}
|
|
@@ -100,6 +101,37 @@ class Equipment2 extends Api |
|
@@ -100,6 +101,37 @@ class Equipment2 extends Api |
100
|
}
|
101
|
}
|
101
|
}
|
102
|
}
|
102
|
|
103
|
|
|
|
104
|
+ public function warning($deviceid, $data)
|
|
|
105
|
+ {
|
|
|
106
|
+ $type = $this->model->where('deviceId', $deviceid)->value('type');
|
|
|
107
|
+ $threshold = Db::name('reservoir_threshold')->where('deviceId', $deviceid)->field('config,reservoir_id')->find();
|
|
|
108
|
+ $config = json_decode($threshold['config'], true);
|
|
|
109
|
+ $reservoir = Db::name('reservoir_list')->where('id', $threshold['reservoir_id'])->field('user_mobile,name')->find();
|
|
|
110
|
+
|
|
|
111
|
+ if (!$config) {
|
|
|
112
|
+ return;
|
|
|
113
|
+ }
|
|
|
114
|
+ //水位
|
|
|
115
|
+ if ($type == '1') {
|
|
|
116
|
+ $arr = explode(',', $config['value']);
|
|
|
117
|
+ sort($arr);
|
|
|
118
|
+ foreach ($data as $k => $v) {
|
|
|
119
|
+ if ($v['value'] < $arr[0] || $v['value'] > $arr[1]) {
|
|
|
120
|
+ $insert = [
|
|
|
121
|
+ 'value' => $v['value'],
|
|
|
122
|
+ 'warning' => $arr[0] . ',' . $arr[1],
|
|
|
123
|
+ 'equipment_id' => $deviceid,
|
|
|
124
|
+ 'reservoir_id' => $threshold['reservoir_id'],
|
|
|
125
|
+ 'createtime' => time(),
|
|
|
126
|
+ 'reporttime' => $v['reportTime']
|
|
|
127
|
+ ];
|
|
|
128
|
+ Db::name('reservoir_warning_waterlevel')->insert($insert);
|
|
|
129
|
+ // $sms = new Index();
|
|
|
130
|
+ // $res = $sms->send_param($reservoir['user_mobile'],'SMS_227742188','云南智慧水库安全云平台',array('password'=>$reservoir['name']));
|
|
|
131
|
+ }
|
|
|
132
|
+ }
|
|
|
133
|
+ }
|
103
|
|
134
|
|
|
|
135
|
+ }
|
104
|
|
136
|
|
105
|
} |
137
|
} |