|
@@ -0,0 +1,53 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Console\Commands;
|
|
|
+
|
|
|
+use App\Models\BimFile;
|
|
|
+use App\Models\Enums\BimFileConvertStatus;
|
|
|
+use App\Services\File\BIM\BIMFactory;
|
|
|
+use Carbon\Carbon;
|
|
|
+use Illuminate\Console\Command;
|
|
|
+use Illuminate\Database\Eloquent\Collection;
|
|
|
+
|
|
|
+class SyncBimConvertStatus extends Command
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * The name and signature of the console command.
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $signature = 'lpc:sync-bim-convert-status';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The console command description.
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $description = 'sync bim convert status';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Execute the console command.
|
|
|
+ */
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ BimFile::query()
|
|
|
+ ->where("created_at", ">=", Carbon::now()->subDay())
|
|
|
+ ->whereIn("convert_status", BimFileConvertStatus::unfinishedStatus())
|
|
|
+ ->chunkById(2000, function (Collection $bimFiles) {
|
|
|
+ $this->queryStatus($bimFiles);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function queryStatus(Collection $bimFiles)
|
|
|
+ {
|
|
|
+ foreach ($bimFiles as $bimFile) {
|
|
|
+ try {
|
|
|
+ $status = BIMFactory::make($bimFile->bim_driver)->findConvertStatus($bimFile->bim_data_set_id);
|
|
|
+
|
|
|
+ $bimFile->convert_status = $status;
|
|
|
+ $bimFile->save();
|
|
|
+ } catch (\Exception $exception) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|