partial update count and sum dashboard
This commit is contained in:
@@ -56,4 +56,90 @@ enum PbgTaskStatus: int
|
||||
{
|
||||
return self::getStatuses()[$status] ?? null;
|
||||
}
|
||||
|
||||
public static function getWaitingClickDpmptsp(): array
|
||||
{
|
||||
return [
|
||||
self::MENUNGGU_PEMBAYARAN_RETRIBUSI->value,
|
||||
self::PROSES_PENERBITAN_SKRD->value,
|
||||
self::VERIFIKASI_PEMBAYARAN_RETRIBUSI->value
|
||||
];
|
||||
}
|
||||
|
||||
public static function getIssuanceRealizationPbg(): array
|
||||
{
|
||||
return [
|
||||
self::PENERBITAN_SK_PBG->value,
|
||||
self::SK_PBG_TERBIT->value,
|
||||
self::VERIFIKASI_SK_PBG->value
|
||||
];
|
||||
}
|
||||
|
||||
public static function getProcessInTechnicalOffice(): array
|
||||
{
|
||||
return [
|
||||
self::PENERBITAN_SPPST->value,
|
||||
self::PERHITUNGAN_RETRIBUSI->value,
|
||||
self::RETRIBUSI_TIDAK_SESUAI->value,
|
||||
self::MENUNGGU_JADWAL_KONSULTASI->value,
|
||||
self::MENUNGGU_PENUGASAN_TPT_TPA->value,
|
||||
self::PELAKSANAAN_KONSULTASI->value
|
||||
];
|
||||
}
|
||||
|
||||
public static function getVerified(): array
|
||||
{
|
||||
return [
|
||||
self::MENUNGGU_PEMBAYARAN_RETRIBUSI->value,
|
||||
self::PROSES_PENERBITAN_SKRD->value,
|
||||
self::VERIFIKASI_PEMBAYARAN_RETRIBUSI->value,
|
||||
self::PENERBITAN_SK_PBG->value,
|
||||
self::SK_PBG_TERBIT->value,
|
||||
self::VERIFIKASI_SK_PBG->value,
|
||||
self::PENERBITAN_SPPST->value,
|
||||
self::PERHITUNGAN_RETRIBUSI->value,
|
||||
self::RETRIBUSI_TIDAK_SESUAI->value,
|
||||
self::MENUNGGU_JADWAL_KONSULTASI->value,
|
||||
self::MENUNGGU_PENUGASAN_TPT_TPA->value,
|
||||
self::PELAKSANAAN_KONSULTASI->value
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNonVerified(): array
|
||||
{
|
||||
return [
|
||||
self::VERIFIKASI_KELENGKAPAN->value,
|
||||
self::PERBAIKAN_DOKUMEN->value,
|
||||
self::PERBAIKAN_DOKUMEN_KONSULTASI->value,
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPotention(): array
|
||||
{
|
||||
return [
|
||||
self::MENUNGGU_PEMBAYARAN_RETRIBUSI->value,
|
||||
self::PROSES_PENERBITAN_SKRD->value,
|
||||
self::VERIFIKASI_PEMBAYARAN_RETRIBUSI->value,
|
||||
self::PENERBITAN_SK_PBG->value,
|
||||
self::SK_PBG_TERBIT->value,
|
||||
self::VERIFIKASI_SK_PBG->value,
|
||||
self::PENERBITAN_SPPST->value,
|
||||
self::PERHITUNGAN_RETRIBUSI->value,
|
||||
self::RETRIBUSI_TIDAK_SESUAI->value,
|
||||
self::MENUNGGU_JADWAL_KONSULTASI->value,
|
||||
self::MENUNGGU_PENUGASAN_TPT_TPA->value,
|
||||
self::PELAKSANAAN_KONSULTASI->value,
|
||||
self::VERIFIKASI_KELENGKAPAN->value,
|
||||
self::PERBAIKAN_DOKUMEN->value,
|
||||
self::PERBAIKAN_DOKUMEN_KONSULTASI->value,
|
||||
];
|
||||
}
|
||||
|
||||
public static function getRejected(): array
|
||||
{
|
||||
return [
|
||||
self::PERMOHONAN_DITOLAK->value,
|
||||
self::PERMOHONAN_DIBATALKAN->value
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -51,12 +51,12 @@ class BigDataResumeController extends Controller
|
||||
}
|
||||
|
||||
$target_pad = floatval(optional($data_settings->where('key', 'TARGET_PAD')->first())->value);
|
||||
$realisasi_terbit_pbg_sum = cleanNumber(optional($data_settings->where('key', 'REALISASI_TERBIT_PBG_SUM')->first())->value);
|
||||
$realisasi_terbit_pbg_count = cleanNumber(optional($data_settings->where('key', 'REALISASI_TERBIT_PBG_COUNT')->first())->value);
|
||||
$menunggu_klik_dpmptsp_sum = cleanNumber(optional($data_settings->where('key', 'MENUNGGU_KLIK_DPMPTSP_SUM')->first())->value);
|
||||
$menunggu_klik_dpmptsp_count = cleanNumber(optional($data_settings->where('key', 'MENUNGGU_KLIK_DPMPTSP_COUNT')->first())->value);
|
||||
$proses_dinas_teknis_sum = cleanNumber(optional($data_settings->where('key', 'PROSES_DINAS_TEKNIS_SUM')->first())->value);
|
||||
$proses_dinas_teknis_count = cleanNumber(optional($data_settings->where('key', 'PROSES_DINAS_TEKNIS_COUNT')->first())->value);
|
||||
$realisasi_terbit_pbg_sum = $big_data_resume->issuance_realization_pbg_sum;
|
||||
$realisasi_terbit_pbg_count = $big_data_resume->issuance_realization_pbg_count;
|
||||
$menunggu_klik_dpmptsp_sum = $big_data_resume->waiting_click_dpmptsp_sum;
|
||||
$menunggu_klik_dpmptsp_count = $big_data_resume->waiting_click_dpmptsp_count;
|
||||
$proses_dinas_teknis_sum = $big_data_resume->process_in_technical_office_sum;
|
||||
$proses_dinas_teknis_count = $big_data_resume->process_in_technical_office_count;
|
||||
|
||||
$tata_ruang = $big_data_resume->spatial_sum;
|
||||
$kekurangan_potensi = $target_pad - $big_data_resume->potention_sum;
|
||||
@@ -69,36 +69,42 @@ class BigDataResumeController extends Controller
|
||||
$total_potensi_percentage = $big_data_resume->potention_sum > 0 && $target_pad > 0
|
||||
? round(($big_data_resume->potention_sum / $target_pad) * 100, 2) : 0;
|
||||
|
||||
// percentage verified document
|
||||
$verified_percentage = $big_data_resume->verified_sum > 0 && $big_data_resume->potention_sum > 0
|
||||
? round(($big_data_resume->verified_sum / $big_data_resume->potention_sum) * 100, 2) : 0;
|
||||
// percentage verified document (verified_sum / potention_sum) - by value/amount
|
||||
$verified_percentage = $big_data_resume->potention_sum > 0 && $big_data_resume->verified_sum >= 0
|
||||
? round(($big_data_resume->verified_sum / $big_data_resume->potention_sum) * 100, 4) : 0;
|
||||
|
||||
// percentage non-verified document
|
||||
$non_verified_percentage = $big_data_resume->non_verified_sum > 0 && $big_data_resume->potention_sum > 0
|
||||
? round(($big_data_resume->non_verified_sum / $big_data_resume->potention_sum) * 100, 2) : 0;
|
||||
// percentage non-verified document (non_verified_sum / potention_sum) - by value/amount
|
||||
$non_verified_percentage = $big_data_resume->potention_sum > 0 && $big_data_resume->non_verified_sum >= 0
|
||||
? round(($big_data_resume->non_verified_sum / $big_data_resume->potention_sum) * 100, 4) : 0;
|
||||
|
||||
// percentage business document
|
||||
$business_percentage = $big_data_resume->business_sum > 0 && $big_data_resume->non_verified_sum > 0
|
||||
// Alternative: percentage by count (if needed)
|
||||
// $verified_count_percentage = $big_data_resume->potention_count > 0
|
||||
// ? round(($big_data_resume->verified_count / $big_data_resume->potention_count) * 100, 2) : 0;
|
||||
// $non_verified_count_percentage = $big_data_resume->potention_count > 0
|
||||
// ? round(($big_data_resume->non_verified_count / $big_data_resume->potention_count) * 100, 2) : 0;
|
||||
|
||||
// percentage business document (business / non_verified)
|
||||
$business_percentage = $big_data_resume->non_verified_sum > 0 && $big_data_resume->business_sum >= 0
|
||||
? round(($big_data_resume->business_sum / $big_data_resume->non_verified_sum) * 100, 2) : 0;
|
||||
|
||||
// percentage non-business document
|
||||
$non_business_percentage = $big_data_resume->non_business_sum > 0 && $big_data_resume->potention_sum > 0
|
||||
? round(($big_data_resume->non_business_sum / $big_data_resume->potention_sum) * 100, 2) : 0;
|
||||
// percentage non-business document (non_business / non_verified)
|
||||
$non_business_percentage = $big_data_resume->non_verified_sum > 0 && $big_data_resume->non_business_sum >= 0
|
||||
? round(($big_data_resume->non_business_sum / $big_data_resume->non_verified_sum) * 100, 2) : 0;
|
||||
|
||||
// percentage tata ruang
|
||||
$tata_ruang_percentage = $tata_ruang > 0 && $big_data_resume->potention_sum > 0
|
||||
// percentage tata ruang (spatial / potention)
|
||||
$tata_ruang_percentage = $big_data_resume->potention_sum > 0 && $tata_ruang >= 0
|
||||
? round(($tata_ruang / $big_data_resume->potention_sum) * 100, 2) : 0;
|
||||
|
||||
// percentage realisasi terbit pbg
|
||||
$realisasi_terbit_percentage = $big_data_resume->verified_sum > 0 && $realisasi_terbit_pbg_sum > 0
|
||||
// percentage realisasi terbit pbg (issuance / verified)
|
||||
$realisasi_terbit_percentage = $big_data_resume->verified_sum > 0 && $realisasi_terbit_pbg_sum >= 0
|
||||
? round(($realisasi_terbit_pbg_sum / $big_data_resume->verified_sum) * 100, 2) : 0;
|
||||
|
||||
// percentage menunggu klik dpmptsp
|
||||
$menunggu_klik_dpmptsp_percentage = $big_data_resume->verified_sum > 0 && $menunggu_klik_dpmptsp_sum > 0
|
||||
// percentage menunggu klik dpmptsp (waiting / verified)
|
||||
$menunggu_klik_dpmptsp_percentage = $big_data_resume->verified_sum > 0 && $menunggu_klik_dpmptsp_sum >= 0
|
||||
? round(($menunggu_klik_dpmptsp_sum / $big_data_resume->verified_sum) * 100, 2) : 0;
|
||||
|
||||
// percentage proses_dinas_teknis
|
||||
$proses_dinas_teknis_percentage = $big_data_resume->verified_sum > 0 && $proses_dinas_teknis_sum > 0
|
||||
// percentage proses_dinas_teknis (process / verified)
|
||||
$proses_dinas_teknis_percentage = $big_data_resume->verified_sum > 0 && $proses_dinas_teknis_sum >= 0
|
||||
? round(($proses_dinas_teknis_sum / $big_data_resume->verified_sum) * 100, 2) : 0;
|
||||
|
||||
$result = [
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Enums\PbgTaskStatus;
|
||||
|
||||
class BigdataResume extends Model
|
||||
{
|
||||
@@ -38,94 +39,61 @@ class BigdataResume extends Model
|
||||
}
|
||||
|
||||
public static function generateResumeData($import_datasource_id, $year, $data_setting){
|
||||
$stats = PbgTask::with(['pbg_task_retributions'])
|
||||
->leftJoin('pbg_task_retributions as ptr', 'pbg_task.uuid', '=', 'ptr.pbg_task_uid')
|
||||
$stats = PbgTask::leftJoin('pbg_task_retributions as ptr', 'pbg_task.uuid', '=', 'ptr.pbg_task_uid')
|
||||
->selectRaw("
|
||||
COUNT(CASE WHEN pbg_task.status = 20 THEN 1 END) AS verified_count,
|
||||
SUM(CASE WHEN pbg_task.status = 20 THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS verified_total,
|
||||
COUNT(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getVerified()).") THEN pbg_task.uuid END) AS verified_count,
|
||||
SUM(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getVerified()).") THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS verified_total,
|
||||
|
||||
COUNT(CASE WHEN pbg_task.status != 20 OR pbg_task.status IS NULL THEN 1 END) AS non_verified_count,
|
||||
SUM(CASE WHEN pbg_task.status != 20 OR pbg_task.status IS NULL THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS non_verified_total,
|
||||
COUNT(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getNonVerified()).") THEN pbg_task.uuid END) AS non_verified_count,
|
||||
SUM(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getNonVerified()).") THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS non_verified_total,
|
||||
|
||||
COUNT(CASE WHEN (LOWER(TRIM(pbg_task.function_type)) LIKE '%fungsi usaha%'
|
||||
OR LOWER(TRIM(pbg_task.function_type)) LIKE '%sebagai tempat usaha%')
|
||||
AND pbg_task.status != 20 THEN 1 END) AS business_count,
|
||||
AND pbg_task.status in (".implode(',', PbgTaskStatus::getNonVerified()).") THEN pbg_task.uuid END) AS business_count,
|
||||
SUM(CASE WHEN (LOWER(TRIM(pbg_task.function_type)) LIKE '%fungsi usaha%'
|
||||
OR LOWER(TRIM(pbg_task.function_type)) LIKE '%sebagai tempat usaha%')
|
||||
AND pbg_task.status != 20 THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS business_total,
|
||||
AND pbg_task.status in (".implode(',', PbgTaskStatus::getNonVerified()).") THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS business_total,
|
||||
|
||||
COUNT(CASE WHEN (LOWER(TRIM(pbg_task.function_type)) NOT LIKE '%fungsi usaha%'
|
||||
AND LOWER(TRIM(pbg_task.function_type)) NOT LIKE '%sebagai tempat usaha%'
|
||||
AND pbg_task.status != 20)
|
||||
OR pbg_task.function_type IS NULL THEN 1 END) AS non_business_count,
|
||||
AND pbg_task.status in (".implode(',', PbgTaskStatus::getNonVerified())."))
|
||||
OR (pbg_task.function_type IS NULL AND pbg_task.status in (".implode(',', PbgTaskStatus::getNonVerified()).")) THEN pbg_task.uuid END) AS non_business_count,
|
||||
SUM(CASE WHEN (LOWER(TRIM(pbg_task.function_type)) NOT LIKE '%fungsi usaha%'
|
||||
AND LOWER(TRIM(pbg_task.function_type)) NOT LIKE '%sebagai tempat usaha%'
|
||||
AND pbg_task.status != 20)
|
||||
OR pbg_task.function_type IS NULL THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS non_business_total
|
||||
AND pbg_task.status in (".implode(',', PbgTaskStatus::getNonVerified())."))
|
||||
OR (pbg_task.function_type IS NULL AND pbg_task.status in (".implode(',', PbgTaskStatus::getNonVerified()).")) THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS non_business_total,
|
||||
COUNT(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getWaitingClickDpmptsp()).") THEN pbg_task.uuid END) AS waiting_click_dpmptsp_count,
|
||||
SUM(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getWaitingClickDpmptsp()).") THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS waiting_click_dpmptsp_total,
|
||||
COUNT(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getIssuanceRealizationPbg()).") THEN pbg_task.uuid END) AS issuance_realization_pbg_count,
|
||||
SUM(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getIssuanceRealizationPbg()).") THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS issuance_realization_pbg_total,
|
||||
COUNT(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getProcessInTechnicalOffice()).") THEN pbg_task.uuid END) AS process_in_technical_office_count,
|
||||
SUM(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getProcessInTechnicalOffice()).") THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS process_in_technical_office_total,
|
||||
COUNT(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getPotention()).") THEN pbg_task.uuid END) AS potention_count,
|
||||
SUM(CASE WHEN pbg_task.status in (".implode(',', PbgTaskStatus::getPotention()).") THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS potention_total
|
||||
")
|
||||
->first();
|
||||
|
||||
// Assign Results
|
||||
$verified_count = $stats->verified_count ?? 0;
|
||||
$verified_total = $stats->verified_total ?? 0;
|
||||
$non_verified_count = $stats->non_verified_count ?? 0;
|
||||
$non_verified_total = $stats->non_verified_total ?? 0;
|
||||
$business_count = $stats->business_count ?? 0;
|
||||
$business_total = $stats->business_total ?? 0;
|
||||
$non_business_count = $stats->non_business_count ?? 0;
|
||||
$non_business_total = $stats->non_business_total ?? 0;
|
||||
|
||||
$query_potention = once(function () use ($year) {
|
||||
$query = PbgTask::leftJoin('pbg_task_retributions as ptr', 'pbg_task.uuid', '=', 'ptr.pbg_task_uid')
|
||||
->selectRaw('COUNT(DISTINCT pbg_task.id) as task_count, SUM(ptr.nilai_retribusi_bangunan) as total_retribution');
|
||||
|
||||
return $query->first();
|
||||
});
|
||||
|
||||
$potention_count = $query_potention->task_count ?? 0;
|
||||
$potention_total = $query_potention->total_retribution ?? 0;
|
||||
|
||||
// $query_spatial_plannings = once(function () use ($year) {
|
||||
// $query = PbgTask::leftJoin('spatial_plannings as sp', 'pbg_task.document_number', '=', 'sp.number')
|
||||
// ->leftJoin('pbg_task_retributions as ptr', 'ptr.pbg_task_uid', '=', 'pbg_task.uuid')
|
||||
// ->selectRaw('
|
||||
// CASE
|
||||
// WHEN COUNT(DISTINCT sp.id) > 0 THEN COUNT(DISTINCT sp.id)
|
||||
// ELSE (SELECT COUNT(*) FROM spatial_plannings)
|
||||
// END as task_count,
|
||||
// SUM(CASE WHEN sp.id IS NOT NULL AND ptr.id IS NOT NULL THEN ptr.nilai_retribusi_bangunan ELSE 0 END) as total_retribution
|
||||
// ');
|
||||
|
||||
// return $query->first();
|
||||
// });
|
||||
|
||||
$spatial_planning_count = $data_setting['SPATIAL_PLANNING_COUNT'] ?? 0;
|
||||
$spatial_planning_total = $data_setting['SPATIAL_PLANNING_SUM'] ?? 0;
|
||||
|
||||
$potention_count -= $spatial_planning_count;
|
||||
$potention_total -= $spatial_planning_total;
|
||||
|
||||
return self::create([
|
||||
'import_datasource_id' => $import_datasource_id,
|
||||
'spatial_count' => $spatial_planning_count,
|
||||
'spatial_sum' => $spatial_planning_total ?? 0.00,
|
||||
'potention_count' => $potention_count ?? 0,
|
||||
'potention_sum' => $potention_total ?? 0.00,
|
||||
'non_verified_count' => $non_verified_count ?? 0,
|
||||
'non_verified_sum' => $non_verified_total ?? 0.00,
|
||||
'verified_count' => $verified_count ?? 0,
|
||||
'verified_sum' => $verified_total ?? 0.00,
|
||||
'business_count' => $business_count ?? 0,
|
||||
'business_sum' => $business_total ?? 0.00,
|
||||
'non_business_count' => $non_business_count ?? 0,
|
||||
'non_business_sum' => $non_business_total ?? 0.00,
|
||||
'spatial_count' => $data_setting['SPATIAL_PLANNING_COUNT'] ?? 0,
|
||||
'spatial_sum' => $data_setting['SPATIAL_PLANNING_SUM'] ?? 0.00,
|
||||
'potention_count' => ($stats->potention_count ?? 0),
|
||||
'potention_sum' => ($stats->potention_total ?? 0),
|
||||
'non_verified_count' => $stats->non_verified_count ?? 0,
|
||||
'non_verified_sum' => $stats->non_verified_total ?? 0.00,
|
||||
'verified_count' => $stats->verified_count ?? 0,
|
||||
'verified_sum' => $stats->verified_total ?? 0.00,
|
||||
'business_count' => $stats->business_count ?? 0,
|
||||
'business_sum' => $stats->business_total ?? 0.00,
|
||||
'non_business_count' => $stats->non_business_count ?? 0,
|
||||
'non_business_sum' => $stats->non_business_total ?? 0.00,
|
||||
'year' => $year,
|
||||
'waiting_click_dpmptsp_count' => $data_setting['MENUNGGU_KLIK_DPMPTSP_COUNT'] ?? 0,
|
||||
'waiting_click_dpmptsp_sum' => $data_setting['MENUNGGU_KLIK_DPMPTSP_SUM'] ?? 0.00,
|
||||
'issuance_realization_pbg_count' => $data_setting['REALISASI_TERBIT_PBG_COUNT'] ?? 0,
|
||||
'issuance_realization_pbg_sum' => $data_setting['REALISASI_TERBIT_PBG_SUM'] ?? 0.00,
|
||||
'process_in_technical_office_count' => $data_setting['PROSES_DINAS_TEKNIS_COUNT'] ?? 0,
|
||||
'process_in_technical_office_sum' => $data_setting['PROSES_DINAS_TEKNIS_SUM'] ??0.00,
|
||||
'waiting_click_dpmptsp_count' => $stats->waiting_click_dpmptsp_count ?? 0,
|
||||
'waiting_click_dpmptsp_sum' => $stats->waiting_click_dpmptsp_total ?? 0.00,
|
||||
'issuance_realization_pbg_count' => $stats->issuance_realization_pbg_count ?? 0,
|
||||
'issuance_realization_pbg_sum' => $stats->issuance_realization_pbg_total ?? 0.00,
|
||||
'process_in_technical_office_count' => $stats->process_in_technical_office_count ?? 0,
|
||||
'process_in_technical_office_sum' => $stats->process_in_technical_office_total ?? 0.00,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user