Jing Li 2022-11-07 10:14:13 +08:00
parent 153e830ed3
commit cd75ea7a2b
2 changed files with 19 additions and 14 deletions

View File

@ -9,6 +9,7 @@ use App\Services\LinkosDeviceLogService;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
class LinkosController extends Controller class LinkosController extends Controller
{ {
@ -16,6 +17,7 @@ class LinkosController extends Controller
{ {
$input = $request->input(); $input = $request->input();
DB::transaction(function () use ($input) {
if (isset($input['notify_type'])) { if (isset($input['notify_type'])) {
// 设备上线、离线通知 // 设备上线、离线通知
if ($input['notify_type'] === 'online_state_change') { if ($input['notify_type'] === 'online_state_change') {
@ -30,6 +32,7 @@ class LinkosController extends Controller
break; break;
} }
} }
});
return response()->json(['code' => 0, 'msg' => 'ok']); return response()->json(['code' => 0, 'msg' => 'ok']);
} }

View File

@ -437,8 +437,10 @@ class LinkosDeviceLogService
// 角度转弧度 // 角度转弧度
$radian = deg2rad($sample['wind_degree']); $radian = deg2rad($sample['wind_degree']);
$x += $sample['wind_speed'] * sin($radian); // $x += $sample['wind_speed'] * sin($radian);
$y += $sample['wind_speed'] * cos($radian); // $y += $sample['wind_speed'] * cos($radian);
$x += sin($radian);
$y += cos($radian);
} }
$degree = round(rad2deg(atan($x / $y))); $degree = round(rad2deg(atan($x / $y)));