This commit is contained in:
weiz 2023-10-26 16:10:26 +08:00
parent a757ccf91d
commit b5b1be9578
2 changed files with 37 additions and 2 deletions

View File

@ -171,7 +171,7 @@
return $resust ? $this->success('删除成功') : $this->fail('删除失败');
}
//删除水产养殖操作记录
//编辑水产养殖操作记录
public function ediFishRecord(): Json
{
$params = $this->request->post(['record_id','action_content']);
@ -207,7 +207,7 @@
return $this->success('请求成功',$data);
}
//获取农户土地监测数据实时数据
//农户池塘环境监测数据实时数据
public function pondEnvData(): Json
{
$params = $this->request->get(['user_id']);

View File

@ -86,6 +86,41 @@ class UserController extends BaseApiController
'breed' => $poultryBreed
];
}
//判断是否是水产养殖户
if($curl_result['data']['is_sc_user']){
$ponds = $curl_result['data']['pond_detail'];
foreach($ponds as $k=>$v) {
//获取养殖信息
$breedData = Db::name('farmer_pond_breed')->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->sum('number');
//获取捕捞信息
$catchData = Db::name('farmer_pond_catch')->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->sum('number');
if($breedData - $catchData != 0){
$ponds[$k]['is_culture'] = true;
$ponds[$k]['total_num'] = $breedData - $catchData;
//获取水产养殖种类
$fishKind = Db::name('farmer_pond_breed')->distinct(true)->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->limit(4)->column('kind');
//获取水产养殖具体品种
$fiskBreed = Db::name('farmer_pond_breed')->distinct(true)->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->limit(4)->column('breed');
$ponds[$k]['kind'] = $fishKind;
$ponds[$k]['breed'] = $fiskBreed;
//获取去最新的图片
$pic = Db::name('farmer_pond_pic')->field('pic,create_time')->where('pond_id',$v['pond_id'])->findOrEmpty();
if(!empty($pic)){
$ponds[$k]['pic_detail'] = $pic;
$ponds[$k]['pic_detail']['create_time'] = date('Y-m-d H:i:s',$pic['create_time']);
}else{
$ponds[$k]['pic_detail'] = [];
}
//获取养殖时间
$firstBreed = Db::name('farmer_pond_breed')->where('user_id',$params['user_id'])->where('pond_id',$v['pond_id'])->findOrEmpty();
$ponds[$k]['source_code'] = $firstBreed['source_code'];
$ponds[$k]['create_time'] = date('Y-m-d H:i:s',$firstBreed['create_time']);
}else{
$ponds[$k]['is_culture'] = false;
}
}
$curl_result['data']['pond_detail'] = $ponds;
}
//返回数据
return json($curl_result);
}