summaryrefslogtreecommitdiff
path: root/lib/soap/ecc/send/pcr-confirm.ts
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-08-27 01:52:54 +0000
committerjoonhoekim <26rote@gmail.com>2025-08-27 01:52:54 +0000
commit818a500d9969d1c03098f612bb0b68502b6a5ae2 (patch)
treed1b52f040972696993502dfa8a71f7bb1bc89cc2 /lib/soap/ecc/send/pcr-confirm.ts
parentf61e9e9c6ea5b415d64ecb9f703a0633a5029da4 (diff)
(김준회) soap sender 함수 오류수정 및 벤더마스터 전송함수 리팩터링
Diffstat (limited to 'lib/soap/ecc/send/pcr-confirm.ts')
-rw-r--r--lib/soap/ecc/send/pcr-confirm.ts240
1 files changed, 4 insertions, 236 deletions
diff --git a/lib/soap/ecc/send/pcr-confirm.ts b/lib/soap/ecc/send/pcr-confirm.ts
index 46d1a909..72d4a574 100644
--- a/lib/soap/ecc/send/pcr-confirm.ts
+++ b/lib/soap/ecc/send/pcr-confirm.ts
@@ -64,7 +64,7 @@ export interface PCRConfirmResponse {
// SOAP Body Content 생성 함수
function createPCRConfirmSoapBodyContent(pcrData: PCRConfirmRequest): Record<string, unknown> {
return {
- 'ns0:MT_P2MM3019_S': {
+ 'p1:MT_P2MM3019_S': { // WSDL에서 사용하는 p1 접두사 적용
'ZMM_PCR': pcrData.ZMM_PCR
}
};
@@ -168,7 +168,8 @@ async function sendPCRConfirmToECC(pcrData: PCRConfirmRequest): Promise<SoapSend
timeout: 30000, // PCR 확인은 30초 타임아웃
retryCount: 3,
retryDelay: 1000,
- namespace: 'http://shi.samsung.co.kr/P2_MM/MMM' // ECC MM 모듈 네임스페이스
+ namespace: 'http://shi.samsung.co.kr/P2_MM/MMM', // ECC MM 모듈 네임스페이스
+ prefix: 'p1' // WSDL에서 사용하는 p1 접두사
};
// 로그 정보
@@ -447,237 +448,4 @@ export async function confirmTestPCR(): Promise<{
}
}
-// ========================================
-// 유틸리티 함수들
-// ========================================
-
-// PCR 확인 데이터 생성 헬퍼 함수
-function createPCRConfirmData(pcrItems: Array<{
- PCR_REQ: string;
- PCR_REQ_SEQ: string;
- PCR_DEC_DATE: string;
- EBELN: string;
- EBELP: string;
- PCR_STATUS: string;
- WAERS?: string;
- PCR_NETPR?: string;
- PEINH?: string;
- PCR_NETWR?: string;
- REJ_CD?: string;
- REJ_RSN?: string;
- CONFIRM_CD?: string;
- CONFIRM_RSN?: string;
-}>): PCRConfirmRequest {
- return {
- ZMM_PCR: pcrItems
- };
-}
-
-// PCR 요청번호 검증 함수
-function validatePCRNumber(pcrReq: string): { isValid: boolean; error?: string } {
- if (!pcrReq || typeof pcrReq !== 'string') {
- return { isValid: false, error: 'PCR 요청번호는 문자열이어야 합니다.' };
- }
-
- const trimmed = pcrReq.trim();
- if (trimmed === '') {
- return { isValid: false, error: 'PCR 요청번호는 비어있을 수 없습니다.' };
- }
-
- // 기본적인 길이 검증 (10자 제한 - WSDL에서 CHAR 10으로 정의)
- if (trimmed.length > 10) {
- return { isValid: false, error: 'PCR 요청번호는 10자를 초과할 수 없습니다.' };
- }
-
- return { isValid: true };
-}
-
-// PCR 요청순번 검증 함수
-function validatePCRSequence(pcrReqSeq: string): { isValid: boolean; error?: string } {
- if (!pcrReqSeq || typeof pcrReqSeq !== 'string') {
- return { isValid: false, error: 'PCR 요청순번은 문자열이어야 합니다.' };
- }
-
- const trimmed = pcrReqSeq.trim();
- if (trimmed === '') {
- return { isValid: false, error: 'PCR 요청순번은 비어있을 수 없습니다.' };
- }
-
- // 숫자 형식 검증 (NUMC 5자리)
- if (!/^\d{1,5}$/.test(trimmed)) {
- return { isValid: false, error: 'PCR 요청순번은 1-5자리 숫자여야 합니다.' };
- }
-
- return { isValid: true };
-}
-
-// PCR 결정일 검증 함수
-function validatePCRDecisionDate(pcrDecDate: string): { isValid: boolean; error?: string } {
- if (!pcrDecDate || typeof pcrDecDate !== 'string') {
- return { isValid: false, error: 'PCR 결정일은 문자열이어야 합니다.' };
- }
-
- const trimmed = pcrDecDate.trim();
- if (trimmed === '') {
- return { isValid: false, error: 'PCR 결정일은 비어있을 수 없습니다.' };
- }
-
- // YYYYMMDD 형식 검증
- if (!/^\d{8}$/.test(trimmed)) {
- return { isValid: false, error: 'PCR 결정일은 YYYYMMDD 형식이어야 합니다.' };
- }
-
- // 날짜 유효성 검증
- const year = parseInt(trimmed.substring(0, 4));
- const month = parseInt(trimmed.substring(4, 6));
- const day = parseInt(trimmed.substring(6, 8));
-
- if (month < 1 || month > 12) {
- return { isValid: false, error: 'PCR 결정일의 월이 올바르지 않습니다.' };
- }
-
- if (day < 1 || day > 31) {
- return { isValid: false, error: 'PCR 결정일의 일이 올바르지 않습니다.' };
- }
-
- // 실제 날짜 검증
- const date = new Date(year, month - 1, day);
- if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) {
- return { isValid: false, error: 'PCR 결정일이 유효하지 않은 날짜입니다.' };
- }
-
- return { isValid: true };
-}
-
-// PCR 상태 검증 함수
-function validatePCRStatus(pcrStatus: string): { isValid: boolean; error?: string } {
- if (!pcrStatus || typeof pcrStatus !== 'string') {
- return { isValid: false, error: 'PCR 상태는 문자열이어야 합니다.' };
- }
-
- const trimmed = pcrStatus.trim();
- if (trimmed === '') {
- return { isValid: false, error: 'PCR 상태는 비어있을 수 없습니다.' };
- }
-
- if (trimmed.length !== 1) {
- return { isValid: false, error: 'PCR 상태는 1자리여야 합니다.' };
- }
-
- return { isValid: true };
-}
-
-// 구매오더 검증 함수
-function validatePurchaseOrder(ebeln: string): { isValid: boolean; error?: string } {
- if (!ebeln || typeof ebeln !== 'string') {
- return { isValid: false, error: '구매오더는 문자열이어야 합니다.' };
- }
-
- const trimmed = ebeln.trim();
- if (trimmed === '') {
- return { isValid: false, error: '구매오더는 비어있을 수 없습니다.' };
- }
-
- if (trimmed.length > 10) {
- return { isValid: false, error: '구매오더는 10자를 초과할 수 없습니다.' };
- }
-
- return { isValid: true };
-}
-
-// 구매오더 품번 검증 함수
-function validatePurchaseOrderItem(ebelp: string): { isValid: boolean; error?: string } {
- if (!ebelp || typeof ebelp !== 'string') {
- return { isValid: false, error: '구매오더 품번은 문자열이어야 합니다.' };
- }
-
- const trimmed = ebelp.trim();
- if (trimmed === '') {
- return { isValid: false, error: '구매오더 품번은 비어있을 수 없습니다.' };
- }
-
- // 숫자 형식 검증 (NUMC 5자리)
- if (!/^\d{1,5}$/.test(trimmed)) {
- return { isValid: false, error: '구매오더 품번은 1-5자리 숫자여야 합니다.' };
- }
-
- return { isValid: true };
-}
-
-// 통화 검증 함수
-function validateCurrency(waers?: string): { isValid: boolean; error?: string } {
- if (!waers) {
- return { isValid: true }; // 선택 필드
- }
-
- if (typeof waers !== 'string') {
- return { isValid: false, error: '통화는 문자열이어야 합니다.' };
- }
-
- const trimmed = waers.trim();
- if (trimmed.length > 5) {
- return { isValid: false, error: '통화는 5자를 초과할 수 없습니다.' };
- }
-
- return { isValid: true };
-}
-
-// 여러 PCR 아이템 검증 함수
-function validatePCRItems(pcrItems: Array<{
- PCR_REQ: string;
- PCR_REQ_SEQ: string;
- PCR_DEC_DATE: string;
- EBELN: string;
- EBELP: string;
- PCR_STATUS: string;
- WAERS?: string;
-}>): { isValid: boolean; errors: string[] } {
- const errors: string[] = [];
-
- if (!Array.isArray(pcrItems) || pcrItems.length === 0) {
- errors.push('최소 1개 이상의 PCR 아이템이 필요합니다.');
- return { isValid: false, errors };
- }
-
- pcrItems.forEach((item, index) => {
- const pcrReqValid = validatePCRNumber(item.PCR_REQ);
- if (!pcrReqValid.isValid) {
- errors.push(`PCR[${index}] 요청번호: ${pcrReqValid.error}`);
- }
-
- const pcrSeqValid = validatePCRSequence(item.PCR_REQ_SEQ);
- if (!pcrSeqValid.isValid) {
- errors.push(`PCR[${index}] 요청순번: ${pcrSeqValid.error}`);
- }
-
- const pcrDateValid = validatePCRDecisionDate(item.PCR_DEC_DATE);
- if (!pcrDateValid.isValid) {
- errors.push(`PCR[${index}] 결정일: ${pcrDateValid.error}`);
- }
-
- const eBelnValid = validatePurchaseOrder(item.EBELN);
- if (!eBelnValid.isValid) {
- errors.push(`PCR[${index}] 구매오더: ${eBelnValid.error}`);
- }
-
- const eBelpValid = validatePurchaseOrderItem(item.EBELP);
- if (!eBelpValid.isValid) {
- errors.push(`PCR[${index}] 구매오더품번: ${eBelpValid.error}`);
- }
-
- const statusValid = validatePCRStatus(item.PCR_STATUS);
- if (!statusValid.isValid) {
- errors.push(`PCR[${index}] 상태: ${statusValid.error}`);
- }
-
- const currencyValid = validateCurrency(item.WAERS);
- if (!currencyValid.isValid) {
- errors.push(`PCR[${index}] 통화: ${currencyValid.error}`);
- }
- });
-
- return {
- isValid: errors.length === 0,
- errors
- };
-}
+// 사용하지 않는 유틸리티 함수들 삭제 (linter 오류 해결)