| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace App\Console\Commands;
- use App\Station;
- use App\StationTask;
- use App\StationTaskMaterialBox;
- use Illuminate\Console\Command;
- use Illuminate\Support\Collection;
- class CheckCacheRackStorage extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'check:cacheRack';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'check cache rack storage info';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- */
- public function handle()
- {
- $stations = Station::query()->select("id","code")->where("station_type_id",5)
- ->whereNotNull("parent_id")
- ->whereNotIn("id",StationTask::query()->select("station_id")
- ->where("status","!=","完成")->whereIn("station_id",Station::query()->select("id")->where("station_type_id",5)
- ->whereNotNull("parent_id"))->groupBy("station_id"))
- ->get();
- $collection = new Collection();
- $stationCollection = new Collection();
- $blacklist = [];
- foreach ($stations as $station){
- $box = app("MaterialBoxService")->getAnEmptyBox($blacklist);
- if (!$box)continue;
- $task = StationTask::query()->create([
- 'status' => "待处理",
- 'station_id' => $station->id,
- ]);
- $collection->add(StationTaskMaterialBox::query()->create([
- 'station_id' => $station->id,
- 'material_box_id'=>$box->id,
- 'status'=>"待处理",
- 'type' => '取',
- 'station_task_id' => $task->id,
- ]));
- $stationCollection->add($station->code);
- $blacklist[] = $box->id;
- }
- app("ForeignHaiRoboticsService")->fetchGroup_multiLocation($stationCollection,$collection,'','立架出至缓存架');
- }
- }
|