From 5a54f0b692bddd1ed573684ed15bebdf1f5b4b0c Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Wed, 13 Dec 2023 11:24:38 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=95=B0=E6=8D=AE=E9=87=87=E9=9B=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/DataCollectController.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/api/controller/DataCollectController.php b/app/api/controller/DataCollectController.php index 24a9813c..a98a227d 100644 --- a/app/api/controller/DataCollectController.php +++ b/app/api/controller/DataCollectController.php @@ -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']]);