refactor(webstatement): Migrasi ke StagingController dan ubah storage disk ke local 'staging'
Perubahan yang dilakukan: - Hapus file `MigrasiController.php` yang tidak lagi digunakan - Ganti referensi controller dari `MigrasiController` menjadi `StagingController` di `ProcessDailyMigration.php` - Update semua Job class untuk menggunakan disk `staging` menggantikan `sftpStatement` - Ganti konstanta `DISK_NAME` di class berikut: * `ProcessAccountDataJob` * `ProcessArrangementDataJob` * `ProcessAtmTransactionJob` * `ProcessBillDetailDataJob` * `ProcessCategoryDataJob` * `ProcessCompanyDataJob` * `ProcessCustomerDataJob` * `ProcessDataCaptureDataJob` * `ProcessFtTxnTypeConditionJob` * `ProcessFundsTransferDataJob` * `ProcessProvinceDataJob` - Komentari sementara `array_pop()` di `ProcessDataCaptureDataJob` untuk debugging - Rapikan whitespace dan formatting di `GenerateClosingBalanceReportCommand` - Sesuaikan konfigurasi storage agar menggunakan local filesystem (`disk: staging`) - Konsolidasikan penamaan dan penggunaan disk untuk environment `staging` - Hilangkan ketergantungan terhadap koneksi SFTP dalam proses development/staging Manfaat: - Mempercepat proses development dan debugging dengan akses file lokal - Menyederhanakan konfigurasi untuk staging environment - Meningkatkan konsistensi dan maintainability kode - Mengurangi potensi error akibat koneksi eksternal (SFTP)
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Modules\Webstatement\Console;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Modules\Webstatement\Http\Controllers\MigrasiController;
|
use Modules\Webstatement\Http\Controllers\StagingController;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class ProcessDailyMigration extends Command
|
class ProcessDailyMigration extends Command
|
||||||
@@ -46,7 +46,7 @@ class ProcessDailyMigration extends Command
|
|||||||
$this->info('Period: ' . ($period ?? '-1 day (default)'));
|
$this->info('Period: ' . ($period ?? '-1 day (default)'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$controller = app(MigrasiController::class);
|
$controller = app(StagingController::class);
|
||||||
$response = $controller->index($processParameter, $period);
|
$response = $controller->index($processParameter, $period);
|
||||||
|
|
||||||
$responseData = json_decode($response->getContent(), true);
|
$responseData = json_decode($response->getContent(), true);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
ProcessProvinceDataJob,
|
ProcessProvinceDataJob,
|
||||||
ProcessStmtEntryDetailDataJob};
|
ProcessStmtEntryDetailDataJob};
|
||||||
|
|
||||||
class MigrasiController extends Controller
|
class StagingController extends Controller
|
||||||
{
|
{
|
||||||
private const PROCESS_TYPES = [
|
private const PROCESS_TYPES = [
|
||||||
'transaction' => ProcessTransactionDataJob::class,
|
'transaction' => ProcessTransactionDataJob::class,
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
'period' => $period
|
'period' => $period
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$disk = Storage::disk('sftpStatement');
|
$disk = Storage::disk('staging');
|
||||||
|
|
||||||
if ($processParameter) {
|
if ($processParameter) {
|
||||||
Log::info('Processing parameter data');
|
Log::info('Processing parameter data');
|
||||||
@@ -20,7 +20,7 @@ class ProcessAccountDataJob implements ShouldQueue
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.ACCOUNT.csv';
|
private const FILENAME = 'ST.ACCOUNT.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.AA.ARRANGEMENT.csv';
|
private const FILENAME = 'ST.AA.ARRANGEMENT.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.ATM.TRANSACTION.csv';
|
private const FILENAME = 'ST.ATM.TRANSACTION.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
||||||
private const HEADER_MAP = [
|
private const HEADER_MAP = [
|
||||||
'id' => 'transaction_id',
|
'id' => 'transaction_id',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.AA.BILL.DETAILS.csv';
|
private const FILENAME = 'ST.AA.BILL.DETAILS.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.CATEGORY.csv';
|
private const FILENAME = 'ST.CATEGORY.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const HEADER_MAP = [
|
private const HEADER_MAP = [
|
||||||
'id' => 'id_category',
|
'id' => 'id_category',
|
||||||
'date_time' => 'date_time',
|
'date_time' => 'date_time',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.COMPANY.csv';
|
private const FILENAME = 'ST.COMPANY.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const FIELD_MAP = [
|
private const FIELD_MAP = [
|
||||||
'id' => null, // Not mapped to model
|
'id' => null, // Not mapped to model
|
||||||
'date_time' => null, // Not mapped to model
|
'date_time' => null, // Not mapped to model
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.CUSTOMER.csv';
|
private const FILENAME = 'ST.CUSTOMER.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.DATA.CAPTURE.csv';
|
private const FILENAME = 'ST.DATA.CAPTURE.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
||||||
private const CSV_HEADERS = [
|
private const CSV_HEADERS = [
|
||||||
'id',
|
'id',
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
{
|
{
|
||||||
// Exclude the last field from CSV
|
// Exclude the last field from CSV
|
||||||
if (count($row) > 0) {
|
if (count($row) > 0) {
|
||||||
array_pop($row);
|
//array_pop($row);
|
||||||
Log::info("Excluded last field from row $rowCount. New column count: " . count($row));
|
Log::info("Excluded last field from row $rowCount. New column count: " . count($row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
];
|
];
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.FT.TXN.TYPE.CONDITION.csv';
|
private const FILENAME = 'ST.FT.TXN.TYPE.CONDITION.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
private int $processedCount = 0;
|
private int $processedCount = 0;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.FUNDS.TRANSFER.csv';
|
private const FILENAME = 'ST.FUNDS.TRANSFER.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
private int $processedCount = 0;
|
private int $processedCount = 0;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.PROVINCE.csv';
|
private const FILENAME = 'ST.PROVINCE.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
private int $processedCount = 0;
|
private int $processedCount = 0;
|
||||||
@@ -29,7 +29,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Membuat instance job baru untuk memproses data provinsi
|
* Membuat instance job baru untuk memproses data provinsi
|
||||||
*
|
*
|
||||||
* @param string $period Periode data yang akan diproses
|
* @param string $period Periode data yang akan diproses
|
||||||
*/
|
*/
|
||||||
public function __construct(string $period = '')
|
public function __construct(string $period = '')
|
||||||
@@ -41,17 +41,17 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* Menjalankan job untuk memproses file ST.PROVINCE.csv
|
* Menjalankan job untuk memproses file ST.PROVINCE.csv
|
||||||
* Menggunakan transaction untuk memastikan konsistensi data
|
* Menggunakan transaction untuk memastikan konsistensi data
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Log::info('ProcessProvinceDataJob: Memulai pemrosesan data provinsi');
|
Log::info('ProcessProvinceDataJob: Memulai pemrosesan data provinsi');
|
||||||
|
|
||||||
$this->initializeJob();
|
$this->initializeJob();
|
||||||
|
|
||||||
if ($this->period === '') {
|
if ($this->period === '') {
|
||||||
@@ -62,10 +62,10 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
|
|
||||||
$this->processPeriod();
|
$this->processPeriod();
|
||||||
$this->logJobCompletion();
|
$this->logJobCompletion();
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
Log::info('ProcessProvinceDataJob: Transaction berhasil di-commit');
|
Log::info('ProcessProvinceDataJob: Transaction berhasil di-commit');
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
DB::rollback();
|
DB::rollback();
|
||||||
Log::error('ProcessProvinceDataJob: Error dalam pemrosesan, transaction di-rollback: ' . $e->getMessage());
|
Log::error('ProcessProvinceDataJob: Error dalam pemrosesan, transaction di-rollback: ' . $e->getMessage());
|
||||||
@@ -76,7 +76,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* Inisialisasi pengaturan job
|
* Inisialisasi pengaturan job
|
||||||
* Mengatur timeout dan reset counter
|
* Mengatur timeout dan reset counter
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function initializeJob(): void
|
private function initializeJob(): void
|
||||||
@@ -85,14 +85,14 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
$this->processedCount = 0;
|
$this->processedCount = 0;
|
||||||
$this->errorCount = 0;
|
$this->errorCount = 0;
|
||||||
$this->skippedCount = 0;
|
$this->skippedCount = 0;
|
||||||
|
|
||||||
Log::info('ProcessProvinceDataJob: Job diinisialisasi dengan timeout ' . self::MAX_EXECUTION_TIME . ' detik');
|
Log::info('ProcessProvinceDataJob: Job diinisialisasi dengan timeout ' . self::MAX_EXECUTION_TIME . ' detik');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Memproses file untuk periode tertentu
|
* Memproses file untuk periode tertentu
|
||||||
* Mengambil file dari SFTP dan memproses data
|
* Mengambil file dari SFTP dan memproses data
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function processPeriod(): void
|
private function processPeriod(): void
|
||||||
@@ -101,7 +101,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
$filePath = "$this->period/" . self::FILENAME;
|
$filePath = "$this->period/" . self::FILENAME;
|
||||||
|
|
||||||
Log::info('ProcessProvinceDataJob: Memproses periode ' . $this->period);
|
Log::info('ProcessProvinceDataJob: Memproses periode ' . $this->period);
|
||||||
|
|
||||||
if (!$this->validateFile($disk, $filePath)) {
|
if (!$this->validateFile($disk, $filePath)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validasi keberadaan file di storage
|
* Validasi keberadaan file di storage
|
||||||
*
|
*
|
||||||
* @param mixed $disk Storage disk instance
|
* @param mixed $disk Storage disk instance
|
||||||
* @param string $filePath Path file yang akan divalidasi
|
* @param string $filePath Path file yang akan divalidasi
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -133,7 +133,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Membuat file temporary untuk pemrosesan
|
* Membuat file temporary untuk pemrosesan
|
||||||
*
|
*
|
||||||
* @param mixed $disk Storage disk instance
|
* @param mixed $disk Storage disk instance
|
||||||
* @param string $filePath Path file sumber
|
* @param string $filePath Path file sumber
|
||||||
* @return string Path file temporary
|
* @return string Path file temporary
|
||||||
@@ -142,7 +142,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
{
|
{
|
||||||
$tempFilePath = storage_path("app/temp_" . self::FILENAME);
|
$tempFilePath = storage_path("app/temp_" . self::FILENAME);
|
||||||
file_put_contents($tempFilePath, $disk->get($filePath));
|
file_put_contents($tempFilePath, $disk->get($filePath));
|
||||||
|
|
||||||
Log::info("ProcessProvinceDataJob: File temporary dibuat: $tempFilePath");
|
Log::info("ProcessProvinceDataJob: File temporary dibuat: $tempFilePath");
|
||||||
return $tempFilePath;
|
return $tempFilePath;
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* Memproses file CSV dan mengimpor data ke database
|
* Memproses file CSV dan mengimpor data ke database
|
||||||
* Format CSV: id~date_time~province~province_name
|
* Format CSV: id~date_time~province~province_name
|
||||||
*
|
*
|
||||||
* @param string $tempFilePath Path file temporary
|
* @param string $tempFilePath Path file temporary
|
||||||
* @param string $filePath Path file asli untuk logging
|
* @param string $filePath Path file asli untuk logging
|
||||||
* @return void
|
* @return void
|
||||||
@@ -164,20 +164,20 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log::info("ProcessProvinceDataJob: Memulai pemrosesan file: $filePath");
|
Log::info("ProcessProvinceDataJob: Memulai pemrosesan file: $filePath");
|
||||||
|
|
||||||
$rowCount = 0;
|
$rowCount = 0;
|
||||||
$isFirstRow = true;
|
$isFirstRow = true;
|
||||||
|
|
||||||
while (($row = fgetcsv($handle, 0, self::CSV_DELIMITER)) !== false) {
|
while (($row = fgetcsv($handle, 0, self::CSV_DELIMITER)) !== false) {
|
||||||
$rowCount++;
|
$rowCount++;
|
||||||
|
|
||||||
// Skip header row
|
// Skip header row
|
||||||
if ($isFirstRow) {
|
if ($isFirstRow) {
|
||||||
$isFirstRow = false;
|
$isFirstRow = false;
|
||||||
Log::info("ProcessProvinceDataJob: Melewati header row: " . implode(self::CSV_DELIMITER, $row));
|
Log::info("ProcessProvinceDataJob: Melewati header row: " . implode(self::CSV_DELIMITER, $row));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->processRow($row, $rowCount, $filePath);
|
$this->processRow($row, $rowCount, $filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Memproses satu baris data CSV
|
* Memproses satu baris data CSV
|
||||||
*
|
*
|
||||||
* @param array $row Data baris CSV
|
* @param array $row Data baris CSV
|
||||||
* @param int $rowCount Nomor baris untuk logging
|
* @param int $rowCount Nomor baris untuk logging
|
||||||
* @param string $filePath Path file untuk logging
|
* @param string $filePath Path file untuk logging
|
||||||
@@ -207,16 +207,16 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
'code' => trim($row[2]), // province code
|
'code' => trim($row[2]), // province code
|
||||||
'name' => trim($row[3]) // province_name
|
'name' => trim($row[3]) // province_name
|
||||||
];
|
];
|
||||||
|
|
||||||
Log::debug("ProcessProvinceDataJob: Memproses baris $rowCount dengan data: " . json_encode($data));
|
Log::debug("ProcessProvinceDataJob: Memproses baris $rowCount dengan data: " . json_encode($data));
|
||||||
|
|
||||||
$this->saveRecord($data, $rowCount, $filePath);
|
$this->saveRecord($data, $rowCount, $filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menyimpan record provinsi ke database
|
* Menyimpan record provinsi ke database
|
||||||
* Menggunakan updateOrCreate untuk menghindari duplikasi
|
* Menggunakan updateOrCreate untuk menghindari duplikasi
|
||||||
*
|
*
|
||||||
* @param array $data Data provinsi yang akan disimpan
|
* @param array $data Data provinsi yang akan disimpan
|
||||||
* @param int $rowCount Nomor baris untuk logging
|
* @param int $rowCount Nomor baris untuk logging
|
||||||
* @param string $filePath Path file untuk logging
|
* @param string $filePath Path file untuk logging
|
||||||
@@ -237,10 +237,10 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
['code' => $data['code']], // Kondisi pencarian
|
['code' => $data['code']], // Kondisi pencarian
|
||||||
['name' => $data['name']] // Data yang akan diupdate/insert
|
['name' => $data['name']] // Data yang akan diupdate/insert
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->processedCount++;
|
$this->processedCount++;
|
||||||
Log::debug("ProcessProvinceDataJob: Berhasil menyimpan provinsi ID: {$province->id}, Code: {$data['code']}, Name: {$data['name']}");
|
Log::debug("ProcessProvinceDataJob: Berhasil menyimpan provinsi ID: {$province->id}, Code: {$data['code']}, Name: {$data['name']}");
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->errorCount++;
|
$this->errorCount++;
|
||||||
Log::error("ProcessProvinceDataJob: Error menyimpan data provinsi pada baris $rowCount di $filePath: " . $e->getMessage());
|
Log::error("ProcessProvinceDataJob: Error menyimpan data provinsi pada baris $rowCount di $filePath: " . $e->getMessage());
|
||||||
@@ -250,7 +250,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Membersihkan file temporary
|
* Membersihkan file temporary
|
||||||
*
|
*
|
||||||
* @param string $tempFilePath Path file temporary yang akan dihapus
|
* @param string $tempFilePath Path file temporary yang akan dihapus
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -264,7 +264,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Logging hasil akhir pemrosesan job
|
* Logging hasil akhir pemrosesan job
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function logJobCompletion(): void
|
private function logJobCompletion(): void
|
||||||
@@ -273,14 +273,14 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
"Total diproses: {$this->processedCount}, " .
|
"Total diproses: {$this->processedCount}, " .
|
||||||
"Total error: {$this->errorCount}, " .
|
"Total error: {$this->errorCount}, " .
|
||||||
"Total dilewati: {$this->skippedCount}";
|
"Total dilewati: {$this->skippedCount}";
|
||||||
|
|
||||||
Log::info($message);
|
Log::info($message);
|
||||||
|
|
||||||
// Log summary untuk monitoring
|
// Log summary untuk monitoring
|
||||||
if ($this->errorCount > 0) {
|
if ($this->errorCount > 0) {
|
||||||
Log::warning("ProcessProvinceDataJob: Terdapat {$this->errorCount} error dalam pemrosesan");
|
Log::warning("ProcessProvinceDataJob: Terdapat {$this->errorCount} error dalam pemrosesan");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->skippedCount > 0) {
|
if ($this->skippedCount > 0) {
|
||||||
Log::info("ProcessProvinceDataJob: Terdapat {$this->skippedCount} baris yang dilewati");
|
Log::info("ProcessProvinceDataJob: Terdapat {$this->skippedCount} baris yang dilewati");
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle job failure
|
* Handle job failure
|
||||||
*
|
*
|
||||||
* @param Exception $exception
|
* @param Exception $exception
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -297,4 +297,4 @@ class ProcessProvinceDataJob implements ShouldQueue
|
|||||||
Log::error('ProcessProvinceDataJob: Job gagal dijalankan: ' . $exception->getMessage());
|
Log::error('ProcessProvinceDataJob: Job gagal dijalankan: ' . $exception->getMessage());
|
||||||
Log::error('ProcessProvinceDataJob: Stack trace: ' . $exception->getTraceAsString());
|
Log::error('ProcessProvinceDataJob: Stack trace: ' . $exception->getTraceAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ProcessSectorDataJob implements ShouldQueue
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.SECTOR.csv';
|
private const FILENAME = 'ST.SECTOR.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
private int $processedCount = 0;
|
private int $processedCount = 0;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.STMT.ENTRY.csv';
|
private const FILENAME = 'ST.STMT.ENTRY.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class ProcessStmtEntryDetailDataJob implements ShouldQueue
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.STMT.ENTRY.DETAIL.csv';
|
private const FILENAME = 'ST.STMT.ENTRY.DETAIL.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.STMT.NARR.FORMAT.csv';
|
private const FILENAME = 'ST.STMT.NARR.FORMAT.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
private int $processedCount = 0;
|
private int $processedCount = 0;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.STMT.NARR.PARAM.csv';
|
private const FILENAME = 'ST.STMT.NARR.PARAM.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
private int $processedCount = 0;
|
private int $processedCount = 0;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.TELLER.csv';
|
private const FILENAME = 'ST.TELLER.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
private const CHUNK_SIZE = 1000; // Process data in chunks to reduce memory usage
|
||||||
private const HEADER_MAP = [
|
private const HEADER_MAP = [
|
||||||
'id' => 'id_teller',
|
'id' => 'id_teller',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
private const CSV_DELIMITER = '~';
|
private const CSV_DELIMITER = '~';
|
||||||
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
private const MAX_EXECUTION_TIME = 86400; // 24 hours in seconds
|
||||||
private const FILENAME = 'ST.TRANSACTION.csv';
|
private const FILENAME = 'ST.TRANSACTION.csv';
|
||||||
private const DISK_NAME = 'sftpStatement';
|
private const DISK_NAME = 'staging';
|
||||||
|
|
||||||
private string $period = '';
|
private string $period = '';
|
||||||
private int $processedCount = 0;
|
private int $processedCount = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user