| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace App\Services;
- use App\Exceptions\ErrorException;
- use App\MaterialBox;
- use App\Station;
- use App\StationCacheShelfGrid;
- use App\StationTaskMaterialBox;
- use App\Traits\ServiceAppAop;
- use Illuminate\Support\Facades\Http;
- class CacheShelfService
- {
- use ServiceAppAop;
- protected $modelClass=Station::class;
- /**
- * 缓存架上架料箱
- * @param Station $station
- * @param MaterialBox $materialBox
- * @param $pointX
- * @param $pointY
- * @return string
- * @throws ErrorException
- */
- public function pushTask(Station $station,MaterialBox $materialBox,$pointX, $pointY)
- {
- /** 推送任务 */
- if($this->putBinToStore($station,$materialBox)){
- /** 亮灯 */
- return $this->lightOn($station,$pointX, $pointY);
- }
- else return false;
- }
- /**
- * 获取缓存架任务
- * @param Station $station
- */
- public function getTasks(Station $station)
- {
- $grids = StationCacheShelfGrid::query()->with('materialBox:code')->where('station_id',$station['id'])->where('status',2)->orderBy('grid_id')->get();
- $station->setRelation('grids',$grids);
- }
- /**
- * 缓存架 【亮灯】
- * @param Station $station
- * @param $pointX
- * @param $pointY
- * @return string
- */
- public function lightOn(Station $station,$pointX,$pointY): string
- {
- $locCode = 'HAI'.$station['code'].'-0'.$pointX.'-0'.$pointY;
- $params = [
- "areaCode"=> "1004",
- "PTLAction"=> 1, //1是开,0是关
- "PTLSettings"=> [
- "color"=> 1,
- "frequency"=> 1
- ],
- "displayInfo"=> [
- "detail01"=> "detail01",
- "detail02"=> "detail02",
- "detail03"=> "detail03",
- "qrCode"=> "qrCode",
- "qty00"=> "11",
- "qty01"=> 1,
- "qty02"=> 2,
- "title"=> "title",
- "uomDesc01"=> "uo",
- "uomDesc02"=> "uo"
- ],
- "locCode"=> $locCode//灯条口,B1\B2=设备编号,中间号码代表从右往左数的列,右边号码时从下往上数
- ];
- $response = Http::post(config('api.haiq.storage.light'),$params);
- return $response->body();
- }
- /**
- * 推送到海柔的任务
- * @param Station $station
- * @param MaterialBox $materialBox
- * @return bool
- * @throws ErrorException
- */
- public function putBinToStore(Station $station,MaterialBox $materialBox): bool
- {
- $stationTaskMaterialBox = new StationTaskMaterialBox();
- $stationTaskMaterialBox->setRelation('station',$station);
- $stationTaskMaterialBox->setRelation('materialBox',$materialBox);
- /** @var ForeignHaiRoboticsService $foreignHaiRoboticsService */
- $foreignHaiRoboticsService = app(ForeignHaiRoboticsService::class);
- return $foreignHaiRoboticsService->putBinToStore_fromCacheShelf($stationTaskMaterialBox);
- }
- }
|