fix add bigdata resume after syncronize
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Jobs;
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Models\BigdataResume;
|
||||||
use App\Models\ImportDatasource;
|
use App\Models\ImportDatasource;
|
||||||
use App\Services\ServiceGoogleSheet;
|
use App\Services\ServiceGoogleSheet;
|
||||||
use App\Services\ServicePbgTask;
|
use App\Services\ServicePbgTask;
|
||||||
@@ -51,6 +52,11 @@ class ScrapingDataJob implements ShouldQueue
|
|||||||
$service_pbg_task->run_service();
|
$service_pbg_task->run_service();
|
||||||
$service_tab_pbg_task->run_service();
|
$service_tab_pbg_task->run_service();
|
||||||
|
|
||||||
|
$data_setting_result = $service_google_sheet->get_big_resume_data();
|
||||||
|
|
||||||
|
BigdataResume::generateResumeData($import_datasource->id, "all", $data_setting_result);
|
||||||
|
BigdataResume::generateResumeData($import_datasource->id, now()->year, $data_setting_result);
|
||||||
|
|
||||||
// Update status to success
|
// Update status to success
|
||||||
$import_datasource->update([
|
$import_datasource->update([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class ServiceGoogleSheet
|
|||||||
|
|
||||||
if (empty($sheet_data) || count($sheet_data) < 2) {
|
if (empty($sheet_data) || count($sheet_data) < 2) {
|
||||||
Log::warning("sync_google_sheet_data: No valid data found.");
|
Log::warning("sync_google_sheet_data: No valid data found.");
|
||||||
throw new \Exception("sync_google_sheet_data: No valid data found.");
|
throw new Exception("sync_google_sheet_data: No valid data found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$cleanValue = function ($value) {
|
$cleanValue = function ($value) {
|
||||||
@@ -210,6 +210,47 @@ class ServiceGoogleSheet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_big_resume_data(){
|
||||||
|
try {
|
||||||
|
$sheet_big_data = $this->get_data_by_sheet();
|
||||||
|
$data_setting_result = []; // Initialize result storage
|
||||||
|
|
||||||
|
$found_section = null; // Track which section is found
|
||||||
|
|
||||||
|
foreach ($sheet_big_data as $row) {
|
||||||
|
// Check for section headers
|
||||||
|
if (in_array("•PROSES PENERBITAN:", $row)) {
|
||||||
|
$found_section = "MENUNGGU_KLIK_DPMPTSP";
|
||||||
|
} elseif (in_array("•BERKAS AKTUAL TERVERIFIKASI DINAS TEKNIS 2024:", $row)) {
|
||||||
|
$found_section = "REALISASI_TERBIT_PBG";
|
||||||
|
} elseif (in_array("•TERPROSES DI DPUTR: belum selesai rekomtek'", $row)) {
|
||||||
|
$found_section = "PROSES_DINAS_TEKNIS";
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a section is found and we reach "Grand Total", save the corresponding values
|
||||||
|
if ($found_section && isset($row[0]) && trim($row[0]) === "Grand Total") {
|
||||||
|
if ($found_section === "MENUNGGU_KLIK_DPMPTSP") {
|
||||||
|
$data_setting_result["MENUNGGU_KLIK_DPMPTSP_COUNT"] = $this->convertToInteger($row[2]) ?? null;
|
||||||
|
$data_setting_result["MENUNGGU_KLIK_DPMPTSP_SUM"] = $this->convertToDecimal($row[3]) ?? null;
|
||||||
|
} elseif ($found_section === "REALISASI_TERBIT_PBG") {
|
||||||
|
$data_setting_result["REALISASI_TERBIT_PBG_COUNT"] = $this->convertToInteger($row[2]) ?? null;
|
||||||
|
$data_setting_result["REALISASI_TERBIT_PBG_SUM"] = $this->convertToDecimal($row[4]) ?? null;
|
||||||
|
} elseif ($found_section === "PROSES_DINAS_TEKNIS") {
|
||||||
|
$data_setting_result["PROSES_DINAS_TEKNIS_COUNT"] = $this->convertToInteger($row[2]) ?? null;
|
||||||
|
$data_setting_result["PROSES_DINAS_TEKNIS_SUM"] = $this->convertToDecimal($row[3]) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset section tracking after capturing "Grand Total"
|
||||||
|
$found_section = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data_setting_result;
|
||||||
|
}catch(Exception $exception){
|
||||||
|
Log::error("Error getting big resume data", ['error' => $exception->getMessage()]);
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function get_data_by_sheet($no_sheet = 1){
|
private function get_data_by_sheet($no_sheet = 1){
|
||||||
$spreadsheet = $this->service->spreadsheets->get($this->spreadsheetID);
|
$spreadsheet = $this->service->spreadsheets->get($this->spreadsheetID);
|
||||||
$sheets = $spreadsheet->getSheets();
|
$sheets = $spreadsheet->getSheets();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class ServiceTabPbgTask
|
|||||||
public function run_service()
|
public function run_service()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$pbg_tasks = PbgTask::all();
|
$pbg_tasks = PbgTask::take(5)->get();
|
||||||
|
|
||||||
foreach ($pbg_tasks as $pbg_task) {
|
foreach ($pbg_tasks as $pbg_task) {
|
||||||
$this->scraping_task_assignments($pbg_task->uuid);
|
$this->scraping_task_assignments($pbg_task->uuid);
|
||||||
|
|||||||
Reference in New Issue
Block a user