|
|
@@ -50,13 +50,12 @@ class CacheShelfTaskJob implements ShouldQueue
|
|
|
//等待一定时间来合并同类请求至此
|
|
|
$available = Cache::get($this->key,0);
|
|
|
Log::debug("队列事务1",["当前数量:{$this->count}","缓存数量:$available"]);
|
|
|
- if ($this->count!==$available)return;
|
|
|
+ if ($this->count!=$available)return;
|
|
|
Cache::forget($this->key); //无论是否开始分发 都清除本次缓存架的计数器
|
|
|
//获取可用缓存架
|
|
|
$stations = app("StationService")->getCacheShelf(true);
|
|
|
Log::debug("队列事务2",["可用缓存架:{$stations->count()}"]);
|
|
|
if ($stations->count()==0)break;
|
|
|
- LogService::log("海柔任务","队列事务分发",$stations->toJson());
|
|
|
//检查事务 尝试分发任务 改变下方序列来控制分发顺序 逐级分发 一次成功就终止
|
|
|
if ($this->dispatchOutTask($stations,$service))break; //首先尝试向出库事务分发 分发成功跳出
|
|
|
if ($this->dispatchInTask($stations,$service))break; //尝试向入库事务分发
|
|
|
@@ -65,7 +64,7 @@ class CacheShelfTaskJob implements ShouldQueue
|
|
|
if (!Cache::has($this->key))return;
|
|
|
/** @var Collection $task */
|
|
|
list($task,$location) = Cache::get($this->key);
|
|
|
- if ($this->count!==$task->count())return;
|
|
|
+ if ($this->count!=$task->count())return;
|
|
|
$dataToPost = $service->makeJson_move_multi($task, '缓存架入立架', $location);
|
|
|
$controlSuccess = $service->controlHaiRobot($dataToPost,$task,'缓存架入立架');
|
|
|
$tIds = [];
|
|
|
@@ -119,7 +118,9 @@ class CacheShelfTaskJob implements ShouldQueue
|
|
|
}else $updateTransaction[] = ["id"=>$obj->id,"to_station_id"=>$stationId,"status"=>0,"updated_at"=>$time];
|
|
|
},function ($service,$toLocation,$task,$prefix){
|
|
|
return $service->fetchGroup_multiLocation($toLocation,$task,$prefix,'立架出至缓存架',20,false);
|
|
|
- },"to_station_id")){DB::commit();return $stations->count()==0;} //缓存架用完 跳出,否则接着分发
|
|
|
+ },"to_station_id")){
|
|
|
+ Log::debug("队列事务4",["缓存架剩余数量:{$stations->count()}"]);
|
|
|
+ DB::commit();return $stations->count()==0;} //缓存架用完 跳出,否则接着分发
|
|
|
DB::rollBack();
|
|
|
}catch (\Exception $e){
|
|
|
DB::rollBack();
|
|
|
@@ -151,6 +152,7 @@ class CacheShelfTaskJob implements ShouldQueue
|
|
|
},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();
|
|
|
@@ -186,7 +188,7 @@ class CacheShelfTaskJob implements ShouldQueue
|
|
|
}
|
|
|
app("BatchUpdateService")->batchUpdate("station_task_material_boxes",$updateTask);
|
|
|
app("BatchUpdateService")->batchUpdate("task_transactions",$updateTransaction);
|
|
|
- if ($execute($service,$toLocation,$task,$tasks[0]->station_task_batch_id)){
|
|
|
+ if ($execute($service,$toLocation,$task,$tasks[0]->station_task_batch_id ?: '')){
|
|
|
foreach ($toLocation as $value){
|
|
|
app("CacheShelfService")->lightUp($value,'3','0',["title"=>"机器人取箱中,禁止操作"]);
|
|
|
Cache::forever("CACHE_SHELF_OCCUPANCY_{$map[$value]}",true);
|