option('sync-log-id'); $batchSize = (int) $this->option('batch-size'); $queueName = $this->option('queue'); $filtersJson = $this->option('filters'); $isDryRun = $this->option('dry-run'); // Parse filters jika ada $filters = []; if ($filtersJson) { $filters = json_decode($filtersJson, true); if (json_last_error() !== JSON_ERROR_NONE) { $this->error('Format JSON filters tidak valid'); return Command::FAILURE; } } // Validasi input if ($batchSize <= 0) { $this->error('Batch size harus lebih besar dari 0'); return Command::FAILURE; } $this->info('Konfigurasi job:'); $this->info("- Sync Log ID: " . ($syncLogId ?: 'Akan dibuat baru')); $this->info("- Batch Size: {$batchSize}"); $this->info("- Queue: {$queueName}"); $this->info("- Filters: " . ($filtersJson ?: 'Tidak ada')); $this->info("- Dry Run: " . ($isDryRun ? 'Ya' : 'Tidak')); if ($isDryRun) { $this->warn('Mode DRY RUN - Job tidak akan dijalankan'); return Command::SUCCESS; } // Konfirmasi sebelum menjalankan if (!$this->confirm('Apakah Anda yakin ingin menjalankan job update seluruh kartu ATM?')) { $this->info('Operasi dibatalkan'); return Command::SUCCESS; } // Dispatch job $job = new UpdateAllAtmCardsBatchJob($syncLogId, $batchSize, $filters); $job->onQueue($queueName); dispatch($job); $this->info('Job berhasil dijadwalkan!'); $this->info("Queue: {$queueName}"); $this->info('Gunakan command berikut untuk memonitor:'); $this->info('php artisan queue:work --queue=' . $queueName); Log::info('Command update seluruh kartu ATM selesai', [ 'sync_log_id' => $syncLogId, 'batch_size' => $batchSize, 'queue' => $queueName, 'filters' => $filters ]); return Command::SUCCESS; } catch (Exception $e) { $this->error('Terjadi error: ' . $e->getMessage()); Log::error('Error dalam command update seluruh kartu ATM: ' . $e->getMessage(), [ 'file' => $e->getFile(), 'line' => $e->getLine() ]); return Command::FAILURE; } } }