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,'','立架出至缓存架'); } } }