From 74a83e671100cdfd4fdb022611804d14f7e8f5a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Thu, 19 Feb 2026 20:58:53 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=8A=AC=EB=9E=AB=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EC=9D=BC=EC=A7=80=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=B4=ED=94=84=EB=9D=BC=EC=9D=B8=20=EA=B5=AC=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - OrderService.createFromQuote: BOM 결과에서 slat_info(조인트바/방화유리 수량) 추출하여 OrderNode.options에 저장 - OrderService.createWorkOrders: nodeOptions에 slat_info 없을 때 bom_result에서 fallback 추출 - OrderService.syncFromQuote: 동일하게 slat_info 추출 추가 - WorkOrderService: salesOrder eager loading에 client_contact, options 추가 Co-Authored-By: Claude Opus 4.6 --- app/Services/OrderService.php | 51 ++++++++++++++++++++++++++++++- app/Services/WorkOrderService.php | 2 +- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index ec9a7ee..716cd49 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -668,6 +668,7 @@ public function createFromQuote(int $quoteId, array $data = []) 'wing_size' => $locItem['wingSize'] ?? null, 'inspection_fee' => $locItem['inspectionFee'] ?? null, 'bom_result' => $bomResult, + 'slat_info' => $this->extractSlatInfoFromBom($bomResult, $locItem), ], 'depth' => 0, 'sort_order' => $idx, @@ -850,6 +851,7 @@ public function syncFromQuote(Quote $quote, int $revision): ?Order 'wing_size' => $locItem['wingSize'] ?? null, 'inspection_fee' => $locItem['inspectionFee'] ?? null, 'bom_result' => $bomResult, + 'slat_info' => $this->extractSlatInfoFromBom($bomResult, $locItem), ], 'depth' => 0, 'sort_order' => $idx, @@ -1154,13 +1156,19 @@ public function createProductionOrder(int $orderId, array $data) $node = $order->rootNodes->firstWhere('id', $orderItem->order_node_id); $nodeOptions = $node ? ($node->options ?? []) : []; } + // slat_info: nodeOptions에 있으면 사용, 없으면 bom_result에서 추출 (하위 호환) + $slatInfo = $nodeOptions['slat_info'] ?? null; + if (! $slatInfo && isset($nodeOptions['bom_result'])) { + $slatInfo = $this->extractSlatInfoFromBom($nodeOptions['bom_result']); + } + $woItemOptions = array_filter([ 'floor' => $orderItem->floor_code, 'code' => $orderItem->symbol_code, 'width' => $nodeOptions['width'] ?? $nodeOptions['open_width'] ?? null, 'height' => $nodeOptions['height'] ?? $nodeOptions['open_height'] ?? null, 'cutting_info' => $nodeOptions['cutting_info'] ?? null, - 'slat_info' => $nodeOptions['slat_info'] ?? null, + 'slat_info' => $slatInfo, 'bending_info' => $nodeOptions['bending_info'] ?? null, 'wip_info' => $nodeOptions['wip_info'] ?? null, ], fn ($v) => $v !== null); @@ -1198,6 +1206,47 @@ public function createProductionOrder(int $orderId, array $data) }); } + /** + * BOM 결과에서 슬랫 공정 정보 추출 + * + * 조인트바 수량: BOM items에서 '조인트바' 항목의 quantity, 없으면 inputVariables의 joint_bar_qty + * 방화유리 수량: 프론트 입력값(glass_qty) 우선, 없으면 QTY(개소당 수량) 사용 + */ + private function extractSlatInfoFromBom(?array $bomResult, array $locItem = []): ?array + { + if (! $bomResult) { + return null; + } + + $bomVars = $bomResult['variables'] ?? []; + $bomItems = $bomResult['items'] ?? []; + $productType = $bomVars['product_type'] ?? 'screen'; + + // 스크린 전용 제품은 슬랫 정보 불필요 + if ($productType === 'screen') { + return null; + } + + // 조인트바 수량: BOM items에서 추출, 없으면 입력 변수에서 + $jointBarQty = (int) ($bomVars['joint_bar_qty'] ?? 0); + if ($jointBarQty === 0) { + foreach ($bomItems as $item) { + if (str_contains($item['item_name'] ?? '', '조인트바')) { + $jointBarQty = (int) ($item['quantity'] ?? 0); + break; + } + } + } + + // 방화유리 수량: 프론트 입력값 우선, 없으면 개소 수량(QTY) + $glassQty = (int) ($locItem['glass_qty'] ?? $bomVars['glass_qty'] ?? $locItem['quantity'] ?? 0); + + return [ + 'joint_bar' => $jointBarQty, + 'glass_qty' => $glassQty, + ]; + } + /** * 작업지시번호 자동 생성 */ diff --git a/app/Services/WorkOrderService.php b/app/Services/WorkOrderService.php index 18e0f05..344f598 100644 --- a/app/Services/WorkOrderService.php +++ b/app/Services/WorkOrderService.php @@ -53,7 +53,7 @@ public function index(array $params) 'assignee:id,name', 'assignees.user:id,name', 'team:id,name', - 'salesOrder' => fn ($q) => $q->select('id', 'order_no', 'client_id', 'client_name', 'site_name', 'quantity', 'received_at', 'delivery_date')->withCount('rootNodes'), + 'salesOrder' => fn ($q) => $q->select('id', 'order_no', 'client_id', 'client_name', 'client_contact', 'site_name', 'quantity', 'received_at', 'delivery_date', 'options')->withCount('rootNodes'), 'salesOrder.client:id,name', 'process:id,process_name,process_code,department,options', 'items:id,work_order_id,item_id,item_name,specification,quantity,unit,status,options,sort_order,source_order_item_id',