update
This commit is contained in:
parent
7e9930a444
commit
762a5c5f11
|
@ -5,6 +5,7 @@ use app\common\enum\notice\NoticeEnum;
|
||||||
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\AirMonitor;
|
||||||
|
use app\common\model\monitor\MonitorData;
|
||||||
use app\common\model\monitor\SoilMonitor;
|
use app\common\model\monitor\SoilMonitor;
|
||||||
use app\common\model\product\ProductDevice;
|
use app\common\model\product\ProductDevice;
|
||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
|
@ -39,14 +40,31 @@ class IndexController extends BaseApiController
|
||||||
if($landProduct->isEmpty()){
|
if($landProduct->isEmpty()){
|
||||||
$data['monitor'] = [];
|
$data['monitor'] = [];
|
||||||
}else{
|
}else{
|
||||||
$device = ProductDevice::where('product_id',$landProduct['product_id'])->select();
|
$monitor = MonitorData::where('product_id',$landProduct['product_id'])->order('id desc')->findOrEmpty();
|
||||||
foreach($device as $v) {
|
if($monitor->isEmpty()){
|
||||||
if($v['device_type'] == 1){
|
$data['monitor'] = [];
|
||||||
$data['monitor']['soil_monitor_data'] = SoilMonitor::where('device_id',$v['device_id'])->order('id desc')->findOrEmpty()->toArray();
|
}else{
|
||||||
}
|
$data['monitor']['soil_monitor_data'] = [
|
||||||
if($v['device_type'] == 2){
|
'wind_direction'=>$monitor['wind_direction'],
|
||||||
$data['monitor']['air_monitor_data'] = AirMonitor::where('device_id',$v['device_id'])->order('id desc')->findOrEmpty()->toArray();
|
'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']
|
||||||
|
];
|
||||||
|
$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']
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->success('请求成功',$data);
|
return $this->success('请求成功',$data);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\monitor;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
class MonitorData extends BaseModel
|
||||||
|
{
|
||||||
|
protected $name = 'monitor_data';
|
||||||
|
}
|
Loading…
Reference in New Issue