Compare commits
3 Commits
fix/handle
...
feat/sync-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
154b7f40df | ||
|
|
59e9431b2d | ||
|
|
074edc607d |
@@ -6,6 +6,7 @@ use App\Enums\ImportDatasourceStatus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\PbgTaskMultiStepRequest;
|
||||
use App\Http\Resources\PbgTaskResource;
|
||||
use App\Models\DataSetting;
|
||||
use App\Models\ImportDatasource;
|
||||
use App\Models\PbgTask;
|
||||
use App\Models\PbgTaskGoogleSheet;
|
||||
@@ -109,17 +110,54 @@ class PbgTaskController extends Controller
|
||||
}
|
||||
|
||||
public function syncPbgFromGoogleSheet(){
|
||||
try{
|
||||
$totalRowCount = $this->googleSheetService->getLastRowByColumn("C");
|
||||
$sheetData = $this->googleSheetService->getSheetDataCollection($totalRowCount);
|
||||
$mapToUpsert = [];
|
||||
$count = 0;
|
||||
|
||||
$import_datasource = ImportDatasource::create([
|
||||
"message" => "initialization",
|
||||
"response_body" => null,
|
||||
"status" => ImportDatasourceStatus::Processing->value,
|
||||
]);
|
||||
try{
|
||||
$totalRowCount = $this->googleSheetService->getLastRowByColumn("C");
|
||||
$sheetData = $this->googleSheetService->getSheetDataCollection($totalRowCount);
|
||||
$sheet_big_data = $this->googleSheetService->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"] = $row[2] ?? null;
|
||||
$data_setting_result["MENUNGGU_KLIK_DPMPTSP_SUM"] = $row[3] ?? null;
|
||||
} elseif ($found_section === "REALISASI_TERBIT_PBG") {
|
||||
$data_setting_result["REALISASI_TERBIT_PBG_COUNT"] = $row[2] ?? null;
|
||||
$data_setting_result["REALISASI_TERBIT_PBG_SUM"] = $row[4] ?? null;
|
||||
} elseif ($found_section === "PROSES_DINAS_TEKNIS") {
|
||||
$data_setting_result["PROSES_DINAS_TEKNIS_COUNT"] = $row[2] ?? null;
|
||||
$data_setting_result["PROSES_DINAS_TEKNIS_SUM"] = $row[3] ?? null;
|
||||
}
|
||||
|
||||
// Reset section tracking after capturing "Grand Total"
|
||||
$found_section = null;
|
||||
}
|
||||
}
|
||||
foreach ($data_setting_result as $key => $value) {
|
||||
DataSetting::updateOrInsert(
|
||||
["key" => $key], // Find by key
|
||||
["value" => $value] // Update or insert value
|
||||
);
|
||||
}
|
||||
$mapToUpsert = [];
|
||||
$count = 0;
|
||||
|
||||
foreach($sheetData as $data){
|
||||
$mapToUpsert[] =
|
||||
|
||||
@@ -140,4 +140,13 @@ class GoogleSheetService
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
public function get_data_by_sheet($no_sheet = 1){
|
||||
$spreadsheet = $this->service->spreadsheets->get($this->spreadsheetID);
|
||||
$sheets = $spreadsheet->getSheets();
|
||||
$sheetTitle = $sheets[$no_sheet]->getProperties()->getTitle();
|
||||
$range = "{$sheetTitle}";
|
||||
$response = $this->service->spreadsheets_values->get($this->spreadsheetID, $range);
|
||||
$values = $response->getValues();
|
||||
return!empty($values)? $values : [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,15 @@ class ServiceSIMBG
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->email = trim((string) GlobalSetting::where('key','SIMBG_EMAIL')->firstOrFail()->value);
|
||||
$this->password = trim((string) GlobalSetting::where('key','SIMBG_PASSWORD')->firstOrFail()->value);
|
||||
$this->simbg_host = trim((string)GlobalSetting::where('key','SIMBG_HOST')->firstOrFail()->value);
|
||||
$this->fetch_per_page = trim((string)GlobalSetting::where('key','FETCH_PER_PAGE')->firstOrFail()->value);
|
||||
$settings = GlobalSetting::whereIn('key', [
|
||||
'SIMBG_EMAIL', 'SIMBG_PASSWORD', 'SIMBG_HOST', 'FETCH_PER_PAGE'
|
||||
])->pluck('value', 'key');
|
||||
|
||||
$this->email = trim((string) ($settings['SIMBG_EMAIL'] ?? ""));
|
||||
$this->password = trim((string) ($settings['SIMBG_PASSWORD'] ?? ""));
|
||||
$this->simbg_host = trim((string) ($settings['SIMBG_HOST'] ?? ""));
|
||||
$this->fetch_per_page = trim((string) ($settings['FETCH_PER_PAGE'] ?? ""));
|
||||
|
||||
$this->service_client = new ServiceClient($this->simbg_host);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,37 @@ class DataSettingSeeder extends Seeder
|
||||
"key" => "TATA_RUANG",
|
||||
"value" => "10000000000",
|
||||
"type" => "integer"
|
||||
]
|
||||
],
|
||||
[
|
||||
"key" => "REALISASI_TERBIT_PBG_SUM",
|
||||
"value" => "1507253788",
|
||||
"type" => "integer"
|
||||
],
|
||||
[
|
||||
"key" => "REALISASI_TERBIT_PBG_COUNT",
|
||||
"value" => "88",
|
||||
"type" => "integer"
|
||||
],
|
||||
[
|
||||
"key" => "MENUNGGU_KLIK_DPMPTSP_SUM",
|
||||
"value" => "83457536",
|
||||
"type" => "integer"
|
||||
],
|
||||
[
|
||||
"key" => "MENUNGGU_KLIK_DPMPTSP_COUNT",
|
||||
"value" => "266",
|
||||
"type" => "integer"
|
||||
],
|
||||
[
|
||||
"key" => "PROSES_DINAS_TEKNIS_SUM",
|
||||
"value" => "83457536",
|
||||
"type" => "integer"
|
||||
],
|
||||
[
|
||||
"key" => "PROSES_DINAS_TEKNIS_COUNT",
|
||||
"value" => "11",
|
||||
"type" => "integer"
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($data_settings as $setting) {
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
"isEntry": true
|
||||
},
|
||||
"resources/js/dashboards/bigdata.js": {
|
||||
"file": "assets/bigdata-DYDUaCEC.js",
|
||||
"file": "assets/bigdata-Cyb9tZIY.js",
|
||||
"name": "bigdata",
|
||||
"src": "resources/js/dashboards/bigdata.js",
|
||||
"isEntry": true,
|
||||
@@ -391,7 +391,7 @@
|
||||
"isEntry": true
|
||||
},
|
||||
"resources/scss/dashboards/_bigdata.scss": {
|
||||
"file": "assets/_bigdata-0hCjAhYp.css",
|
||||
"file": "assets/_bigdata-Syu0AGbZ.css",
|
||||
"src": "resources/scss/dashboards/_bigdata.scss",
|
||||
"isEntry": true
|
||||
},
|
||||
@@ -401,7 +401,7 @@
|
||||
"isEntry": true
|
||||
},
|
||||
"resources/scss/style.scss": {
|
||||
"file": "assets/style-DUYVmgAM.css",
|
||||
"file": "assets/style-H92i7DXd.css",
|
||||
"src": "resources/scss/style.scss",
|
||||
"isEntry": true
|
||||
}
|
||||
|
||||
@@ -49,13 +49,31 @@ class BigData {
|
||||
}
|
||||
async updateData(year) {
|
||||
try {
|
||||
this.totalTargetPAD = await this.getTargetPAD(year);
|
||||
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.getDataTataRuang(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);
|
||||
@@ -190,38 +208,6 @@ class BigData {
|
||||
}
|
||||
}
|
||||
|
||||
async getTargetPAD(year) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${GlobalConfig.apiHost}/api/api-data-settings?search=target_pad`,
|
||||
{
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const valueTargetPAD = data.data[0]?.value ?? 0;
|
||||
const currentMonth = new Date().getMonth() + 1;
|
||||
let result = (currentMonth / 12) * valueTargetPAD;
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error("Error fetching chart data:", error);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async getDataVerfication(year) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
@@ -346,10 +332,10 @@ class BigData {
|
||||
}
|
||||
}
|
||||
|
||||
async getDataTataRuang() {
|
||||
async getDataSettings(string_key) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${GlobalConfig.apiHost}/api/api-data-settings?search=tata_ruang`,
|
||||
`${GlobalConfig.apiHost}/api/api-data-settings?search=${string_key}`,
|
||||
{
|
||||
credentials: "include",
|
||||
headers: {
|
||||
@@ -519,12 +505,14 @@ class BigData {
|
||||
document
|
||||
.querySelectorAll(".document-count.chart-realisasi-tebit-pbg")
|
||||
.forEach((element) => {
|
||||
element.innerText = `0`;
|
||||
element.innerText = `${this.dataCountRealisasiTerbit}`;
|
||||
});
|
||||
document
|
||||
.querySelectorAll(".document-total.chart-realisasi-tebit-pbg")
|
||||
.forEach((element) => {
|
||||
element.innerText = `Rp.${addThousandSeparators("0.00")}`;
|
||||
element.innerText = `Rp.${addThousandSeparators(
|
||||
this.dataSumRealisasiTerbit
|
||||
)}`;
|
||||
});
|
||||
document
|
||||
.querySelectorAll(".small-percentage.chart-realisasi-tebit-pbg")
|
||||
@@ -536,12 +524,14 @@ class BigData {
|
||||
document
|
||||
.querySelectorAll(".document-count.chart-menunggu-klik-dpmptsp")
|
||||
.forEach((element) => {
|
||||
element.innerText = `${0}`;
|
||||
element.innerText = `${this.dataCountMenungguKlikDPMPTSP}`;
|
||||
});
|
||||
document
|
||||
.querySelectorAll(".document-total.chart-menunggu-klik-dpmptsp")
|
||||
.forEach((element) => {
|
||||
element.innerText = `Rp.${addThousandSeparators("0.00")}`;
|
||||
element.innerText = `Rp.${addThousandSeparators(
|
||||
this.dataSumMenungguKlikDPMPTSP
|
||||
)}`;
|
||||
});
|
||||
document
|
||||
.querySelectorAll(".small-percentage.chart-menunggu-klik-dpmptsp")
|
||||
@@ -553,12 +543,14 @@ class BigData {
|
||||
document
|
||||
.querySelectorAll(".document-count.chart-proses-dinas-teknis")
|
||||
.forEach((element) => {
|
||||
element.innerText = `${0}`;
|
||||
element.innerText = `${this.dataCountProsesDinasTeknis}`;
|
||||
});
|
||||
document
|
||||
.querySelectorAll(".document-total.chart-proses-dinas-teknis")
|
||||
.forEach((element) => {
|
||||
element.innerText = `Rp.${addThousandSeparators("0.00")}`;
|
||||
element.innerText = `Rp.${addThousandSeparators(
|
||||
this.dataSumProsesDinasTeknis
|
||||
)}`;
|
||||
});
|
||||
document
|
||||
.querySelectorAll(".small-percentage.chart-proses-dinas-teknis")
|
||||
|
||||
@@ -41,9 +41,10 @@
|
||||
}
|
||||
|
||||
#dashboard-fixed-wrapper {
|
||||
background-image: url("../../../public/images/bg-dashboard.jpg");
|
||||
background-image: url("/public/images/bg-dashboard.jpg");
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
max-width: 100vw; /* Ensures it doesn't exceed viewport */
|
||||
}
|
||||
|
||||
#dashboard-fixed-wrapper::before {
|
||||
@@ -62,10 +63,6 @@
|
||||
); /* Black overlay with 50% opacity */
|
||||
}
|
||||
|
||||
#dashboard-fixed-wrapper {
|
||||
max-width: 100vw; /* Ensures it doesn't exceed viewport */
|
||||
}
|
||||
|
||||
#dashboard-fixed-container {
|
||||
min-width: 1110px;
|
||||
max-width: unset; /* Allow it to grow if needed */
|
||||
|
||||
Reference in New Issue
Block a user