diff options
Diffstat (limited to 'app/api')
| -rw-r--r-- | app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PCR/route.ts | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PCR/route.ts b/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PCR/route.ts index 623fa29e..2e6f1729 100644 --- a/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PCR/route.ts +++ b/app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PCR/route.ts @@ -13,6 +13,9 @@ import { import { bulkUpsert } from "@/lib/soap/batch-utils"; +import { + mapAndSaveECCPcrData, +} from '@/lib/soap/ecc/mapper/pcr-mapper'; type PCRData = typeof ZMM_PCR.$inferInsert; @@ -65,12 +68,23 @@ export async function POST(request: NextRequest) { } } - // 5) 데이터베이스 저장 + // 5) 데이터베이스 저장 (ZMM_PCR 수신 테이블) await saveToDatabase(processedData); - console.log(`🎉 처리 완료: ${processedData.length}개 PCR 데이터`); + console.log(`🎉 ZMM_PCR 저장 완료: ${processedData.length}개 PCR 데이터`); + + // 6) 비즈니스 테이블로 매핑 및 저장 (pcrPo, pcrPr) + console.log('📋 비즈니스 테이블 매핑 시작...'); + const mappingResult = await mapAndSaveECCPcrData(processedData); + + if (mappingResult.success) { + console.log(`✅ 비즈니스 테이블 매핑 완료: ${mappingResult.processedCount}개 PCR`); + } else { + console.error(`❌ 비즈니스 테이블 매핑 실패: ${mappingResult.message}`); + // 매핑 실패해도 수신 테이블에는 저장되었으므로 경고만 출력 + } - // 6) 성공 응답 반환 - 각 PCR 데이터에 대해 ZMM_RT 객체 생성 + // 7) 성공 응답 반환 - 각 PCR 데이터에 대해 ZMM_RT 객체 생성 const responseZmmRtList = processedData.map((pcrData) => ({ PCR_REQ: pcrData.PCR_REQ || '', PCR_REQ_SEQ: pcrData.PCR_REQ_SEQ || '', |
