Преглед изворни кода

处理队列commodities
添加fix

LD пре 5 година
родитељ
комит
42e833c21f
2 измењених фајлова са 16 додато и 23 уклоњено
  1. 8 0
      app/Http/Controllers/TestController.php
  2. 8 23
      app/Services/StationTaskCommodityService.php

+ 8 - 0
app/Http/Controllers/TestController.php

@@ -316,6 +316,14 @@ sql;
         broadcast(new BroadcastToStation(2,json_encode(['abc'=>332])));
     }
 
+    function t2(Request $request)
+    {
+        $arr=collect([['aa'=>11,'bb'=>221],['aa'=>111,'bb'=>222],['aa'=>111,'bb'=>223]]);
+        $a = $arr->where('aa', 11);
+        $b = $arr->where('aa', 111);
+        dd($a, $b);
+    }
+
     function packageT(Request $request)
     {
         $package = Package::where('created_at', '<', '2020-07-08')->whereNotNull('logistic_number')->first();

+ 8 - 23
app/Services/StationTaskCommodityService.php

@@ -153,32 +153,17 @@ class StationTaskCommodityService
                     $stationTaskCommodity['status']=$status;
                 });
             })();
-//            ($将所有要标记的商品任务先放在队列里=function()use(&$groupByBatch){
-//                $groupByBatch->each(function (&$stationTaskCommodity){
-//                    $stationTaskCommodity['status']='处理队列';
-//                });
-//            })();
-//            ($如果之前没有处理中则标记第一个为处理目标,并持久化=function()use(&$groupByBatch){
-//                $taskBatchId=$groupByBatch[0]['station_task_batch_id'];
-//                $processing=$this->getProcessing_byTaskBatch($taskBatchId);
-//                if(!$processing){
-//                    $groupByBatch[0]['status']='处理中';
-//                    $groupByBatch[0]->update();
-//                }else{
-//                    foreach ($groupByBatch as &$stationTaskCommodity){
-//                        if($stationTaskCommodity['id']==$processing['id']){
-//                            $stationTaskCommodity['status']='处理中';
-//                        }
-//                    }
-//                }
-//            })();
         });
         ($持久化处理队列的记录=function()use(&$stationTaskCommodities_grouped){
             $toArray = $stationTaskCommodities_grouped->collapse();
-            $toArray=$toArray->where('status','处理队列');
-            $ids_toUpdate = data_get($toArray, '*.id');
-            if(count($ids_toUpdate))
-                StationTaskCommodity::query()->where('id',$ids_toUpdate)->update(['status'=>'处理队列']);
+            $toQueue=$toArray->where('status','处理队列');
+            $toProcess=$toArray->where('status','处理中');
+            $ids_toQueue_toUpdate = data_get($toQueue, '*.id');
+            if(count($ids_toQueue_toUpdate))
+                StationTaskCommodity::query()->where('id',$ids_toQueue_toUpdate)->update(['status'=>'处理队列']);
+            $ids_toProcess_toUpdate = data_get($toProcess, '*.id');
+            if(count($ids_toProcess_toUpdate))
+                StationTaskCommodity::query()->where('id',$ids_toProcess_toUpdate)->update(['status'=>'处理中']);
         })();
 
     }