From b45c35a5e86b770d339fa14a638cf6240d89c5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Wed, 4 Mar 2026 23:27:12 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[production]=20=EC=A0=88=EA=B3=A1=20?= =?UTF-8?q?=EC=A4=91=EA=B0=84=EA=B2=80=EC=82=AC=20=EC=88=98=EC=A3=BC=20?= =?UTF-8?q?=EB=8B=A8=EC=9C=84=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EA=B3=B5?= =?UTF-8?q?=EC=9C=A0=20=EB=AA=A8=EB=8D=B8=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 로드 경로: 절곡 공정 시 어떤 item이든 inspection_data 있으면 모든 개소에 공유 - 저장 경로: 절곡 검사 완료 시 inspectionDataMap에 모든 workItem 동기화 - TemplateInspectionContent: products 배열 우선 복원 (EAV 문서 데이터보다 우선) - workOrderId prop 추가 (절곡 gap_points API 동적 로딩) --- .../documents/TemplateInspectionContent.tsx | 5 +- .../production/WorkerScreen/index.tsx | 53 ++++++++++++++----- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/components/production/WorkOrders/documents/TemplateInspectionContent.tsx b/src/components/production/WorkOrders/documents/TemplateInspectionContent.tsx index eafb1b78..d14c2b4d 100644 --- a/src/components/production/WorkOrders/documents/TemplateInspectionContent.tsx +++ b/src/components/production/WorkOrders/documents/TemplateInspectionContent.tsx @@ -626,12 +626,11 @@ export const TemplateInspectionContent = forwardRef { if (!isBending || !inspectionDataMap || !workItems || bendingProducts.length === 0) return; - // EAV 문서 데이터가 있으면 우선 (이미 위 useEffect에서 복원됨) - if (documentRecords && documentRecords.length > 0) return; - // inspectionDataMap에서 products 배열 찾기 type SavedProduct = { id: string; diff --git a/src/components/production/WorkerScreen/index.tsx b/src/components/production/WorkerScreen/index.tsx index 8e6c8fec..422a3bca 100644 --- a/src/components/production/WorkerScreen/index.tsx +++ b/src/components/production/WorkerScreen/index.tsx @@ -875,20 +875,39 @@ export default function WorkerScreen() { const completionUpdates: Record = {}; setInspectionDataMap((prev) => { const next = new Map(prev); - for (const apiItem of result.data!.items) { - if (!apiItem.inspection_data) continue; - // workItems에서 apiItemId가 일치하는 항목 찾기 - const match = workItems.find((w) => w.apiItemId === apiItem.item_id); - if (match) { - next.set(match.id, apiItem.inspection_data as unknown as InspectionData); - // 검사 step 완료 처리 (실제 step name 사용) - const inspStep = match.steps.find((s) => s.isInspection || s.needsInspection); - if (inspStep) { - const stepKey = `${match.id.replace('-node-', '-')}-${inspStep.name}`; - completionUpdates[stepKey] = true; + + // 절곡 공정: 수주 단위 검사 → 어떤 item이든 inspection_data 있으면 모든 개소가 공유 + const isBendingProcess = workItems.some(w => w.processType === 'bending'); + if (isBendingProcess) { + const bendingItem = result.data!.items.find(i => i.inspection_data); + if (bendingItem?.inspection_data) { + for (const w of workItems) { + next.set(w.id, bendingItem.inspection_data as unknown as InspectionData); + const inspStep = w.steps.find((s) => s.isInspection || s.needsInspection); + if (inspStep) { + const stepKey = `${w.id.replace('-node-', '-')}-${inspStep.name}`; + completionUpdates[stepKey] = true; + } + } + } + } else { + // 기존: item별 개별 매칭 + for (const apiItem of result.data!.items) { + if (!apiItem.inspection_data) continue; + // workItems에서 apiItemId가 일치하는 항목 찾기 + const match = workItems.find((w) => w.apiItemId === apiItem.item_id); + if (match) { + next.set(match.id, apiItem.inspection_data as unknown as InspectionData); + // 검사 step 완료 처리 (실제 step name 사용) + const inspStep = match.steps.find((s) => s.isInspection || s.needsInspection); + if (inspStep) { + const stepKey = `${match.id.replace('-node-', '-')}-${inspStep.name}`; + completionUpdates[stepKey] = true; + } } } } + return next; }); // stepCompletionMap 일괄 업데이트 @@ -1348,9 +1367,18 @@ export default function WorkerScreen() { `${selectedOrder.id.replace('-node-', '-')}-${stepName}`; // 메모리에 즉시 반영 + // 절곡: 수주 단위 검사 → 모든 개소가 동일한 검사 데이터 공유 + const inspProcessType = getInspectionProcessType(); + const isBendingInsp = inspProcessType === 'bending' || inspProcessType === 'bending_wip'; setInspectionDataMap((prev) => { const next = new Map(prev); - next.set(selectedOrder.id, data); + if (isBendingInsp) { + for (const w of workItems) { + next.set(w.id, data); + } + } else { + next.set(selectedOrder.id, data); + } return next; }); @@ -1817,6 +1845,7 @@ export default function WorkerScreen() { onComplete={handleInspectionComplete} templateData={inspectionTemplateData} workItemDimensions={inspectionDimensions} + workOrderId={workItems.find(w => w.id === selectedOrder?.id)?.workOrderId} /> );