From fc537898fcfd4c7b0f7e5717fdce27b738fc70ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Tue, 3 Mar 2026 20:57:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[production]=20=EC=9E=90=EC=9E=AC?= =?UTF-8?q?=ED=88=AC=EC=9E=85=20=EB=AA=A8=EB=8B=AC=20=EA=B0=9C=EC=84=A0=20?= =?UTF-8?q?=E2=80=94=20lot=5Fmanaged=20=ED=95=84=ED=84=B0=EB=A7=81,=20BOM?= =?UTF-8?q?=20=EA=B7=B8=EB=A3=B9=ED=82=A4,=20=EC=85=94=ED=84=B0=EB=B0=95?= =?UTF-8?q?=EC=8A=A4=20=EC=88=9C=EC=84=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getMaterialsForItem: lot_managed===false 품목 자재투입 목록에서 제외 (L-Bar, 보강평철) - getMaterialsForItem: bom_group_key 필드 추가 (category+partType 기반 고유키) - BendingInfoBuilder: shutterPartTypes에서 top_cover/fin_cover 제거 (별도 생성과 중복) - BendingInfoBuilder: 셔터박스 루프 순서 파트→길이로 변경 (작업일지 순서 일치) Co-Authored-By: Claude Opus 4.6 --- .../Production/BendingInfoBuilder.php | 17 ++++++++------- app/Services/WorkOrderService.php | 21 ++++++++++++++++++- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/Services/Production/BendingInfoBuilder.php b/app/Services/Production/BendingInfoBuilder.php index cad62df..37ac551 100644 --- a/app/Services/Production/BendingInfoBuilder.php +++ b/app/Services/Production/BendingInfoBuilder.php @@ -220,14 +220,17 @@ public function buildDynamicBomForItem(array $context, int $width, int $height, if ($boxSize) { $isStandard = $boxSize === '500*380'; $dist = $this->shutterBoxDistribution($width); - $shutterPartTypes = ['front', 'lintel', 'inspection', 'rear_corner', 'top_cover', 'fin_cover']; + // 상부덮개(top_cover), 마구리(fin_cover)는 1219mm 기준으로 별도 생성 (아래 256행~) + $shutterPartTypes = ['front', 'lintel', 'inspection', 'rear_corner']; + + // 작업일지와 동일한 순서: 파트 → 길이 + foreach ($shutterPartTypes as $partType) { + foreach ($dist as $length => $count) { + $totalCount = $count * $qty; + if ($totalCount <= 0) { + continue; + } - foreach ($dist as $length => $count) { - $totalCount = $count * $qty; - if ($totalCount <= 0) { - continue; - } - foreach ($shutterPartTypes as $partType) { $prefix = $resolver->resolveShutterBoxPrefix($partType, $isStandard); $itemCode = $resolver->buildItemCode($prefix, $length); if (! $itemCode) { diff --git a/app/Services/WorkOrderService.php b/app/Services/WorkOrderService.php index 77d6a73..bb5c5f9 100644 --- a/app/Services/WorkOrderService.php +++ b/app/Services/WorkOrderService.php @@ -3165,6 +3165,12 @@ public function getMaterialsForItem(int $workOrderId, int $itemId): array continue; } + // LOT 관리 대상이 아닌 품목은 자재투입 목록에서 제외 + $childOptions = $childItems[$childItemId]->options ?? []; + if (isset($childOptions['lot_managed']) && $childOptions['lot_managed'] === false) { + continue; + } + // dynamic_bom.qty는 아이템 수량이 곱해져 있으므로 나눠서 개소당 수량 산출 // (작업일지 bendingInfo와 동일한 수량) $bomQty = (float) ($bomEntry['qty'] ?? 1); @@ -3202,6 +3208,12 @@ public function getMaterialsForItem(int $workOrderId, int $itemId): array continue; } + // LOT 관리 대상이 아닌 품목은 자재투입 목록에서 제외 + $childOptions = $childItem->options ?? []; + if (isset($childOptions['lot_managed']) && $childOptions['lot_managed'] === false) { + continue; + } + $materialItems[] = [ 'item' => $childItem, 'bom_qty' => $bomQty, @@ -3232,11 +3244,16 @@ public function getMaterialsForItem(int $workOrderId, int $itemId): array $materials = []; $rank = 1; - foreach ($materialItems as $matInfo) { + foreach ($materialItems as $bomIdx => $matInfo) { $materialItem = $matInfo['item']; $alreadyInputted = (float) ($inputtedQties[$materialItem->id] ?? 0); $remainingRequired = max(0, $matInfo['required_qty'] - $alreadyInputted); + // BOM 엔트리별 고유 그룹키 (같은 item_id라도 category+partType이 다르면 별도 그룹) + $bomGroupKey = $materialItem->id + .'_'.($matInfo['category'] ?? '') + .'_'.($matInfo['part_type'] ?? ''); + $stock = \App\Models\Tenants\Stock::where('tenant_id', $tenantId) ->where('item_id', $materialItem->id) ->first(); @@ -3256,6 +3273,7 @@ public function getMaterialsForItem(int $workOrderId, int $itemId): array $materials[] = [ 'stock_lot_id' => $lot->id, 'item_id' => $materialItem->id, + 'bom_group_key' => $bomGroupKey, 'lot_no' => $lot->lot_no, 'material_code' => $materialItem->code, 'material_name' => $materialItem->name, @@ -3282,6 +3300,7 @@ public function getMaterialsForItem(int $workOrderId, int $itemId): array $materials[] = [ 'stock_lot_id' => null, 'item_id' => $materialItem->id, + 'bom_group_key' => $bomGroupKey, 'lot_no' => null, 'material_code' => $materialItem->code, 'material_name' => $materialItem->name,