summaryrefslogtreecommitdiff
path: root/app/api
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-08-25 07:20:26 +0000
committerjoonhoekim <26rote@gmail.com>2025-08-25 07:20:26 +0000
commitfe924e1581fff24a91d65b33313bd3f39499bd72 (patch)
tree9b5f7b26db3079ce0a10fc6f57700a78e678c00d /app/api
parent4a10344c046a8746744c311804f46bd60c0d8bd8 (diff)
(김준회) ECC 인터페이스 관련 작업사항2 (PO, PR 수신부 관련)
Diffstat (limited to 'app/api')
-rw-r--r--app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PO_INFORMATION/route.ts22
-rw-r--r--app/api/(S-ERP)/(ECC)/IF_ECC_EVCP_PR_INFORMATION/route.ts2
-rw-r--r--app/api/(S-ERP)/(MDG)/IF_MDZ_EVCP_PROJECT_MASTER/route.ts18
3 files changed, 35 insertions, 7 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";
// 스키마에서 타입 추론
diff --git a/app/api/(S-ERP)/(MDG)/IF_MDZ_EVCP_PROJECT_MASTER/route.ts b/app/api/(S-ERP)/(MDG)/IF_MDZ_EVCP_PROJECT_MASTER/route.ts
index fd7fb027..a1a016c2 100644
--- a/app/api/(S-ERP)/(MDG)/IF_MDZ_EVCP_PROJECT_MASTER/route.ts
+++ b/app/api/(S-ERP)/(MDG)/IF_MDZ_EVCP_PROJECT_MASTER/route.ts
@@ -15,6 +15,9 @@ import {
withSoapLogging
} from "@/lib/soap/utils";
import { bulkUpsert } from "@/lib/soap/batch-utils"; // 서브테이블 없음
+import {
+ mapAndSaveMDGProjectData
+} from "@/lib/soap/mdg/mapper/project-mapper";
// 스키마에서 직접 타입 추론
@@ -51,7 +54,7 @@ export async function POST(request: NextRequest) {
'IF_MDZ_EVCP_PROJECT_MASTER',
body,
async () => {
- console.log('Request Body 일부:', body.substring(0, 200) + (body.length > 200 ? '...' : ''));
+ console.log('🚀 PROJECT_MASTER 수신 시작, 데이터 길이:', body.length);
const parser = createXMLParser(['CMCTB_PROJ_MAST']);
const parsedData = parser.parse(body);
@@ -83,10 +86,19 @@ export async function POST(request: NextRequest) {
}
}
- // 데이터베이스 저장
+ // 1) 원본 MDG 데이터 저장 (기존 로직 유지)
await saveToDatabase(processedProjects);
- console.log(`Processed ${processedProjects.length} projects`);
+ // 2) 비즈니스 테이블 projects에 매핑하여 저장
+ const projectMappingResult = await mapAndSaveMDGProjectData(
+ processedProjects.map(p => p.project)
+ );
+
+ if (!projectMappingResult.success) {
+ throw new Error(`프로젝트 비즈니스 테이블 매핑 실패: ${projectMappingResult.message}`);
+ }
+
+ console.log(`🎉 처리 완료: ${processedProjects.length}개 프로젝트, ${projectMappingResult.processedCount}개 비즈니스 테이블 매핑`);
return createSuccessResponse('http://60.101.108.100/api/IF_MDZ_EVCP_PROJECT_MASTER/');
}