停车场管理系统
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.
 
 

70 lines
2.1 KiB

<?php
namespace App\Services;
use App\Models\LicensePlateRecognition;
use App\Models\ParkingLicensePlate;
use App\Models\ParkingSpaceType;
use Exception;
use Illuminate\Support\Facades\DB;
class LicensePlateRecognitionService extends BaseService
{
/**
* 构造函数
* @param OperationLogService $logService
*/
public function __construct(OperationLogService $logService)
{
parent::__construct($logService);
$this->logService->menuTitle = 'recognition_rate';
}
/**
* @param $data
* @throws Exception
*/
public function createData($data)
{
$model = LicensePlateRecognition::query()->create([
'time_slot' => get_datetime('date'),
'manual_modification' => $data['manual_modification'],
'license_plate' => $data['license_plate'],
'recognition' => $data['recognition'],
'capture_images' => $data['capture_images'],
'created_at' => get_datetime()
]);
return $model;
}
public function getCount($time_slot)
{
$manualWhere = $highWhere = $middleWhere = $where = [
'time_slot' => $time_slot
];
$where['manual_modification'] = 0;
$sumCount = LicensePlateRecognition::query()->where($where)
->count();
$highCount = LicensePlateRecognition::query()->where(
$where
)->where('recognition', '>=', 80)->count();
$middleCount = LicensePlateRecognition::query()->where(
$where
)->where('recognition', '<', 80)->count();
$manualWhere['manual_modification'] = 1;
$manualCount = LicensePlateRecognition::query()->where(
$manualWhere
)->count();
return [
'sum_count' => $sumCount,
'high_count' => $highCount,
'middle_count' => $middleCount,
'manual_count' => $manualCount,
'high_ratio' => get_ratio($sumCount, $highCount),
'middle_ratio' => get_ratio($sumCount, $middleCount),
'manual_ratio' => get_ratio($sumCount, $manualCount)
];
}
}