瀏覽代碼

海柔“完成”标记给batch

LD 5 年之前
父節點
當前提交
2235c66f1d

+ 4 - 1
app/Services/ForeignHaiRoboticsService.php

@@ -19,6 +19,8 @@ class ForeignHaiRoboticsService
 
     /** @var  $stationTaskMaterialBoxService StationTaskMaterialBoxService */
     private $stationTaskMaterialBoxService;
+    /** @var  $stationTaskBatchService StationTaskBatchService */
+    private $stationTaskBatchService;
     /** @var  $stationTaskCommoditiesService StationTaskCommodityService */
     private $stationTaskCommoditiesService;
     /** @var  $materialBoxService MaterialBoxService */
@@ -116,6 +118,7 @@ class ForeignHaiRoboticsService
         $this->instant($this->materialBoxService,'MaterialBoxService');
         $this->instant($this->stationTaskMaterialBoxService,'StationTaskMaterialBoxService');
         $this->instant($this->stationTaskCommoditiesService,'StationTaskCommodityService');
+        $this->instant($this->stationTaskBatchService,'StationTaskBatchService');
         try{
             LogService::log('海柔请求','markBinProcessed1.2',
                 json_encode([$binCode,$success,$exception,$is_in_plan]));
@@ -170,9 +173,9 @@ class ForeignHaiRoboticsService
                     ->markProcessing($stationTaskMaterialBox_next['stationTaskCommodities']);//因为上边商品任务被标记完成了,所以这里要将队列中找出正在处理的料箱对应的标记为“处理中”
             if(!$stationTaskMaterialBox_next){
                 $this->instant($this->stationTaskService,'StationTaskService');
-                $stationTaskMaterialBox->loadMissing('stationTaskBatch');
                 LogService::log('海柔请求','markBinProcessed1.81',
                     json_encode($stationTaskMaterialBox['stationTaskBatch']));
+                $stationTaskMaterialBox->loadMissing('stationTaskBatch');
                 $this->stationTaskBatchService->markProcessed($stationTaskMaterialBox['stationTaskBatch']);
                 LogService::log('海柔请求','markBinProcessed1.82',
                     json_encode($stationTaskMaterialBox['stationTaskBatch']));

+ 15 - 0
app/Services/StationTaskBatchService.php

@@ -223,6 +223,21 @@ class StationTaskBatchService
             ->whereIn('id', $ids)
             ->update(['status'=>'处理中']);
     }
+    function markProcessed($stationTaskBatch_orCollection)
+    {
+        if (get_class($stationTaskBatch_orCollection)==StationTaskBatch::class){
+            $stationTaskBatch_orCollection = collect([$stationTaskBatch_orCollection]);
+        }
+        $this->markProcessed_byIds(data_get($stationTaskBatch_orCollection, '*.id'));
+    }
+    function markProcessed_byIds($ids)
+    {
+        if(!$ids)$ids=[];
+        if(!is_array($ids))$ids=[$ids];
+        StationTaskBatch::query()
+            ->whereIn('id', $ids)
+            ->update(['status'=>'完成']);
+    }
 
 //    function markFinished($stationTaskBatches)
 //    {

+ 1 - 0
resources/views/station/monitor/show.blade.php

@@ -321,6 +321,7 @@
                     return this.station['current_station_task'];
                 },
                 batchCode(){
+                    if(!this.task)return;
                     let batches = this.task.station_task_batches;
                     if(batches
                         && Array.isArray(batches)