新增种养殖监管相关接口

This commit is contained in:
weiz 2023-10-31 10:30:51 +08:00
parent 8bd66e64c0
commit d269f344d5
5 changed files with 148 additions and 4 deletions

View File

@ -11,7 +11,8 @@
'addAnimal','animalInfo','animalList','animalSell','animalStatus','animalChangeList','animalSearchByCode', 'addAnimal','animalInfo','animalList','animalSell','animalStatus','animalChangeList','animalSearchByCode',
'addAnimalPic','animalPicList', 'addAnimalPic','animalPicList',
'addAnimalRecord','delAnimalRecord','ediAnimalRecord','animalRecordInfo','animalRecordList', 'addAnimalRecord','delAnimalRecord','ediAnimalRecord','animalRecordInfo','animalRecordList',
'animalEnvData' 'animalEnvData',
'addAnimalCheckData','animalCheckDataList'
]; ];
//获取状态文本 //获取状态文本
@ -339,4 +340,33 @@
} }
return $this->success('请求成功',$data); 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);
}
} }

View File

@ -12,7 +12,8 @@
'addFish','catchFish', 'addFish','catchFish',
'addFishPic','fishPicList', 'addFishPic','fishPicList',
'addFishRecord','delFishRecord','ediFishRecord','fishRecordList', 'addFishRecord','delFishRecord','ediFishRecord','fishRecordList',
'pondEnvData' 'pondEnvData',
'addPondCheckData','pondCheckDataList'
]; ];
//获取农户池塘信息 //获取农户池塘信息
@ -224,4 +225,33 @@
return $this->success('请求成功',$data); 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);
}
} }

View File

@ -11,7 +11,8 @@
'addLandCrop','addLandCropPic','landCropPicList', 'addLandCrop','addLandCropPic','landCropPicList',
'addLandCropRecord','delLandCropRecord','ediLandCropRecord','landCropRecordInfo','landCropRecordList', 'addLandCropRecord','delLandCropRecord','ediLandCropRecord','landCropRecordInfo','landCropRecordList',
'setLandCropRipe', 'setLandCropRipe',
'landEnvDataChart','landEnvDataCurr' 'landEnvDataChart','landEnvDataCurr',
'addLandCheckData','landCheckDataList'
]; ];
//获取农户土地信息 //获取农户土地信息
@ -262,4 +263,33 @@
return $this->success('请求成功',$data); 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);
}
} }

View File

@ -11,7 +11,8 @@
'addPoultry','poultryInfo','poultryList','poultrySell','poultryStatus','poultryChangeList','poultrySearchByCode', 'addPoultry','poultryInfo','poultryList','poultrySell','poultryStatus','poultryChangeList','poultrySearchByCode',
'addPoultryPic','poultryPicList', 'addPoultryPic','poultryPicList',
'addPoultryRecord','delPoultryRecord','ediPoultryRecord','poultryRecordInfo','poultryRecordList', 'addPoultryRecord','delPoultryRecord','ediPoultryRecord','poultryRecordInfo','poultryRecordList',
'poultryEnvData' 'poultryEnvData',
'addPoultryCheckData','poultryCheckDataList'
]; ];
//获取状态文本 //获取状态文本
@ -339,4 +340,33 @@
} }
return $this->success('请求成功',$data); 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);
}
} }

View File

@ -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(); $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(); $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'); $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, 'total_count' => $animalCount,
'male_count' => $maleCount, 'male_count' => $maleCount,
'maternal_count' => $maternalCount, 'maternal_count' => $maternalCount,
'healthy_count' => $healthyCount,
'pregnancy_count' => $pregnancyCount,
'sick_count' => $sickCount,
'marketable_count' => $marketableCount,
'kind' => $animalKind, 'kind' => $animalKind,
'breed' => $animalBreed '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(); $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(); $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'); $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, 'total_count' => $poultryCount,
'male_count' => $maleCount, 'male_count' => $maleCount,
'maternal_count' => $maternalCount, 'maternal_count' => $maternalCount,
'healthy_count' => $healthyCount,
'pregnancy_count' => $pregnancyCount,
'sick_count' => $sickCount,
'marketable_count' => $marketableCount,
'kind' => $poultryKind, 'kind' => $poultryKind,
'breed' => $poultryBreed 'breed' => $poultryBreed
]; ];