|
|
@@ -6,6 +6,7 @@ use App\Components\AsyncResponse;
|
|
|
use App\Components\ErrorPush;
|
|
|
use App\ErrorTemp;
|
|
|
use App\Feature;
|
|
|
+use App\MaterialBox;
|
|
|
use App\MaterialBoxModel;
|
|
|
use App\Owner;
|
|
|
use App\OwnerFeeDetail;
|
|
|
@@ -18,7 +19,9 @@ use App\StationTaskMaterialBox;
|
|
|
use App\TaskTransaction;
|
|
|
use App\Unit;
|
|
|
use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\Auth;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
+use Illuminate\Support\Facades\Cookie;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
|
|
@@ -54,50 +57,13 @@ class TestController extends Controller
|
|
|
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));
|
|
|
+ $modelId = 1;
|
|
|
+ $blacklist = [];
|
|
|
+ $query = MaterialBox::query()->where("material_box_model_id",$modelId)
|
|
|
+ ->where("status",4);
|
|
|
+ $boxes = $query->whereNotIn("id",$query->select("id")->whereHas("performTask"));
|
|
|
+ if ($blacklist)$boxes = $boxes->whereNotIn("id",$blacklist);
|
|
|
+ dd($boxes->get());
|
|
|
}
|
|
|
|
|
|
}
|