data["active_test"] = "active"; } public function method(Request $request, $method) { return call_user_func([$this, $method], $request); } public function lightUp() { app("CacheShelfService")->lightUp('HAIB1-02-02','3','0'); } public function lightOff() { $params = [ "areaCode" => "1004", 'locCode' => "HAIB1-02-02", 'PTLAction' => 0, ]; $response = Http::post(config('api.haiq.storage.light'), $params); return json_decode($response->body()); } private $key = "CACHE_SHELF_AVAILABLE"; public function test() { TaskTransaction::query()->where("id",23)->update([ "to_station_id" => 10, "status" => 0, "updated_at" => date("Y-m-d H:i:s") ]); TaskTransaction::query()->where("id",27)->update([ "to_station_id" => 24, "status" => 0, "updated_at" => date("Y-m-d H:i:s") ]); dd("OK"); $ar = StationTaskMaterialBox::query()->whereIn("id",[66124,66125,66126,66127,66128])->get(); foreach ($ar as $stationTaskMaterialBox){ $stationTaskMaterialBox->materialBox['status']='在缓存架'; $stationTaskMaterialBox->materialBox->update(); $stationTaskMaterialBox->loadMissing("station"); //提前加载站,后续都需要站信息来处理 app("StorageService")->putCacheShelf($stationTaskMaterialBox); app("StorageService")->releaseOccupation($stationTaskMaterialBox); //释放库位占用 $this->set($stationTaskMaterialBox,[ 'id' => $stationTaskMaterialBox['station_id'], 'status' => '完成', ]); if (!$stationTaskMaterialBox->station_task_id)return; $task = StationTaskMaterialBox::query()->select(DB::raw(1)) ->where("station_task_id",$stationTaskMaterialBox->station_task_id) ->where("status","!=","完成")->first(); if (!$task)StationTask::query()->where("id",$stationTaskMaterialBox->station_task_id) ->update(["status"=>"完成"]); } } function set($target,array $kvPairs){ $update = $target->update($kvPairs); Cache::forget($this->cachingKey($kvPairs)); if(isset($kvPairs['id'])){ Cache::forget($this->cachingKey(['id'=>$kvPairs['id']])); } return $update; } protected $modelClass=StationTaskMaterialBox::class; protected function cachingKey(array $kvPairs): string { ksort($kvPairs); return $this->modelClass.md5(json_encode($kvPairs)); } }