CacheShelfService.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace App\Services;
  3. use App\Exceptions\ErrorException;
  4. use App\MaterialBox;
  5. use App\Station;
  6. use App\StationCacheShelfGrid;
  7. use App\StationTaskMaterialBox;
  8. use App\Traits\ServiceAppAop;
  9. use Illuminate\Support\Facades\Http;
  10. class CacheShelfService
  11. {
  12. use ServiceAppAop;
  13. protected $modelClass=Station::class;
  14. /**
  15. * 获取缓存架任务
  16. * @param Station $station
  17. */
  18. public function getTasks(Station $station)
  19. {
  20. $grids = StationCacheShelfGrid::query()->with('materialBox:code')->where('station_id',$station['id'])->where('status',1)->orderBy('grid_id')->get();
  21. $station->setRelation('grids',$grids);
  22. }
  23. /**
  24. * 缓存架 【亮灯】
  25. * @param Station $station
  26. * @param $pointX
  27. * @param $pointY
  28. * @return string
  29. */
  30. public function lightOnApi(Station $station,$pointX,$pointY): string
  31. {
  32. $locCode = 'HAI'.$station['code'].'-0'.$pointX.'-0'.$pointY;
  33. $params = [
  34. "areaCode"=> "1004",
  35. "PTLAction"=> 1, //1是开,0是关
  36. "PTLSettings"=> [
  37. "color"=> 1,
  38. "frequency"=> 1
  39. ],
  40. "displayInfo"=> [
  41. "detail01"=> "detail01",
  42. "detail02"=> "detail02",
  43. "detail03"=> "detail03",
  44. "qrCode"=> "qrCode",
  45. "qty00"=> "11",
  46. "qty01"=> 1,
  47. "qty02"=> 2,
  48. "title"=> "title",
  49. "uomDesc01"=> "uo",
  50. "uomDesc02"=> "uo"
  51. ],
  52. "locCode"=> $locCode//灯条口,B1\B2=设备编号,中间号码代表从右往左数的列,右边号码时从下往上数
  53. ];
  54. $response = Http::post(config('api.haiq.storage.light'),$params);
  55. return $response->body();
  56. }
  57. /**
  58. * 推送到海柔机器人的任务
  59. * @param Station $station
  60. * @param MaterialBox $materialBox
  61. * @param StationCacheShelfGrid $grid
  62. * @return bool
  63. * @throws ErrorException
  64. */
  65. public function putBinToStore(Station $station,MaterialBox $materialBox,StationCacheShelfGrid $grid): bool
  66. {
  67. // 生成任务
  68. /** @var StationTaskMaterialBox $stationTaskMaterialBox */
  69. $stationTaskMaterialBox = StationTaskMaterialBox::query()->create([
  70. 'station_id' => $station['id'],
  71. 'material_box_id' => $materialBox['id'],
  72. 'status' => '待处理'
  73. ]);
  74. $station->setRelation('grids',$grid);
  75. $stationTaskMaterialBox->setRelation('station',$station);
  76. $stationTaskMaterialBox->setRelation('materialBox',$materialBox);
  77. /** @var ForeignHaiRoboticsService $foreignHaiRoboticsService */
  78. $foreignHaiRoboticsService = app(ForeignHaiRoboticsService::class);
  79. return $foreignHaiRoboticsService->putBinToStore_fromCacheShelf($stationTaskMaterialBox);
  80. }
  81. }