LightController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\Log;
  8. class LightController
  9. {
  10. protected $request;
  11. /** @var ForeignHaiRoboticsService $service */
  12. private $service;
  13. public function __construct(){
  14. $this->service=app('ForeignHaiRoboticsService');
  15. }
  16. public function lightOn($post){
  17. }
  18. public function lightOff(Request $request){
  19. }
  20. /**
  21. * @param Request $request {"areaCode":"1004","locCode":"HAIB2-02-03","displayInfo":null,"PTLAction":0,"PTLSettings":null}
  22. * @return array
  23. */
  24. public function update(Request $request){// 拍灯以后的消息发至此处
  25. $station = Station::query()->with('stationType')->where('code',$request['locCode'])->first();
  26. if( ($station ?? false) && ($station->stationType->name ?? false) && $station->stationType->name == '缓存架' ){ // 拍灯 推送任务
  27. if($request['PTLAction'] !== 0) return ['location' => 200,'errMsg' => 'is cacheShelf','data' => $request->all()];
  28. /** @var CacheShelfService $cacheShelfService */
  29. $cacheShelfService = app(CacheShelfService::class);
  30. $result = $cacheShelfService->lightOffTask($request['locCode'],$request['PTLAction']);
  31. return ['location'=>$result['success'] ? 200 :0,'errMsg'=>$result['errMsg'] ?? null,'data'=>$request->all()];
  32. }
  33. $success = $request->input('success');
  34. $location = $success?200:0;
  35. app('LogService')->log(__METHOD__,__FUNCTION__,'拍灯:'.json_encode($request->all()));
  36. return ['location'=>$location,'errMsg'=>'','data'=>$request->all()];
  37. }
  38. }