停车场系统数据中间件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

91 lines
2.2 KiB

<?php
namespace App\Console\Commands;
use App\Services\CameraDeviceService;
use GuzzleHttp\Client;
use Illuminate\Console\Command;
/**
* 检测设备状态信息
*/
class SetCameraData extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'run:set-camera-data';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
protected string $sysUrl;
public function __construct() {
parent::__construct();
$this->sysUrl = env('sys_url', 'http://192.168.66.16:8010');
}
/**
* Execute the console command.
*/
public function handle()
{
// 获取所有设备信息
$ip = '192.168.66.64';
$service = new CameraDeviceService($ip);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8010",
CURLOPT_URL => $this->sysUrl . "/api/device/camera/getBody",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => [
"Accept: */*",
"Accept-Encoding: gzip, deflate, br",
"Cache-Control: no-cache",
"Connection: keep-alive",
"Host: 192.168.66.16:8010",
"User-Agent: PostmanRuntime-ApipostRuntime/1.1.0"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
exit;
}
$resData = json_decode($response, true);
if ($resData['error'] < 1) {
$body = $resData['body'];
} else {
echo $resData['message'];
exit;
}
// 通过设备信息获取设备状态
$service->setColor($body);
echo 'SUCCESS';
exit;
// 返回告诉设备状态情况
}
}