summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/soap/mdg/send/vendor-master/action.ts123
1 files changed, 52 insertions, 71 deletions
diff --git a/lib/soap/mdg/send/vendor-master/action.ts b/lib/soap/mdg/send/vendor-master/action.ts
index 46d6e71f..b353eab0 100644
--- a/lib/soap/mdg/send/vendor-master/action.ts
+++ b/lib/soap/mdg/send/vendor-master/action.ts
@@ -143,6 +143,14 @@ export async function sendVendorMasterToMDG(vendorCodes: string[]): Promise<{
const soapData = buildSoapData(vendorData);
console.log(`๐Ÿ“„ VENDOR ${vendorCode} SOAP ๋ฐ์ดํ„ฐ ์ƒ์„ฑ ์™„๋ฃŒ`);
+ // ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ๊ฒ€์ฆ (๋””๋ฒ„๊น…์šฉ)
+ const validation = validateSoapDataStructure(soapData);
+ if (!validation.isValid) {
+ console.warn(`โš ๏ธ VENDOR ${vendorCode} ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ๋ฌธ์ œ:`, validation.issues);
+ } else {
+ console.log(`โœ… VENDOR ${vendorCode} ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ๊ฒ€์ฆ ํ†ต๊ณผ`);
+ }
+
// SOAP ํด๋ผ์ด์–ธํŠธ๋กœ ์š”์ฒญ ์ „์†ก
await withSoapLogging(
'OUTBOUND',
@@ -311,11 +319,10 @@ function buildSoapData(vendorData: NonNullable<Awaited<ReturnType<typeof fetchVe
supplierMaster[f.field] = mapping[f.field] ?? '';
});
- // SOAP ์š”์ฒญ ๊ตฌ์กฐ ์ƒ์„ฑ
+ // SOAP ์š”์ฒญ ๊ตฌ์กฐ ์ƒ์„ฑ (P2MD3007_S ์ค‘๋ณต ์ œ๊ฑฐ)
+ // SOAP ํด๋ผ์ด์–ธํŠธ๊ฐ€ MT_P2MD3007_S๋กœ ๋ž˜ํ•‘ํ•˜๋ฏ€๋กœ, ์—ฌ๊ธฐ์„œ๋Š” SUPPLIER_MASTER๋งŒ ๋ฐ˜ํ™˜
return {
- P2MD3007_S: {
- SUPPLIER_MASTER: supplierMaster
- }
+ SUPPLIER_MASTER: supplierMaster
};
}
@@ -570,6 +577,34 @@ export async function sendRecentModifiedVendorsToMDG(
}
}
+// SOAP ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ๊ฒ€์ฆ ์œ ํ‹ธ๋ฆฌํ‹ฐ ํ•จ์ˆ˜
+export function validateSoapDataStructure(soapData: Record<string, unknown>): {
+ isValid: boolean;
+ structure: string;
+ issues: string[];
+} {
+ const issues: string[] = [];
+
+ // ์˜ฌ๋ฐ”๋ฅธ ๊ตฌ์กฐ์ธ์ง€ ํ™•์ธ
+ if (!soapData.SUPPLIER_MASTER) {
+ issues.push('SUPPLIER_MASTER ํ•„๋“œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.');
+ }
+
+ // P2MD3007_S ์ค‘๋ณต ํ™•์ธ (์ด์ œ๋Š” ์—†์–ด์•ผ ํ•จ)
+ if (soapData.P2MD3007_S) {
+ issues.push('P2MD3007_S ๋ž˜ํ•‘์ด ๋ฐœ๊ฒฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ค‘๋ณต ๊ตฌ์กฐ๋กœ ์ธํ•ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.');
+ }
+
+ // ๊ตฌ์กฐ ์ถœ๋ ฅ
+ const structure = JSON.stringify(soapData, null, 2);
+
+ return {
+ isValid: issues.length === 0,
+ structure,
+ issues
+ };
+}
+
// ํ†ต๊ณ„ ์กฐํšŒ ์œ ํ‹ธ๋ฆฌํ‹ฐ ํ•จ์ˆ˜
export async function getVendorSendStatistics(): Promise<{
total: number;
@@ -668,13 +703,23 @@ export async function sendTestVendorDataToMDG(formData: Record<string, string>):
// SOAP ์š”์ฒญ ๊ตฌ์กฐ ์ƒ์„ฑ
const soapData = {
- P2MD3007_S: {
- SUPPLIER_MASTER: supplierMaster
- }
+ SUPPLIER_MASTER: supplierMaster
};
console.log('๐Ÿ“„ ํ…Œ์ŠคํŠธ SOAP ๋ฐ์ดํ„ฐ ์ƒ์„ฑ ์™„๋ฃŒ');
+ // ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ๊ฒ€์ฆ (๋””๋ฒ„๊น…์šฉ)
+ const validation = validateSoapDataStructure(soapData);
+ if (!validation.isValid) {
+ console.warn('โš ๏ธ ํ…Œ์ŠคํŠธ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ๋ฌธ์ œ:', validation.issues);
+ return {
+ success: false,
+ message: `๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ์˜ค๋ฅ˜: ${validation.issues.join(', ')}`
+ };
+ } else {
+ console.log('โœ… ํ…Œ์ŠคํŠธ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ ๊ฒ€์ฆ ํ†ต๊ณผ');
+ }
+
// SOAP ํด๋ผ์ด์–ธํŠธ๋กœ ์š”์ฒญ ์ „์†ก
const responseData = await withSoapLogging(
'OUTBOUND',
@@ -712,68 +757,4 @@ export async function sendTestVendorDataToMDG(formData: Record<string, string>):
}
}
-// ์ง์ ‘ XML ์ „์†ก ํ•จ์ˆ˜ (๊ธฐ์กด ํ˜ธํ™˜์„ฑ ์œ ์ง€)
-export async function sendVendorEnvelopeToMDG(envelope: string): Promise<{
- success: boolean;
- message: string;
- responseText?: string;
-}> {
- try {
- const responseText = await withSoapLogging(
- 'OUTBOUND',
- 'MDG',
- 'IF_MDZ_EVCP_VENDOR_MASTER_TEST', // ํ…Œ์ŠคํŠธ์šฉ ์ธํ„ฐํŽ˜์ด์Šค๋ช…
- envelope,
- async () => {
- // ์ง์ ‘ XML ์ „์†ก์˜ ๊ฒฝ์šฐ ๊ธฐ์กด fetch ๋ฐฉ์‹ ์œ ์ง€
- const MDG_ENDPOINT_URL = "http://shii8dvddb01.hec.serp.shi.samsung.net:50000/sap/xi/engine?type=entry&version=3.0&Sender.Service=P2038_Q&Interface=http%3A%2F%2Fshi.samsung.co.kr%2FP2_MD%2FMDZ%5EP2MD3007_AO&QualityOfService=ExactlyOnce";
-
- // ์ธ์ฆ ํ—ค๋” ์ค€๋น„
- const headers: Record<string, string> = {
- 'Content-Type': 'text/xml; charset=utf-8',
- 'SOAPAction': 'http://sap.com/xi/WebService/soap1.1',
- };
-
- // Basic Authentication ํ—ค๋” ์ถ”๊ฐ€
- if (MDG_SOAP_USERNAME && MDG_SOAP_PASSWORD) {
- const credentials = Buffer.from(`${MDG_SOAP_USERNAME}:${MDG_SOAP_PASSWORD}`).toString('base64');
- headers['Authorization'] = `Basic ${credentials}`;
- console.log('๐Ÿ” Basic Authentication ํ—ค๋” ์ถ”๊ฐ€ ์™„๋ฃŒ');
- } else {
- console.warn('โš ๏ธ MDG SOAP ์ธ์ฆ ์ •๋ณด๊ฐ€ ํ™˜๊ฒฝ๋ณ€์ˆ˜์— ์„ค์ •๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.');
- }
-
- const res = await fetch(MDG_ENDPOINT_URL, {
- method: 'POST',
- headers,
- body: envelope,
- });
-
- const text = await res.text();
-
- if (!res.ok) {
- throw new Error(`HTTP ${res.status}: ${res.statusText}`);
- }
-
- // SOAP Fault ๊ฒ€์‚ฌ
- if (text.includes('soap:Fault') || text.includes('SOAP:Fault')) {
- throw new Error(`MDG SOAP Fault: ${text}`);
- }
-
- return text;
- }
- );
- return {
- success: true,
- message: '์ „์†ก ์„ฑ๊ณต',
- responseText,
- };
- } catch (error) {
- console.error('XML ์ „์†ก ์‹คํŒจ:', error);
- return {
- success: false,
- message: error instanceof Error ? error.message : 'Unknown error',
- };
- }
-}