diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-19 17:44:48 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-19 17:44:48 +0900 |
| commit | 60382940bac4ac8309be64be16f4774b6820df22 (patch) | |
| tree | 976909a239b0712de59131ee10055735568447fc /lib/soap/ecc/mapper/common-mapper-utils.ts | |
| parent | ec74a7862eb33a9da1e3d6ba2877d5b9662dbfca (diff) | |
(김준회) PR 데이터 수신시 Spec 정보도 넣어주도록 수정
Diffstat (limited to 'lib/soap/ecc/mapper/common-mapper-utils.ts')
| -rw-r--r-- | lib/soap/ecc/mapper/common-mapper-utils.ts | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/lib/soap/ecc/mapper/common-mapper-utils.ts b/lib/soap/ecc/mapper/common-mapper-utils.ts index ed655e0e..9141a29f 100644 --- a/lib/soap/ecc/mapper/common-mapper-utils.ts +++ b/lib/soap/ecc/mapper/common-mapper-utils.ts @@ -14,7 +14,7 @@ import { debugLog, debugSuccess, debugError } from '@/lib/debug-utils'; import db from '@/db/db'; import { users, vendors } from '@/db/schema'; import { projects } from '@/db/schema/projects'; -import { EQUP_MASTER_MATL_CHARASGN } from '@/db/schema/MDG/mdg'; +import { EQUP_MASTER_MATL_CHARASGN, MATERIAL_MASTER_PART_MATL } from '@/db/schema/MDG/mdg'; import { eq } from 'drizzle-orm'; import { oracleKnex } from '@/lib/oracle-db/db'; @@ -386,4 +386,37 @@ export async function findVendorIdByLIFNR(lifnr: string | null | undefined): Pro debugError('Vendor 조회 중 오류 발생', { lifnr, error }); return null; } +} + +/** + * Specification 조회 함수 (MATNR 기반) + * MATNR을 기반으로 MATERIAL_MASTER_PART_MATL 테이블에서 ZZSPEC 조회 + */ +export async function findSpecificationByMATNR(MATNR: string | null): Promise<string | null> { + try { + debugLog('Specification 조회 시작', { MATNR }); + + if (!MATNR) { + debugError('MATNR이 null 또는 undefined', { MATNR }); + return null; + } + + const specResult = await db + .select({ ZZSPEC: MATERIAL_MASTER_PART_MATL.ZZSPEC }) + .from(MATERIAL_MASTER_PART_MATL) + .where(eq(MATERIAL_MASTER_PART_MATL.MATNR, MATNR)) + .limit(1); + + if (specResult.length === 0) { + debugLog('MATNR에 해당하는 Specification을 찾을 수 없음', { MATNR }); + return null; + } + + const specification = specResult[0].ZZSPEC; + debugSuccess('Specification 조회 완료', { MATNR, specification }); + return specification; + } catch (error) { + debugError('Specification 조회 중 오류 발생', { MATNR, error }); + return null; + } }
\ No newline at end of file |
