CheckCacheRackStorage.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Station;
  4. use App\StationTask;
  5. use App\StationTaskMaterialBox;
  6. use Illuminate\Console\Command;
  7. use Illuminate\Support\Collection;
  8. class CheckCacheRackStorage extends Command
  9. {
  10. /**
  11. * The name and signature of the console command.
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'check:cacheRack';
  16. /**
  17. * The console command description.
  18. *
  19. * @var string
  20. */
  21. protected $description = 'check cache rack storage info';
  22. /**
  23. * Create a new command instance.
  24. *
  25. * @return void
  26. */
  27. public function __construct()
  28. {
  29. parent::__construct();
  30. }
  31. /**
  32. * Execute the console command.
  33. *
  34. */
  35. public function handle()
  36. {
  37. $stations = Station::query()->select("id","code")->where("station_type_id",5)
  38. ->whereNotNull("parent_id")
  39. ->whereNotIn("id",StationTask::query()->select("station_id")
  40. ->where("status","!=","完成")->whereIn("station_id",Station::query()->select("id")->where("station_type_id",5)
  41. ->whereNotNull("parent_id"))->groupBy("station_id"))
  42. ->get();
  43. $collection = new Collection();
  44. $stationCollection = new Collection();
  45. $blacklist = [];
  46. foreach ($stations as $station){
  47. $box = app("MaterialBoxService")->getAnEmptyBox($blacklist);
  48. if (!$box)continue;
  49. $task = StationTask::query()->create([
  50. 'status' => "待处理",
  51. 'station_id' => $station->id,
  52. ]);
  53. $collection->add(StationTaskMaterialBox::query()->create([
  54. 'station_id' => $station->id,
  55. 'material_box_id'=>$box->id,
  56. 'status'=>"待处理",
  57. 'type' => '取',
  58. 'station_task_id' => $task->id,
  59. ]));
  60. $stationCollection->add($station->code);
  61. $blacklist[] = $box->id;
  62. }
  63. app("ForeignHaiRoboticsService")->fetchGroup_multiLocation($stationCollection,$collection,'','立架出至缓存架');
  64. }
  65. }