udpate 溯源首页详情接口

This commit is contained in:
chenbo 2023-12-19 10:18:47 +08:00
parent 0fc1f7fcc3
commit 8df9a67241
1 changed files with 20 additions and 19 deletions

View File

@ -6,6 +6,7 @@ use app\common\model\action\Action;
use app\common\model\device\Device;
use app\common\model\land\Land;
use app\common\model\land\LandProduct;
use app\common\model\LandCollection;
use app\common\model\monitor\MonitorData;
use app\common\model\plant\Plant;
use app\common\model\product\ProductDevice;
@ -42,30 +43,30 @@ class IndexController extends BaseApiController
if($landProduct->isEmpty()){
$data['monitor'] = [];
}else{
$monitor = MonitorData::where('product_id',$landProduct['product_id'])->order('id desc')->findOrEmpty();
if($monitor->isEmpty()){
$landCollection = LandCollection::where('land_id',$params['land_id'])->order('id desc')->findOrEmpty();
if($landCollection->isEmpty()){
$data['monitor'] = [];
}else{
$data['monitor']['soil_monitor_data'] = [
'wind_direction'=>$monitor['wind_direction'],
'wind_speed'=>$monitor['wind_speed'],
'air_temperature'=>$monitor['air_temperature'],
'air_moisture'=>$monitor['air_moisture'],
'co2_content'=>$monitor['co2_content'],
'pressure'=>$monitor['pressure'],
'rainfall'=>$monitor['rainfall'],
'light_intensity'=>$monitor['light_intensity'],
'create_time' => $monitor['create_time']
'wind_direction'=>$landCollection['wind_direction'],
'wind_speed'=>$landCollection['wind_speed'],
'air_temperature'=>$landCollection['ambient_temperature'],
'air_moisture'=>$landCollection['ambient_humidity'],
'co2_content'=>$landCollection['carbon_dioxide'],
'pressure'=>$landCollection['ambient_air_pressure'],
'rainfall'=>$landCollection['rainfall'],
'light_intensity'=>$landCollection['ambient_lighting'],
'create_time' => $landCollection['create_time']
];
$data['monitor']['air_monitor_data'] = [
'soil_temperature'=>$monitor['soil_temperature'],
'soil_moisture'=>$monitor['soil_moisture'],
'conductivity'=>$monitor['conductivity'],
'ph'=>$monitor['ph'],
'n_content'=>$monitor['n_content'],
'p_content'=>$monitor['p_content'],
'k_content'=>$monitor['k_content'],
'create_time' => $monitor['create_time']
'soil_temperature'=>$landCollection['soil_temperature'],
'soil_moisture'=>$landCollection['soil_moisture'],
'conductivity'=>$landCollection['soil_conductivity'],
'ph'=>$landCollection['soil_PH'],
'n_content'=>$landCollection['soil_potassium_phosphate_nitrogen'],
'p_content'=>$landCollection['soil_potassium_phosphate_phosphorus'],
'k_content'=>$landCollection['soil_potassium_phosphate_potassium'],
'create_time' => $landCollection['create_time']
];
}
}