From 54686cfc8a71e2d9cfc8d68996e124f6aea5e051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 13 Mar 2026 18:54:37 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[work-order]=20=EC=83=9D=EC=82=B0?= =?UTF-8?q?=EC=A7=80=EC=8B=9C=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20=EB=B6=80?= =?UTF-8?q?=EC=84=9C/=EC=9A=B0=EC=84=A0=EC=88=9C=EC=9C=84=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=20=EB=A7=A4=ED=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - team_id 미지정 시 공정 담당부서에서 자동 매핑 - priority 문자열→숫자 변환 (urgent=1, high=4, normal=7) - 부서/담당자 배정 시 작업대기(waiting) 상태로 설정 --- app/Services/OrderService.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index c3df77a..3138d18 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -1346,6 +1346,21 @@ public function createProductionOrder(int $orderId, array $data) } } + // team_id 결정: 명시적 전달값 > 공정 담당부서 자동 매핑 + $teamId = $data['team_id'] ?? null; + if (! $teamId && $process && $process->department) { + $teamId = DB::table('departments') + ->where('tenant_id', $tenantId) + ->where('name', $process->department) + ->value('id'); + } + + // priority 결정: 문자열 → 숫자 변환 (urgent=1, high=4, normal=7) + $priorityMap = ['urgent' => 1, 'high' => 4, 'normal' => 7]; + $priority = is_numeric($data['priority'] ?? null) + ? (int) $data['priority'] + : ($priorityMap[$data['priority'] ?? 'normal'] ?? 7); + // 작업지시 생성 $workOrder = WorkOrder::create([ 'tenant_id' => $tenantId, @@ -1353,9 +1368,10 @@ public function createProductionOrder(int $orderId, array $data) 'sales_order_id' => $order->id, 'project_name' => $order->site_name ?? $order->client_name, 'process_id' => $processId, - 'status' => ! empty($assigneeIds) ? WorkOrder::STATUS_PENDING : WorkOrder::STATUS_UNASSIGNED, + 'status' => (! empty($assigneeIds) || $teamId) ? WorkOrder::STATUS_WAITING : WorkOrder::STATUS_UNASSIGNED, + 'priority' => $priority, 'assignee_id' => $primaryAssigneeId, - 'team_id' => $data['team_id'] ?? null, + 'team_id' => $teamId, 'scheduled_date' => $data['scheduled_date'] ?? $order->delivery_date, 'memo' => $data['memo'] ?? null, 'options' => $workOrderOptions,