diff options
Diffstat (limited to 'app/api/(S-ERP)/(ECC)')
| -rw-r--r-- | app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PO_INFORMATION/route.ts | 22 | ||||
| -rw-r--r-- | app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PR_INFORMATION/route.ts | 2 |
2 files changed, 20 insertions, 4 deletions
diff --git a/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PO_INFORMATION/route.ts b/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PO_INFORMATION/route.ts index 44ec3f36..c2b9db46 100644 --- a/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PO_INFORMATION/route.ts +++ b/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PO_INFORMATION/route.ts @@ -23,6 +23,10 @@ import { bulkUpsert, bulkReplaceSubTableData } from "@/lib/soap/batch-utils"; +import { + mapAndSaveECCPOData, + ProcessedPOData as POMapperProcessedData +} from "@/lib/soap/ecc/mapper/po-mapper"; // 스키마에서 타입 추론 type HeaderData = typeof ZMM_HD.$inferInsert; @@ -105,12 +109,24 @@ export async function POST(request: NextRequest) { } } - // 5) 데이터베이스 저장 + // 5) 원본 ECC 데이터 저장 (기존 로직 유지) await saveToDatabase(processedData); - console.log(`🎉 처리 완료: ${processedData.length}개 PO 데이터`); + // 6) PO 데이터를 비즈니스 테이블(contracts, contract_items)로 매핑 + // ProcessedPOData를 POMapperProcessedData 형식으로 변환 + const mappingData: POMapperProcessedData[] = processedData.map(poData => ({ + header: poData.header, + details: poData.details + })); + + const poMappingResult = await mapAndSaveECCPOData(mappingData); + if (!poMappingResult.success) { + throw new Error(`PO 비즈니스 테이블 매핑 실패: ${poMappingResult.message}`); + } + + console.log(`🎉 처리 완료: ${processedData.length}개 PO 데이터, ${poMappingResult.processedCount}개 계약 매핑`); - // 6) 성공 응답 반환 + // 7) 성공 응답 반환 return createSoapResponse('http://60.101.108.100/', { 'tns:IF_ECC_EVCP_PO_INFORMATIONRes': { EV_TYPE: 'S', diff --git a/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PR_INFORMATION/route.ts b/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PR_INFORMATION/route.ts index 4ae1bbda..6eddf757 100644 --- a/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PR_INFORMATION/route.ts +++ b/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PR_INFORMATION/route.ts @@ -20,7 +20,7 @@ import { } from "@/lib/soap/batch-utils"; import { mapAndSaveECCRfqData -} from "@/lib/soap/ecc-mapper"; +} from "@/lib/soap/ecc/mapper/rfq-and-pr-mapper"; // 스키마에서 타입 추론 |
