| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Console\Commands;
- use App\Station;
- use App\StationTask;
- use App\StationTaskMaterialBox;
- use Illuminate\Console\Command;
- use Illuminate\Database\Eloquent\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();
- foreach ($stations as $station){
- $box = app("MaterialBoxService")->getAnEmptyBox();
- if (!$box)continue;
- $task = StationTask::query()->create([
- 'status' => "待处理",
- 'station_id' => $station->id,
- ]);
- $collection = new Collection();
- $collection->append(StationTaskMaterialBox::query()->create([
- 'station_id' => $station->id,
- 'material_box_id'=>$box->id,
- 'status'=>"待处理",
- 'type' => '取',
- 'station_task_id' => $task->id,
- ]));
- app("ForeignHaiRoboticsService")->fetchGroup($station->code,$collection,'','立架出至缓存架');
- }
- }
- }
|