From d269f344d5b021a3e0784b66947d9d074344aa13 Mon Sep 17 00:00:00 2001 From: weiz Date: Tue, 31 Oct 2023 10:30:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=A7=8D=E5=85=BB=E6=AE=96?= =?UTF-8?q?=E7=9B=91=E7=AE=A1=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/AnimalBreedController.php | 32 ++++++++++++++++++- app/api/controller/FishBreedController.php | 32 ++++++++++++++++++- app/api/controller/LandPlantController.php | 32 ++++++++++++++++++- app/api/controller/PoultryBreedController.php | 32 ++++++++++++++++++- app/api/controller/UserController.php | 24 ++++++++++++++ 5 files changed, 148 insertions(+), 4 deletions(-) diff --git a/app/api/controller/AnimalBreedController.php b/app/api/controller/AnimalBreedController.php index 1c4fc01d..a5cf7b5d 100644 --- a/app/api/controller/AnimalBreedController.php +++ b/app/api/controller/AnimalBreedController.php @@ -11,7 +11,8 @@ 'addAnimal','animalInfo','animalList','animalSell','animalStatus','animalChangeList','animalSearchByCode', 'addAnimalPic','animalPicList', 'addAnimalRecord','delAnimalRecord','ediAnimalRecord','animalRecordInfo','animalRecordList', - 'animalEnvData' + 'animalEnvData', + 'addAnimalCheckData','animalCheckDataList' ]; //获取状态文本 @@ -339,4 +340,33 @@ } return $this->success('请求成功',$data); } + + //提交农户动物饲养监管数据 + public function addAnimalCheckData(): Json + { + $params = $this->request->post(['user_id','check_status','pic']); + if(empty($params['user_id']) || empty($params['check_status']) || !in_array($params['check_status'],[1,2,3]) || empty($params['pic'])){ + return $this->fail('参数错误'); + } + $params['create_time'] = time(); + $result = Db::name('farmer_animal_check')->insert($params); + return $result ? $this->success('添加成功',[],1,1) : $this->fail('添加失败',[],1,1); + } + + //农户动物饲养监管数据列表 + public function animalCheckDataList(): Json + { + $params = $this->request->get(['user_id','page_no','page_size']); + if(empty($params['user_id'])){ + return $this->fail('参数错误'); + } + //设置分页条件 + $pageNo = empty($params['page_no']) || $params['page_no'] < 0 ? 1 : $params['page_no']; + $pageSize = empty($params['page_size']) || $params['page_size'] < 0 ? 10 : $params['page_size']; + $data = Db::name('farmer_animal_check')->where('user_id',$params['user_id'])->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){ + $item['create_time'] = date('Y-m-d H:i:s',$item['create_time']); + return $item; + })->toArray(); + return $this->success('请求成功',$data); + } } \ No newline at end of file diff --git a/app/api/controller/FishBreedController.php b/app/api/controller/FishBreedController.php index ff8b18c6..e2935902 100644 --- a/app/api/controller/FishBreedController.php +++ b/app/api/controller/FishBreedController.php @@ -12,7 +12,8 @@ 'addFish','catchFish', 'addFishPic','fishPicList', 'addFishRecord','delFishRecord','ediFishRecord','fishRecordList', - 'pondEnvData' + 'pondEnvData', + 'addPondCheckData','pondCheckDataList' ]; //获取农户池塘信息 @@ -224,4 +225,33 @@ return $this->success('请求成功',$data); } + //提交池塘监管数据 + public function addPondCheckData(): Json + { + $params = $this->request->post(['pond_id','check_status','pic']); + if(empty($params['pond_id']) || empty($params['check_status']) || !in_array($params['check_status'],[1,2,3]) || empty($params['pic'])){ + return $this->fail('参数错误'); + } + $params['create_time'] = time(); + $result = Db::name('farmer_pond_check')->insert($params); + return $result ? $this->success('添加成功',[],1,1) : $this->fail('添加失败',[],1,1); + } + + //池塘监管数据列表 + public function pondCheckDataList(): Json + { + $params = $this->request->get(['pond_id','page_no','page_size']); + if(empty($params['pond_id'])){ + return $this->fail('参数错误'); + } + //设置分页条件 + $pageNo = empty($params['page_no']) || $params['page_no'] < 0 ? 1 : $params['page_no']; + $pageSize = empty($params['page_size']) || $params['page_size'] < 0 ? 10 : $params['page_size']; + $data = Db::name('farmer_pond_check')->where('pond_id',$params['pond_id'])->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){ + $item['create_time'] = date('Y-m-d H:i:s',$item['create_time']); + return $item; + })->toArray(); + return $this->success('请求成功',$data); + } + } \ No newline at end of file diff --git a/app/api/controller/LandPlantController.php b/app/api/controller/LandPlantController.php index 05c98d08..02dca50e 100644 --- a/app/api/controller/LandPlantController.php +++ b/app/api/controller/LandPlantController.php @@ -11,7 +11,8 @@ 'addLandCrop','addLandCropPic','landCropPicList', 'addLandCropRecord','delLandCropRecord','ediLandCropRecord','landCropRecordInfo','landCropRecordList', 'setLandCropRipe', - 'landEnvDataChart','landEnvDataCurr' + 'landEnvDataChart','landEnvDataCurr', + 'addLandCheckData','landCheckDataList' ]; //获取农户土地信息 @@ -262,4 +263,33 @@ return $this->success('请求成功',$data); } + //提交土地监管数据 + public function addLandCheckData(): Json + { + $params = $this->request->post(['land_id','check_status','pic']); + if(empty($params['land_id']) || empty($params['check_status']) || !in_array($params['check_status'],[1,2,3]) || empty($params['pic'])){ + return $this->fail('参数错误'); + } + $params['create_time'] = time(); + $result = Db::name('farmer_land_check')->insert($params); + return $result ? $this->success('添加成功',[],1,1) : $this->fail('添加失败',[],1,1); + } + + //土地监管数据列表 + public function landCheckDataList(): Json + { + $params = $this->request->get(['land_id','page_no','page_size']); + if(empty($params['land_id'])){ + return $this->fail('参数错误'); + } + //设置分页条件 + $pageNo = empty($params['page_no']) || $params['page_no'] < 0 ? 1 : $params['page_no']; + $pageSize = empty($params['page_size']) || $params['page_size'] < 0 ? 10 : $params['page_size']; + $data = Db::name('farmer_land_check')->where('land_id',$params['land_id'])->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){ + $item['create_time'] = date('Y-m-d H:i:s',$item['create_time']); + return $item; + })->toArray(); + return $this->success('请求成功',$data); + } + } \ No newline at end of file diff --git a/app/api/controller/PoultryBreedController.php b/app/api/controller/PoultryBreedController.php index 52ffa1f7..3c042a6a 100644 --- a/app/api/controller/PoultryBreedController.php +++ b/app/api/controller/PoultryBreedController.php @@ -11,7 +11,8 @@ 'addPoultry','poultryInfo','poultryList','poultrySell','poultryStatus','poultryChangeList','poultrySearchByCode', 'addPoultryPic','poultryPicList', 'addPoultryRecord','delPoultryRecord','ediPoultryRecord','poultryRecordInfo','poultryRecordList', - 'poultryEnvData' + 'poultryEnvData', + 'addPoultryCheckData','poultryCheckDataList' ]; //获取状态文本 @@ -339,4 +340,33 @@ } return $this->success('请求成功',$data); } + + //提交农户家禽饲养监管数据 + public function addPoultryCheckData(): Json + { + $params = $this->request->post(['user_id','check_status','pic']); + if(empty($params['user_id']) || empty($params['check_status']) || !in_array($params['check_status'],[1,2,3]) || empty($params['pic'])){ + return $this->fail('参数错误'); + } + $params['create_time'] = time(); + $result = Db::name('farmer_poultry_check')->insert($params); + return $result ? $this->success('添加成功',[],1,1) : $this->fail('添加失败',[],1,1); + } + + //农户家禽饲养监管数据列表 + public function poultryCheckDataList(): Json + { + $params = $this->request->get(['user_id','page_no','page_size']); + if(empty($params['user_id'])){ + return $this->fail('参数错误'); + } + //设置分页条件 + $pageNo = empty($params['page_no']) || $params['page_no'] < 0 ? 1 : $params['page_no']; + $pageSize = empty($params['page_size']) || $params['page_size'] < 0 ? 10 : $params['page_size']; + $data = Db::name('farmer_poultry_check')->where('user_id',$params['user_id'])->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){ + $item['create_time'] = date('Y-m-d H:i:s',$item['create_time']); + return $item; + })->toArray(); + return $this->success('请求成功',$data); + } } \ No newline at end of file diff --git a/app/api/controller/UserController.php b/app/api/controller/UserController.php index 07c08953..3e2057a8 100644 --- a/app/api/controller/UserController.php +++ b/app/api/controller/UserController.php @@ -59,6 +59,14 @@ class UserController extends BaseApiController $maleCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_gender',1)->where('animal_status','<>',5)->count(); //获取家畜是母的数量 $maternalCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_gender',2)->where('animal_status','<>',5)->count(); + //健康的 + $healthyCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_status',1)->count(); + //怀孕的 + $pregnancyCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_status',2)->count(); + //生病的 + $sickCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_status',3)->count(); + //可出栏的 + $marketableCount = Db::name('farmer_animal_breed')->where('user_id',$params['user_id'])->where('animal_status',4)->count(); //获取家畜养殖种类 $animalKind = Db::name('farmer_animal_breed')->distinct(true)->where('user_id',$params['user_id'])->where('animal_status','<>',5)->limit(4)->column('animal_kind'); //获取家畜养殖具体品种 @@ -67,6 +75,10 @@ class UserController extends BaseApiController 'total_count' => $animalCount, 'male_count' => $maleCount, 'maternal_count' => $maternalCount, + 'healthy_count' => $healthyCount, + 'pregnancy_count' => $pregnancyCount, + 'sick_count' => $sickCount, + 'marketable_count' => $marketableCount, 'kind' => $animalKind, 'breed' => $animalBreed ]; @@ -79,6 +91,14 @@ class UserController extends BaseApiController $maleCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('gender',1)->where('status','<>',5)->count(); //获取家畜是母的数量 $maternalCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('gender',2)->where('status','<>',5)->count(); + //健康的 + $healthyCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('status',1)->count(); + //怀孕的 + $pregnancyCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('status',2)->count(); + //生病的 + $sickCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('status',3)->count(); + //可出栏的 + $marketableCount = Db::name('farmer_poultry_breed')->where('user_id',$params['user_id'])->where('status',4)->count(); //获取家畜养殖种类 $poultryKind = Db::name('farmer_poultry_breed')->distinct(true)->where('user_id',$params['user_id'])->where('status','<>',5)->limit(4)->column('kind'); //获取家畜养殖具体品种 @@ -87,6 +107,10 @@ class UserController extends BaseApiController 'total_count' => $poultryCount, 'male_count' => $maleCount, 'maternal_count' => $maternalCount, + 'healthy_count' => $healthyCount, + 'pregnancy_count' => $pregnancyCount, + 'sick_count' => $sickCount, + 'marketable_count' => $marketableCount, 'kind' => $poultryKind, 'breed' => $poultryBreed ];