Ver Fonte

修改CacheShelfService

ajun há 5 anos atrás
pai
commit
1a2a6c8063
1 ficheiros alterados com 27 adições e 4 exclusões
  1. 27 4
      app/Services/CacheShelfService.php

+ 27 - 4
app/Services/CacheShelfService.php

@@ -15,9 +15,8 @@ class CacheShelfService
     use ServiceAppAop;
     protected $modelClass=Station::class;
 
-
     /**
-     * 获取缓存架任务
+     * 获取现有的缓存架任务
      * @param Station $station
      */
     public function getTasks(Station $station)
@@ -27,7 +26,7 @@ class CacheShelfService
     }
 
     /**
-     * 缓存架  【亮灯
+     * 亮灯
      * @param Station $station
      * @param $pointX
      * @param $pointY
@@ -35,6 +34,7 @@ class CacheShelfService
      */
     public function lightOnApi(Station $station,$pointX,$pointY): string
     {
+
         $locCode = 'HAI'.$station['code'].'-0'.$pointX.'-0'.$pointY;
         $params = [
             "areaCode"=> "1004",
@@ -63,7 +63,7 @@ class CacheShelfService
     }
 
     /**
-     * 推送到海柔机器人的任务
+     * 拍灯
      * @param Station $station
      * @param MaterialBox $materialBox
      * @param StationCacheShelfGrid $grid
@@ -80,14 +80,37 @@ class CacheShelfService
             'status' => '待处理'
         ]);
 
+        // 格口状态修改
+        $grid->update(['station_id'=>$station['id'],'status'=>1]);
         $station->setRelation('grids',$grid);
         $stationTaskMaterialBox->setRelation('station',$station);
         $stationTaskMaterialBox->setRelation('materialBox',$materialBox);
 
+        // 推送任务给海柔
         /** @var ForeignHaiRoboticsService $foreignHaiRoboticsService */
         $foreignHaiRoboticsService = app(ForeignHaiRoboticsService::class);
         return $foreignHaiRoboticsService->putBinToStore_fromCacheShelf($stationTaskMaterialBox);
     }
 
+    /**
+     * 入库任务完成
+     * @param $params
+     */
+    public function putBinToStoreFinish($params)
+    {
+        $locCode = $params['locCode'];
+
+        list($stationCode,$gridId) = StationCacheShelfGrid::getGridByCode($locCode);
+        $station = Station::query()->where('code',$stationCode)->first();
+
+        $stationCacheShelfGrid = StationCacheShelfGrid::query()->with('materialBox')->where('station_id',$station)->where('grid_id',$gridId)->first();
+        $stationCacheShelfGrid->update(['status'=>'0','material_box_id' => null]);
+        $StationTaskMaterialBox = StationTaskMaterialBox::query()->where('station_id',$station['id'])->where('material_box_id',$stationCacheShelfGrid['$stationCacheShelfGrid'])->first();
+
+        /** @var StationTaskMaterialBoxService  $stationTaskMaterialBoxService */
+        $stationTaskMaterialBoxService = app(StationTaskMaterialBoxService::class);
+        $stationTaskMaterialBoxService->set($StationTaskMaterialBox,['status'=>'已完成']);
+
+    }
 
 }