Merge branch 'dev' of 178.128.21.43:arifal/sibedas into dev

This commit is contained in:
arifal hidayat
2025-09-11 23:33:35 +07:00
5 changed files with 137 additions and 13 deletions

View File

@@ -0,0 +1,118 @@
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use App\Models\PbgTask;
use App\Enums\PbgTaskFilterData;
class PbgTaskExport implements FromCollection, WithHeadings
{
protected $category;
protected $year;
public function __construct(string $category, int $year)
{
$this->category = $category;
$this->year = $year;
}
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
$query = PbgTask::query()
->whereYear('task_created_at', $this->year);
// Menggunakan switch case karena lebih readable dan maintainable
// untuk multiple conditions yang berbeda
switch ($this->category) {
case PbgTaskFilterData::all->value:
// Tidak ada filter tambahan, ambil semua data
break;
case PbgTaskFilterData::business->value:
$query->where('application_type', 'business');
break;
case PbgTaskFilterData::non_business->value:
$query->where('application_type', 'non-business');
break;
case PbgTaskFilterData::verified->value:
$query->where('is_valid', true);
break;
case PbgTaskFilterData::non_verified->value:
$query->where('is_valid', false);
break;
case PbgTaskFilterData::potention->value:
$query->where('status', 'potention');
break;
case PbgTaskFilterData::issuance_realization_pbg->value:
$query->where('status', 'issuance-realization-pbg');
break;
case PbgTaskFilterData::process_in_technical_office->value:
$query->where('status', 'process-in-technical-office');
break;
case PbgTaskFilterData::waiting_click_dpmptsp->value:
$query->where('status', 'waiting-click-dpmptsp');
break;
case PbgTaskFilterData::non_business_rab->value:
$query->where('application_type', 'non-business')
->where('consultation_type', 'rab');
break;
case PbgTaskFilterData::non_business_krk->value:
$query->where('application_type', 'non-business')
->where('consultation_type', 'krk');
break;
case PbgTaskFilterData::business_rab->value:
$query->where('application_type', 'business')
->where('consultation_type', 'rab');
break;
case PbgTaskFilterData::business_krk->value:
$query->where('application_type', 'business')
->where('consultation_type', 'krk');
break;
case PbgTaskFilterData::business_dlh->value:
$query->where('application_type', 'business')
->where('consultation_type', 'dlh');
break;
default:
// Jika category tidak dikenali, return empty collection
return collect();
}
return $query->select([
'registration_number',
'document_number',
'owner_name',
'address',
'name as building_name',
'function_type'
])->get();
}
public function headings(): array{
return [
'Nomor Registrasi',
'Nomor Dokumen',
'Nama Pemilik',
'Alamat Pemilik',
'Nama Bangunan',
'Fungsi Bangunan',
];
}
}

View File

@@ -486,14 +486,14 @@ class BigDataResumeController extends Controller
{
try {
// Get sum and count from PbgTaskPayment model
$totalSum = PbgTaskPayment::whereYear('payment_date', date('Y'))->sum('pad_amount') ?? 0;
$totalCount = PbgTaskPayment::whereYear('payment_date', date('Y'))->count() ?? 0;
$stats = PbgTaskPayment::whereNotNull('payment_date_raw')
->whereNotNull('retribution_total_pad')
->whereYear('payment_date_raw', date('Y'))
->selectRaw('SUM(retribution_total_pad) as total_sum, COUNT(*) as total_count')
->first();
Log::info("Real-time PBG Task Payments Data", [
'total_records' => $totalCount,
'total_sum' => $totalSum,
'source' => 'pbg_task_payments table'
]);
$totalSum = $stats->total_sum ?? 0;
$totalCount = $stats->total_count ?? 0;
return [
'sum' => (float) $totalSum,