LightController.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Http\Controllers\api\thirdPart\haiq;
  3. use App\MaterialBox;
  4. use App\Services\CacheShelfService;
  5. use App\Services\ForeignHaiRoboticsService;
  6. use App\Services\StationCacheShelfGridService;
  7. use App\Station;
  8. use App\StationCacheShelfGrid;
  9. use Illuminate\Http\Request;
  10. use Illuminate\Support\Facades\Http;
  11. class LightController
  12. {
  13. protected $request;
  14. /** @var ForeignHaiRoboticsService $service */
  15. private $service;
  16. public function __construct(){
  17. $this->service=app('ForeignHaiRoboticsService');
  18. }
  19. public function lightOn($post){
  20. $response = Http::post(config('api.haiq.storage.light'),$post);
  21. return $response->body();
  22. }
  23. public function lightOff(Request $request){
  24. // $locCode = $request['locCode'];
  25. // $PTLAction = $request['PTLAction'];
  26. // list($stationCode, $gridId, $x, $y) = StationCacheShelfGrid::getGridByCode($locCode);
  27. // $station = Station::query()->where('code',$stationCode)->first();
  28. // $grid = StationCacheShelfGrid::query()->where('station_id',$station['id'])->where('grid_id',$gridId)->first();
  29. // $materialBox = MaterialBox::query()->where('id',$grid['material_box_id'])->first();
  30. // $cacheShelfService = app(CacheShelfService::class);
  31. // $cacheShelfService->putBinToStore($station,$materialBox,$grid);
  32. }
  33. /**
  34. * @param Request $request {"areaCode":"1004","locCode":"HAIB2-02-03","displayInfo":null,"PTLAction":0,"PTLSettings":null}
  35. * @param StationCacheShelfGridService $gridService
  36. * @return array
  37. */
  38. public function update(Request $request,StationCacheShelfGridService $gridService){// 拍灯以后的消息发至此处
  39. $gridService->lightOff($request['locCode'],$request['PTLAction']);
  40. $success = $request->input('success');
  41. $location = $success?200:0;
  42. app('LogService')->log(__METHOD__,__FUNCTION__,json_encode($request->all()));
  43. return ['location'=>$location,'errMsg'=>'','data'=>$request->all()];
  44. }
  45. }