From 5e1573731a56b0b5a6b1a761b77b3ecdfe83677a Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Fri, 15 Dec 2023 18:24:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E9=A1=B5=20=E5=9C=B0?= =?UTF-8?q?=E5=9D=97=E7=A7=8D=E6=A4=8D=E9=9D=A2=E7=A7=AF/=E7=A7=8D?= =?UTF-8?q?=E7=B1=BB=E7=BB=9F=E8=AE=A1=20=E6=94=B9=E9=80=A0=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=91=8A=E8=AD=A6=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=85=BC=E5=AE=B9=E6=9F=90=E4=B8=AA=E5=9C=B0=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/dataview/DeviceController.php | 14 ++++++++++---- app/api/controller/dataview/LandController.php | 14 +++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/api/controller/dataview/DeviceController.php b/app/api/controller/dataview/DeviceController.php index ea3ecb51..74531921 100644 --- a/app/api/controller/dataview/DeviceController.php +++ b/app/api/controller/dataview/DeviceController.php @@ -32,20 +32,26 @@ class DeviceController extends BaseApiController // 设备告警统计 public function deviceAlarmCount() { + $landId = $this->request->get('land_id', 0); $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.town_code', $this->streetCode); + ->where(function ($query) use ($landId) { + if ($landId != 0) { + $query->where('ma.land_id', $landId); } else { - $query->where('l.county_code', $this->areaCode); + if ($this->streetCode != '') { + $query->where('l.town_code', $this->streetCode); + } else { + $query->where('l.county_code', $this->areaCode); + } } }) ->whereWeek('ma.create_time') ->limit(30) + ->fetchSql() ->select(); return $this->success('成功', compact('list')); } diff --git a/app/api/controller/dataview/LandController.php b/app/api/controller/dataview/LandController.php index fcbdf532..7b199564 100644 --- a/app/api/controller/dataview/LandController.php +++ b/app/api/controller/dataview/LandController.php @@ -14,7 +14,7 @@ use think\exception\ValidateException; class LandController extends BaseApiController { - public array $notNeedLogin = ['plantProductCount', 'landCollectionList', 'landMonitorAlarmHistory', 'productList', 'landList', 'centralCount']; + public array $notNeedLogin = ['plantProductCount', 'landCollectionList', 'landMonitorAlarmHistory', 'productList', 'landList', 'centralCount', 'areaPlantTypeCount']; public $areaCode; public $streetCode; @@ -185,4 +185,16 @@ class LandController extends BaseApiController return $this->success('成功', compact('landCount', 'totalArea', 'plantCount')); } + + // 第二页 种植面积/种类 + public function areaPlantTypeCount() + { + $landId = $this->request->get('land_id'); + $query = Land::alias('l')->where('l.id', $landId); + // 种植面积 + $totalArea = $query->value('total_area'); + // 种植种类 + $plantKindList = $query->field('lp.land_id,lp.kind')->join('land_plant lp', 'l.id = lp.land_id')->group('lp.kind')->select(); + return $this->success('成功', compact('totalArea', 'plantKindList')); + } } \ No newline at end of file