From 66a75746f3d76ea01a4a949716728031c41cb6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Wed, 18 Mar 2026 20:33:32 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[bending]=20=EC=9B=90=EC=9E=90=EC=9E=AC?= =?UTF-8?q?=20LOT=20=EC=A1=B0=ED=9A=8C=20=EC=9E=AC=EC=A7=88=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - status 필터 확장: completed → completed + inspection_completed - 재질 키워드 분해 검색: "EGI 1.55T" → "EGI" AND "1.55" (공백/T 무관) - 기존: LIKE "%EGI 1.55T%" → 매칭 실패 (실제 데이터: "EGI1.55") --- .../Controllers/Api/V1/BendingController.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/V1/BendingController.php b/app/Http/Controllers/Api/V1/BendingController.php index 9c92750f..4b7f4b58 100644 --- a/app/Http/Controllers/Api/V1/BendingController.php +++ b/app/Http/Controllers/Api/V1/BendingController.php @@ -58,24 +58,33 @@ public function resolveItem(Request $request): JsonResponse } /** - * 원자재 LOT 목록 조회 (수입검사 완료 입고 기준) + * 원자재 LOT 목록 조회 (입고 + 수입검사 완료 기준) * - * 재질(material)이 일치하는 입고 LOT 목록 반환 + * 재질(material) 키워드를 분해하여 유연 검색 + * 예: "EGI 1.55T" → "EGI" AND "1.55" 로 검색 (공백/T 무관) */ public function materialLots(Request $request): JsonResponse { return ApiResponse::handle(function () use ($request) { $material = $request->query('material'); - $query = Receiving::where('status', 'completed') + $query = Receiving::whereIn('status', ['completed', 'inspection_completed']) ->whereNotNull('lot_no') ->where('lot_no', '!=', ''); - // 재질(item_name 또는 specification)으로 필터링 + // 재질 키워드 분해 검색 (공백/T 접미사 무관) if ($material) { - $query->where(function ($q) use ($material) { - $q->where('item_name', 'LIKE', "%{$material}%") - ->orWhere('specification', 'LIKE', "%{$material}%"); + // "EGI 1.55T" → ["EGI", "1.55"], "SUS 1.2T" → ["SUS", "1.2"] + $keywords = preg_split('/[\s]+/', preg_replace('/T$/i', '', trim($material))); + $keywords = array_filter($keywords); + + $query->where(function ($q) use ($keywords) { + foreach ($keywords as $kw) { + $q->where(function ($sub) use ($kw) { + $sub->where('item_name', 'LIKE', "%{$kw}%") + ->orWhere('specification', 'LIKE', "%{$kw}%"); + }); + } }); }