dev
Jing Li 2023-10-20 11:05:45 +08:00
parent 2cbf5314a5
commit 6cbb8c0336
1 changed files with 20 additions and 0 deletions

View File

@ -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']);