with('stationType:name', 'parent:name')->whereHas('stationType', function ($query) { /** @var Builder $query */ $query->where('name', '缓存架'); })->paginate(100); return view('station.cachingShelf.list.index', compact('stations')); } /** * 获取缓存货架上的任务列表 * @param Request $request * @param string $id * @param CacheShelfService $service */ public function getTasksApi(Request $request,string $id,CacheShelfService $service) { /** @var Station $station */ $station = Station::query()->where('id',$id)->first(); $service->getTasks($station); $this->success($station['grids']); } /** * 缓存架亮灯 * @param Request $request * @param StationCacheShelfGridService $gridService */ public function lightOnApi(Request $request,StationCacheShelfGridService $gridService) { $grid_id = $request['index']; /** @var Station $station */ $station = Station::query()->where('id',$request['id'])->first(); $grid = StationCacheShelfGrid::query()->firstOrCreate(['station_id'=>$station['id'],'grid_id'=>$grid_id]); $materialBox = MaterialBox::query()->firstOrCreate(['code'=>$request['code']]); $grid->update(['material_box_id' => $materialBox['id'],'status' => 1]); return $gridService->lightOn($station,$request['x'],$request['y']); } // /** // * 拍灯推送任务 // * @param Request $request // * @param CacheShelfService $service // */ // public function pushTaskApi(Request $request,CacheShelfService $service) // { // /** // * @var Station $station // * @var MaterialBox $materialBox // * @var StationCacheShelfGrid $grid // */ // $station = Station::query()->where('id',$request['id'])->first(); // $materialBox = MaterialBox::query()->where('code',$request['code'])->first(); // $grid = StationCacheShelfGrid::query()->where(['station_id'=>$station['id'],'grid_id'=>$request['index']])->first(); // // try { // $bool = $service->putBinToStore($station, $materialBox, $grid); // if($bool)$this->success(); // else $this->error('推送任务异常'); // } catch (ErrorException $e) { // $this->error($e->getMessage()); // } // } }