feat: 업체별 동적 BOM 계산 시스템 구현

- 데이터베이스 스키마 확장: BOM 테이블에 계산 관련 필드 추가
- 계산 엔진 구현: CalculationEngine, FormulaParser, ParameterValidator
- API 구현: 견적 파라미터 추출, 실시간 BOM 계산, 업체별 산출식 관리
- FormRequest 검증: 모든 입력 데이터 검증 및 한국어 에러 메시지
- 라우트 등록: 5개 BOM 계산 API 엔드포인트 추가

주요 기능:
• BOM에서 필요한 조건만 동적 추출하여 견적 화면에 표시
• 경동기업 하드코딩 산출식을 동적 시스템으로 전환
• 업체별 산출식 버전 관리 및 실시간 테스트 지원

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-22 22:09:42 +09:00
parent fa9f8ac707
commit bd678dfea9
15 changed files with 2039 additions and 3 deletions

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* BOM 테이블에 산출식 관련 필드 추가
* - bom_templates: 견적시 필요한 파라미터 스키마 정의
* - bom_template_items: 개별 아이템의 계산식 정의
*/
public function up(): void {
// BOM 템플릿에 산출식 조건 스키마 추가
Schema::table('bom_templates', function (Blueprint $table) {
$table->json('calculation_schema')->nullable()->comment('견적 파라미터 스키마 (JSON)');
$table->string('company_type', 50)->default('default')->comment('업체 타입 (경동기업, 삼성물산 등)');
$table->string('formula_version', 10)->default('v1.0')->comment('산출식 버전');
});
// BOM 아이템에 계산식 필드 추가
Schema::table('bom_template_items', function (Blueprint $table) {
$table->boolean('is_calculated')->default(false)->comment('계산식 적용 여부');
$table->text('calculation_formula')->nullable()->comment('계산식 표현식');
$table->json('depends_on')->nullable()->comment('의존하는 파라미터 목록 (JSON)');
$table->json('calculation_config')->nullable()->comment('계산 설정 (JSON)');
});
}
/**
* Reverse the migrations.
*/
public function down(): void {
Schema::table('bom_template_items', function (Blueprint $table) {
$table->dropColumn(['is_calculated', 'calculation_formula', 'depends_on', 'calculation_config']);
});
Schema::table('bom_templates', function (Blueprint $table) {
$table->dropColumn(['calculation_schema', 'company_type', 'formula_version']);
});
}
};

View File

@@ -0,0 +1,41 @@
<?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('calculation_configs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id')->comment('테넌트ID');
$table->string('company_name', 100)->comment('업체명 (경동기업, 삼성물산 등)');
$table->string('formula_type', 100)->comment('산출식 타입 (screen_weight, motor_capacity 등)');
$table->string('version', 10)->default('v1.0')->comment('산출식 버전');
$table->text('formula_expression')->comment('실제 계산식 표현식');
$table->json('parameters')->comment('필요한 입력 파라미터 정의');
$table->json('conditions')->nullable()->comment('적용 조건 (제품타입, 사이즈 범위 등)');
$table->json('validation_rules')->nullable()->comment('파라미터 검증 규칙');
$table->text('description')->nullable()->comment('산출식 설명');
$table->boolean('is_active')->default(true)->comment('활성 상태');
$table->timestamps();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unique(['tenant_id', 'company_name', 'formula_type', 'version'], 'uq_calc_config_unique');
$table->index(['tenant_id', 'company_name', 'is_active'], 'idx_calc_config_company');
$table->index(['tenant_id', 'formula_type', 'is_active'], 'idx_calc_config_type');
});
}
/**
* Reverse the migrations.
*/
public function down(): void {
Schema::dropIfExists('calculation_configs');
}
};