ajun 5 anni fa
parent
commit
39cbce0019

+ 24 - 24
app/Http/Controllers/CacheShelfController.php

@@ -67,29 +67,29 @@ class CacheShelfController extends Controller
         return $gridService->lightOn($station,$request['x'],$request['y']);
     }
 
-    /**
-     * 拍灯推送任务
-     * @param Request $request
-     * @param CacheShelfService $service
-     */
-    public function pushTaskApi(Request $request,CacheShelfService $service)
-    {
-        /**
-         * @var Station $station
-         * @var MaterialBox $materialBox
-         * @var StationCacheShelfGrid $grid
-         */
-        $station = Station::query()->where('id',$request['id'])->first();
-        $materialBox = MaterialBox::query()->where('code',$request['code'])->first();
-        $grid = StationCacheShelfGrid::query()->where(['station_id'=>$station['id'],'grid_id'=>$request['index']])->first();
-
-        try {
-            $bool = $service->putBinToStore($station, $materialBox, $grid);
-            if($bool)$this->success();
-            else $this->error('推送任务异常');
-        } catch (ErrorException $e) {
-            $this->error($e->getMessage());
-        }
-    }
+//    /**
+//     * 拍灯推送任务
+//     * @param Request $request
+//     * @param CacheShelfService $service
+//     */
+//    public function pushTaskApi(Request $request,CacheShelfService $service)
+//    {
+//        /**
+//         * @var Station $station
+//         * @var MaterialBox $materialBox
+//         * @var StationCacheShelfGrid $grid
+//         */
+//        $station = Station::query()->where('id',$request['id'])->first();
+//        $materialBox = MaterialBox::query()->where('code',$request['code'])->first();
+//        $grid = StationCacheShelfGrid::query()->where(['station_id'=>$station['id'],'grid_id'=>$request['index']])->first();
+//
+//        try {
+//            $bool = $service->putBinToStore($station, $materialBox, $grid);
+//            if($bool)$this->success();
+//            else $this->error('推送任务异常');
+//        } catch (ErrorException $e) {
+//            $this->error($e->getMessage());
+//        }
+//    }
 
 }

+ 12 - 1
app/Http/Controllers/api/thirdPart/haiq/LightController.php

@@ -6,8 +6,12 @@ namespace App\Http\Controllers\api\thirdPart\haiq;
 
 
 
+use App\MaterialBox;
+use App\Services\CacheShelfService;
 use App\Services\ForeignHaiRoboticsService;
 use App\Services\StationCacheShelfGridService;
+use App\Station;
+use App\StationCacheShelfGrid;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Http;
 
@@ -26,7 +30,14 @@ class LightController
         return $response->body();
     }
     public function lightOff(Request $request){
-
+//        $locCode = $request['locCode'];
+//        $PTLAction = $request['PTLAction'];
+//        list($stationCode, $gridId, $x, $y) = StationCacheShelfGrid::getGridByCode($locCode);
+//        $station = Station::query()->where('code',$stationCode)->first();
+//        $grid = StationCacheShelfGrid::query()->where('station_id',$station['id'])->where('grid_id',$gridId)->first();
+//        $materialBox = MaterialBox::query()->where('id',$grid['material_box_id'])->first();
+//        $cacheShelfService = app(CacheShelfService::class);
+//        $cacheShelfService->putBinToStore($station,$materialBox,$grid);
     }
 
     /**

+ 19 - 3
app/Services/StationCacheShelfGridService.php

@@ -14,6 +14,13 @@ class StationCacheShelfGridService
 
     protected $modelClass = StationCacheShelfGrid::class;
 
+    /**
+     * processGrid 格口上放入料箱
+     * lightOff 解析HaiQ格口灭灯请求  完成格口上的任务 进行灭灯完成后的广播
+     * cancelTask 完成格口上的任务
+     * lightOn 发送给HaiQ的格口亮灯
+     */
+
     /**
      * 修改格口的状态
      * @param $stationCacheShelfGrid
@@ -36,7 +43,7 @@ class StationCacheShelfGridService
     }
 
     /**
-     * 格口灭灯
+     * 格口灭灯完成后的广播
      * @param $locCode
      * @param $PTLAction
      */
@@ -45,6 +52,8 @@ class StationCacheShelfGridService
         if ($PTLAction == '0') {
             list($stationCode, $gridId, $x, $y) = StationCacheShelfGrid::getGridByCode($locCode);
             $station = Station::query()->where('code', $stationCode)->first();
+            $gird = StationCacheShelfGrid::query()->where('station_id',$station['id'])->where('grid_id',$gridId)->first();
+            $this->cancelTask($gird);
             $json = json_encode([
                 'code' => $stationCode,
                 'x' => $x,
@@ -57,6 +66,13 @@ class StationCacheShelfGridService
         }
     }
 
+    /**
+     * 通知HaiQ亮灯
+     * @param Station $station
+     * @param $pointX
+     * @param $pointY
+     * @return string
+     */
     public function lightOn(Station $station, $pointX, $pointY)
     {
 
@@ -82,9 +98,9 @@ class StationCacheShelfGridService
             ],
             "locCode" => $locCode//灯条口,B1\B2=设备编号,中间号码代表从右往左数的列,右边号码时从下往上数
         ];
-        LogService::log(__METHOD__,'海柔亮灯请求',json_encode($params));
+//        LogService::log(__METHOD__,'海柔亮灯请求',json_encode($params));
         $response = Http::post(config('api.haiq.storage.light'), $params);
-        LogService::log(__METHOD__,'海柔亮灯请求返回',json_encode($params));
+//        LogService::log(__METHOD__,'海柔亮灯请求返回',json_encode($params));
         return $response->body();
     }
 }