19 changed files with 193 additions and 59 deletions
@ -0,0 +1,56 @@ |
|||||
|
<?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') |
||||
|
]; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue