feat: [quote/quality] Phase 2B 견적 product_code 자동추출 + inspections work_order_id FK
- QuoteService: extractProductCodeFromInputs() 추가, store/update에서 자동 추출 - BackfillQuoteProductCodeCommand: 기존 quotes 25건 product_code 보정 - inspections 테이블에 work_order_id FK 마이그레이션 (nullable, nullOnDelete) - Inspection↔WorkOrder 양방향 관계 추가 - InspectionService: store/show/index에 work_order_id 처리 + transformToFrontend - InspectionStoreRequest: work_order_id 검증 규칙 추가
This commit is contained in:
@@ -33,7 +33,7 @@ public function index(array $params)
|
||||
|
||||
$query = Inspection::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->with(['inspector:id,name', 'item:id,item_name']);
|
||||
->with(['inspector:id,name', 'item:id,item_name', 'workOrder:id,work_order_no']);
|
||||
|
||||
// 검색어 (검사번호, LOT번호)
|
||||
if ($q !== '') {
|
||||
@@ -126,7 +126,7 @@ public function show(int $id)
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$inspection = Inspection::where('tenant_id', $tenantId)
|
||||
->with(['inspector:id,name', 'item:id,item_name'])
|
||||
->with(['inspector:id,name', 'item:id,item_name', 'workOrder:id,work_order_no'])
|
||||
->find($id);
|
||||
|
||||
if (! $inspection) {
|
||||
@@ -183,6 +183,7 @@ public function store(array $data)
|
||||
'inspection_type' => $data['inspection_type'],
|
||||
'request_date' => $data['request_date'] ?? now()->toDateString(),
|
||||
'lot_no' => $data['lot_no'],
|
||||
'work_order_id' => $data['work_order_id'] ?? null,
|
||||
'inspector_id' => $data['inspector_id'] ?? null,
|
||||
'meta' => $meta,
|
||||
'items' => $items,
|
||||
@@ -200,7 +201,7 @@ public function store(array $data)
|
||||
$inspection->toArray()
|
||||
);
|
||||
|
||||
return $this->transformToFrontend($inspection->load(['inspector:id,name']));
|
||||
return $this->transformToFrontend($inspection->load(['inspector:id,name', 'workOrder:id,work_order_no']));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -277,7 +278,7 @@ public function update(int $id, array $data)
|
||||
$inspection->fresh()->toArray()
|
||||
);
|
||||
|
||||
return $this->transformToFrontend($inspection->load(['inspector:id,name']));
|
||||
return $this->transformToFrontend($inspection->load(['inspector:id,name', 'workOrder:id,work_order_no']));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -360,7 +361,7 @@ public function complete(int $id, array $data)
|
||||
$inspection->fresh()->toArray()
|
||||
);
|
||||
|
||||
return $this->transformToFrontend($inspection->load(['inspector:id,name']));
|
||||
return $this->transformToFrontend($inspection->load(['inspector:id,name', 'workOrder:id,work_order_no']));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -380,6 +381,8 @@ private function transformToFrontend(Inspection $inspection): array
|
||||
'inspection_date' => $inspection->inspection_date?->format('Y-m-d'),
|
||||
'item_name' => $inspection->item?->item_name ?? ($meta['item_name'] ?? null),
|
||||
'lot_no' => $inspection->lot_no,
|
||||
'work_order_id' => $inspection->work_order_id,
|
||||
'work_order_no' => $inspection->workOrder?->work_order_no,
|
||||
'process_name' => $meta['process_name'] ?? null,
|
||||
'quantity' => $meta['quantity'] ?? null,
|
||||
'unit' => $meta['unit'] ?? null,
|
||||
|
||||
Reference in New Issue
Block a user