ajun vor 5 Jahren
Ursprung
Commit
c46701ec75
1 geänderte Dateien mit 10 neuen und 3 gelöschten Zeilen
  1. 10 3
      app/Services/CacheShelfService.php

+ 10 - 3
app/Services/CacheShelfService.php

@@ -2,10 +2,12 @@
 
 namespace App\Services;
 
+use App\Events\BroadcastToStation;
 use App\Exceptions\ErrorException;
 use App\MaterialBox;
 use App\Station;
 use App\StationCacheShelfGrid;
+use App\StationTask;
 use App\StationTaskMaterialBox;
 use App\Traits\ServiceAppAop;
 use Illuminate\Support\Facades\Http;
@@ -26,8 +28,13 @@ class CacheShelfService
      */
     public function pushTask(Station $station,MaterialBox $materialBox,$pointX, $pointY)
     {
-        /** 推送任务 */
+        $grid = (3-$pointX)*3 + (3-$pointX);
+        $params = ['station'=>$station['id'],'grid_id'=>$grid];
+        $stationCacheShelfGrid = StationCacheShelfGrid::query()->firstOrCreate($params,$params);
+        $stationCacheShelfGrid->update(['material_box_id' => $materialBox['id'],'status'=> 0]);
+        /** 推送任务至海柔机器人 */
         if($this->putBinToStore($station,$materialBox)){
+            $stationCacheShelfGrid->update(['material_box_id' => $materialBox['id'],'status'=> 1]);
             /** 亮灯 */
             return $this->lightOn($station,$pointX, $pointY);
         }
@@ -40,7 +47,7 @@ class CacheShelfService
      */
     public function getTasks(Station $station)
     {
-        $grids = StationCacheShelfGrid::query()->with('materialBox:code')->where('station_id',$station['id'])->where('status',2)->orderBy('grid_id')->get();
+        $grids = StationCacheShelfGrid::query()->with('materialBox:code')->where('station_id',$station['id'])->where('status',1)->orderBy('grid_id')->get();
         $station->setRelation('grids',$grids);
     }
 
@@ -75,6 +82,7 @@ class CacheShelfService
             ],
             "locCode"=> $locCode//灯条口,B1\B2=设备编号,中间号码代表从右往左数的列,右边号码时从下往上数
         ];
+
         $response = Http::post(config('api.haiq.storage.light'),$params);
         return $response->body();
     }
@@ -98,5 +106,4 @@ class CacheShelfService
     }
 
 
-
 }