feat: [품질관리] 백엔드 API 구현 - 품질관리서 + 실적신고

- 품질관리서(quality_documents) CRUD API 14개 엔드포인트
- 실적신고(performance_reports) 관리 API 6개 엔드포인트
- DB 마이그레이션 4개 테이블 (quality_documents, quality_document_orders, quality_document_locations, performance_reports)
- 모델 4개 + 서비스 2개 + 컨트롤러 2개 + FormRequest 4개
- stats() ambiguous column 버그 수정 (JOIN 시 테이블 접두사 추가)
- missing() status_code 컬럼명/값 수정

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 20:29:39 +09:00
parent 0aa0a8592d
commit a6e29bc1f3
19 changed files with 1807 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('quality_documents', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained();
$table->string('quality_doc_number', 30)->comment('품질관리서 번호');
$table->string('site_name')->comment('현장명');
$table->string('status', 20)->default('received')->comment('received/in_progress/completed');
$table->foreignId('client_id')->nullable()->constrained('clients')->comment('수주처');
$table->foreignId('inspector_id')->nullable()->constrained('users')->comment('검사자');
$table->date('received_date')->nullable()->comment('접수일');
$table->json('options')->nullable()->comment('관련자정보, 검사정보, 현장주소 등');
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unique(['tenant_id', 'quality_doc_number']);
$table->index(['tenant_id', 'status']);
$table->index(['tenant_id', 'client_id']);
$table->index(['tenant_id', 'inspector_id']);
$table->index(['tenant_id', 'received_date']);
});
}
public function down(): void
{
Schema::dropIfExists('quality_documents');
}
};

View File

@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('quality_document_orders', function (Blueprint $table) {
$table->id();
$table->foreignId('quality_document_id')->constrained()->cascadeOnDelete();
$table->foreignId('order_id')->constrained('orders');
$table->timestamps();
$table->unique(['quality_document_id', 'order_id']);
});
}
public function down(): void
{
Schema::dropIfExists('quality_document_orders');
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('quality_document_locations', function (Blueprint $table) {
$table->id();
$table->foreignId('quality_document_id')->constrained()->cascadeOnDelete();
$table->foreignId('quality_document_order_id')->constrained('quality_document_orders', 'id', 'qdl_qdo_id_fk')->cascadeOnDelete();
$table->foreignId('order_item_id')->constrained('order_items');
$table->integer('post_width')->nullable()->comment('시공후 가로');
$table->integer('post_height')->nullable()->comment('시공후 세로');
$table->string('change_reason')->nullable()->comment('규격 변경사유');
$table->foreignId('document_id')->nullable()->comment('검사성적서 문서 ID');
$table->string('inspection_status', 20)->default('pending')->comment('pending/completed');
$table->timestamps();
$table->index(['quality_document_id', 'inspection_status'], 'qdl_doc_id_status_index');
});
}
public function down(): void
{
Schema::dropIfExists('quality_document_locations');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('performance_reports', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained();
$table->foreignId('quality_document_id')->constrained();
$table->unsignedSmallInteger('year')->comment('연도');
$table->unsignedTinyInteger('quarter')->comment('분기 1-4');
$table->string('confirmation_status', 20)->default('unconfirmed')->comment('unconfirmed/confirmed/reported');
$table->date('confirmed_date')->nullable();
$table->foreignId('confirmed_by')->nullable()->constrained('users');
$table->text('memo')->nullable();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unique(['tenant_id', 'quality_document_id']);
$table->index(['tenant_id', 'year', 'quarter']);
$table->index(['tenant_id', 'confirmation_status']);
});
}
public function down(): void
{
Schema::dropIfExists('performance_reports');
}
};