fix: [QMS] 로트심사 서류 목록 개선
- 작업일지/중간검사: 인식 가능한 공정만 표시, 공정별 그룹핑 - 중간검사 detail: PQC Inspection 대신 WorkOrder 기반으로 변경 - 문서 아이템 표시 개선 (공정명, 작업지시번호, 문서번호 추가) - 루트 정보에 거래처(client) 필드 추가 - location에 document 관계 eager loading 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -82,13 +82,14 @@ public function show(int $id): array
|
||||
}
|
||||
|
||||
/**
|
||||
* 수주 루트별 8종 서류 목록 (Document[])
|
||||
* 수주 로트별 8종 서류 목록 (Document[])
|
||||
*/
|
||||
public function routeDocuments(int $qualityDocumentOrderId): array
|
||||
{
|
||||
$docOrder = QualityDocumentOrder::with([
|
||||
'order.workOrders.process',
|
||||
'locations.orderItem',
|
||||
'locations.document',
|
||||
'qualityDocument',
|
||||
])->findOrFail($qualityDocumentOrderId);
|
||||
|
||||
@@ -118,20 +119,15 @@ public function routeDocuments(int $qualityDocumentOrderId): array
|
||||
// 2. 수주서
|
||||
$documents[] = $this->formatDocument('order', '수주서', collect([$order]));
|
||||
|
||||
// 3. 작업일지 (공정별 1개씩 — 같은 공정의 WO는 그룹핑)
|
||||
$workOrdersByProcess = $workOrders->groupBy('process_id')->map(fn ($group) => $group->first());
|
||||
$documents[] = $this->formatDocumentWithSubType('log', '작업일지', $workOrdersByProcess);
|
||||
// 3. 작업일지 & 4. 중간검사 성적서 (인식 가능한 공정만 — 공정별 1개씩)
|
||||
$recognizedWorkOrders = $workOrders->filter(function ($wo) {
|
||||
$subType = $this->mapProcessToSubType($wo->process?->process_name);
|
||||
|
||||
// 4. 중간검사 성적서 (PQC — 공정별 1개씩)
|
||||
$pqcInspections = Inspection::where('inspection_type', 'PQC')
|
||||
->whereIn('work_order_id', $workOrders->pluck('id'))
|
||||
->with('workOrder.process')
|
||||
->get();
|
||||
return $subType !== null;
|
||||
})->groupBy('process_id')->map(fn ($group) => $group->first());
|
||||
|
||||
// 공정별 그룹핑 (같은 공정의 PQC는 최신 1개만)
|
||||
$pqcByProcess = $pqcInspections->groupBy(fn ($insp) => $insp->workOrder?->process_id)
|
||||
->map(fn ($group) => $group->sortByDesc('inspection_date')->first());
|
||||
$documents[] = $this->formatDocumentWithSubType('report', '중간검사 성적서', $pqcByProcess, 'workOrder');
|
||||
$documents[] = $this->formatDocumentWithSubType('log', '작업일지', $recognizedWorkOrders);
|
||||
$documents[] = $this->formatDocumentWithSubType('report', '중간검사 성적서', $recognizedWorkOrders);
|
||||
|
||||
// 5. 납품확인서
|
||||
$shipments = $order->shipments()->get();
|
||||
@@ -161,7 +157,7 @@ public function documentDetail(string $type, int $id): array
|
||||
'import' => $this->getInspectionDetail($id, 'IQC'),
|
||||
'order' => $this->getOrderDetail($id),
|
||||
'log' => $this->getWorkOrderLogDetail($id),
|
||||
'report' => $this->getInspectionDetail($id, 'PQC'),
|
||||
'report' => $this->getWorkOrderLogDetail($id),
|
||||
'confirmation', 'shipping' => $this->getShipmentDetail($id),
|
||||
'product' => $this->getLocationDetail($id),
|
||||
'quality' => $this->getQualityDocDetail($id),
|
||||
@@ -240,6 +236,7 @@ private function transformRouteToFrontend(QualityDocumentOrder $docOrder, Qualit
|
||||
'id' => (string) $docOrder->id,
|
||||
'code' => $docOrder->order->order_no,
|
||||
'date' => $docOrder->order->received_at?->toDateString(),
|
||||
'client' => $docOrder->order->client_name ?? '',
|
||||
'site' => $docOrder->order->site_name ?? '',
|
||||
'location_count' => $docOrder->locations->count(),
|
||||
'sub_items' => $docOrder->locations->values()->map(fn ($loc, $idx) => [
|
||||
@@ -317,12 +314,18 @@ private function formatDocumentWithSubType(string $type, string $title, $collect
|
||||
private function formatDocumentItem(string $type, $item): array
|
||||
{
|
||||
return match ($type) {
|
||||
'import', 'report' => [
|
||||
'import' => [
|
||||
'id' => (string) $item->id,
|
||||
'title' => $item->inspection_no ?? '',
|
||||
'date' => $item->inspection_date?->toDateString() ?? $item->request_date?->toDateString() ?? '',
|
||||
'code' => $item->inspection_no ?? '',
|
||||
],
|
||||
'report' => [
|
||||
'id' => (string) $item->id,
|
||||
'title' => $item->process?->process_name ?? '중간검사 성적서',
|
||||
'date' => $item->created_at?->toDateString() ?? '',
|
||||
'code' => $item->work_order_no ?? '',
|
||||
],
|
||||
'order' => [
|
||||
'id' => (string) $item->id,
|
||||
'title' => $item->order_no,
|
||||
@@ -331,9 +334,9 @@ private function formatDocumentItem(string $type, $item): array
|
||||
],
|
||||
'log' => [
|
||||
'id' => (string) $item->id,
|
||||
'title' => $item->project_name ?? '작업일지',
|
||||
'title' => $item->process?->process_name ?? '작업일지',
|
||||
'date' => $item->created_at?->toDateString() ?? '',
|
||||
'code' => $item->id,
|
||||
'code' => $item->work_order_no ?? '',
|
||||
],
|
||||
'confirmation', 'shipping' => [
|
||||
'id' => (string) $item->id,
|
||||
@@ -345,7 +348,7 @@ private function formatDocumentItem(string $type, $item): array
|
||||
'id' => (string) $item->id,
|
||||
'title' => trim(($item->orderItem?->floor_code ?? '').' '.($item->orderItem?->symbol_code ?? '')) ?: '제품검사 성적서',
|
||||
'date' => $item->updated_at?->toDateString() ?? '',
|
||||
'code' => '',
|
||||
'code' => $item->document?->document_no ?? '',
|
||||
],
|
||||
'quality' => [
|
||||
'id' => (string) $item->id,
|
||||
|
||||
Reference in New Issue
Block a user