FetchBimInfo.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\BimFile;
  4. use App\Services\File\BimService;
  5. use Illuminate\Console\Command;
  6. /**
  7. * 拉取引擎服务器的BIM信息
  8. */
  9. class FetchBimInfo extends Command
  10. {
  11. /**
  12. * The name and signature of the console command.
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'lpc:fetch-bim-info {scope=1}';
  17. /**
  18. * The console command description.
  19. *
  20. * @var string
  21. */
  22. protected $description = 'fetch bim info from engine';
  23. /**
  24. * Execute the console command.
  25. */
  26. public function handle()
  27. {
  28. $this->info('start to fetch bim info');
  29. $scopeDay = (int) $this->argument('scope'); //拉取最近n天
  30. if ($scopeDay == 0) {
  31. $startDateTime = '';
  32. } else {
  33. $startDateTime = date_time_str(strtotime('-' . $scopeDay . 'days'));
  34. }
  35. $bimService = new BimService;
  36. BimFile::query()->createdAtStart($startDateTime)
  37. ->chunkById(50, function ($bimFiles) use ($bimService) {
  38. foreach ($bimFiles as $bimFile) {
  39. $bimFile = $bimService->storeBimInfo($bimFile);
  40. $this->info($bimFile->id . ' extra is ' . json_encode($bimFile->extra));
  41. // $bimService->syncGlendaleBimData($bimFile);
  42. }
  43. });
  44. }
  45. }