|
|
@ -13,23 +13,26 @@ class SetCameraData extends Command |
|
|
{ |
|
|
{ |
|
|
/** |
|
|
/** |
|
|
* The name and signature of the console command. |
|
|
* The name and signature of the console command. |
|
|
* |
|
|
|
|
|
* @var string |
|
|
* @var string |
|
|
*/ |
|
|
*/ |
|
|
protected $signature = 'run:set-camera-data'; |
|
|
protected $signature = 'run:set-camera-data'; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* The console command description. |
|
|
* The console command description. |
|
|
* |
|
|
|
|
|
* @var string |
|
|
* @var string |
|
|
*/ |
|
|
*/ |
|
|
protected $description = 'Command description'; |
|
|
protected $description = 'Command description'; |
|
|
|
|
|
|
|
|
protected string $sysUrl; |
|
|
protected string $sysUrl; |
|
|
|
|
|
protected string $sysPost; |
|
|
|
|
|
protected string $sysHttp; |
|
|
|
|
|
|
|
|
public function __construct() { |
|
|
public function __construct() |
|
|
|
|
|
{ |
|
|
parent::__construct(); |
|
|
parent::__construct(); |
|
|
$this->sysUrl = env('sys_url', 'http://192.168.66.16:8010'); |
|
|
$this->sysUrl = env('SYS_URL', '192.168.66.16'); |
|
|
|
|
|
$this->sysPost = env('SYS_POST', ''); |
|
|
|
|
|
$this->sysHttp = env('SYS_HOST', 'http'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -40,25 +43,31 @@ class SetCameraData extends Command |
|
|
// 获取所有设备信息 |
|
|
// 获取所有设备信息 |
|
|
$ip = '192.168.66.64'; |
|
|
$ip = '192.168.66.64'; |
|
|
$service = new CameraDeviceService($ip); |
|
|
$service = new CameraDeviceService($ip); |
|
|
|
|
|
$url = $this->sysHttp . '://' . $this->sysUrl; |
|
|
|
|
|
$Host = $this->sysUrl; |
|
|
|
|
|
if ($this->sysPost) { |
|
|
|
|
|
$url .= ':' . $this->sysPost; |
|
|
|
|
|
$Host .= ':' . $this->sysPost; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$curl = curl_init(); |
|
|
$curl = curl_init(); |
|
|
|
|
|
|
|
|
curl_setopt_array($curl, [ |
|
|
curl_setopt_array($curl, [ |
|
|
CURLOPT_PORT => "8010", |
|
|
CURLOPT_PORT => $this->sysPost, |
|
|
CURLOPT_URL => $this->sysUrl . "/api/device/camera/getBody", |
|
|
CURLOPT_URL => $url . "/api/device/camera/getBody", |
|
|
CURLOPT_RETURNTRANSFER => true, |
|
|
CURLOPT_RETURNTRANSFER => true, |
|
|
CURLOPT_ENCODING => "", |
|
|
CURLOPT_ENCODING => "", |
|
|
CURLOPT_MAXREDIRS => 10, |
|
|
CURLOPT_MAXREDIRS => 10, |
|
|
CURLOPT_TIMEOUT => 30, |
|
|
CURLOPT_TIMEOUT => 30, |
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
|
CURLOPT_CUSTOMREQUEST => "GET", |
|
|
CURLOPT_CUSTOMREQUEST => "GET", |
|
|
CURLOPT_POSTFIELDS => "", |
|
|
CURLOPT_POSTFIELDS => "", |
|
|
CURLOPT_HTTPHEADER => [ |
|
|
CURLOPT_HTTPHEADER => [ |
|
|
"Accept: */*", |
|
|
"Accept: */*", |
|
|
"Accept-Encoding: gzip, deflate, br", |
|
|
"Accept-Encoding: gzip, deflate, br", |
|
|
"Cache-Control: no-cache", |
|
|
"Cache-Control: no-cache", |
|
|
"Connection: keep-alive", |
|
|
"Connection: keep-alive", |
|
|
"Host: 192.168.66.16:8010", |
|
|
"Host: {$Host}", |
|
|
"User-Agent: PostmanRuntime-ApipostRuntime/1.1.0" |
|
|
"User-Agent: PostmanRuntime-ApipostRuntime/1.1.0" |
|
|
], |
|
|
], |
|
|
]); |
|
|
]); |
|
|
@ -72,17 +81,18 @@ class SetCameraData extends Command |
|
|
echo "cURL Error #:" . $err; |
|
|
echo "cURL Error #:" . $err; |
|
|
exit; |
|
|
exit; |
|
|
} |
|
|
} |
|
|
|
|
|
if ($response) { |
|
|
|
|
|
$resData = json_decode($response, true); |
|
|
|
|
|
if ($resData['error'] < 1) { |
|
|
|
|
|
$body = $resData['body']; |
|
|
|
|
|
} else { |
|
|
|
|
|
echo $resData['message']; |
|
|
|
|
|
exit; |
|
|
|
|
|
} |
|
|
|
|
|
// 通过设备信息获取设备状态 |
|
|
|
|
|
|
|
|
$resData = json_decode($response, true); |
|
|
$service->setColor($body); |
|
|
if ($resData['error'] < 1) { |
|
|
|
|
|
$body = $resData['body']; |
|
|
|
|
|
} else { |
|
|
|
|
|
echo $resData['message']; |
|
|
|
|
|
exit; |
|
|
|
|
|
} |
|
|
} |
|
|
// 通过设备信息获取设备状态 |
|
|
|
|
|
|
|
|
|
|
|
$service->setColor($body); |
|
|
|
|
|
|
|
|
|
|
|
echo 'SUCCESS'; |
|
|
echo 'SUCCESS'; |
|
|
exit; |
|
|
exit; |
|
|
|