5 changed files with 143 additions and 87 deletions
@ -0,0 +1,56 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use App\Services\Api\CameraApiService; |
|||
use App\Services\Device\CameraDeviceService; |
|||
use Illuminate\Console\Command; |
|||
|
|||
class VehicleEntryAndExit extends Command |
|||
{ |
|||
|
|||
/** |
|||
* The name and signature of the console command. |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'run:vehicle-entry-and-exit'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* @var string |
|||
*/ |
|||
protected $description = 'Command description'; |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
// 获取所有设备车位信息 |
|||
$data = CameraApiService::query()->getCameraPlateNoBody(); |
|||
if ($data && isset($data['body']['list'])) { |
|||
$list = $data['body']['list']; |
|||
// 通过设备信息获取设备状态 |
|||
$data = []; |
|||
foreach ($list as $item) { |
|||
$ip = $item['camera_ip']; |
|||
try { |
|||
$ParkingNo = CameraDeviceService::query($ip)->getParkingNo(); |
|||
} catch (\Exception $e) { |
|||
continue; |
|||
} |
|||
$data[] = [ |
|||
'camera_ip' => $ip, |
|||
'number' => $item['number'], |
|||
'license_plate_number' => $ParkingNo, |
|||
'date_time' => date('Y-m-d H:i:s', time()), |
|||
]; |
|||
} |
|||
// 返回告诉设备状态情况 |
|||
CameraApiService::query()->putCameraPlateNoBody(['list' => $data]); |
|||
echo 'SUCCESS'; |
|||
} |
|||
echo 'empty'; |
|||
exit(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue