add spatial planning count and sum on dashboard simbg

This commit is contained in:
arifal
2025-08-08 15:11:32 +07:00
parent ef3c9d6fc3
commit b5f7bf39b2
2 changed files with 16 additions and 14 deletions

View File

@@ -85,22 +85,22 @@ class BigdataResume extends Model
$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
');
// $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();
});
// return $query->first();
// });
$spatial_planning_count = $query_spatial_plannings->task_count ?? 0;
$spatial_planning_total = $query_spatial_plannings->total_retribution;
$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;

View File

@@ -393,6 +393,8 @@ class ServiceGoogleSheet
'MENUNGGU_KLIK_DPMPTSP_SUM' => $this->convertToDecimal($result['WAITING_KLIK_DPMPTSP']['nominal']) ?? 0,
'PROSES_DINAS_TEKNIS_COUNT' => $this->convertToInteger($result['PROSES_DINAS_TEKNIS']['total']) ?? 0,
'PROSES_DINAS_TEKNIS_SUM' => $this->convertToDecimal($result['PROSES_DINAS_TEKNIS']['nominal']) ?? 0,
'SPATIAL_PLANNING_COUNT' => $this->getSpatialPlanningWithCalculationCount(),
'SPATIAL_PLANNING_SUM' => $this->getSpatialPlanningCalculationSum()
];
foreach ($dataSettings as $key => $value) {