Форматирование
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
// app/Console/Commands/RecalculatePreoperativeMetric.php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Report;
|
||||
use App\Models\MedicalHistorySnapshot;
|
||||
use App\Models\MetrikaResult;
|
||||
use App\Models\Report;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -66,19 +67,21 @@ class RecalculatePreoperativeMetric extends Command
|
||||
}
|
||||
|
||||
$force = $this->option('force');
|
||||
$chunkSize = (int)$this->option('chunk');
|
||||
$chunkSize = (int) $this->option('chunk');
|
||||
|
||||
$totalReports = $query->count();
|
||||
|
||||
if ($totalReports === 0) {
|
||||
$this->warn('❌ Отчеты не найдены');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->info("📊 Найдено отчетов: {$totalReports}");
|
||||
|
||||
if ($totalReports > 1000 && !$this->confirm("⚠️ Обработка {$totalReports} отчетов может занять время. Продолжить?")) {
|
||||
if ($totalReports > 1000 && ! $this->confirm("⚠️ Обработка {$totalReports} отчетов может занять время. Продолжить?")) {
|
||||
$this->info('❌ Операция отменена');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -104,7 +107,7 @@ class RecalculatePreoperativeMetric extends Command
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$errors++;
|
||||
Log::error("Ошибка обработки отчета {$report->report_id}: " . $e->getMessage());
|
||||
Log::error("Ошибка обработки отчета {$report->report_id}: ".$e->getMessage());
|
||||
}
|
||||
|
||||
$bar->advance();
|
||||
@@ -131,16 +134,17 @@ class RecalculatePreoperativeMetric extends Command
|
||||
$this->newLine();
|
||||
$this->info('📋 Примеры обновленных отчетов:');
|
||||
|
||||
$samples = Report::whereHas('metrikaResults', function($q) {
|
||||
$samples = Report::whereHas('metrikaResults', function ($q) {
|
||||
$q->where('rf_metrika_item_id', 21);
|
||||
})
|
||||
->orderBy('report_id', 'desc')
|
||||
->limit(5)
|
||||
->get()
|
||||
->map(function($report) {
|
||||
->map(function ($report) {
|
||||
$metric = $report->metrikaResults
|
||||
->where('rf_metrika_item_id', 21)
|
||||
->first();
|
||||
|
||||
return [
|
||||
'report_id' => $report->report_id,
|
||||
'department' => $report->rf_department_id,
|
||||
@@ -168,7 +172,7 @@ class RecalculatePreoperativeMetric extends Command
|
||||
->where('rf_metrika_item_id', 21)
|
||||
->first();
|
||||
|
||||
if ($existing && !$force) {
|
||||
if ($existing && ! $force) {
|
||||
return 'skipped';
|
||||
}
|
||||
|
||||
@@ -186,6 +190,7 @@ class RecalculatePreoperativeMetric extends Command
|
||||
],
|
||||
['value' => 0]
|
||||
);
|
||||
|
||||
return 'no_patients';
|
||||
}
|
||||
|
||||
@@ -212,6 +217,7 @@ class RecalculatePreoperativeMetric extends Command
|
||||
],
|
||||
['value' => 0]
|
||||
);
|
||||
|
||||
return 'no_patients';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user