From b3869cfadb1b62c9ecc535ff1c84382307f141dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Wed, 18 Mar 2026 23:15:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[production-order]=20=EC=83=9D=EC=82=B0?= =?UTF-8?q?=EC=A7=80=EC=8B=9C=20=EC=83=81=EC=84=B8=20=EA=B0=9C=EC=84=A0=20?= =?UTF-8?q?-=20=EC=88=98=EB=9F=89=EC=9D=84=20=EA=B0=9C=EC=86=8C=EC=88=98?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD,=20BOM=20=EA=B3=B5=EC=A0=95?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20=ED=95=9C=EA=B8=80=20=EB=9D=BC=EB=B2=A8=20?= =?UTF-8?q?=EB=A7=A4=ED=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- app/Services/ProductionOrderService.php | 32 +++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/app/Services/ProductionOrderService.php b/app/Services/ProductionOrderService.php index 6f23f6ac..e421c4bc 100644 --- a/app/Services/ProductionOrderService.php +++ b/app/Services/ProductionOrderService.php @@ -168,12 +168,13 @@ public function show(int $orderId): array ]; // WorkOrder 목록 가공 (생산 공정만) - $workOrders = $productionWorkOrders->values()->map(function ($wo) { + $nodeCount = $order->nodes_count ?? $order->nodes->count(); + $workOrders = $productionWorkOrders->values()->map(function ($wo) use ($nodeCount) { return [ 'id' => $wo->id, 'work_order_no' => $wo->work_order_no, 'process_name' => $wo->process?->process_name ?? '', - 'quantity' => $wo->items->count(), + 'quantity' => $nodeCount, 'status' => $wo->status, 'assignees' => $wo->assignees->map(fn ($a) => $a->user?->name ?? '')->filter()->values()->toArray(), ]; @@ -234,16 +235,17 @@ private function extractBomProcessGroups($nodes): array continue; } - $processGroup = $item['process_group'] ?? $item['category_group'] ?? '기타'; + $processGroupKey = $item['process_group'] ?? $item['category_group'] ?? '기타'; + $processGroupLabel = $this->mapProcessGroupLabel($processGroupKey); - if (! isset($groups[$processGroup])) { - $groups[$processGroup] = [ - 'process_name' => $processGroup, + if (! isset($groups[$processGroupKey])) { + $groups[$processGroupKey] = [ + 'process_name' => $processGroupLabel, 'items' => [], ]; } - $groups[$processGroup]['items'][] = [ + $groups[$processGroupKey]['items'][] = [ 'id' => $item['item_id'] ?? null, 'item_code' => $item['item_code'] ?? '', 'item_name' => $item['item_name'] ?? '', @@ -260,6 +262,22 @@ private function extractBomProcessGroups($nodes): array return array_values($groups); } + /** + * BOM process_group 코드 → 한글 라벨 + */ + private function mapProcessGroupLabel(string $key): string + { + return match ($key) { + 'inspection' => '검사비', + 'material' => '원자재', + 'motor' => '모터', + 'controller' => '제어장치', + 'steel' => '절곡물', + 'parts' => '부자재', + default => $key, + }; + } + /** * 주문 ID 목록에 대해 작업지시 진행률을 일괄 조회 (단일 쿼리) */