summaryrefslogtreecommitdiff
path: root/lib/soap/ecc/mapper/common-mapper-utils.ts
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-11-17 15:47:07 +0900
committerjoonhoekim <26rote@gmail.com>2025-11-17 15:47:07 +0900
commita5be73b70e7d8e6be1724252e6923c664c3771f4 (patch)
treecc8942f867a8bdeb9d55a000d70f9ee44867b5a8 /lib/soap/ecc/mapper/common-mapper-utils.ts
parentb9f575f6110faabc7b062f84bf491d69d88a10a5 (diff)
(김준회) 입찰 매핑 안된 필드들 처리
Diffstat (limited to 'lib/soap/ecc/mapper/common-mapper-utils.ts')
-rw-r--r--lib/soap/ecc/mapper/common-mapper-utils.ts34
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 조회
*