CacheShelfService.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. /** @var StationTaskMaterialBoxService $stationTaskMaterialBoxService */
  15. private $stationTaskMaterialBoxService;
  16. /** @var StationCacheShelfGridService $stationCacheShelfGridService */
  17. private $stationCacheShelfGridService;
  18. /** @var ForeignHaiRoboticsService $foreignHaiRoboticsService */
  19. private $foreignHaiRoboticsService;
  20. /**
  21. * 获取现有的缓存架任务
  22. * @param Station $station
  23. */
  24. public function getTasks(Station $station)
  25. {
  26. $grids = StationCacheShelfGrid::query()->with('materialBox')->where('station_id', $station['id'])->where('status', 1)->orderBy('grid_id')->get();
  27. $station->setRelation('grids', $grids);
  28. }
  29. /**
  30. * 拍灯
  31. * @param Station $station
  32. * @param MaterialBox $materialBox
  33. * @param StationCacheShelfGrid $grid
  34. * @return bool
  35. * @throws ErrorException
  36. */
  37. public function putBinToStore(Station $station, MaterialBox $materialBox, StationCacheShelfGrid $grid): bool
  38. {
  39. $this->instant($this->stationTaskMaterialBoxService,'StationTaskMaterialBoxService');
  40. $this->instant($this->stationCacheShelfGridService,'StationCacheShelfGridService');
  41. $this->instant($this->foreignHaiRoboticsService,'ForeignHaiRoboticsService');
  42. /** @var StationTaskMaterialBox $stationTaskMaterialBox */
  43. $stationTaskMaterialBox = $this->stationTaskMaterialBoxService->createByStationMaterialBox($station, $materialBox);
  44. $this->stationCacheShelfGridService->processGrid($grid,$station,$materialBox);
  45. $station->setRelation('grids', $grid);
  46. $stationTaskMaterialBox->setRelation('station', $station);
  47. $stationTaskMaterialBox->setRelation('materialBox', $materialBox);
  48. return $this->foreignHaiRoboticsService->putBinToStore_fromCacheShelf($stationTaskMaterialBox);
  49. }
  50. // /**
  51. // * 入库任务
  52. // * @param $params
  53. // */
  54. // public function putBinToStoreFinish($params)
  55. // {
  56. // $this->instant($this->stationTaskMaterialBoxService,'StationTaskMaterialBoxService');
  57. //
  58. // $locCode = $params['locCode'];
  59. //
  60. // list($stationCode, $gridId) = StationCacheShelfGrid::getGridByCode($locCode);
  61. // $station = Station::query()->where('code', $stationCode)->first();
  62. //
  63. // $stationCacheShelfGrid = StationCacheShelfGrid::query()->with('materialBox')->where('station_id', $station)->where('grid_id', $gridId)->first();
  64. // $stationCacheShelfGrid->update(['status' => '0', 'material_box_id' => null]);
  65. //
  66. // $StationTaskMaterialBox = StationTaskMaterialBox::query()->where('station_id', $station['id'])->where('material_box_id', $stationCacheShelfGrid['$stationCacheShelfGrid'])->first();
  67. // $this->stationTaskMaterialBoxService->set($StationTaskMaterialBox, ['status' => '已完成']);
  68. // }
  69. // /**
  70. // * 取消格口任务
  71. // * @param Station $station
  72. // * @param array $girds
  73. // */
  74. // public function cancelTask(Station $station, array $girds = [])
  75. // {
  76. // $gridQuery = StationCacheShelfGrid::query()->where('station_id', $station['id']);
  77. // if (count($girds) > 0) $gridQuery->whereIn('grid_id', $girds);
  78. // $this->stationCacheShelfGridService->cancelTask($gridQuery->get());
  79. // }
  80. }