getUrl($this->MULTI_PARKING_SPACES_LAMP); $body = $this->getColorBody($color_occupy, $color_vacant, $is_flicker); if (!$body) { return []; } $response = $this->putHttp($url, $body); return json_decode($response->body(), true); } /** * 获取车位相机信息 * @param $color_occupy * @param $color_vacant * @param $is_flicker * @return array */ public function getColorBody( $color_occupy, $color_vacant, $is_flicker ): array { $is_flicker = (bool)$is_flicker; $url = $this->getUrl($this->MULTI_PARKING_SPACES_LAMP); $response = $this->getHttp($url); $body = json_decode($response->body(), true); if ($body) { if (isset($body['VehicleNumber']['VehicleChannelList'][0])) { $VehicleChannelList = $body['VehicleNumber']['VehicleChannelList'][0]; if (isset($VehicleChannelList['VehicleNoExist'])) { // 是否闪烁 $body['VehicleNumber']['VehicleChannelList'][0]['VehicleNoExist']['flashEnabled'] = $is_flicker; // 无车显示颜色 $body['VehicleNumber']['VehicleChannelList'][0]['VehicleNoExist']['lampColor'] = $color_vacant; } if (isset($VehicleChannelList['VehicleExist'])) { // 是否闪烁 $body['VehicleNumber']['VehicleChannelList'][0]['VehicleExist']['flashEnabled'] = $is_flicker; // 有车显示颜色 $body['VehicleNumber']['VehicleChannelList'][0]['VehicleExist']['lampColor'] = $color_occupy; } } } else { return []; } return $body; } public function getStatus(): bool { $url = $this->getUrl($this->SYSTEM_STATUS); $response = $this->getHttp($url); return $response->successful(); } // 返回车牌号码 public function getParkingNo($channels_id = 1) { $url = $this->getUrl(str_replace('?', $channels_id, $this->PARKING_STATUS)); $response = $this->getHttp($url); $body = $response->body(); $bodyArr = $this->getBodyArray($body); if (isset($bodyArr['ParkingStatusList']['ParkingStatus'])) { $parkingStatus = $bodyArr['ParkingStatusList']['ParkingStatus']; if ($parkingStatus['carStatus'] == 'true') { return $parkingStatus['plateNo']; } } return ''; } }