fix: [production] 절곡 중간검사 수주 단위 데이터 공유 모델 적용

- 로드 경로: 절곡 공정 시 어떤 item이든 inspection_data 있으면 모든 개소에 공유
- 저장 경로: 절곡 검사 완료 시 inspectionDataMap에 모든 workItem 동기화
- TemplateInspectionContent: products 배열 우선 복원 (EAV 문서 데이터보다 우선)
- workOrderId prop 추가 (절곡 gap_points API 동적 로딩)
This commit is contained in:
2026-03-04 23:27:12 +09:00
parent b05e19e9f8
commit b45c35a5e8
2 changed files with 43 additions and 15 deletions

View File

@@ -626,12 +626,11 @@ export const TemplateInspectionContent = forwardRef<InspectionContentRef, Templa
// ===== Bending: inspectionDataMap의 products 배열에서 셀 값 복원 =====
// InspectionInputModal이 저장한 products 배열 → bending 셀 키로 매핑
// ★ inspectionDataMap의 products가 있으면 documentRecords(EAV)보다 우선
// (입력 모달에서 방금 저장한 신규 데이터가 이전 문서 데이터보다 최신)
useEffect(() => {
if (!isBending || !inspectionDataMap || !workItems || bendingProducts.length === 0) return;
// EAV 문서 데이터가 있으면 우선 (이미 위 useEffect에서 복원됨)
if (documentRecords && documentRecords.length > 0) return;
// inspectionDataMap에서 products 배열 찾기
type SavedProduct = {
id: string;

View File

@@ -875,20 +875,39 @@ export default function WorkerScreen() {
const completionUpdates: Record<string, boolean> = {};
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}
/>
</PageLayout>
);