From b5f7bf39b2a7f36fcd6be0396975c0e8a956a144 Mon Sep 17 00:00:00 2001 From: arifal Date: Fri, 8 Aug 2025 15:11:32 +0700 Subject: [PATCH] add spatial planning count and sum on dashboard simbg --- app/Models/BigdataResume.php | 28 ++++++++++++++-------------- app/Services/ServiceGoogleSheet.php | 2 ++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/Models/BigdataResume.php b/app/Models/BigdataResume.php index 4e65aeb..7517462 100644 --- a/app/Models/BigdataResume.php +++ b/app/Models/BigdataResume.php @@ -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; diff --git a/app/Services/ServiceGoogleSheet.php b/app/Services/ServiceGoogleSheet.php index 29c43ac..c85f0e4 100644 --- a/app/Services/ServiceGoogleSheet.php +++ b/app/Services/ServiceGoogleSheet.php @@ -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) {