Update
parent
f0f78aa038
commit
c4d4f6fc37
|
|
@ -61,6 +61,7 @@ class DeviceLogSyncCommand extends Command
|
||||||
|
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||||
$devices = Device::with(['project'])
|
$devices = Device::with(['project'])
|
||||||
|
->where('sn', 'CB15D3716349AEA2')
|
||||||
->supplierBy("device-supplier-biang")
|
->supplierBy("device-supplier-biang")
|
||||||
->whereIn('status', [DeviceStatus::Online, DeviceStatus::Offline])
|
->whereIn('status', [DeviceStatus::Online, DeviceStatus::Offline])
|
||||||
->get();
|
->get();
|
||||||
|
|
@ -157,25 +158,29 @@ class DeviceLogSyncCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($data['imgUrl'] as $item) {
|
foreach ($data['imgUrl'] as $item) {
|
||||||
// 下载图片
|
try {
|
||||||
$name = md5($item['url']);
|
// 下载图片
|
||||||
if ($ext = pathinfo($item['url'], PATHINFO_EXTENSION)) {
|
$name = md5($item['url']);
|
||||||
$name .= ".{$ext}";
|
if ($ext = pathinfo($item['url'], PATHINFO_EXTENSION)) {
|
||||||
|
$name .= ".{$ext}";
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = "{$dir}/{$name}";
|
||||||
|
|
||||||
|
$disk = Storage::disk('public');
|
||||||
|
if (! $disk->exists($path)) {
|
||||||
|
$disk->put($path, file_get_contents($item['url']));
|
||||||
|
}
|
||||||
|
|
||||||
|
WormPhoto::updateOrCreate([
|
||||||
|
'device_id' => $device->id,
|
||||||
|
'uploaded_at' => $item['time'],
|
||||||
|
], [
|
||||||
|
'url' => $path,
|
||||||
|
]);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
report($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = "{$dir}/{$name}";
|
|
||||||
|
|
||||||
$disk = Storage::disk('public');
|
|
||||||
if (! $disk->exists($path)) {
|
|
||||||
$disk->put($path, file_get_contents($item['url']));
|
|
||||||
}
|
|
||||||
|
|
||||||
WormPhoto::updateOrCreate([
|
|
||||||
'device_id' => $device->id,
|
|
||||||
'uploaded_at' => $item['time'],
|
|
||||||
], [
|
|
||||||
'url' => $path,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$device->update([
|
$device->update([
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue