Quellcode durchsuchen

缓存架出库优化

Zhouzhendong vor 4 Jahren
Ursprung
Commit
0193afba6e

+ 3 - 5
app/Http/Controllers/TestController.php

@@ -173,11 +173,9 @@ class TestController extends Controller
     }
     public function test3()
     {
-        $a = collect(["1",'2',"3"]);
-        foreach ($a as $index => $v){
-            $a->offsetSet($index,'0');
-        }
-        dd($a);
+       $a = Waybill::with("owner")->get();
+
+       dd($a->where("owner.code","TUCG2202012122323"));
     }
     public function test1()
     {

+ 2 - 1
app/Jobs/CacheShelfTaskJob.php

@@ -51,9 +51,10 @@ class CacheShelfTaskJob implements ShouldQueue
                     $tasks = TaskTransaction::query()->with("task")
                         ->where("type","出库")->whereHas("task",function ($query){
                             $query->where("status","待处理");
-                        })->where("status",3)
+                        })->where("status",3)->lockForUpdate()
                         ->where("mark",2)->groupBy("task_id")->get(); //检索等待的队列事务来获取对应任务
                     if (!$tasks->count())return;
+                    $tasks = $tasks->where("task.station_task_batch_id",$tasks[0]->task->station_task_batch_id);//仅处理同波次
                     if ($tasks->count()>count($available))$tasks = $tasks->slice(0,count($available));//事务过多切割部分处理
                     $toLocation = collect();
                     $task = collect();

+ 1 - 1
app/Services/StationTaskMaterialBoxService.php

@@ -224,8 +224,8 @@ class StationTaskMaterialBoxService
             Cache::forever("CACHE_SHELF_AVAILABLE",$available);
             CacheShelfTaskJob::dispatch("CACHE_SHELF_AVAILABLE",count($available))->delay(now()->addSeconds(config("haiRou.cacheShelf.outBinAwait")));
             unset($map[$stationTaskMaterialBox->material_box_id]);
+            Cache::forever("CACHE_SHELF_MAPPING",$map);
         }
-        Cache::forever("CACHE_SHELF_MAPPING",$map);
     }
 
     function processNextQueued(?StationTaskMaterialBox $stationTaskMaterialBox_lastProcessed){