summaryrefslogtreecommitdiff
path: root/components/common/selectors/wbs-code/wbs-code-service.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-11-24 11:16:32 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-11-24 11:16:32 +0000
commita8674e6b91fb4d356c311fad0251878de154da53 (patch)
tree8bdf91ef99b2628f319df37912ccede1e2f5009c /components/common/selectors/wbs-code/wbs-code-service.ts
parent68160eba15a2c8408329b6e14b94d5e44fa7e3ab (diff)
(최겸) 구매 입찰 수정(폐찰, 낙찰 결재 기능 추가 등)
Diffstat (limited to 'components/common/selectors/wbs-code/wbs-code-service.ts')
-rw-r--r--components/common/selectors/wbs-code/wbs-code-service.ts48
1 files changed, 13 insertions, 35 deletions
diff --git a/components/common/selectors/wbs-code/wbs-code-service.ts b/components/common/selectors/wbs-code/wbs-code-service.ts
index 7d9c17b1..6ceedcb7 100644
--- a/components/common/selectors/wbs-code/wbs-code-service.ts
+++ b/components/common/selectors/wbs-code/wbs-code-service.ts
@@ -4,54 +4,35 @@ import { oracleKnex } from '@/lib/oracle-db/db'
// WBS 코드 타입 정의
export interface WbsCode {
- PROJ_NO: string // 프로젝트 번호
WBS_ELMT: string // WBS 요소
WBS_ELMT_NM: string // WBS 요소명
- WBS_LVL: string // WBS 레벨
}
// 테스트 환경용 폴백 데이터
const FALLBACK_TEST_DATA: WbsCode[] = [
- { PROJ_NO: 'SN2661', WBS_ELMT: 'WBS001', WBS_ELMT_NM: 'WBS 항목 1(테스트데이터 - 오라클 페칭 실패시)', WBS_LVL: '1' },
- { PROJ_NO: 'SN2661', WBS_ELMT: 'WBS002', WBS_ELMT_NM: 'WBS 항목 2(테스트데이터 - 오라클 페칭 실패시)', WBS_LVL: '2' },
- { PROJ_NO: 'SN2661', WBS_ELMT: 'WBS003', WBS_ELMT_NM: 'WBS 항목 3(테스트데이터 - 오라클 페칭 실패시)', WBS_LVL: '1' },
- { PROJ_NO: 'SN2661', WBS_ELMT: 'WBS004', WBS_ELMT_NM: 'WBS 항목 4(테스트데이터 - 오라클 페칭 실패시)', WBS_LVL: '2' },
- { PROJ_NO: 'SN2661', WBS_ELMT: 'WBS005', WBS_ELMT_NM: 'WBS 항목 5(테스트데이터 - 오라클 페칭 실패시)', WBS_LVL: '3' },
+ { WBS_ELMT: 'WBS001', WBS_ELMT_NM: 'WBS 항목 1' },
+ { WBS_ELMT: 'WBS002', WBS_ELMT_NM: 'WBS 항목 2' },
+ { WBS_ELMT: 'WBS003', WBS_ELMT_NM: 'WBS 항목 3' },
+ { WBS_ELMT: 'WBS004', WBS_ELMT_NM: 'WBS 항목 4' },
+ { WBS_ELMT: 'WBS005', WBS_ELMT_NM: 'WBS 항목 5' },
]
/**
* WBS 코드 목록 조회 (Oracle에서 전체 조회, 실패 시 폴백 데이터 사용)
* CMCTB_PROJ_WBS 테이블에서 조회
- * @param projNo - 프로젝트 번호 (선택적, 없으면 전체 조회)
*/
-export async function getWbsCodes(projNo?: string): Promise<{
+export async function getWbsCodes(): Promise<{
success: boolean
data: WbsCode[]
error?: string
isUsingFallback?: boolean
}> {
try {
- console.log('📋 [getWbsCodes] Oracle 쿼리 시작...', projNo ? `프로젝트: ${projNo}` : '전체')
+ console.log('📋 [getWbsCodes] Oracle 쿼리 시작...')
- let query = `
- SELECT
- PROJ_NO,
- WBS_ELMT,
- WBS_ELMT_NM,
- WBS_LVL
- FROM CMCTB_PROJ_WBS
- WHERE ROWNUM < 100
- `
-
- if (projNo) {
- query += ` AND PROJ_NO = :projNo`
- }
-
- query += ` ORDER BY PROJ_NO, WBS_ELMT`
-
- const result = projNo
- ? await oracleKnex.raw(query, { projNo })
- : await oracleKnex.raw(query)
+ const result = await oracleKnex.raw(`
+ SELECT WBS_ELMT,WBS_ELMT_NM FROM CMCTB_PROJ_WBS WHERE ROWNUM < 30 AND PROJ_NO = 'SN2673'
+ `)
// Oracle raw query의 결과는 rows 배열에 들어있음
const rows = (result.rows || result) as Array<Record<string, unknown>>
@@ -60,16 +41,13 @@ export async function getWbsCodes(projNo?: string): Promise<{
// null 값 필터링
const cleanedResult = rows
- .filter((item) =>
- item.PROJ_NO &&
- item.WBS_ELMT &&
+ .filter((item) =>
+ item.WBS_ELMT &&
item.WBS_ELMT_NM
)
.map((item) => ({
- PROJ_NO: String(item.PROJ_NO),
WBS_ELMT: String(item.WBS_ELMT),
- WBS_ELMT_NM: String(item.WBS_ELMT_NM),
- WBS_LVL: String(item.WBS_LVL || '')
+ WBS_ELMT_NM: String(item.WBS_ELMT_NM)
}))
console.log(`✅ [getWbsCodes] 필터링 후 ${cleanedResult.length}건`)