Files
webstatement/app/Console/ProcessDailyMigration.php
Daeng Deni Mardaeni 9cdc7f9487 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)
2025-07-28 16:00:45 +07:00

68 lines
2.1 KiB
PHP

<?php
namespace Modules\Webstatement\Console;
use Exception;
use Illuminate\Console\Command;
use Modules\Webstatement\Http\Controllers\StagingController;
use Illuminate\Support\Facades\Log;
class ProcessDailyMigration extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'webstatement:process-daily-migration
{--process_parameter= : To process migration parameter true/false}
{--period= : Period to process (default: -1 day, format: Ymd or relative date)}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Process data migration for the specified period (default: previous day)';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$processParameter = $this->option('process_parameter');
$period = $this->option('period');
// Log start of process
Log::info('Starting daily data migration process', [
'process_parameter' => $processParameter ?? 'false',
'period' => $period ?? '-1 day'
]);
$this->info('Starting daily data migration process...');
$this->info('Process Parameter: ' . ($processParameter ?? 'False'));
$this->info('Period: ' . ($period ?? '-1 day (default)'));
try {
$controller = app(StagingController::class);
$response = $controller->index($processParameter, $period);
$responseData = json_decode($response->getContent(), true);
$message = $responseData['message'] ?? 'Process completed';
$this->info($message);
Log::info('Daily migration process completed successfully', ['message' => $message]);
return Command::SUCCESS;
} catch (Exception $e) {
$errorMessage = 'Error processing daily migration: ' . $e->getMessage();
$this->error($errorMessage);
Log::error($errorMessage, ['exception' => $e->getTraceAsString()]);
return Command::FAILURE;
}
}
}