From 6cbb8c033612ab19973cda60650a16ef1e015143 Mon Sep 17 00:00:00 2001 From: Jing Li Date: Fri, 20 Oct 2023 11:05:45 +0800 Subject: [PATCH] Update --- .../Commands/BiAng/DeviceLogSyncCommand.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/Console/Commands/BiAng/DeviceLogSyncCommand.php b/app/Console/Commands/BiAng/DeviceLogSyncCommand.php index 3573ee9..643457d 100644 --- a/app/Console/Commands/BiAng/DeviceLogSyncCommand.php +++ b/app/Console/Commands/BiAng/DeviceLogSyncCommand.php @@ -92,6 +92,11 @@ class DeviceLogSyncCommand extends Command case DeviceType::Soil: $data = $httpClient->getLatestSoilReport($device->sn); + if (empty($data)) { + $this->warn('设备数据为空'); + break; + } + $log = DeviceLog::firstOrCreate([ 'device_id' => $device->id, 'reported_at' => $data['time'], @@ -107,6 +112,11 @@ class DeviceLogSyncCommand extends Command case DeviceType::Meteorological: $data = $httpClient->getLatestMeteorologicalReport($device->sn); + if (empty($data)) { + $this->warn('设备数据为空'); + break; + } + $log = DeviceLog::firstOrCreate([ 'device_id' => $device->id, 'reported_at' => $data['time'], @@ -122,6 +132,11 @@ class DeviceLogSyncCommand extends Command case DeviceType::InsecticidalLamp: $data = $httpClient->getLatestLampReport($device->sn); + if (empty($data)) { + $this->warn('设备数据为空'); + break; + } + $log = DeviceLog::firstOrCreate([ 'device_id' => $device->id, 'reported_at' => $data['time'], @@ -142,6 +157,11 @@ class DeviceLogSyncCommand extends Command $data = $httpClient->getWormPhotos($device->sn, $now->copy()->subHours(24), $now); + if (empty($data)) { + $this->warn('设备数据为空'); + break; + } + foreach ($data['imgUrl'] as $item) { // 下载图片 $name = md5($item['url']);