From cd75ea7a2b9ed397d8be2adcc1ad35988d567ad5 Mon Sep 17 00:00:00 2001 From: Jing Li Date: Mon, 7 Nov 2022 10:14:13 +0800 Subject: [PATCH] Fix --- .../Controllers/Callback/LinkosController.php | 27 ++++++++++--------- app/Services/LinkosDeviceLogService.php | 6 +++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Callback/LinkosController.php b/app/Http/Controllers/Callback/LinkosController.php index 00cace5..24dab6a 100644 --- a/app/Http/Controllers/Callback/LinkosController.php +++ b/app/Http/Controllers/Callback/LinkosController.php @@ -9,6 +9,7 @@ use App\Services\LinkosDeviceLogService; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\DB; class LinkosController extends Controller { @@ -16,20 +17,22 @@ class LinkosController extends Controller { $input = $request->input(); - if (isset($input['notify_type'])) { - // 设备上线、离线通知 - if ($input['notify_type'] === 'online_state_change') { - $this->handleOnlineStateChangeNotify($input); - } - } elseif (Arr::has($input, ['device_id', 'device_unit', 'device_category'])) { - $type = (int) ($input['type'] ?? 0); + DB::transaction(function () use ($input) { + if (isset($input['notify_type'])) { + // 设备上线、离线通知 + if ($input['notify_type'] === 'online_state_change') { + $this->handleOnlineStateChangeNotify($input); + } + } elseif (Arr::has($input, ['device_id', 'device_unit', 'device_category'])) { + $type = (int) ($input['type'] ?? 0); - switch ($type) { - case 0: - $this->handleDeviceDataNotify($input); - break; + switch ($type) { + case 0: + $this->handleDeviceDataNotify($input); + break; + } } - } + }); return response()->json(['code' => 0, 'msg' => 'ok']); } diff --git a/app/Services/LinkosDeviceLogService.php b/app/Services/LinkosDeviceLogService.php index 7e8a51a..a32606d 100644 --- a/app/Services/LinkosDeviceLogService.php +++ b/app/Services/LinkosDeviceLogService.php @@ -437,8 +437,10 @@ class LinkosDeviceLogService // 角度转弧度 $radian = deg2rad($sample['wind_degree']); - $x += $sample['wind_speed'] * sin($radian); - $y += $sample['wind_speed'] * cos($radian); + // $x += $sample['wind_speed'] * sin($radian); + // $y += $sample['wind_speed'] * cos($radian); + $x += sin($radian); + $y += cos($radian); } $degree = round(rad2deg(atan($x / $y)));