fix:생산지시 생성 시 다중 담당자(assignee_ids) 저장 누락 수정
- CreateProductionOrderRequest에 assignee_ids 배열 validation 추가 - OrderService::createProductionOrder에 work_order_assignees 저장 로직 추가 - 담당자 유무에 따른 status 분기 (pending/unassigned) 적용 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user