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.
56 lines
1.9 KiB
56 lines
1.9 KiB
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use App\Models\LicensePlateRecognition;
|
|
use App\Services\LicensePlateRecognitionService;
|
|
use App\Services\OperationLogService;
|
|
use Maatwebsite\Excel\Concerns\FromArray;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
class LicensePlateRecognitionExport implements FromArray, WithHeadings
|
|
{
|
|
public function array(): array
|
|
{
|
|
$data = [];
|
|
$index = 1;
|
|
$query = LicensePlateRecognition::query();
|
|
$columns = ['time_slot'];
|
|
$query->groupBy('time_slot')->select($columns)->get()->each(
|
|
function ($item) use (&$data, &$index) {
|
|
$countData = (new LicensePlateRecognitionService(
|
|
new OperationLogService()
|
|
))->getCount($item['time_slot']);
|
|
|
|
$data[] = [
|
|
'id' => $index,
|
|
'time_slot' => $item['time_slot'],
|
|
'sum_count' => $countData['sum_count'],
|
|
'high_ratio' => $countData['high_ratio'],
|
|
'middle_ratio' => $countData['middle_ratio'],
|
|
'manual_count' => $countData['manual_count'],
|
|
'manual_ratio' => $countData['manual_ratio']
|
|
];
|
|
$index += 1;
|
|
return $item;
|
|
}
|
|
);
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
__('exports.global.index'),
|
|
__('exports.license_plate_recognition.time_slot'),
|
|
__('exports.license_plate_recognition.sum_count'),
|
|
__('exports.license_plate_recognition.high_ratio'),
|
|
__('exports.license_plate_recognition.middle_ratio'),
|
|
__('exports.license_plate_recognition.manual_count'),
|
|
__('exports.license_plate_recognition.manual_ratio')
|
|
];
|
|
}
|
|
}
|
|
|