新增溯源结果查询接口
This commit is contained in:
parent
84a941a1fc
commit
cd0dd00d6d
|
@ -2,12 +2,11 @@
|
||||||
namespace app\api\controller;
|
namespace app\api\controller;
|
||||||
|
|
||||||
use app\common\enum\notice\NoticeEnum;
|
use app\common\enum\notice\NoticeEnum;
|
||||||
|
use app\common\model\action\Action;
|
||||||
use app\common\model\land\Land;
|
use app\common\model\land\Land;
|
||||||
use app\common\model\land\LandProduct;
|
use app\common\model\land\LandProduct;
|
||||||
use app\common\model\monitor\AirMonitor;
|
|
||||||
use app\common\model\monitor\MonitorData;
|
use app\common\model\monitor\MonitorData;
|
||||||
use app\common\model\monitor\SoilMonitor;
|
use app\common\model\plant\Plant;
|
||||||
use app\common\model\product\ProductDevice;
|
|
||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
use think\response\Json;
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue