feat: [생산지시] 재고생산 보조 공정 일반 워크플로우에서 분리

- Process P-004 options에 is_auxiliary 플래그 도입
- WO 생성 시 Process의 is_auxiliary를 WO options에 자동 복사
- ProductionOrderService: 보조 공정 WO를 공정 진행 현황에서 제외
- WorkOrderService: 보조 공정 WO의 상태 변경이 수주 상태에 영향 주지 않도록 처리
  - syncOrderStatus(): 보조 공정이면 스킵
  - autoStartWorkOrderOnMaterialInput(): WO는 진행중 전환하되 수주 상태는 유지

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 20:05:54 +09:00
parent 38c2402771
commit 0aa0a8592d
3 changed files with 62 additions and 8 deletions

View File

@@ -82,8 +82,8 @@ public function index(array $params): LengthAwarePaginator
// 개소수 (order_nodes 수)
$order->node_count = $order->nodes_count ?? 0;
// 생산 공정이 있는 WO만 (구매품/서비스 제외)
$productionWOs = $order->workOrders->filter(fn ($wo) => ! empty($wo->process_id));
// 주요 생산 공정 WO만 (구매품 + 보조 공정 제외)
$productionWOs = $this->filterMainProductionWOs($order->workOrders);
$order->work_order_progress = [
'total' => $productionWOs->count(),
'completed' => $productionWOs->where('status', 'completed')->count()
@@ -158,8 +158,8 @@ public function show(int $orderId): array
: null;
$order->production_status = $this->mapProductionStatus($order->status_code);
// 생산 공정이 있는 WorkOrder만 필터 (process_id가 null인 구매품/서비스 제외)
$productionWorkOrders = $order->workOrders->filter(fn ($wo) => ! empty($wo->process_id));
// 주요 생산 공정 WO만 필터 (구매품 + 보조 공정 제외)
$productionWorkOrders = $this->filterMainProductionWOs($order->workOrders);
// WorkOrder 진행 현황 (생산 공정 기준)
$workOrderProgress = [
@@ -261,4 +261,23 @@ private function extractBomProcessGroups($nodes): array
return array_values($groups);
}
/**
* 주요 생산 공정 WO만 필터 (구매품/서비스 + 보조 공정 제외)
*
* 제외 대상:
* - process_id가 null인 WO (구매품/서비스)
* - options.is_auxiliary가 true인 WO (재고생산 등 보조 공정)
*/
private function filterMainProductionWOs($workOrders): \Illuminate\Support\Collection
{
return $workOrders->filter(function ($wo) {
if (empty($wo->process_id)) {
return false;
}
$options = is_array($wo->options) ? $wo->options : (json_decode($wo->options, true) ?? []);
return empty($options['is_auxiliary']);
});
}
}