diff options
| author | joonhoekim <26rote@gmail.com> | 2025-08-11 09:34:40 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-08-11 09:34:40 +0000 |
| commit | bcd462d6e60871b86008e072f4b914138fc5c328 (patch) | |
| tree | c22876fd6c6e7e48254587848b9dff50cdb8b032 /app/api | |
| parent | cbb4c7fe0b94459162ad5e998bc05cd293e0ff96 (diff) | |
(김준회) 리치텍스트에디터 (결재템플릿을 위한 공통컴포넌트), command-menu 에러 수정, 결재 템플릿 관리, 결재선 관리, ECC RFQ+PR Item 수신시 비즈니스테이블(ProcurementRFQ) 데이터 적재, WSDL 오류 수정
Diffstat (limited to 'app/api')
| -rw-r--r-- | app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PR_INFORMATION/route.ts | 42 |
1 files changed, 38 insertions, 4 deletions
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 fdf0c8d4..4ae1bbda 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 @@ -11,8 +11,6 @@ import { extractRequestData, convertXMLToDBData, processNestedArray, - createErrorResponse, - createSuccessResponse, createSoapResponse, withSoapLogging, } from '@/lib/soap/utils'; @@ -20,6 +18,9 @@ import { bulkUpsert, bulkReplaceSubTableData } from "@/lib/soap/batch-utils"; +import { + mapAndSaveECCRfqData +} from "@/lib/soap/ecc-mapper"; // 스키마에서 타입 추론 @@ -90,10 +91,43 @@ export async function POST(request: NextRequest) { } } - // 5) 데이터베이스 저장 + // 5) 원본 ECC 데이터 저장 (기존 로직 유지) await saveToDatabase(processedData); - console.log(`🎉 처리 완료: ${processedData.length}개 PR 데이터`); + // 6) ZBSART에 따라 비즈니스 테이블 분기 처리 + const anHeaders: BidHeaderData[] = []; + const abHeaders: BidHeaderData[] = []; + const anItems: BidItemData[] = []; + const abItems: BidItemData[] = []; + + // ZBSART에 따라 데이터 분류 + for (const prData of processedData) { + if (prData.bidHeader.ZBSART === 'AN') { + anHeaders.push(prData.bidHeader); + anItems.push(...prData.bidItems); + } else if (prData.bidHeader.ZBSART === 'AB') { + abHeaders.push(prData.bidHeader); + abItems.push(...prData.bidItems); + } + } + + // AN (RFQ) 데이터 처리 - procurementRfqs 테이블 + let rfqMappingResult = null; + if (anHeaders.length > 0) { + rfqMappingResult = await mapAndSaveECCRfqData(anHeaders, anItems); + if (!rfqMappingResult.success) { + throw new Error(`RFQ 비즈니스 테이블 매핑 실패: ${rfqMappingResult.message}`); + } + } + + // AB (Bidding) 데이터 처리 - TODO + if (abHeaders.length > 0) { + console.log(`⚠️ TODO: Bidding 데이터 처리 필요 - ${abHeaders.length}개 헤더, ${abItems.length}개 아이템`); + // TODO: mapAndSaveECCBiddingData 함수 구현 필요 + // const biddingMappingResult = await mapAndSaveECCBiddingData(abHeaders, abItems); + } + + console.log(`🎉 처리 완료: ${processedData.length}개 PR 데이터, ${rfqMappingResult?.processedCount || 0}개 RFQ 매핑, ${abHeaders.length}개 Bidding (TODO)`); // 6) 성공 응답 반환 return createSoapResponse('http://60.101.108.100/', { |
