From 8571666ad5dea96534b2f65814494e2b52bbbc73 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Thu, 14 Dec 2023 15:00:45 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E8=AE=BE=E5=A4=87=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/dataview/DeviceController.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 app/api/controller/dataview/DeviceController.php diff --git a/app/api/controller/dataview/DeviceController.php b/app/api/controller/dataview/DeviceController.php new file mode 100644 index 00000000..d6924924 --- /dev/null +++ b/app/api/controller/dataview/DeviceController.php @@ -0,0 +1,51 @@ +areaCode = $this->request->param('areaCode', ''); + $this->streetCode = $this->request->param('streetCode', ''); + if ($this->areaCode == '') { + throw new ValidateException('未获取到位置信息'); + } + } + + public function deviceAlarmCount() + { + $list = MonitorAlarm::alias('ma')->field('ma.*,d.code AS device_code,d.name AS device_name') + ->join('device d', 'ma.device_id=d.id') + ->join('product_device pd', 'd.id=pd.device_id') + ->join('land_product lp', 'pd.product_id=lp.product_id') + ->join('land l', 'l.id=lp.land_id') + ->where(function ($query) { + if ($this->streetCode != '') { + $query->where('l.street_code', $this->streetCode); + } else { + $query->where('l.area_code', $this->areaCode); + } + }) + ->whereWeek('ma.create_time') + ->limit(30) + ->select(); + return $this->success('成功', compact('list')); + } + +} \ No newline at end of file