- Menambahkan opsi baru `--process_parameter` pada command `webstatement:process-daily-migration`. - Memungkinkan pengguna untuk menentukan parameter proses migrasi seperti tanggal (`date`) dan tipe (`type`). - Menambahkan logging tambahan untuk mencatat nilai parameter yang diproviding pengguna. - Memperbarui logika command dan controller: - Mengirimkan parameter `date` dan `type` ke controller untuk mendukung proses migrasi dengan parameter yang lebih spesifik. - Menambahkan proses migrasi baru untuk data sektor: - Membuat job `ProcessSectorDataJob` yang bertugas membaca file CSV terkait sektor dari SFTP. - Melakukan validasi keberadaan file, memproses tiap baris data, dan menyimpannya ke database jika valid. - Logging untuk setiap aktivitas proses sektor, termasuk error dan kesuksesan per baris. - Membuat model `Sector` untuk mendukung operasi database data sektor: - Menambah atribut dapat diolah (`fillable`) seperti `sector_code`, `co_code`, `description`, dll. - Menambahkan cast `date_time` ke tipe datetime. - Menambahkan migrasi baru untuk tabel `sectors`: - Tabel memiliki kolom seperti `id`, `date_time`, `description`, `curr_no`, `co_code`, dan `sector_code`. - Meningkatkan pendukung penyimpanan data sektor untuk migrasi masa depan. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?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
|
|
{--process_parameter= : To process migration parameter true/false}';
|
|
|
|
/**
|
|
* 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()
|
|
{
|
|
$date = $this->option('date');
|
|
$type = $this->option('type');
|
|
|
|
$this->info('Starting daily data migration process...');
|
|
$this->info('Date: ' . ($date ?? 'Not specified'));
|
|
$this->info('Type: ' . ($type ?? 'Not specified'));
|
|
|
|
try {
|
|
$controller = app(MigrasiController::class);
|
|
$response = $controller->index([
|
|
'date' => $date,
|
|
'type' => $type
|
|
]);
|
|
|
|
$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;
|
|
}
|
|
}
|
|
}
|