|
@@ -5,11 +5,12 @@
|
|
|
* @Author: likang
|
|
|
* @Date: 2022-08-12 11:31:01
|
|
|
* @LastEditors: likang
|
|
|
- * @LastEditTime: 2022-08-13 14:23:39
|
|
|
+ * @LastEditTime: 2022-08-13 17:00:52
|
|
|
*/
|
|
|
|
|
|
namespace catchAdmin\tag_history\controller;
|
|
|
|
|
|
+use catchAdmin\report\model\Report;
|
|
|
use catcher\base\CatchRequest as Request;
|
|
|
use catcher\CatchResponse;
|
|
|
use catcher\base\CatchController;
|
|
@@ -38,12 +39,12 @@ class TagHistory extends CatchController
|
|
|
$mac = isset($data['mac']) ? $data['mac'] : '';
|
|
|
$tage = isset($data['tage']) ? $data['tage'] : '';
|
|
|
$endtime = isset($data['endtime']) ? $data['endtime'] : "";
|
|
|
-
|
|
|
+ $meter = isset($data['meter']) ? $data['meter'] : "";
|
|
|
$where = [];
|
|
|
if (!empty($time)) {
|
|
|
$where[] = ['addTime', '>=', $time];
|
|
|
} else {
|
|
|
- $where[] = ['addTime', '>=', $time];
|
|
|
+ $where[] = ['addTime', '>=', time()];
|
|
|
}
|
|
|
|
|
|
if (!empty($mac)) {
|
|
@@ -53,6 +54,22 @@ class TagHistory extends CatchController
|
|
|
if (!empty($tage)) {
|
|
|
$where[] = ['lable', 'in', implode(",", $tage)];
|
|
|
}
|
|
|
+ if ($endtime == 1) {
|
|
|
+ //生成报告
|
|
|
+ $end = time();
|
|
|
+
|
|
|
+ $tagList = $this->tagHistoryModel->where($where)->where('addTime', '<=', $end)->select();
|
|
|
+ $content = [
|
|
|
+ 'mac' => json_encode($mac),
|
|
|
+ 'lable' => json_encode($tage),
|
|
|
+ 'meter' => $meter,
|
|
|
+ 'startTime' => $time,
|
|
|
+ 'endTime' => $end,
|
|
|
+ 'data' => json_encode($tagList)
|
|
|
+ ];
|
|
|
+ $report = new Report();
|
|
|
+ $report->save($content);
|
|
|
+ }
|
|
|
|
|
|
$list = $this->tagHistoryModel->group('mac,lable')->where($where)
|
|
|
->field('mac,lable,max(addTime) as addTime,AVG(rssi) as ave_rssi,count(*) as num')->select()->toArray();
|
|
@@ -67,6 +84,7 @@ class TagHistory extends CatchController
|
|
|
$list[$key]['rssi'] = $da['rssi'];
|
|
|
$list[$key]['addTime'] = date('Y-m-d H:i:s', $value['addTime']);
|
|
|
$list[$key]['time'] = date('Y-m-d H:i:s', $da['time']);
|
|
|
+ $list[$key]['id'] = $da['id'];
|
|
|
}
|
|
|
return CatchResponse::success($list);
|
|
|
}
|
|
@@ -133,7 +151,11 @@ class TagHistory extends CatchController
|
|
|
$list = $this->tagHistoryModel->group('lable')->column('lable');
|
|
|
return CatchResponse::success($list);
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @Descripttion: 获取时间
|
|
|
+ * @name: likang
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
public function getTime()
|
|
|
{
|
|
|
|