fix: [생산지시] 날짜포맷·개소수·자재투입 시 자동 상태전환
- ProductionOrderService: production_ordered_at를 Y-m-d 포맷으로 변환
- ProductionOrderService: withCount('nodes')로 개소수(node_count) 응답 추가
- WorkOrderService: autoStartWorkOrderOnMaterialInput() 신규 메서드
- 자재투입 시 WO가 unassigned/pending/waiting이면 in_progress로 자동 전환
- syncOrderStatus()로 Order도 IN_PRODUCTION 동기화
- Swagger: node_count 필드 문서화, 날짜 포맷 수정
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@ public function index(array $params): LengthAwarePaginator
|
||||
->where('tenant_id', $tenantId)
|
||||
->whereIn('status_code', self::PRODUCTION_STATUSES)
|
||||
->with(['client', 'workOrders.process', 'workOrders.assignees.user'])
|
||||
->withCount('workOrders');
|
||||
->withCount(['workOrders', 'nodes']);
|
||||
|
||||
// 검색어 필터
|
||||
if (! empty($params['search'])) {
|
||||
@@ -71,7 +71,13 @@ public function index(array $params): LengthAwarePaginator
|
||||
|
||||
// 가공 필드 추가
|
||||
$result->getCollection()->transform(function (Order $order) {
|
||||
$order->production_ordered_at = $order->workOrders->min('created_at');
|
||||
$minCreatedAt = $order->workOrders->min('created_at');
|
||||
$order->production_ordered_at = $minCreatedAt
|
||||
? $minCreatedAt->format('Y-m-d')
|
||||
: null;
|
||||
|
||||
// 개소수 (order_nodes 수)
|
||||
$order->node_count = $order->nodes_count ?? 0;
|
||||
|
||||
$workOrders = $order->workOrders;
|
||||
$order->work_order_progress = [
|
||||
@@ -138,10 +144,14 @@ public function show(int $orderId): array
|
||||
'workOrders.assignees.user',
|
||||
'nodes',
|
||||
])
|
||||
->withCount('nodes')
|
||||
->findOrFail($orderId);
|
||||
|
||||
// 생산지시일
|
||||
$order->production_ordered_at = $order->workOrders->min('created_at');
|
||||
// 생산지시일 (날짜만)
|
||||
$minCreatedAt = $order->workOrders->min('created_at');
|
||||
$order->production_ordered_at = $minCreatedAt
|
||||
? $minCreatedAt->format('Y-m-d')
|
||||
: null;
|
||||
$order->production_status = $this->mapProductionStatus($order->status_code);
|
||||
|
||||
// WorkOrder 진행 현황
|
||||
@@ -171,6 +181,7 @@ public function show(int $orderId): array
|
||||
'order' => $order->makeHidden(['workOrders', 'nodes']),
|
||||
'production_ordered_at' => $order->production_ordered_at,
|
||||
'production_status' => $order->production_status,
|
||||
'node_count' => $order->nodes_count ?? 0,
|
||||
'work_order_progress' => $workOrderProgress,
|
||||
'work_orders' => $workOrders,
|
||||
'bom_process_groups' => $bomProcessGroups,
|
||||
|
||||
Reference in New Issue
Block a user