shjTwoService = $shjTwoService; } /** * コンソールコマンドを実行 * * 処理フロー: * 現時点の世代シフトを行う * フルバックアップを行う * バッチ処理ログを作成する * * @return int */ public function handle() { try { // 開始ログ出力 $startTime = now(); $this->info('SHJ-2 データバックアップ処理を開始します。'); Log::info('SHJ-2 データバックアップ処理開始', [ 'start_time' => $startTime ]); // SHJ-2メイン処理実行 $result = $this->shjTwoService->execute(); $endTime = now(); // 処理結果に応じた出力 if ($result['success']) { $this->info('SHJ-2 データバックアップ処理が正常に完了しました。'); $this->info("処理時間: {$startTime->diffInSeconds($endTime)}秒"); $this->info("ステータス: {$result['status']}"); $this->info("コメント: {$result['status_comment']}"); Log::info('SHJ-2 データバックアップ処理完了', [ 'end_time' => $endTime, 'duration_seconds' => $startTime->diffInSeconds($endTime), 'status' => $result['status'], 'status_comment' => $result['status_comment'] ]); return self::SUCCESS; } else { $this->error('SHJ-2 データバックアップ処理でエラーが発生しました: ' . $result['status_comment']); Log::error('SHJ-2 データバックアップ処理エラー', [ 'status' => $result['status'], 'status_comment' => $result['status_comment'] ]); return self::FAILURE; } } catch (\Exception $e) { $this->error('SHJ-2 データバックアップ処理で予期しないエラーが発生しました: ' . $e->getMessage()); Log::error('SHJ-2 データバックアップ処理例外エラー', [ 'exception' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return self::FAILURE; } } }