123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Console\Commands;
- use App\Models\BimFile;
- use App\Services\File\BimService;
- use Illuminate\Console\Command;
- /**
- * 拉取引擎服务器的BIM信息
- */
- class FetchBimInfo extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'lpc:fetch-bim-info {scope=1}';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'fetch bim info from engine';
- /**
- * Execute the console command.
- */
- public function handle()
- {
- $this->info('start to fetch bim info');
- $scopeDay = (int) $this->argument('scope'); //拉取最近n天
- if ($scopeDay == 0) {
- $startDateTime = '';
- } else {
- $startDateTime = date_time_str(strtotime('-' . $scopeDay . 'days'));
- }
- $bimService = new BimService;
- BimFile::query()->createdAtStart($startDateTime)
- ->chunkById(50, function ($bimFiles) use ($bimService) {
- foreach ($bimFiles as $bimFile) {
- $bimFile = $bimService->storeBimInfo($bimFile);
- $this->info($bimFile->id . ' extra is ' . json_encode($bimFile->extra));
- // $bimService->syncGlendaleBimData($bimFile);
- }
- });
- }
- }
|