| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Http\Controllers\api\thirdPart\haiq;
- use App\Services\CacheShelfService;
- use App\Services\ForeignHaiRoboticsService;
- use App\Station;
- use App\Traits\TestableInstant;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Log;
- class LightController
- {
- protected $request;
- use TestableInstant;
- /** @var ForeignHaiRoboticsService $service */
- private $foreignHaiRoboticsService;
- public function __construct(){
- $this->foreignHaiRoboticsService=null;
- }
- public function lightOn($post){
- }
- public function lightOff(Request $request){
- }
- /**
- * @param Request $request {"areaCode":"1004","locCode":"HAIB2-02-03","displayInfo":null,"PTLAction":0,"PTLSettings":null}
- * @return array
- */
- public function update(Request $request){// 拍灯以后的消息发至此处
- app('LogService')->log(__METHOD__,__FUNCTION__,'拍灯:'.json_encode($request->all()));
- $this->instant($this->foreignHaiRoboticsService, 'ForeignHaiRoboticsService');
- $success = $request->input('success');
- $location = $success?200:0;
- /** @var Station $station */
- $station = Station::query()->with('stationType')->where('code',$request['locCode'])->first();
- $response = ['location' => $location, 'errMsg' => '', 'data' => $request->all()];
- if(empty($station)
- ||empty($station->stationType->name))return $response;
- switch ($station->stationType->name) {
- case '缓存架': // 拍灯 推送任务
- if($request['PTLAction'] !== 0){
- $response['errMsg']='灯条未开启';return $response;
- }
- /** @var CacheShelfService $cacheShelfService */
- $cacheShelfService = app(CacheShelfService::class);
- $result = $cacheShelfService->lightOffTask($request['locCode'],$request['PTLAction']);
- $response['location']=$result['success'];
- $response['errMsg']=$result['errMsg'];
- return $response;
- case 'U型线拍灯':
- $this->foreignHaiRoboticsService->uLineLightPat($station);
- }
- return $response;
- }
- }
|