|
|
@@ -49,12 +49,10 @@ class CacheShelfTaskJob implements ShouldQueue
|
|
|
case "CACHE_SHELF_AVAILABLE"://缓存架释放呼叫
|
|
|
//等待一定时间来合并同类请求至此
|
|
|
$available = Cache::get($this->key,0);
|
|
|
- Log::debug("队列事务1",["当前数量:{$this->count}","缓存数量:$available"]);
|
|
|
if ($this->count!=$available)return;
|
|
|
Cache::forget($this->key); //无论是否开始分发 都清除本次缓存架的计数器
|
|
|
//获取可用缓存架
|
|
|
$stations = app("StationService")->getCacheShelf(true);
|
|
|
- Log::debug("队列事务2",["可用缓存架:{$stations->count()}"]);
|
|
|
if ($stations->count()==0)break;
|
|
|
//检查事务 尝试分发任务 改变下方序列来控制分发顺序 逐级分发 一次成功就终止
|
|
|
if ($this->dispatchOutTask($stations,$service))break; //首先尝试向出库事务分发 分发成功跳出
|
|
|
@@ -109,7 +107,6 @@ class CacheShelfTaskJob implements ShouldQueue
|
|
|
$query->where("status","待处理");
|
|
|
})->where("status",3)->lockForUpdate()
|
|
|
->where("mark",2)->groupBy("task_id")->get(); //检索等待的队列事务来获取对应任务
|
|
|
- Log::debug("队列事务3",["队列出库任务:{$tasks->count()}"]);
|
|
|
if ($tasks->count()==0)return false;
|
|
|
if ($this->dispatchTask($tasks,$stations,$service,function ($obj,$stationId,$time,&$updateTransaction){
|
|
|
if ($obj->ids!=$obj->id){
|
|
|
@@ -119,7 +116,6 @@ class CacheShelfTaskJob implements ShouldQueue
|
|
|
},function ($service,$toLocation,$task,$prefix){
|
|
|
return $service->fetchGroup_multiLocation($toLocation,$task,$prefix,'立架出至缓存架',20,false);
|
|
|
},"to_station_id")){
|
|
|
- Log::debug("队列事务4",["缓存架剩余数量:{$stations->count()}"]);
|
|
|
DB::commit();return $stations->count()==0;} //缓存架用完 跳出,否则接着分发
|
|
|
DB::rollBack();
|
|
|
}catch (\Exception $e){
|
|
|
@@ -145,14 +141,12 @@ class CacheShelfTaskJob implements ShouldQueue
|
|
|
$query->where("status","待处理");
|
|
|
})->where("status",3)->lockForUpdate()
|
|
|
->where("mark",1)->get(); //检索等待的队列事务来获取对应任务
|
|
|
- Log::debug("队列事务3",["队列入库任务:{$tasks->count()}"]);
|
|
|
if ($tasks->count()==0)return false;
|
|
|
if ($this->dispatchTask($tasks,$stations,$service,function ($obj,$stationId,$time,&$updateTransaction){
|
|
|
$updateTransaction[] = ["id"=>$obj->id,"fm_station_id"=>$stationId,"status"=>0,"updated_at"=>$time];
|
|
|
},function ($service,$toLocation,$task,$prefix){
|
|
|
return $service->fetchGroup_multiLocation($toLocation,$task,'','立架出至缓存架',20,false);
|
|
|
},"fm_station_id")){
|
|
|
- Log::debug("队列事务5",["缓存架剩余数量:{$stations->count()}"]);
|
|
|
DB::commit();return $stations->count()==0; //缓存架用完 跳出,否则接着分发
|
|
|
}
|
|
|
DB::rollBack();
|