feat: [quote] 수식 시더 품목/매핑 데이터 추가

- QuoteFormulaSeeder: CONTROLLER_TYPE input 수식 추가
- QuoteFormulaItemSeeder: 14개 품목 마스터 (GR, CASE, MOTOR, CTRL, EDGE, INSP)
- QuoteFormulaMappingSeeder: CTRL_AUTO_SELECT 매핑 3건 (매립형/노출형/일체형)
This commit is contained in:
2025-12-04 16:23:39 +09:00
parent 165512e121
commit ccd8b6f81d
3 changed files with 331 additions and 2 deletions

View File

@@ -0,0 +1,235 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class QuoteFormulaItemSeeder extends Seeder
{
/**
* 견적수식 품목 시드 데이터
* 견적서에 들어갈 품목 마스터
*/
public function run(): void
{
// 수식 ID 맵 조회
$formulas = DB::table('quote_formulas')
->whereIn('variable', [
'GR_AUTO_SELECT',
'CASE_AUTO_SELECT',
'MOTOR_AUTO_SELECT',
'CTRL_AUTO_SELECT',
'EDGE_QTY',
'INSP_FEE',
])
->pluck('id', 'variable')
->toArray();
$items = [];
// ==============================
// 1. 가이드레일 품목
// ==============================
if (isset($formulas['GR_AUTO_SELECT'])) {
$items = array_merge($items, [
[
'formula_id' => $formulas['GR_AUTO_SELECT'],
'item_code' => 'PT-GR-2438',
'item_name' => '가이드레일 2438',
'specification' => '2438mm',
'unit' => 'EA',
'quantity_formula' => '2',
'unit_price_formula' => '35000',
'sort_order' => 1,
],
[
'formula_id' => $formulas['GR_AUTO_SELECT'],
'item_code' => 'PT-GR-3000',
'item_name' => '가이드레일 3000',
'specification' => '3000mm',
'unit' => 'EA',
'quantity_formula' => '2',
'unit_price_formula' => '42000',
'sort_order' => 2,
],
[
'formula_id' => $formulas['GR_AUTO_SELECT'],
'item_code' => 'PT-GR-3600',
'item_name' => '가이드레일 3600',
'specification' => '3600mm',
'unit' => 'EA',
'quantity_formula' => '2',
'unit_price_formula' => '50000',
'sort_order' => 3,
],
]);
}
// ==============================
// 2. 케이스(셔터박스) 품목
// ==============================
if (isset($formulas['CASE_AUTO_SELECT'])) {
$items = array_merge($items, [
[
'formula_id' => $formulas['CASE_AUTO_SELECT'],
'item_code' => 'PT-CASE-1219',
'item_name' => '케이스 1219',
'specification' => '1219mm',
'unit' => 'EA',
'quantity_formula' => '1',
'unit_price_formula' => '85000',
'sort_order' => 1,
],
[
'formula_id' => $formulas['CASE_AUTO_SELECT'],
'item_code' => 'PT-CASE-2438',
'item_name' => '케이스 2438',
'specification' => '2438mm',
'unit' => 'EA',
'quantity_formula' => '1',
'unit_price_formula' => '120000',
'sort_order' => 2,
],
[
'formula_id' => $formulas['CASE_AUTO_SELECT'],
'item_code' => 'PT-CASE-3000',
'item_name' => '케이스 3000',
'specification' => '3000mm',
'unit' => 'EA',
'quantity_formula' => '1',
'unit_price_formula' => '150000',
'sort_order' => 3,
],
]);
}
// ==============================
// 3. 모터(개폐전동기) 품목
// ==============================
if (isset($formulas['MOTOR_AUTO_SELECT'])) {
$items = array_merge($items, [
[
'formula_id' => $formulas['MOTOR_AUTO_SELECT'],
'item_code' => 'PT-MOTOR-150',
'item_name' => '개폐전동기 150kg',
'specification' => '150kg',
'unit' => 'EA',
'quantity_formula' => '1',
'unit_price_formula' => '280000',
'sort_order' => 1,
],
[
'formula_id' => $formulas['MOTOR_AUTO_SELECT'],
'item_code' => 'PT-MOTOR-300',
'item_name' => '개폐전동기 300kg',
'specification' => '300kg',
'unit' => 'EA',
'quantity_formula' => '1',
'unit_price_formula' => '380000',
'sort_order' => 2,
],
[
'formula_id' => $formulas['MOTOR_AUTO_SELECT'],
'item_code' => 'PT-MOTOR-400',
'item_name' => '개폐전동기 400kg',
'specification' => '400kg',
'unit' => 'EA',
'quantity_formula' => '1',
'unit_price_formula' => '480000',
'sort_order' => 3,
],
]);
}
// ==============================
// 4. 제어기 품목
// ==============================
if (isset($formulas['CTRL_AUTO_SELECT'])) {
$items = array_merge($items, [
[
'formula_id' => $formulas['CTRL_AUTO_SELECT'],
'item_code' => 'PT-CTRL-EMB',
'item_name' => '매립형 제어기',
'specification' => '매립형',
'unit' => 'EA',
'quantity_formula' => '1',
'unit_price_formula' => '65000',
'sort_order' => 1,
],
[
'formula_id' => $formulas['CTRL_AUTO_SELECT'],
'item_code' => 'PT-CTRL-EXP',
'item_name' => '노출형 제어기',
'specification' => '노출형',
'unit' => 'EA',
'quantity_formula' => '1',
'unit_price_formula' => '55000',
'sort_order' => 2,
],
[
'formula_id' => $formulas['CTRL_AUTO_SELECT'],
'item_code' => 'PT-CTRL-INT',
'item_name' => '일체형 제어기',
'specification' => '모터일체형',
'unit' => 'EA',
'quantity_formula' => '1',
'unit_price_formula' => '45000',
'sort_order' => 3,
],
]);
}
// ==============================
// 5. 마구리 품목
// ==============================
if (isset($formulas['EDGE_QTY'])) {
$items = array_merge($items, [
[
'formula_id' => $formulas['EDGE_QTY'],
'item_code' => 'PT-EDGE-STD',
'item_name' => '마구리 날개',
'specification' => '표준형',
'unit' => 'EA',
'quantity_formula' => 'EDGE_QTY',
'unit_price_formula' => '12000',
'sort_order' => 1,
],
]);
}
// ==============================
// 6. 검사비 품목
// ==============================
if (isset($formulas['INSP_FEE'])) {
$items = array_merge($items, [
[
'formula_id' => $formulas['INSP_FEE'],
'item_code' => 'SV-INSP-STD',
'item_name' => '제품 검사비',
'specification' => '표준 검사',
'unit' => '식',
'quantity_formula' => '1',
'unit_price_formula' => 'INSP_FEE',
'sort_order' => 1,
],
]);
}
// 데이터 삽입
foreach ($items as $item) {
DB::table('quote_formula_items')->updateOrInsert(
[
'formula_id' => $item['formula_id'],
'item_code' => $item['item_code'],
],
array_merge($item, [
'created_at' => now(),
'updated_at' => now(),
])
);
}
$this->command->info('QuoteFormulaItemSeeder: '.count($items).'개 품목 생성 완료');
}
}

