From ccd8b6f81dbc50961cbe44f55746bf4f294bea31 Mon Sep 17 00:00:00 2001 From: hskwon Date: Thu, 4 Dec 2025 16:23:39 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[quote]=20=EC=88=98=EC=8B=9D=20?= =?UTF-8?q?=EC=8B=9C=EB=8D=94=20=ED=92=88=EB=AA=A9/=EB=A7=A4=ED=95=91=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - QuoteFormulaSeeder: CONTROLLER_TYPE input 수식 추가 - QuoteFormulaItemSeeder: 14개 품목 마스터 (GR, CASE, MOTOR, CTRL, EDGE, INSP) - QuoteFormulaMappingSeeder: CTRL_AUTO_SELECT 매핑 3건 (매립형/노출형/일체형) --- database/seeders/QuoteFormulaItemSeeder.php | 235 ++++++++++++++++++ .../seeders/QuoteFormulaMappingSeeder.php | 86 +++++++ database/seeders/QuoteFormulaSeeder.php | 12 +- 3 files changed, 331 insertions(+), 2 deletions(-) create mode 100644 database/seeders/QuoteFormulaItemSeeder.php create mode 100644 database/seeders/QuoteFormulaMappingSeeder.php diff --git a/database/seeders/QuoteFormulaItemSeeder.php b/database/seeders/QuoteFormulaItemSeeder.php new file mode 100644 index 0000000..d8046f3 --- /dev/null +++ b/database/seeders/QuoteFormulaItemSeeder.php @@ -0,0 +1,235 @@ +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).'개 품목 생성 완료'); + } +} diff --git a/database/seeders/QuoteFormulaMappingSeeder.php b/database/seeders/QuoteFormulaMappingSeeder.php new file mode 100644 index 0000000..5b53215 --- /dev/null +++ b/database/seeders/QuoteFormulaMappingSeeder.php @@ -0,0 +1,86 @@ +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개 매핑 생성 완료'); + } +} diff --git a/database/seeders/QuoteFormulaSeeder.php b/database/seeders/QuoteFormulaSeeder.php index 7e85e89..1cac292 100644 --- a/database/seeders/QuoteFormulaSeeder.php +++ b/database/seeders/QuoteFormulaSeeder.php @@ -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, ],