From cd0dd00d6d8c4821c7314615990f7d041d99f177 Mon Sep 17 00:00:00 2001 From: weiz Date: Tue, 28 Nov 2023 09:54:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=BA=AF=E6=BA=90=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/IndexController.php | 36 ++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index b9e1eec6..a8000bac 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -2,12 +2,11 @@ namespace app\api\controller; use app\common\enum\notice\NoticeEnum; +use app\common\model\action\Action; use app\common\model\land\Land; use app\common\model\land\LandProduct; -use app\common\model\monitor\AirMonitor; use app\common\model\monitor\MonitorData; -use app\common\model\monitor\SoilMonitor; -use app\common\model\product\ProductDevice; +use app\common\model\plant\Plant; use think\facade\Log; use think\response\Json; @@ -102,8 +101,35 @@ class IndexController extends BaseApiController } } - public function suYuan() { - + public function suYuan(): Json + { + $params = $this->request->get(['plant_id']); + if(empty($params['plant_id'])){ + return $this->fail('参数错误'); + } + $plantInfo = Plant::where('id',$params['plant_id'])->findOrEmpty(); + if($plantInfo->isEmpty()){ + return $this->fail('种植信息错误'); + } + if($plantInfo['status'] != 2){ + return $this->fail('种植信息状态错误'); + } + $landInfo = Land::where('id',$plantInfo['land_id'])->findOrEmpty(); + if($landInfo->isEmpty()){ + return $this->fail('土地信息错误'); + } + $plantInfo['pic'] = json_decode($plantInfo['pic'],true); + $plantInfo['plant_date'] = date('Y-m-d',$plantInfo['plant_date']); + $plantInfo['land_name'] = $landInfo['title']; + $plantInfo['land_area'] = $landInfo['total_area']; + $plantInfo['land_address'] = $landInfo['province_name'].$landInfo['city_name'].$landInfo['county_name'].$landInfo['town_name'].$landInfo['village_name'].$landInfo['group_name']; + //获取操作 + $action = Action::field('type_text,detail,create_time')->where('plant_id',$params['plant_id'])->select()->each(function($item){ + $item['detail'] = json_decode($item['detail'],true); + return $item; + })->toArray(); + $plantInfo['actions'] = $action; + return $this->success('请求成功',$plantInfo->toArray()); }