View File

@@ -0,0 +1,86 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class QuoteFormulaMappingSeeder extends Seeder
{
/**
* 견적수식 매핑 시드 데이터
* mapping 타입 수식(CTRL_AUTO_SELECT)의 조건별 결과값
*/
public function run(): void
{
// CTRL_AUTO_SELECT 수식 ID 조회
$ctrlFormula = DB::table('quote_formulas')
->where('variable', 'CTRL_AUTO_SELECT')
->first();
if (! $ctrlFormula) {
$this->command->warn('CTRL_AUTO_SELECT 수식을 찾을 수 없습니다.');
return;
}
$mappings = [
// 제어기 자동 선택 - CONTROLLER_TYPE 기반
[
'formula_id' => $ctrlFormula->id,
'source_variable' => 'CONTROLLER_TYPE',
'source_value' => '매립형',
'result_value' => json_encode([
'value' => '매립형 제어기',
'item_code' => 'PT-CTRL-EMB',
'quantity' => 1,
'note' => '매립형 설치',
], JSON_UNESCAPED_UNICODE),
'result_type' => 'fixed',
'sort_order' => 1,
],
[
'formula_id' => $ctrlFormula->id,
'source_variable' => 'CONTROLLER_TYPE',
'source_value' => '노출형',
'result_value' => json_encode([
'value' => '노출형 제어기',
'item_code' => 'PT-CTRL-EXP',
'quantity' => 1,
'note' => '노출형 설치',
], JSON_UNESCAPED_UNICODE),
'result_type' => 'fixed',
'sort_order' => 2,
],
[
'formula_id' => $ctrlFormula->id,
'source_variable' => 'CONTROLLER_TYPE',
'source_value' => '일체형',
'result_value' => json_encode([
'value' => '일체형 제어기',
'item_code' => 'PT-CTRL-INT',
'quantity' => 1,
'note' => '모터 일체형',
], JSON_UNESCAPED_UNICODE),
'result_type' => 'fixed',
'sort_order' => 3,
],
];
foreach ($mappings as $mapping) {
DB::table('quote_formula_mappings')->updateOrInsert(
[
'formula_id' => $mapping['formula_id'],
'source_variable' => $mapping['source_variable'],
'source_value' => $mapping['source_value'],
],
array_merge($mapping, [
'created_at' => now(),
'updated_at' => now(),
])
);
}
$this->command->info('QuoteFormulaMappingSeeder: 3개 매핑 생성 완료');
}
}

View File

@@ -254,8 +254,17 @@ public function run(): void
],
// ==============================
// 8. 제어기 (CONTROLLER) - 1
// 8. 제어기 (CONTROLLER) - 2
// ==============================
[
'category_code' => 'CONTROLLER',
'variable' => 'CONTROLLER_TYPE',
'name' => '제어기 유형',
'type' => 'input',
'formula' => null,
'description' => '제어기 설치 유형 선택 (매립형/노출형/일체형)',
'sort_order' => 0,
],
[
'category_code' => 'CONTROLLER',
'variable' => 'CTRL_AUTO_SELECT',
@@ -263,7 +272,6 @@ public function run(): void
'type' => 'mapping',
'formula' => null,
'description' => '연동제어기 설치 유형(매립/노출)에 따라 자동 선택',
'metadata' => ['unit' => 'EA', 'input_variable' => 'CONTROLLER_TYPE'],
'sort_order' => 1,
],