From 56226b84a62841207e958494d0feb76836b6696c Mon Sep 17 00:00:00 2001 From: Jing Li Date: Fri, 11 Aug 2023 20:56:09 +0800 Subject: [PATCH] Update --- app/Console/Commands/BiAng/DeviceLogSyncCommand.php | 2 +- app/Services/BiAngDeviceLogService.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/BiAng/DeviceLogSyncCommand.php b/app/Console/Commands/BiAng/DeviceLogSyncCommand.php index 7f7fb6c..4c7827b 100644 --- a/app/Console/Commands/BiAng/DeviceLogSyncCommand.php +++ b/app/Console/Commands/BiAng/DeviceLogSyncCommand.php @@ -76,7 +76,7 @@ class DeviceLogSyncCommand extends Command }); try { - (new BiAngDeviceLogService())->sync($device, $now); + (new BiAngDeviceLogService())->sync($device, $now->copy()); $this->info('同步成功!'); } catch (Throwable $e) { diff --git a/app/Services/BiAngDeviceLogService.php b/app/Services/BiAngDeviceLogService.php index 7153fbd..5b42817 100644 --- a/app/Services/BiAngDeviceLogService.php +++ b/app/Services/BiAngDeviceLogService.php @@ -38,7 +38,7 @@ class BiAngDeviceLogService ]); $device->update([ - 'status' => $syncTime->copy()->subMinutes(60)->lt($log->reported_at) ? DeviceStatus::Online : DeviceStatus::Offline, + 'status' => $syncTime->subMinutes(60)->lt($log->reported_at) ? DeviceStatus::Online : DeviceStatus::Offline, ]); break; case DeviceType::Meteorological: @@ -52,7 +52,7 @@ class BiAngDeviceLogService ]); $device->update([ - 'status' => $syncTime->copy()->subMinutes(60)->lt($log->reported_at) ? DeviceStatus::Online : DeviceStatus::Offline, + 'status' => $syncTime->subMinutes(60)->lt($log->reported_at) ? DeviceStatus::Online : DeviceStatus::Offline, ]); break; @@ -62,7 +62,7 @@ class BiAngDeviceLogService if ($data['status'] === 'online') { InsecticidalLampReport::updateOrCreate([ 'device_id' => $device->id, - 'reported_at' => $syncTime->copy()->startOfHour(), + 'reported_at' => $syncTime->startOfHour(), ], [ 'battery_vol' => $data['vol'], 'killed_num' => $data['dct'],