|
@@ -122,6 +122,13 @@ class TagHistory extends CatchController
|
|
|
$list[$key]['temperature'] = $da['temperature'];
|
|
|
$list[$key]['addTime'] = date('Y-m-d H:i:s', $value['addTime']);
|
|
|
$list[$key]['time'] = date('Y-m-d H:i:s', $da['time']);
|
|
|
+ if ($da['temperWarn'] == '00') {
|
|
|
+ $list[$key]['temperWarn'] = '正常';
|
|
|
+ } elseif ($da['temperWarn'] == '01') {
|
|
|
+ $list[$key]['temperWarn'] = '低温告警';
|
|
|
+ } elseif ($da['temperWarn'] == '10') {
|
|
|
+ $list[$key]['temperWarn'] = '高温告警';
|
|
|
+ }
|
|
|
}
|
|
|
return CatchResponse::success($list);
|
|
|
}
|
|
@@ -263,6 +270,13 @@ class TagHistory extends CatchController
|
|
|
foreach ($list as $key => $value) {
|
|
|
$list[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
|
|
|
$list[$key]['addTime'] = date('Y-m-d H:i:s', $value['addTime']);
|
|
|
+ if ($value['temperWarn'] == '00') {
|
|
|
+ $list[$key]['temperWarn'] = '正常';
|
|
|
+ } elseif ($value['temperWarn'] == '01') {
|
|
|
+ $list[$key]['temperWarn'] = '低温告警';
|
|
|
+ } elseif ($value['temperWarn'] == '10') {
|
|
|
+ $list[$key]['temperWarn'] = '高温告警';
|
|
|
+ }
|
|
|
}
|
|
|
return json([
|
|
|
'code' => Code::SUCCESS,
|
|
@@ -273,79 +287,62 @@ class TagHistory extends CatchController
|
|
|
'data' => $list,
|
|
|
]);
|
|
|
}
|
|
|
- //随机生成温度
|
|
|
- public function randomTemperature()
|
|
|
- {
|
|
|
|
|
|
- $resout = 38.5;
|
|
|
- return $resout;
|
|
|
- }
|
|
|
- //生成随机步数
|
|
|
- public function randomStep()
|
|
|
- {
|
|
|
- $intage = 10;
|
|
|
- $resout = $intage;
|
|
|
- return $resout;
|
|
|
- }
|
|
|
/**
|
|
|
* 折现图
|
|
|
*/
|
|
|
public function lineChart(Request $request)
|
|
|
{
|
|
|
$data = $request->get();
|
|
|
- $start_time = $data['start_time'];
|
|
|
+ $mac = null;
|
|
|
+ $lable = null;
|
|
|
+ if (!empty($data['start_time'])) {
|
|
|
+ $start_time = strtotime($data['start_time'][0]);
|
|
|
+ $end_time = strtotime($data['start_time'][1]);
|
|
|
+ }
|
|
|
|
|
|
if (empty($start_time)) {
|
|
|
$start_time = strtotime(date('Y-m-d'));
|
|
|
}
|
|
|
-
|
|
|
+ if (!empty($data['mac'])) {
|
|
|
+ $mac = $data['mac'];
|
|
|
+ }
|
|
|
+ if (!empty($data['lable'])) {
|
|
|
+ $lable = $data['lable'];
|
|
|
+ }
|
|
|
$end_time = null;
|
|
|
if (!$end_time) {
|
|
|
$end_time = time();
|
|
|
}
|
|
|
|
|
|
$where = [];
|
|
|
- $where[] = [$start_time, '>=', 'addTime'];
|
|
|
- $where[] = [$end_time, '=<', 'addTime'];
|
|
|
- $where[] = ['mac', 'in', '30B5F10138ED'];
|
|
|
- $where[] = ['lable', 'in', "000000880002,000000880003"];
|
|
|
+ $where[] = ['addTime', '>=', $start_time];
|
|
|
+ $where[] = ['addTime', '<', $end_time];
|
|
|
+ $where[] = ['mac', '=', $mac];
|
|
|
+ $where[] = ['lable', '=', $lable];
|
|
|
+
|
|
|
+ $list = $this->tagHistoryModel->where($where)->order('addTime asc')->select();
|
|
|
|
|
|
- $list = $this->tagHistoryModel->where($where)->order('addTime desc')->select()->toArray();
|
|
|
|
|
|
$time = [];
|
|
|
$lable1 = [];
|
|
|
- $lable2 = [];
|
|
|
+
|
|
|
foreach ($list as $item) {
|
|
|
- $time[] = $item['addTime'];
|
|
|
- if ($item['lable'] == '000000880002') {
|
|
|
- $lable1[$item['addTime']] = $item['temperature'];
|
|
|
- if (!$lable2[$item['addTime']]) {
|
|
|
- $lable2[$item['addTime']] = null;
|
|
|
- }
|
|
|
- } else if ($item['lable'] == '000000880003') {
|
|
|
- $lable2[] = $item['temperature'];
|
|
|
- if (!$lable1[$item['addTime']]) {
|
|
|
- $lable1[$item['addTime']] = null;
|
|
|
- }
|
|
|
- }
|
|
|
+ $time[] = date('Y-m-d H:i:s', $item['addTime']);
|
|
|
+ $lable1[] = $item['temperature'];
|
|
|
}
|
|
|
$renData = [];
|
|
|
$renData = [
|
|
|
- 'xAxis' => array_unique($time),
|
|
|
- 'legend' => ['000000880002', '000000880003'],
|
|
|
+ 'xAxis' => $time,
|
|
|
+ 'legend' => [$lable],
|
|
|
'series' => [
|
|
|
[
|
|
|
- 'name' => '000000880002',
|
|
|
+ 'name' => $lable,
|
|
|
'type' => 'line',
|
|
|
'stack' => 'Total',
|
|
|
- 'data' => array_values($lable1)
|
|
|
+ 'data' => $lable1
|
|
|
],
|
|
|
- [
|
|
|
- 'name' => '000000880003',
|
|
|
- 'type' => 'line',
|
|
|
- 'stack' => 'Total',
|
|
|
- 'data' => array_values($lable2)
|
|
|
- ]
|
|
|
+
|
|
|
]
|
|
|
|
|
|
];
|