From adfccc9af05b8a38845a52d02d1346b139b2c33d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 13 Feb 2026 15:57:24 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EC=83=9D=EC=82=B0=EC=A7=80=EC=8B=9C=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=8B=9C=20=EB=8B=A4=EC=A4=91=20=EB=8B=B4?= =?UTF-8?q?=EB=8B=B9=EC=9E=90(assignee=5Fids)=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EB=88=84=EB=9D=BD=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CreateProductionOrderRequest에 assignee_ids 배열 validation 추가 - OrderService::createProductionOrder에 work_order_assignees 저장 로직 추가 - 담당자 유무에 따른 status 분기 (pending/unassigned) 적용 Co-Authored-By: Claude Opus 4.6 --- .../Order/CreateProductionOrderRequest.php | 2 ++ app/Services/OrderService.php | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/Order/CreateProductionOrderRequest.php b/app/Http/Requests/Order/CreateProductionOrderRequest.php index 6397981..cb21a1c 100644 --- a/app/Http/Requests/Order/CreateProductionOrderRequest.php +++ b/app/Http/Requests/Order/CreateProductionOrderRequest.php @@ -22,6 +22,8 @@ public function rules(): array 'priority' => 'nullable|string', 'process_type' => ['nullable', Rule::in(WorkOrder::PROCESS_TYPES)], 'assignee_id' => 'nullable|integer|exists:users,id', + 'assignee_ids' => 'nullable|array', + 'assignee_ids.*' => 'integer|exists:users,id', 'team_id' => 'nullable|integer|exists:departments,id', 'scheduled_date' => 'nullable|date', 'memo' => 'nullable|string', diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 13bdd0b..9ff6daa 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -1089,6 +1089,14 @@ public function createProductionOrder(int $orderId, array $data) return DB::transaction(function () use ($order, $data, $tenantId, $userId, $itemsByProcess, $nodesBomMap) { $workOrders = []; + // 담당자 ID 배열 처리 (assignee_ids 우선, fallback으로 assignee_id) + $assigneeIds = $data['assignee_ids'] ?? []; + if (empty($assigneeIds) && ! empty($data['assignee_id'])) { + $assigneeIds = [$data['assignee_id']]; + } + $assigneeIds = array_unique(array_filter($assigneeIds)); + $primaryAssigneeId = $assigneeIds[0] ?? null; + foreach ($itemsByProcess as $key => $group) { $processId = $group['process_id']; $items = $group['items']; @@ -1103,8 +1111,8 @@ public function createProductionOrder(int $orderId, array $data) 'sales_order_id' => $order->id, 'project_name' => $order->site_name ?? $order->client_name, 'process_id' => $processId, - 'status' => WorkOrder::STATUS_PENDING, - 'assignee_id' => $data['assignee_id'] ?? null, + 'status' => ! empty($assigneeIds) ? WorkOrder::STATUS_PENDING : WorkOrder::STATUS_UNASSIGNED, + 'assignee_id' => $primaryAssigneeId, 'team_id' => $data['team_id'] ?? null, 'scheduled_date' => $data['scheduled_date'] ?? $order->delivery_date, 'memo' => $data['memo'] ?? null, @@ -1113,6 +1121,15 @@ public function createProductionOrder(int $orderId, array $data) 'updated_by' => $userId, ]); + // 다중 담당자 저장 (work_order_assignees) + foreach ($assigneeIds as $index => $assigneeId) { + $workOrder->assignees()->create([ + 'tenant_id' => $tenantId, + 'user_id' => $assigneeId, + 'is_primary' => $index === 0, + ]); + } + // work_order_items에 아이템 추가 $sortOrder = 1; foreach ($items as $orderItem) {