LightController.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Http\Controllers\api\thirdPart\haiq;
  3. use App\Services\CacheShelfService;
  4. use App\Services\ForeignHaiRoboticsService;
  5. use App\Station;
  6. use App\Traits\TestableInstant;
  7. use Illuminate\Http\Request;
  8. class LightController
  9. {
  10. protected $request;
  11. use TestableInstant;
  12. /** @var ForeignHaiRoboticsService $service */
  13. private $foreignHaiRoboticsService;
  14. /**
  15. * @param Request $request {"areaCode":"1004","locCode":"HAIB2-02-03","displayInfo":null,"PTLAction":0,"PTLSettings":null}
  16. * @return array
  17. */
  18. public function update(Request $request){// 拍灯以后的消息发至此处
  19. app('LogService')->log(__METHOD__,__FUNCTION__,'拍灯:'.json_encode($request->all()));
  20. $this->instant($this->foreignHaiRoboticsService, 'ForeignHaiRoboticsService');
  21. $success = $request->input('success');
  22. $location = $success?200:0;
  23. /** @var Station $station */
  24. $station = Station::query()->with('stationType')->where('code',$request['locCode'])->first();
  25. $response = ['location' => $location, 'errMsg' => '', 'data' => $request->all()];
  26. if(empty($station)
  27. ||empty($station->stationType->name))return $response;
  28. switch ($station->stationType->name) {
  29. case '缓存架': // 拍灯 推送任务
  30. if($request['PTLAction'] !== 0){
  31. $response['errMsg']='灯条未开启';return $response;
  32. }
  33. /** @var CacheShelfService $cacheShelfService */
  34. $cacheShelfService = app(CacheShelfService::class);
  35. $result = $cacheShelfService->lightOffTask($request['locCode']);
  36. $response['location']=$result['success']??'';
  37. $response['errMsg']=$result['errMsg']??'';
  38. return $response;
  39. case 'U型线拍灯':
  40. // 废弃此入口 U型线拍灯口迁移至 PickStationController:processed
  41. }
  42. return $response;
  43. }
  44. }