feat(webstatement): tambahkan fitur schedule dan console command untuk migrasi dan ekspor data harian
- Menambahkan dua console command baru: 1. `webstatement:process-daily-migration` untuk memproses migrasi data harian. 2. `webstatement:export-statements` untuk mengekspor laporan harian. - Mendefinisikan command `webstatement:process-daily-migration`: - Menggunakan `MigrasiController` untuk memproses data migrasi. - Menangkap error selama proses migrasi dan memberikan output informasi status. - Mendefinisikan command `webstatement:export-statements`: - Menggunakan `WebstatementController` untuk memproses ekspor laporan harian. - Memberikan informasi terkait jumlah job ekspor yang berhasil di-queue dan menangkap error selama proses. - Menambahkan schedule untuk kedua command: 1. `webstatement:process-daily-migration` dijalankan setiap hari pukul 09:00 dan log aktivitas disimpan di `daily-migration.log`. 2. `webstatement:export-statements` dijalankan setiap hari pukul 09:30 dan log aktivitas disimpan di `statement-export.log`. - Melengkapi `WebstatementServiceProvider` dengan pendaftaran command dan konfigurasi jadwal baru. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
47
app/Console/ProcessDailyMigration.php
Normal file
47
app/Console/ProcessDailyMigration.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Webstatement\Console;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\Webstatement\Http\Controllers\MigrasiController;
|
||||
|
||||
class ProcessDailyMigration extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'webstatement:process-daily-migration';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process data migration for the previous day\'s period';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Starting daily data migration process...');
|
||||
|
||||
try {
|
||||
$controller = app(MigrasiController::class);
|
||||
$response = $controller->index();
|
||||
|
||||
$responseData = json_decode($response->getContent(), true);
|
||||
$this->info($responseData['message'] ?? 'Process completed');
|
||||
|
||||
return Command::SUCCESS;
|
||||
} catch (Exception $e) {
|
||||
$this->error('Error processing daily migration: ' . $e->getMessage());
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user