土壤信息收集详情接口
This commit is contained in:
parent
3a1d9b7eab
commit
5f09f7a92a
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\IndexLogic;
|
||||
use app\common\model\LandCollection;
|
||||
use Exception;
|
||||
use Monolog\Handler\WhatFailureGroupHandler;
|
||||
use think\response\Json;
|
||||
|
||||
class IndexController extends BaseApiController
|
||||
{
|
||||
public $notNeedLogin = ['collect'];
|
||||
// 种植数据采集
|
||||
public function collect()
|
||||
{
|
||||
try {
|
||||
$parmas = $this->request->post();
|
||||
if(!$parmas || !isset($parmas['username']) || $parmas['username']==''){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
$payload= json_decode($parmas['payload'], true);
|
||||
|
||||
$data = [
|
||||
'land_name'=>$parmas['username'],
|
||||
'topic'=>$parmas['topic'],
|
||||
'qos'=>$parmas['qos'],
|
||||
'wind_speed' => $payload['wind_speed'],
|
||||
'wind_direction' => $payload['wind_direction'],
|
||||
'ambient_temperature' => $payload['ambient_temperature'],
|
||||
'ambient_humidity' => $payload['ambient_humidity'],
|
||||
'carbon_dioxide' => $payload['carbon_dioxide'],
|
||||
'ambient_air_pressure' => $payload['ambient_air_pressure'],
|
||||
'rainfall' => $payload['rainfall'],
|
||||
'ambient_lighting' => $payload['ambient_lighting'],
|
||||
'soil_temperature' => $payload['soil_temperature'],
|
||||
'soil_moisture' => $payload['soil_moisture'],
|
||||
'soil_PH' => $payload['soil_PH'],
|
||||
'soil_potassium_phosphate_nitrogen' => $payload['soil_potassium_phosphate_nitrogen'],
|
||||
'soil_potassium_phosphate_phosphorus' => $payload['soil_potassium_phosphate_phosphorus'],
|
||||
'soil_potassium_phosphate_potassium' => $payload['soil_potassium_phosphate_potassium'],
|
||||
'clientid'=>$parmas['clientid'],
|
||||
'create_time'=>date('Y-m-d H:i:s'),
|
||||
'update_time'=>date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
LandCollection::create($data);
|
||||
return $this->success('接收成功', ['user_name'=>$parmas['username'], 'topic'=>$parmas['topic']]);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
class LandCollection extends BaseModel
|
||||
{
|
||||
protected $name = 'land_collection';
|
||||
}
|
Loading…
Reference in New Issue