diff options
Diffstat (limited to 'lib/soap/ecc/mapper/common-mapper-utils.ts')
| -rw-r--r-- | lib/soap/ecc/mapper/common-mapper-utils.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/soap/ecc/mapper/common-mapper-utils.ts b/lib/soap/ecc/mapper/common-mapper-utils.ts index cf5e0fdb..2199490a 100644 --- a/lib/soap/ecc/mapper/common-mapper-utils.ts +++ b/lib/soap/ecc/mapper/common-mapper-utils.ts @@ -169,6 +169,40 @@ export async function findProjectInfoByPSPID(PSPID: string | null): Promise<{ } /** + * 프로젝트 정보 조회 함수 (PSPID 기반으로 ID만 반환) + * PSPID(Project Code)와 projects.code 매칭하여 프로젝트 ID 반환 + */ +export async function findProjectIdByPSPID(PSPID: string | null): Promise<number | null> { + try { + debugLog('프로젝트 ID 찾기 시작 (PSPID 기준)', { PSPID }); + + if (!PSPID) { + debugError('PSPID가 null 또는 undefined', { PSPID }); + return null; + } + + const projectResult = await db + .select({ + id: projects.id + }) + .from(projects) + .where(eq(projects.code, PSPID)) + .limit(1); + + if (projectResult.length === 0) { + debugError('PSPID에 해당하는 프로젝트를 찾을 수 없음', { PSPID }); + return null; + } + + debugSuccess('프로젝트 ID 찾음', { PSPID, projectId: projectResult[0].id }); + return projectResult[0].id; + } catch (error) { + debugError('프로젝트 ID 찾기 중 오류 발생', { PSPID, error }); + return null; + } +} + +/** * 자재명 조회 함수 (MATNR 기반) * MATNR을 기반으로 EQUP_MASTER_MATL_CHARASGN 테이블에서 ATWTB 조회 * |
