feat: [품질관리] 품질관리서/실적신고/검사 API
- QualityDocument CRUD + 수주 연결 + 개소별 데이터 저장 - PerformanceReport 실적신고 확인/메모 API - Inspection 검사 설정 + product_code 전파 수정 - 수주선택 API에 client_name 필드 추가 - 절곡 검사 프로파일 분리 (S1/S2/S3) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
54
app/Console/Commands/BackfillQuoteProductCodeCommand.php
Normal file
54
app/Console/Commands/BackfillQuoteProductCodeCommand.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Quote\Quote;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class BackfillQuoteProductCodeCommand extends Command
|
||||
{
|
||||
protected $signature = 'data:backfill-quote-product-code {--dry-run : 실제 저장하지 않고 결과만 출력}';
|
||||
|
||||
protected $description = 'quotes.product_code가 비어있는 레코드에 calculation_inputs.items[0].productCode 값 보정';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$dryRun = $this->option('dry-run');
|
||||
|
||||
$quotes = Quote::whereNull('product_code')
|
||||
->whereNotNull('calculation_inputs')
|
||||
->get();
|
||||
|
||||
$this->info("대상: {$quotes->count()}건".($dryRun ? ' (dry-run)' : ''));
|
||||
|
||||
$updated = 0;
|
||||
$skipped = 0;
|
||||
|
||||
foreach ($quotes as $quote) {
|
||||
$inputs = $quote->calculation_inputs;
|
||||
if (! is_array($inputs)) {
|
||||
$inputs = json_decode($inputs, true);
|
||||
}
|
||||
|
||||
$productCode = $inputs['items'][0]['productCode'] ?? null;
|
||||
|
||||
if (! $productCode) {
|
||||
$skipped++;
|
||||
$this->line(" SKIP #{$quote->id} ({$quote->quote_number}) — productCode 없음");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $dryRun) {
|
||||
$quote->update(['product_code' => $productCode]);
|
||||
}
|
||||
|
||||
$updated++;
|
||||
$this->line(' '.($dryRun ? 'WOULD ' : '')."UPDATE #{$quote->id} ({$quote->quote_number}) → {$productCode}");
|
||||
}
|
||||
|
||||
$this->info("완료: 보정 {$updated}건, 스킵 {$skipped}건");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user