LightController.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. use Illuminate\Support\Facades\Log;
  9. class LightController
  10. {
  11. protected $request;
  12. use TestableInstant;
  13. /** @var ForeignHaiRoboticsService $service */
  14. private $foreignHaiRoboticsService;
  15. public function __construct(){
  16. $this->foreignHaiRoboticsService=null;
  17. }
  18. public function lightOn($post){
  19. }
  20. public function lightOff(Request $request){
  21. }
  22. /**
  23. * @param Request $request {"areaCode":"1004","locCode":"HAIB2-02-03","displayInfo":null,"PTLAction":0,"PTLSettings":null}
  24. * @return array
  25. */
  26. public function update(Request $request){// 拍灯以后的消息发至此处
  27. app('LogService')->log(__METHOD__,__FUNCTION__,'拍灯:'.json_encode($request->all()));
  28. $this->instant($this->foreignHaiRoboticsService, 'ForeignHaiRoboticsService');
  29. $success = $request->input('success');
  30. $location = $success?200:0;
  31. /** @var Station $station */
  32. $station = Station::query()->with('stationType')->where('code',$request['locCode'])->first();
  33. $response = ['location' => $location, 'errMsg' => '', 'data' => $request->all()];
  34. if(empty($station)
  35. ||empty($station->stationType->name))return $response;
  36. switch ($station->stationType->name) {
  37. case '缓存架': // 拍灯 推送任务
  38. if($request['PTLAction'] !== 0){
  39. $response['errMsg']='灯条未开启';return $response;
  40. }
  41. /** @var CacheShelfService $cacheShelfService */
  42. $cacheShelfService = app(CacheShelfService::class);
  43. $result = $cacheShelfService->lightOffTask($request['locCode'],$request['PTLAction']);
  44. $response['location']=$result['success'];
  45. $response['errMsg']=$result['errMsg'];
  46. return $response;
  47. case 'U型线拍灯':
  48. $this->foreignHaiRoboticsService->uLineLightPat($station);
  49. }
  50. return $response;
  51. }
  52. }