From c4ea661dcc99949182c952938695d1d9f39eb211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Mon, 8 May 2023 12:11:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/DeviceLogService.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Services/DeviceLogService.php b/app/Services/DeviceLogService.php index 6c185ca..713c822 100644 --- a/app/Services/DeviceLogService.php +++ b/app/Services/DeviceLogService.php @@ -45,6 +45,10 @@ class DeviceLogService } foreach ($data['content'] as $item) { + if (! isset($item['data'])) { + continue; + } + $isSoilMonitoring = Arr::hasAny($item['data'], [ 'soil_humidity', 'soil_temperature', From d589404415e5dfa983ad77a4a63dd8d4eeaa15dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Mon, 8 May 2023 13:39:04 +0800 Subject: [PATCH 2/2] Update --- app/Console/Commands/DeviceLogReportCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/DeviceLogReportCommand.php b/app/Console/Commands/DeviceLogReportCommand.php index 369f217..6689010 100644 --- a/app/Console/Commands/DeviceLogReportCommand.php +++ b/app/Console/Commands/DeviceLogReportCommand.php @@ -68,7 +68,7 @@ class DeviceLogReportCommand extends Command $lastReportedAt = $lastMonitoringReport?->reported_at; $device->logs() - ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt->reported_at)) + ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt)) ->oldest('reported_at') ->chunkById(500, function ($deviceLogs) use ($device, &$lastMonitoringReport) { /** @var \App\Models\DeviceLog */ @@ -109,7 +109,7 @@ class DeviceLogReportCommand extends Command $lastReportedAt = $lastMonitoringReport?->reported_at; $device->logs() - ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt->reported_at)) + ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt)) ->oldest('reported_at') ->chunkById(500, function ($deviceLogs) use ($device, &$lastMonitoringReport) { /** @var \App\Models\DeviceLog */ @@ -150,7 +150,7 @@ class DeviceLogReportCommand extends Command $lastReportedAt = $lastMonitoringReport?->reported_at; $device->logs() - ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt->reported_at)) + ->when($lastReportedAt, fn ($query, $lastReportedAt) => $query->where('reported_at', '>=', $lastReportedAt)) ->oldest('reported_at') ->chunkById(500, function ($deviceLogs) use ($device, &$lastMonitoringReport) { /** @var \App\Models\DeviceLog */