feat: 통합 품목 조회 API 및 가격 통합 시스템 구현
- 통합 품목 조회 API (materials + products UNION) - ItemsService, ItemsController, Swagger 문서 생성 - 타입 필터링 (FG/PT/SM/RM/CS), 검색, 카테고리 지원 - Collection merge 방식으로 UNION 쿼리 안정화 - 품목-가격 통합 조회 - PricingService.getPriceByType() 추가 (SALE/PURCHASE 지원) - 단일 품목 조회 시 판매가/매입가 선택적 포함 - 고객그룹 가격 우선순위 적용 및 시계열 조회 - 자재 타입 명시적 관리 - materials.material_type 컬럼 추가 (SM/RM/CS) - 기존 데이터 344개 자동 변환 (RAW→RM, SUB→SM) - 인덱스 추가로 조회 성능 최적화 - DB 데이터 정규화 - products.product_type: 760개 정규화 (PRODUCT→FG, PART/SUBASSEMBLY→PT) - 타입 코드 표준화로 API 일관성 확보 최종 데이터: 제품 760개(FG 297, PT 463), 자재 344개(SM 215, RM 129)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('materials', function (Blueprint $table) {
|
||||
// material_type 컬럼 추가 (SM=부자재, RM=원자재, CS=소모품)
|
||||
$table->string('material_type', 10)
|
||||
->nullable()
|
||||
->after('category_id')
|
||||
->comment('자재 타입: SM=부자재, RM=원자재, CS=소모품');
|
||||
|
||||
// 조회 성능을 위한 인덱스
|
||||
$table->index('material_type');
|
||||
});
|
||||
|
||||
// 기존 데이터 업데이트
|
||||
DB::statement("
|
||||
UPDATE materials
|
||||
SET material_type = CASE
|
||||
WHEN JSON_EXTRACT(options, '$.categories.item_type.code') = 'RAW' THEN 'RM'
|
||||
WHEN JSON_EXTRACT(options, '$.categories.item_type.code') = 'SUB' THEN 'SM'
|
||||
ELSE 'SM'
|
||||
END
|
||||
WHERE tenant_id = 1
|
||||
AND deleted_at IS NULL
|
||||
");
|
||||
|
||||
// 모든 자재에 타입이 설정되었으므로 NOT NULL로 변경
|
||||
Schema::table('materials', function (Blueprint $table) {
|
||||
$table->string('material_type', 10)->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('materials', function (Blueprint $table) {
|
||||
$table->dropIndex(['material_type']);
|
||||
$table->dropColumn('material_type');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user