update 数据采集接口

This commit is contained in:
chenbo 2023-12-13 11:24:38 +08:00
parent 5a8ac9fe86
commit 5a54f0b692
1 changed files with 7 additions and 4 deletions

View File

@ -19,10 +19,11 @@ class DataCollectController extends BaseApiController
return $this->fail('参数错误');
}
$payload= json_decode($parmas['payload'], true);
$land = explode('_', $parmas['username']); // 命名规则land_id id土地表主键id
$device = explode('_', $parmas['topic']); // 命名规则topic_deviceid deviceid为设备主键id
$data = [
'land_name'=>$parmas['username'],
'topic'=>$parmas['topic'],
'land_id' => $land[1],
'topic'=>$device[1],
'qos'=>$parmas['qos'],
'wind_speed' => $payload['wind_speed'],
'wind_direction' => $payload['wind_direction'],
@ -41,7 +42,9 @@ class DataCollectController extends BaseApiController
'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']]);