|
|
@@ -11,8 +11,14 @@ use App\Owner;
|
|
|
use App\OwnerFeeDetail;
|
|
|
use App\OwnerPriceOperation;
|
|
|
use App\RejectedBill;
|
|
|
+use App\Services\ForeignHaiRoboticsService;
|
|
|
+use App\Station;
|
|
|
+use App\StationTask;
|
|
|
+use App\StationTaskMaterialBox;
|
|
|
+use App\TaskTransaction;
|
|
|
use App\Unit;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
|
|
@@ -33,7 +39,7 @@ class TestController extends Controller
|
|
|
}
|
|
|
public function lightUp()
|
|
|
{
|
|
|
- app("CacheShelfService")->lightUp('HAIB1-02-02','3','2');
|
|
|
+ app("CacheShelfService")->lightUp('HAIB1-02-02','3','0');
|
|
|
}
|
|
|
public function lightOff()
|
|
|
{
|
|
|
@@ -45,9 +51,53 @@ class TestController extends Controller
|
|
|
$response = Http::post(config('api.haiq.storage.light'), $params);
|
|
|
return json_decode($response->body());
|
|
|
}
|
|
|
+ private $key = "CACHE_SHELF_AVAILABLE";
|
|
|
public function test()
|
|
|
{
|
|
|
- dd(!!Unit::query()->first());
|
|
|
+ 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));
|
|
|
}
|
|
|
|
|
|
}
|