diff --git a/app/Http/Controllers/Api/BigDataResumeController.php b/app/Http/Controllers/Api/BigDataResumeController.php index 1b89679..e986c12 100644 --- a/app/Http/Controllers/Api/BigDataResumeController.php +++ b/app/Http/Controllers/Api/BigDataResumeController.php @@ -38,14 +38,14 @@ class BigDataResumeController extends Controller } $target_pad = floatval(optional($data_settings->where('key', 'TARGET_PAD')->first())->value); - $tata_ruang = floatval(optional($data_settings->where('key', 'TATA_RUANG')->first())->value); $realisasi_terbit_pbg_sum = floatval(optional($data_settings->where('key', 'REALISASI_TERBIT_PBG_SUM')->first())->value); $realisasi_terbit_pbg_count = floatval(optional($data_settings->where('key', 'REALISASI_TERBIT_PBG_COUNT')->first())->value); $menuggu_klik_dpmptsp_sum = floatval(optional($data_settings->where('key', 'MENUNGGU_KLIK_DPMPTSP_SUM')->first())->value); $menuggu_klik_dpmptsp_count = floatval(optional($data_settings->where('key', 'MENUNGGU_KLIK_DPMPTSP_COUNT')->first())->value); $proses_dinas_teknis_sum = floatval(optional($data_settings->where('key', 'PROSES_DINAS_TEKNIS_SUM')->first())->value); $proses_dinas_teknis_count = floatval(optional($data_settings->where('key', 'PROSES_DINAS_TEKNIS_COUNT')->first())->value); - + + $tata_ruang = $big_data_resume->spatial_sum; $kekurangan_potensi = $target_pad - $big_data_resume->potention_sum; // percentage kekurangan potensi @@ -94,7 +94,8 @@ class BigDataResumeController extends Controller 'percentage' => 100, ], 'tata_ruang' => [ - 'sum' => $tata_ruang, + 'sum' => $big_data_resume->spatial_sum, + 'count' => $big_data_resume->spatial_count, 'percentage' => $tata_ruang_percentage, ], 'kekurangan_potensi' => [ diff --git a/app/Models/BigdataResume.php b/app/Models/BigdataResume.php index a0e2407..081ce19 100644 --- a/app/Models/BigdataResume.php +++ b/app/Models/BigdataResume.php @@ -21,6 +21,9 @@ class BigdataResume extends Model 'business_sum', 'non_business_count', 'non_business_sum', + 'spatial_count', + 'spatial_sum', + 'year' ]; public function importDatasource() @@ -28,88 +31,78 @@ class BigdataResume extends Model return $this->belongsTo(ImportDatasource::class, 'import_datasource_id'); } - public static function generateResumeData($import_datasource_id){ - $query_verified = once( function () { - return DB::table('pbg_task AS pt') - ->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi') - ->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') - ->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) = ?', [strtolower(trim('Selesai Verifikasi'))]) - ->selectRaw('COUNT(pt.id) AS total_data, - SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') - ->first(); - }); - - $verified_count = $query_verified->total_data ?? 0; - $verified_total = $query_verified->total_retribution ?? 0; - - $query_business = once(function () { - return DB::table('pbg_task AS pt') - ->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi') - ->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') - ->where(function ($query) { - $query->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) != ?', [strtolower(trim('Selesai Verifikasi'))]) - ->orWhereNull('ptgs.status_verifikasi'); - }) - ->where(function ($query) { - $query->whereRaw('LOWER(TRIM(pt.function_type)) = ?', [strtolower(trim('Sebagai Tempat Usaha'))]); - }) - ->selectRaw('COUNT(pt.id) AS total_data, - SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') - ->first(); - }); - - $business_count = $query_business->total_data ?? 0; - $business_total = $query_business->total_retribution ?? 0; - - $query_non_business = once( function () { - return DB::table('pbg_task AS pt') - ->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi') - ->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Join ke pbg_task_retributions - ->where(function ($query) { - $query->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) != ?', [strtolower(trim('Selesai Verifikasi'))]) - ->orWhereNull('ptgs.status_verifikasi'); // Include NULL values + public static function generateResumeData($import_datasource_id, $year){ + $stats = PbgTask::with(['googleSheet', 'pbg_task_retributions']) + ->leftJoin('pbg_task_retributions as ptr', 'pbg_task.uuid', '=', 'ptr.pbg_task_uid') + ->leftJoin('pbg_task_google_sheet as ptgs', 'pbg_task.registration_number', '=', 'ptgs.no_registrasi') + ->when($year !== 'all', function ($query) use ($year) { + $query->whereYear('pbg_task.task_created_at', (int) $year); }) - ->where(function ($query) { - $query->whereRaw('LOWER(TRIM(pt.function_type)) != ?', [strtolower(trim('Sebagai Tempat Usaha'))]) - ->orWhereNull('pt.function_type'); // Include NULL values - }) - ->selectRaw('COUNT(pt.id) AS total_data, - SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') // Menambahkan SUM dari pbg_task_retributions - ->first(); - }); - $non_business_count = $query_non_business->total_data ?? 0; - $non_business_total = $query_non_business->total_retribution ?? 0; + ->selectRaw(" + COUNT(CASE WHEN LOWER(TRIM(ptgs.status_verifikasi)) = 'selesai verifikasi' THEN 1 END) AS verified_count, + SUM(CASE WHEN LOWER(TRIM(ptgs.status_verifikasi)) = 'selesai verifikasi' THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS verified_total, + + COUNT(CASE WHEN LOWER(TRIM(ptgs.status_verifikasi)) != 'selesai verifikasi' OR ptgs.status_verifikasi IS NULL THEN 1 END) AS non_verified_count, + SUM(CASE WHEN LOWER(TRIM(ptgs.status_verifikasi)) != 'selesai verifikasi' OR ptgs.status_verifikasi IS NULL THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS non_verified_total, + + COUNT(CASE WHEN (LOWER(TRIM(ptgs.status_verifikasi)) != 'selesai verifikasi' OR ptgs.status_verifikasi IS NULL) + AND LOWER(TRIM(pbg_task.function_type)) = 'sebagai tempat usaha' THEN 1 END) AS business_count, + SUM(CASE WHEN (LOWER(TRIM(ptgs.status_verifikasi)) != 'selesai verifikasi' OR ptgs.status_verifikasi IS NULL) + AND LOWER(TRIM(pbg_task.function_type)) = 'sebagai tempat usaha' THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS business_total, - $query_non_verified = once(function () { - return DB::table('pbg_task AS pt') - ->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi') - ->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Join tabel pbg_task_retributions - ->where(function ($query) { - $query->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) != ?', [strtolower(trim('Selesai Verifikasi'))]) - ->orWhereNull('ptgs.status_verifikasi'); // Include NULL values - }) - ->selectRaw('COUNT(pt.id) AS total_data, - SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') // Menambahkan SUM dari pbg_task_retributions + COUNT(CASE WHEN (LOWER(TRIM(ptgs.status_verifikasi)) != 'selesai verifikasi' OR ptgs.status_verifikasi IS NULL) + AND (LOWER(TRIM(pbg_task.function_type)) != 'sebagai tempat usaha' OR pbg_task.function_type IS NULL) THEN 1 END) AS non_business_count, + SUM(CASE WHEN (LOWER(TRIM(ptgs.status_verifikasi)) != 'selesai verifikasi' OR ptgs.status_verifikasi IS NULL) + AND (LOWER(TRIM(pbg_task.function_type)) != 'sebagai tempat usaha' OR pbg_task.function_type IS NULL) THEN ptr.nilai_retribusi_bangunan ELSE 0 END) AS non_business_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'); + + if ($year !== 'all') { + $query->whereYear('pbg_task.task_created_at', (int) $year); + } + + return $query->first(); }); - $non_verified_count = $query_non_verified->total_data ?? 0; - $non_verified_total = $query_non_verified->total_retribution ?? 0; - - $query_potention = once( function () { - return DB::table('pbg_task as pt') - ->leftJoin('pbg_task_retributions as ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') - ->select( - DB::raw('COUNT(DISTINCT pt.id) as task_count'), - DB::raw('SUM(ptr.nilai_retribusi_bangunan) as total_retribution') - ) - ->first(); - }); $potention_count = $query_potention->task_count ?? 0; $potention_total = $query_potention->total_retribution ?? 0; + $query_spatial_plannings = once(function () use ($year) { + $query = PbgTask::join('spatial_plannings as sp', 'pbg_task.document_number', '=', 'sp.number') + ->join('pbg_task_retributions as ptr', 'ptr.pbg_task_uid', '=', 'pbg_task.uuid') + ->selectRaw('COUNT(DISTINCT pbg_task.id) as task_count, SUM(ptr.nilai_retribusi_bangunan) as total_retribution'); + + if ($year !== 'all') { + $query->whereYear('pbg_task.task_created_at', (int) $year); + } + + return $query->first(); + }); + + $spatial_planning_count = $query_spatial_plannings->task_count ?? 0; + $spatial_planning_total = $query_spatial_plannings->total_retribution ?? 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, @@ -120,6 +113,7 @@ class BigdataResume extends Model 'business_sum' => $business_total ?? 0.00, 'non_business_count' => $non_business_count ?? 0, 'non_business_sum' => $non_business_total ?? 0.00, + 'year' => $year ]); } } diff --git a/app/Models/PbgTask.php b/app/Models/PbgTask.php index b9a265c..b46a802 100644 --- a/app/Models/PbgTask.php +++ b/app/Models/PbgTask.php @@ -37,4 +37,8 @@ class PbgTask extends Model public function pbg_task_index_integrations(){ return $this->hasOne(PbgTaskIndexIntegrations::class, 'pbg_task_uid', 'uuid'); } + + public function googleSheet(){ + return $this->hasOne(PbgTaskGoogleSheet::class, 'no_registrasi', 'registration_number'); + } } diff --git a/app/Services/ServiceSIMBG.php b/app/Services/ServiceSIMBG.php index 64bc2dc..089b01d 100644 --- a/app/Services/ServiceSIMBG.php +++ b/app/Services/ServiceSIMBG.php @@ -81,13 +81,13 @@ class ServiceSIMBG if (empty($res->original['success']) || !$res->original['success']) { // Log error Log::error("API response indicates failure", ['url' => $url, 'uuid' => $uuid]); - return false; + continue; } $data = $res->original['data']['data'] ?? null; if (!$data) { Log::error("No valid data returned from API", ['url' => $url, 'uuid' => $uuid]); - return false; + continue; } $integrations[] = [ @@ -104,19 +104,6 @@ class ServiceSIMBG PbgTaskIndexIntegrations::upsert($integrations, ['pbg_task_uid'], ['indeks_fungsi_bangunan', 'indeks_parameter_kompleksitas', 'indeks_parameter_permanensi', 'indeks_parameter_ketinggian', 'faktor_kepemilikan', 'indeks_terintegrasi', 'total']); - - // $resultData = PbgTaskIndexIntegrations::updateOrCreate( - // ['pbg_task_uid' => $uuid], - // [ - // 'indeks_fungsi_bangunan' => $data['indeks_fungsi_bangunan'] ?? null, - // 'indeks_parameter_kompleksitas' => $data['indeks_parameter_kompleksitas'] ?? null, - // 'indeks_parameter_permanensi' => $data['indeks_parameter_permanensi'] ?? null, - // 'indeks_parameter_ketinggian' => $data['indeks_parameter_ketinggian'] ?? null, - // 'faktor_kepemilikan' => $data['faktor_kepemilikan'] ?? null, - // 'indeks_terintegrasi' => $data['indeks_terintegrasi'] ?? null, - // 'total' => $data['total'] ?? null, - // ] - // ); return true; }catch (Exception $e){ @@ -127,133 +114,136 @@ class ServiceSIMBG public function syncTaskList() { - $initResToken = $this->getToken(); - - $importDatasource = ImportDatasource::create([ - 'status' => ImportDatasourceStatus::Processing->value, - ]); - - if (empty($initResToken->original['data']['token']['access'])) { - $importDatasource->update([ - 'status' => ImportDatasourceStatus::Failed->value, - 'message' => 'Failed to retrieve token' + try { + $importDatasource = ImportDatasource::create([ + 'status' => ImportDatasourceStatus::Processing->value, ]); - return $this->resError("Failed to retrieve token"); - } - $apiToken = $initResToken->original['data']['token']['access']; - $headers = ['Authorization' => "Bearer " . $apiToken]; - - $url = "/api/pbg/v1/list/?page=1&size={$this->fetch_per_page}&sort=ASC"; - $initialResponse = $this->service_client->get($url, $headers); - - $totalPage = $initialResponse->original['data']['total_page'] ?? 0; - if ($totalPage == 0) { - $importDatasource->update([ - 'status' => ImportDatasourceStatus::Failed->value, - 'message' => 'Invalid response: no total_page' - ]); - return $this->resError("Invalid response from API"); - } - - $savedCount = $failedCount = 0; - - for ($currentPage = 1; $currentPage <= $totalPage; $currentPage++) { - $pageUrl = "/api/pbg/v1/list/?page={$currentPage}&size={$this->fetch_per_page}&sort=ASC"; - $getToken = $this->getToken(); - Log::info("response index integration", ['currentPage' => $currentPage]); - if (empty($getToken->original['data']['token']['access'])) { + if (empty($initResToken->original['data']['token']['access'])) { $importDatasource->update([ 'status' => ImportDatasourceStatus::Failed->value, 'message' => 'Failed to retrieve token' ]); - break; + return $this->resError("Failed to retrieve token"); } - $token = $getToken->original['data']['token']['access']; - $headers = ['Authorization' => "Bearer " . $token]; - $response = $this->service_client->get($pageUrl, $headers); - $tasks = $response->original['data']['data'] ?? []; - if (empty($tasks)) { + $initResToken = $this->getToken(); + $apiToken = $initResToken->original['data']['token']['access']; + $headers = ['Authorization' => "Bearer " . $apiToken]; + + $url = "/api/pbg/v1/list/?page=1&size={$this->fetch_per_page}&sort=ASC"; + $initialResponse = $this->service_client->get($url, $headers); + + $totalPage = $initialResponse->original['data']['total_page'] ?? 0; + if ($totalPage == 0) { $importDatasource->update([ 'status' => ImportDatasourceStatus::Failed->value, - 'message' => 'No data found on page' + 'message' => 'Invalid response: no total_page' ]); - Log::warning("No data found on page", ['page' => $currentPage]); - break; + return $this->resError("Invalid response from API"); } - Log::info("executed page", ['page' => $currentPage, 'total' => $totalPage]); + $savedCount = $failedCount = 0; - $tasksCollective = []; - foreach ($tasks as $item) { + for ($currentPage = 1; $currentPage <= $totalPage; $currentPage++) { try { - $tasksCollective[] = [ - 'uuid' => $item['uid'], - 'name' => $item['name'], - 'owner_name' => $item['owner_name'], - 'application_type' => $item['application_type'], - 'application_type_name' => $item['application_type_name'], - 'condition' => $item['condition'], - 'registration_number' => $item['registration_number'], - 'document_number' => $item['document_number'], - 'address' => $item['address'], - 'status' => $item['status'], - 'status_name' => $item['status_name'], - 'slf_status' => $item['slf_status'] ?? null, - 'slf_status_name' => $item['slf_status_name'] ?? null, - 'function_type' => $item['function_type'], - 'consultation_type' => $item['consultation_type'], - 'due_date' => $item['due_date'], - 'land_certificate_phase' => $item['land_certificate_phase'], - 'task_created_at' => isset($item['created_at']) ? Carbon::parse($item['created_at'])->format('Y-m-d H:i:s') : null, - 'updated_at' => now(), - 'created_at' => now(), - ]; + $pageUrl = "/api/pbg/v1/list/?page={$currentPage}&size={$this->fetch_per_page}&sort=ASC"; - // $this->syncIndexIntegration($item['uid'], $token); + Log::info("Fetching tasks", ['currentPage' => $currentPage]); - $this->syncTaskDetailSubmit($item['uid'], $token); - - $savedCount++; + $response = $this->service_client->get($pageUrl, $headers); + $tasks = $response->original['data']['data'] ?? []; + + if (empty($tasks)) { + Log::warning("No data found on page", ['page' => $currentPage]); + continue; + } + + $tasksCollective = []; + foreach ($tasks as $item) { + try { + $tasksCollective[] = [ + 'uuid' => $item['uid'], + 'name' => $item['name'], + 'owner_name' => $item['owner_name'], + 'application_type' => $item['application_type'], + 'application_type_name' => $item['application_type_name'], + 'condition' => $item['condition'], + 'registration_number' => $item['registration_number'], + 'document_number' => $item['document_number'], + 'address' => $item['address'], + 'status' => $item['status'], + 'status_name' => $item['status_name'], + 'slf_status' => $item['slf_status'] ?? null, + 'slf_status_name' => $item['slf_status_name'] ?? null, + 'function_type' => $item['function_type'], + 'consultation_type' => $item['consultation_type'], + 'due_date' => $item['due_date'], + 'land_certificate_phase' => $item['land_certificate_phase'], + 'task_created_at' => isset($item['created_at']) ? Carbon::parse($item['created_at'])->format('Y-m-d H:i:s') : null, + 'updated_at' => now(), + 'created_at' => now(), + ]; + + $this->syncTaskDetailSubmit($item['uid'], $apiToken); + $savedCount++; + } catch (Exception $e) { + $failedCount++; + Log::error("Failed to process task", [ + 'error' => $e->getMessage(), + 'task' => $item, + ]); + continue; // Skip failed task, continue processing the rest + } + } + + if (!empty($tasksCollective)) { + PbgTask::upsert($tasksCollective, ['uuid'], [ + 'name', 'owner_name', 'application_type', 'application_type_name', 'condition', + 'registration_number', 'document_number', 'address', 'status', 'status_name', + 'slf_status', 'slf_status_name', 'function_type', 'consultation_type', 'due_date', + 'land_certificate_phase', 'task_created_at', 'updated_at' + ]); + + $uuids = array_column($tasksCollective, 'uuid'); + $this->syncIndexIntegration($uuids, $apiToken); + } } catch (Exception $e) { - $failedCount++; - $importDatasource->update([ - 'status' => ImportDatasourceStatus::Failed->value, - 'message' => "Successfully processed: $savedCount, Failed: $failedCount" - ]); - Log::error("Failed to process task", [ + Log::error("Failed to process page", [ 'error' => $e->getMessage(), - 'task' => $item, + 'page' => $currentPage, ]); - break; + continue; // Skip the failed page and move to the next } } - PbgTask::upsert($tasksCollective, ['uuid'], [ - 'name', 'owner_name', 'application_type', 'application_type_name', 'condition', - 'registration_number', 'document_number', 'address', 'status', 'status_name', - 'slf_status', 'slf_status_name', 'function_type', 'consultation_type', 'due_date', - 'land_certificate_phase', 'task_created_at', 'updated_at' + BigdataResume::generateResumeData($importDatasource->id, "all"); + BigdataResume::generateResumeData($importDatasource->id, now()->year); + + // Final update after processing all pages + $importDatasource->update([ + 'status' => ImportDatasourceStatus::Success->value, + 'message' => "Successfully processed: $savedCount, Failed: $failedCount" ]); - $uuids = array_column($tasksCollective, 'uuid'); - $this->syncIndexIntegration($uuids, $token); + Log::info("syncTaskList completed", ['savedCount' => $savedCount, 'failedCount' => $failedCount]); + + return $this->resSuccess(['savedCount' => $savedCount, 'failedCount' => $failedCount]); + + } catch (Exception $e) { + Log::error("syncTaskList failed", ['error' => $e->getMessage()]); + if (isset($importDatasource)) { + $importDatasource->update([ + 'status' => ImportDatasourceStatus::Failed->value, + 'message' => 'Critical failure: ' . $e->getMessage() + ]); + } + return $this->resError("Critical failure occurred: " . $e->getMessage()); } - - $importDatasource->update([ - 'status' => ImportDatasourceStatus::Success->value, - 'message' => "Successfully processed: $savedCount, Failed: $failedCount" - ]); - - BigdataResume::generateResumeData($importDatasource->id); - - Log::info("syncTaskList completed", ['savedCount' => $savedCount, 'failedCount' => $failedCount]); - - return $this->resSuccess(['savedCount' => $savedCount, 'failedCount' => $failedCount]); } + public function syncTaskDetailSubmit($uuid, $token) { try{ diff --git a/composer.json b/composer.json index 755703d..a1bcd80 100755 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ ], "dev": [ "Composer\\Config::disableProcessTimeout", - "npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite" + "npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:work --timeout=300 --tries=3\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite" ] }, "extra": { diff --git a/config/queue.php b/config/queue.php index 116bd8d..f4f4ced 100755 --- a/config/queue.php +++ b/config/queue.php @@ -109,4 +109,10 @@ return [ 'table' => 'failed_jobs', ], + // set timeout queue + + 'worker' => [ + 'timeout' => 300 + ] + ]; diff --git a/database/migrations/2025_02_26_140440_add_spatial_in_bigdata_resumes.php b/database/migrations/2025_02_26_140440_add_spatial_in_bigdata_resumes.php new file mode 100644 index 0000000..9241cb7 --- /dev/null +++ b/database/migrations/2025_02_26_140440_add_spatial_in_bigdata_resumes.php @@ -0,0 +1,32 @@ +integer('spatial_count')->default(0); + $table->decimal('spatial_sum', 20,2)->default(0); + $table->string('year'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('bigdata_resumes', function (Blueprint $table) { + $table->dropColumn('spatial_count'); + $table->dropColumn('spatial_sum'); + $table->dropColumn('year'); + }); + } +}; diff --git a/resources/js/dashboards/bigdata.js b/resources/js/dashboards/bigdata.js index 5c90a18..e898718 100644 --- a/resources/js/dashboards/bigdata.js +++ b/resources/js/dashboards/bigdata.js @@ -23,121 +23,9 @@ class BigData { } async updateData(filterDate) { try { - console.log("Filtering data for date:", filterDate); this.resumeBigData = await this.getBigDataResume(filterDate); - // this.totalTargetPAD = await this.getDataSettings("TARGET_PAD"); - // this.resultDataTotal = await this.getDataTotalPotensi(year); - // this.dataVerification = await this.getDataVerfication(year); - // this.dataNonVerification = await this.getDataNonVerfication(year); - // this.dataBusiness = await this.getDataBusiness(year); - // this.dataNonBusiness = await this.getDataNonBusiness(year); - // this.dataTataRuang = await this.getDataSettings("TATA_RUANG"); - // this.dataSumRealisasiTerbit = await this.getDataSettings( - // "REALISASI_TERBIT_PBG_SUM" - // ); - // this.dataCountRealisasiTerbit = await this.getDataSettings( - // "REALISASI_TERBIT_PBG_COUNT" - // ); - // this.dataSumMenungguKlikDPMPTSP = await this.getDataSettings( - // "MENUNGGU_KLIK_DPMPTSP_SUM" - // ); - // this.dataCountMenungguKlikDPMPTSP = await this.getDataSettings( - // "MENUNGGU_KLIK_DPMPTSP_COUNT" - // ); - // this.dataSumProsesDinasTeknis = await this.getDataSettings( - // "PROSES_DINAS_TEKNIS_SUM" - // ); - // this.dataCountProsesDinasTeknis = await this.getDataSettings( - // "PROSES_DINAS_TEKNIS_COUNT" - // ); - // // total potensi - // this.bigTargetPAD = new Big(this.totalTargetPAD ?? 0); - // this.bigTotalPotensi = new Big(this.resultDataTotal.totalData ?? 0); - - // this.resultPercentage = 0; - // if (this.bigTotalPotensi > 0 && this.bigTargetPAD > 0) { - // this.resultPercentage = this.bigTotalPotensi - // .div(this.bigTargetPAD) - // .times(100) - // .toFixed(2); - // if (this.resultPercentage > 100) { - // this.resultPercentage = 100; - // } - // } - - // // tata ruang - // this.bigTotalTataRuang = new Big(this.dataTataRuang); - // this.percentageResultTataRuang = - // this.bigTotalTataRuang <= 0 || this.bigTotalPotensi <= 0 - // ? 0 - // : this.bigTotalTataRuang - // .div(this.bigTotalPotensi) - // .times(100) - // .toFixed(2); - - // // kekurangan potensi - // this.totalKekuranganPotensi = new Big( - // this.bigTargetPAD - this.bigTotalPotensi - // ); - - // this.percentageKekuranganPotensi = - // this.totalKekuranganPotensi <= 0 || this.bigTargetPAD <= 0 - // ? 0 - // : this.totalKekuranganPotensi - // .div(this.bigTargetPAD) - // .times(100) - // .toFixed(2); - - // // non-verification documents - // this.bigTotalNonVerification = new Big( - // this.dataNonVerification.total - // ); - // this.percentageResultNonVerification = - // this.bigTotalNonVerification <= 0 || this.bigTotalPotensi <= 0 - // ? 0 - // : this.bigTotalNonVerification - // .div(this.bigTotalPotensi) - // .times(100) - // .toFixed(2); - - // // verification documents - // this.bigTotalVerification = new Big(this.dataVerification.total); - // this.percetageResultVerification = - // this.bigTotalVerification <= 0 || this.bigTotalPotensi <= 0 - // ? 0 - // : this.bigTotalVerification - // .div(this.bigTargetPAD) - // .times(100) - // .toFixed(2); - - // // business documents - // this.bigTotalBusiness = new Big(this.dataBusiness.total); - // this.percentageResultBusiness = - // this.bigTotalNonVerification <= 0 || this.bigTotalBusiness <= 0 - // ? 0 - // : this.bigTotalBusiness - // .div(this.bigTotalNonVerification) - // .times(100) - // .toFixed(2); - - // // non-business documents - // this.bigTotalNonBusiness = new Big(this.dataNonBusiness.total); - // this.percentageResultNonBusiness = - // this.bigTotalNonBusiness <= 0 || - // this.bigTotalNonVerification <= 0 - // ? 0 - // : this.bigTotalNonBusiness - // .div(this.bigTotalNonVerification) - // .times(100) - // .toFixed(2); - - // if (!this.bigTargetPAD) { - // console.error("Failed to load chart data"); - // return; - // } - - this.initChartTargetPAD(); + this.initChartTargetPAD(filterDate); this.initChartUsaha(); this.initChartNonUsaha(); this.initChartTotalPotensi(); @@ -180,190 +68,17 @@ class BigData { return null; } } - async getDataTotalPotensi(year) { - try { - const response = await fetch( - `${GlobalConfig.apiHost}/api/all-task-documents?year=${year}`, - { - credentials: "include", - headers: { - Authorization: `Bearer ${ - document.querySelector("meta[name='api-token']") - .content - }`, - "Content-Type": "application/json", - }, - } - ); - if (!response.ok) { - console.error("Network response was not ok", response); - } - - const data = await response.json(); - return { - countData: data.data.count, - totalData: data.data.total, - }; - } catch (error) { - console.error("Error fetching chart data:", error); - return null; - } - } - - async getDataVerfication(year) { - try { - const response = await fetch( - `${GlobalConfig.apiHost}/api/verification-documents?year=${year}`, - { - credentials: "include", - headers: { - Authorization: `Bearer ${ - document.querySelector("meta[name='api-token']") - .content - }`, - "Content-Type": "application/json", - }, - } - ); - - if (!response.ok) { - console.error("Network response was not ok", response); - } - - const data = await response.json(); - return { - count: data.data.count, - total: data.data.total, - }; - } catch (error) { - console.error("Error fetching chart data:", error); - return 0; - } - } - - async getDataNonVerfication(year) { - try { - const response = await fetch( - `${GlobalConfig.apiHost}/api/non-verification-documents?year=${year}`, - { - credentials: "include", - headers: { - Authorization: `Bearer ${ - document.querySelector("meta[name='api-token']") - .content - }`, - "Content-Type": "application/json", - }, - } - ); - - if (!response.ok) { - console.error("Network response was not ok", response); - } - - const data = await response.json(); - return { - count: data.data.count, - total: data.data.total, - }; - } catch (error) { - console.error("Error fetching chart data:", error); - return 0; - } - } - - async getDataBusiness(year) { - try { - const response = await fetch( - `${GlobalConfig.apiHost}/api/business-documents?year=${year}`, - { - credentials: "include", - headers: { - Authorization: `Bearer ${ - document.querySelector("meta[name='api-token']") - .content - }`, - "Content-Type": "application/json", - }, - } - ); - - if (!response.ok) { - console.error("Network response was not ok", response); - } - - const data = await response.json(); - return { - count: data.data.count, - total: data.data.total, - }; - } catch (error) { - console.error("Error fetching chart data:", error); - return 0; - } - } - - async getDataNonBusiness(year) { - try { - const response = await fetch( - `${GlobalConfig.apiHost}/api/non-business-documents?year=${year}`, - { - credentials: "include", - headers: { - Authorization: `Bearer ${ - document.querySelector("meta[name='api-token']") - .content - }`, - "Content-Type": "application/json", - }, - } - ); - - if (!response.ok) { - console.error("Network response was not ok", response); - } - - const data = await response.json(); - return { - count: data.data.count, - total: data.data.total, - }; - } catch (error) { - console.error("Error fetching chart data:", error); - return 0; - } - } - - async getDataSettings(string_key) { - try { - const response = await fetch( - `${GlobalConfig.apiHost}/api/api-data-settings?search=${string_key}`, - { - credentials: "include", - headers: { - Authorization: `Bearer ${ - document.querySelector("meta[name='api-token']") - .content - }`, - "Content-Type": "application/json", - }, - } - ); - - if (!response.ok) { - console.error("Network response was not ok", response); - } - - const data = await response.json(); - return data.data[0].value; - } catch (error) { - console.error("Error fetching chart data:", error); - return 0; - } - } - - initChartTargetPAD() { + initChartTargetPAD(filterDate) { + const year = + filterDate === "latest" + ? new Date().getFullYear() + : new Date(filterDate).getFullYear(); + document + .querySelectorAll(".document-title.chart-target-pad") + .forEach((element) => { + element.innerText = `Target PAD ${year}`; + }); document .querySelectorAll(".document-count.chart-target-pad") .forEach((element) => { @@ -373,7 +88,6 @@ class BigData { .querySelectorAll(".document-total.chart-target-pad") .forEach((element) => { element.innerText = `Rp.${addThousandSeparators( - // this.bigTargetPAD.toString() this.resumeBigData.target_pad.sum.toString() )}`; }); @@ -589,20 +303,18 @@ class BigData { document .querySelectorAll(".document-count.chart-potensi-tata-ruang") .forEach((element) => { - element.innerText = ""; + element.innerText = `${this.resumeBigData.tata_ruang.count}`; }); document .querySelectorAll(".document-total.chart-potensi-tata-ruang") .forEach((element) => { element.innerText = `Rp.${addThousandSeparators( - // this.bigTotalTataRuang.toString() this.resumeBigData.tata_ruang.sum.toString() )}`; }); document .querySelectorAll(".small-percentage.chart-potensi-tata-ruang") .forEach((element) => { - // element.innerText = `${this.percentageResultTataRuang}%`; element.innerText = `${this.resumeBigData.tata_ruang.percentage}%`; }); } diff --git a/resources/scss/components/_circle.scss b/resources/scss/components/_circle.scss index 246d598..7e55aab 100644 --- a/resources/scss/components/_circle.scss +++ b/resources/scss/components/_circle.scss @@ -21,8 +21,8 @@ // overflow: hidden; .circle-content { - width: 180px; /* Ukuran lingkaran dalam */ - height: 180px; + min-width: 180px; /* Ukuran lingkaran dalam */ + min-height: 180px; background-color: var(--circle-color); /* Warna lingkaran dalam */ border-radius: 50%; display: flex; @@ -57,17 +57,20 @@ padding: 0 7px; border-radius: 10px; margin: 0; + max-width: 100%; } .circle-content .document-count { font-size: 24px; font-weight: bold; margin: 0; + max-width: 100%; } .circle-content .document-type { font-size: 14px; margin: 0; + max-width: 100%; } .small-circle-container { diff --git a/resources/views/dashboards/bigdata.blade.php b/resources/views/dashboards/bigdata.blade.php index ada0f84..d0c04fe 100644 --- a/resources/views/dashboards/bigdata.blade.php +++ b/resources/views/dashboards/bigdata.blade.php @@ -9,7 +9,7 @@ @include('layouts.partials/page-title', ['title' => 'Dashboards', 'subtitle' => 'Dashboard Pimpinan'])
-
+ +
+
+

+ ANALISA BIG DATA PROSES PBG
+ MELALUI APLIKASI SIBEDAS PBG +

+
+ Terakhir di update - {{$latest_created}} + +
+
@component('components.circle', [ @@ -37,7 +49,7 @@ @endcomponent @component('components.circle', [ - 'document_title' => 'Target PAD 2024', + 'document_title' => 'Target PAD', 'document_color' => '#204f6b', 'document_type' => '', 'document_id' => 'chart-target-pad', diff --git a/resources/views/dashboards/lack_of_potential.blade.php b/resources/views/dashboards/lack_of_potential.blade.php index fd274d8..0be6921 100644 --- a/resources/views/dashboards/lack_of_potential.blade.php +++ b/resources/views/dashboards/lack_of_potential.blade.php @@ -9,20 +9,16 @@
-
-

+
+

ANALISA BIG DATA MELALUI APLIKASI SIBEDAS PBG -

+

+
+ +
-
-
-
- -
-
-