summaryrefslogtreecommitdiff
path: root/lib/soap/utils.ts
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-08-25 07:18:26 +0000
committerjoonhoekim <26rote@gmail.com>2025-08-25 07:18:26 +0000
commit4a10344c046a8746744c311804f46bd60c0d8bd8 (patch)
tree06c46c0e7c61c057b1308d68efd79e1d58513113 /lib/soap/utils.ts
parent4249d57849ee4e9a39fce41a7dd434e7ca0b35e9 (diff)
(김준회) ECC 인터페이스 관련 작업사항
Diffstat (limited to 'lib/soap/utils.ts')
-rw-r--r--lib/soap/utils.ts54
1 files changed, 53 insertions, 1 deletions
diff --git a/lib/soap/utils.ts b/lib/soap/utils.ts
index 52c82d47..6c09edbe 100644
--- a/lib/soap/utils.ts
+++ b/lib/soap/utils.ts
@@ -322,7 +322,7 @@ export function createSuccessResponse(
*/
export async function replaceSubTableData<T extends Record<string, unknown>>(
tx: Parameters<Parameters<typeof db.transaction>[0]>[0],
- table: any, // Drizzle 테이블 객체 - 복잡한 제네릭 타입으로 인해 any 사용
+ table: any, // Drizzle 테이블 객체 - 동적 필드 접근을 위해 any 사용 (규칙에서 허용)
data: T[],
parentField: string,
parentValue: string
@@ -553,4 +553,56 @@ export async function logSoapExecution(
console.error('SOAP 로그 기록 실패:', error);
// 로그 기록 실패는 메인 로직에 영향을 주지 않도록 throw 하지 않음
}
+}
+
+// ========================================
+// SAP 데이터 포맷 변환 공통 함수들
+// ========================================
+
+/**
+ * 날짜 포맷 변환 헬퍼 함수 (YYYY-MM-DD -> YYYYMMDD)
+ * SAP 시스템에서 요구하는 DATS 타입 형식으로 변환
+ * @param dateString ISO 날짜 문자열 (YYYY-MM-DD)
+ * @returns SAP DATS 형식 문자열 (YYYYMMDD)
+ */
+export function formatDateForSAP(dateString: string): string {
+ return dateString.replace(/-/g, '');
+}
+
+/**
+ * 시간 포맷 변환 헬퍼 함수 (HH:MM:SS -> HHMMSS)
+ * SAP 시스템에서 요구하는 TIMS 타입 형식으로 변환
+ * @param timeString ISO 시간 문자열 (HH:MM:SS)
+ * @returns SAP TIMS 형식 문자열 (HHMMSS)
+ */
+export function formatTimeForSAP(timeString: string): string {
+ return timeString.replace(/:/g, '');
+}
+
+/**
+ * 현재 날짜를 SAP DATS 형식으로 반환
+ * @returns 현재 날짜의 SAP DATS 형식 (YYYYMMDD)
+ */
+export function getCurrentSAPDate(): string {
+ return formatDateForSAP(new Date().toISOString().slice(0, 10));
+}
+
+/**
+ * 현재 시간을 SAP TIMS 형식으로 반환
+ * @returns 현재 시간의 SAP TIMS 형식 (HHMMSS)
+ */
+export function getCurrentSAPTime(): string {
+ return formatTimeForSAP(new Date().toTimeString().slice(0, 8));
+}
+
+/**
+ * JavaScript Date 객체를 SAP 날짜/시간 형식으로 변환
+ * @param date JavaScript Date 객체
+ * @returns SAP 날짜/시간 형식 객체 { date: YYYYMMDD, time: HHMMSS }
+ */
+export function dateToSAPFormat(date: Date): { date: string; time: string } {
+ return {
+ date: formatDateForSAP(date.toISOString().slice(0, 10)),
+ time: formatTimeForSAP(date.toTimeString().slice(0, 8))
+ };
} \ No newline at end of file