From 9f3b8915ab20f177edafd3c4a4cc1ca0da0fc766 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 13 Jun 2025 07:22:04 +0000 Subject: (최겸) 기술영업 아이템 수정(컬럼명 및 item table FK 삭제, rfq에서 사용하는 service 수정) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/items-tech/service.ts | 966 +++++++++++---------- lib/items-tech/table/add-items-dialog.tsx | 24 +- lib/items-tech/table/hull/import-item-handler.tsx | 10 +- lib/items-tech/table/hull/item-excel-template.tsx | 6 +- .../table/hull/offshore-hull-table-columns.tsx | 12 +- lib/items-tech/table/import-excel-button.tsx | 16 +- lib/items-tech/table/ship/Items-ship-table.tsx | 4 +- lib/items-tech/table/ship/import-item-handler.tsx | 76 +- lib/items-tech/table/ship/item-excel-template.tsx | 36 +- .../table/ship/items-ship-table-columns.tsx | 8 +- .../table/ship/items-table-toolbar-actions.tsx | 4 +- lib/items-tech/table/top/import-item-handler.tsx | 10 +- lib/items-tech/table/top/item-excel-template.tsx | 6 +- .../table/top/offshore-top-table-columns.tsx | 12 +- lib/items-tech/table/update-items-sheet.tsx | 58 +- lib/items-tech/validations.ts | 42 +- 16 files changed, 579 insertions(+), 711 deletions(-) (limited to 'lib/items-tech') diff --git a/lib/items-tech/service.ts b/lib/items-tech/service.ts index a14afa14..be65f5dd 100644 --- a/lib/items-tech/service.ts +++ b/lib/items-tech/service.ts @@ -9,17 +9,50 @@ import { unstable_cache } from "@/lib/unstable-cache"; import { getErrorMessage } from "@/lib/handle-error"; import { asc, desc, ilike, and, or, eq, count, inArray, sql } from "drizzle-orm"; -import { GetShipbuildingSchema, GetOffshoreTopSchema, GetOffshoreHullSchema, UpdateItemSchema, ShipbuildingItemCreateData, TypedItemCreateData, OffshoreTopItemCreateData, OffshoreHullItemCreateData } from "./validations"; -import { Item, items, itemShipbuilding, itemOffshoreTop, itemOffshoreHull, ItemOffshoreTop, ItemOffshoreHull } from "@/db/schema/items"; -import { findAllItems } from "./repository"; -import { findAllOffshoreItems } from "./repository"; +import { GetShipbuildingSchema, GetOffshoreTopSchema, GetOffshoreHullSchema, ShipbuildingItemCreateData, TypedItemCreateData, OffshoreTopItemCreateData, OffshoreHullItemCreateData } from "./validations"; +import { itemShipbuilding, itemOffshoreTop, itemOffshoreHull } from "@/db/schema/items"; + +// 타입 정의 추가 +type WorkType = '기장' | '전장' | '선실' | '배관' | '철의'; +type OffshoreTopWorkType = 'TM' | 'TS' | 'TE' | 'TP'; +type OffshoreHullWorkType = 'HA' | 'HE' | 'HH' | 'HM' | 'NC'; + +interface ShipbuildingItem { + id: number; + itemCode: string; + workType: WorkType; + itemList: string; + shipTypes: string; + createdAt: Date; + updatedAt: Date; +} + +interface OffshoreTopTechItem { + id: number; + itemCode: string; + workType: OffshoreTopWorkType; + itemList: string; + subItemList?: string; + createdAt: Date; + updatedAt: Date; +} + +interface OffshoreHullTechItem { + id: number; + itemCode: string; + workType: OffshoreHullWorkType; + itemList: string; + subItemList?: string; + createdAt: Date; + updatedAt: Date; +} /* ----------------------------------------------------- 1) 조회 관련 ----------------------------------------------------- */ /** - * 복잡한 조건으로 Item 목록을 조회 (+ pagination) 하고, + * 복잡한 조건으로 조선 아이템 목록을 조회 (+ pagination) 하고, * 총 개수에 따라 pageCount를 계산해서 리턴. * Next.js의 unstable_cache를 사용해 일정 시간 캐시. */ @@ -31,27 +64,21 @@ export async function getShipbuildingItems(input: GetShipbuildingSchema) { // advancedTable 모드면 filterColumns()로 where 절 구성 const advancedWhere = filterColumns({ - table: items, + table: itemShipbuilding, filters: input.filters.filter(filter => { // enum 필드에 대한 isEmpty/isNotEmpty는 제외 return !((filter.id === 'workType' || filter.id === 'shipTypes') && (filter.operator === 'isEmpty' || filter.operator === 'isNotEmpty')) }), joinOperator: input.joinOperator, - joinedTables: { itemShipbuilding }, - customColumnMapping: { - workType: { table: itemShipbuilding, column: "workType" }, - shipTypes: { table: itemShipbuilding, column: "shipTypes" }, - itemList: { table: itemShipbuilding, column: "itemList" }, - }, }); let globalWhere; if (input.search) { const s = `%${input.search}%`; globalWhere = or( - ilike(items.itemCode, s), - ilike(itemShipbuilding.itemList, s) + ilike(itemShipbuilding.itemCode, s), + ilike(itemShipbuilding.itemList, s), ); } @@ -75,27 +102,22 @@ export async function getShipbuildingItems(input: GetShipbuildingSchema) { const orderBy = input.sort.length > 0 ? input.sort.map((item) => { - const column = item.id === "workType" || item.id === "shipTypes" || item.id === "itemList" - ? itemShipbuilding[item.id] - : items[item.id]; + const column = itemShipbuilding[item.id]; return item.desc ? desc(column) : asc(column); }) - : [desc(items.createdAt)]; + : [desc(itemShipbuilding.createdAt)]; - // 조선 아이템 테이블과 기본 아이템 테이블 조인하여 조회 + // 조선 아이템 테이블만 조회 (독립적) const result = await db.select({ id: itemShipbuilding.id, - itemCode: items.itemCode, + itemCode: itemShipbuilding.itemCode, workType: itemShipbuilding.workType, shipTypes: itemShipbuilding.shipTypes, itemList: itemShipbuilding.itemList, - itemName: items.itemName, - description: items.description, createdAt: itemShipbuilding.createdAt, updatedAt: itemShipbuilding.updatedAt, }) .from(itemShipbuilding) - .innerJoin(items, eq(itemShipbuilding.itemCode, items.itemCode)) .where(where) .orderBy(...orderBy) .offset(offset) @@ -106,7 +128,6 @@ export async function getShipbuildingItems(input: GetShipbuildingSchema) { count: count() }) .from(itemShipbuilding) - .innerJoin(items, eq(itemShipbuilding.itemCode, items.itemCode)) .where(where); const pageCount = Math.ceil(Number(total) / input.perPage); @@ -133,26 +154,20 @@ export async function getOffshoreTopItems(input: GetOffshoreTopSchema) { // advancedTable 모드면 filterColumns()로 where 절 구성 const advancedWhere = filterColumns({ - table: items, + table: itemOffshoreTop, filters: input.filters.filter(filter => { // enum 필드에 대한 isEmpty/isNotEmpty는 제외 return !((filter.id === 'workType') && (filter.operator === 'isEmpty' || filter.operator === 'isNotEmpty')) }), joinOperator: input.joinOperator, - joinedTables: { itemOffshoreTop }, - customColumnMapping: { - workType: { table: itemOffshoreTop, column: "workType" }, - itemList: { table: itemOffshoreTop, column: "itemList" }, - subItemList: { table: itemOffshoreTop, column: "subItemList" }, - }, }); let globalWhere; if (input.search) { const s = `%${input.search}%`; globalWhere = or( - ilike(items.itemCode, s), + ilike(itemOffshoreTop.itemCode, s), ilike(itemOffshoreTop.itemList, s), ilike(itemOffshoreTop.subItemList, s) ); @@ -178,27 +193,22 @@ export async function getOffshoreTopItems(input: GetOffshoreTopSchema) { const orderBy = input.sort.length > 0 ? input.sort.map((item) => { - const column = item.id === "workType" || item.id === "itemList" || item.id === "subItemList" - ? itemOffshoreTop[item.id] - : items[item.id]; + const column = itemOffshoreTop[item.id]; return item.desc ? desc(column) : asc(column); }) - : [desc(items.createdAt)]; + : [desc(itemOffshoreTop.createdAt)]; - // 해양 TOP 아이템 테이블과 기본 아이템 테이블 조인하여 조회 + // 해양 TOP 아이템 테이블만 조회 (독립적) const result = await db.select({ id: itemOffshoreTop.id, - itemCode: items.itemCode, + itemCode: itemOffshoreTop.itemCode, workType: itemOffshoreTop.workType, itemList: itemOffshoreTop.itemList, subItemList: itemOffshoreTop.subItemList, - itemName: items.itemName, - description: items.description, createdAt: itemOffshoreTop.createdAt, updatedAt: itemOffshoreTop.updatedAt, }) .from(itemOffshoreTop) - .innerJoin(items, eq(itemOffshoreTop.itemCode, items.itemCode)) .where(where) .orderBy(...orderBy) .offset(offset) @@ -209,7 +219,6 @@ export async function getOffshoreTopItems(input: GetOffshoreTopSchema) { count: count() }) .from(itemOffshoreTop) - .innerJoin(items, eq(itemOffshoreTop.itemCode, items.itemCode)) .where(where); const pageCount = Math.ceil(Number(total) / input.perPage); @@ -236,26 +245,20 @@ export async function getOffshoreHullItems(input: GetOffshoreHullSchema) { // advancedTable 모드면 filterColumns()로 where 절 구성 const advancedWhere = filterColumns({ - table: items, + table: itemOffshoreHull, filters: input.filters.filter(filter => { // enum 필드에 대한 isEmpty/isNotEmpty는 제외 return !((filter.id === 'workType') && (filter.operator === 'isEmpty' || filter.operator === 'isNotEmpty')) }), joinOperator: input.joinOperator, - joinedTables: { itemOffshoreHull }, - customColumnMapping: { - workType: { table: itemOffshoreHull, column: "workType" }, - itemList: { table: itemOffshoreHull, column: "itemList" }, - subItemList: { table: itemOffshoreHull, column: "subItemList" }, - }, }); let globalWhere; if (input.search) { const s = `%${input.search}%`; globalWhere = or( - ilike(items.itemCode, s), + ilike(itemOffshoreHull.itemCode, s), ilike(itemOffshoreHull.itemList, s), ilike(itemOffshoreHull.subItemList, s) ); @@ -281,27 +284,22 @@ export async function getOffshoreHullItems(input: GetOffshoreHullSchema) { const orderBy = input.sort.length > 0 ? input.sort.map((item) => { - const column = item.id === "workType" || item.id === "itemList" || item.id === "subItemList" - ? itemOffshoreHull[item.id] - : items[item.id]; + const column = itemOffshoreHull[item.id]; return item.desc ? desc(column) : asc(column); }) - : [desc(items.createdAt)]; + : [desc(itemOffshoreHull.createdAt)]; - // 해양 HULL 아이템 테이블과 기본 아이템 테이블 조인하여 조회 + // 해양 HULL 아이템 테이블만 조회 (독립적) const result = await db.select({ id: itemOffshoreHull.id, - itemCode: items.itemCode, + itemCode: itemOffshoreHull.itemCode, workType: itemOffshoreHull.workType, itemList: itemOffshoreHull.itemList, subItemList: itemOffshoreHull.subItemList, - itemName: items.itemName, - description: items.description, createdAt: itemOffshoreHull.createdAt, updatedAt: itemOffshoreHull.updatedAt, }) .from(itemOffshoreHull) - .innerJoin(items, eq(itemOffshoreHull.itemCode, items.itemCode)) .where(where) .orderBy(...orderBy) .offset(offset) @@ -312,7 +310,6 @@ export async function getOffshoreHullItems(input: GetOffshoreHullSchema) { count: count() }) .from(itemOffshoreHull) - .innerJoin(items, eq(itemOffshoreHull.itemCode, items.itemCode)) .where(where); const pageCount = Math.ceil(Number(total) / input.perPage); @@ -336,7 +333,7 @@ export async function getOffshoreHullItems(input: GetOffshoreHullSchema) { ----------------------------------------------------- */ /** - * Item 생성 - 아이템 타입에 따라 해당 테이블에 데이터 삽입 + * 조선 아이템 생성 - 독립적으로 생성 */ export async function createShipbuildingItem(input: TypedItemCreateData) { unstable_noStore() @@ -351,60 +348,25 @@ export async function createShipbuildingItem(input: TypedItemCreateData) { } } - // itemName이 없으면 "기술영업"으로 설정 - if (!input.itemName) { - input.itemName = "기술영업" - } - - const result = await db.transaction(async (tx) => { - // 1. itemCode로 직접 쿼리 - const existRows = await tx.select().from(items) - .where(eq(items.itemCode, input.itemCode)); - const existingItem = existRows[0]; - - let itemResult: any; - - if (existingItem) { - // 기존 아이템이 있으면 업데이트하지 않고 그대로 사용 - itemResult = [existingItem]; // 배열 형태로 반환 - } else { - // 없으면 새로 생성 - // 현재 가장 큰 ID 값 가져오기 - const maxIdResult = await tx.select({ maxId: sql`MAX(id)` }).from(items); - const maxId = maxIdResult[0]?.maxId || 0; - const newId = Number(maxId) + 1; - - // 새 ID로 아이템 생성 - itemResult = await tx.insert(items).values({ - id: newId, - itemCode: input.itemCode, - itemName: input.itemName, - description: input.description, - }).returning(); - } - - const shipData = input as ShipbuildingItemCreateData; - const typeResult = await tx.insert(itemShipbuilding).values({ - itemCode: input.itemCode, - workType: shipData.workType ? (shipData.workType as '기장' | '전장' | '선실' | '배관' | '철의') : '기장', - shipTypes: shipData.shipTypes || '', - itemList: shipData.itemList || null, - createdAt: new Date(), - updatedAt: new Date() - }).returning(); - - return { itemData: itemResult[0], shipbuildingData: typeResult[0] }; - }) + const shipData = input as ShipbuildingItemCreateData; + const result = await db.insert(itemShipbuilding).values({ + itemCode: input.itemCode, + workType: shipData.workType ? (shipData.workType as '기장' | '전장' | '선실' | '배관' | '철의') : '기장', + shipTypes: shipData.shipTypes || '', + itemList: shipData.itemList || null, + createdAt: new Date(), + updatedAt: new Date() + }).returning(); revalidateTag("items") return { success: true, - data: result || null, + data: result[0] || null, error: null } } catch (err) { - console.error("아이템 생성/업데이트 오류:", err) + console.error("아이템 생성 오류:", err) if (err instanceof Error && err.message.includes("unique constraint")) { return { @@ -430,16 +392,14 @@ export async function createShipbuildingItem(input: TypedItemCreateData) { */ export async function createShipbuildingImportItem(input: { itemCode: string; - itemName: string; workType: '기장' | '전장' | '선실' | '배관' | '철의'; - description?: string | null; itemList?: string | null; - shipTypes: Record; + subItemList?: string | null; + shipTypes?: string | null; }) { unstable_noStore(); try { - if (!input.itemCode) { return { success: false, @@ -449,80 +409,46 @@ export async function createShipbuildingImportItem(input: { } } - // itemName이 없을 경우 "기술영업"으로 설정 - if (!input.itemName) { - input.itemName = "기술영업"; - } - - const results = await db.transaction(async (tx) => { - // 1. itemCode로 직접 쿼리 - const existRows = await tx.select().from(items) - .where(eq(items.itemCode, input.itemCode)); - const existingItem = existRows[0]; - - console.log('DB에서 직접 조회한 기존 아이템:', existingItem); - - let itemResult: any; - - if (existingItem) { - console.log('기존 아이템 사용, itemCode:', input.itemCode); - } else { - // 없으면 새로 생성 - // 현재 가장 큰 ID 값 가져오기 - const maxIdResult = await tx.select({ maxId: sql`MAX(id)` }).from(items); - const maxId = maxIdResult[0]?.maxId || 0; - const newId = Number(maxId) + 1; - console.log('새 아이템 생성을 위한 ID 계산:', { maxId, newId }); - - // 새 ID로 아이템 생성 - const insertResult = await tx.insert(items).values({ - id: newId, - itemCode: input.itemCode, - itemName: input.itemName, - description: input.description, - }).returning(); - - console.log('새 아이템 생성 완료, itemCode:', input.itemCode); + // 기존 아이템 확인 + const existingItem = await db.select().from(itemShipbuilding) + .where(eq(itemShipbuilding.itemCode, input.itemCode)); + + if (existingItem.length > 0) { + return { + success: false, + message: "이미 존재하는 아이템 코드입니다", + data: null, + error: "중복 키 오류" } + } - const createdItems = []; - for (const shipType of Object.keys(input.shipTypes)) { - // 그대로 선종명 string으로 저장 - const existShip = await tx.select().from(itemShipbuilding) - .where( - and( - eq(itemShipbuilding.itemCode, input.itemCode), - eq(itemShipbuilding.shipTypes, shipType) - ) - ); - if (!existShip[0]) { - const shipbuildingResult = await tx.insert(itemShipbuilding).values({ - itemCode: input.itemCode, - workType: input.workType, - shipTypes: shipType, - itemList: input.itemList || null, - createdAt: new Date(), - updatedAt: new Date() - }).returning(); - createdItems.push({ - ...shipbuildingResult[0] - }); - console.log('조선아이템 생성:', shipType, shipbuildingResult[0]); - } else { - console.log('이미 존재하는 조선아이템:', shipType); - } - } - return createdItems; - }); + const result = await db.insert(itemShipbuilding).values({ + itemCode: input.itemCode, + workType: input.workType, + shipTypes: input.shipTypes || '', + itemList: input.itemList || '', + createdAt: new Date(), + updatedAt: new Date() + }).returning(); revalidateTag("items"); return { success: true, - data: results, + data: result[0], error: null } } catch (err) { + console.error("조선 아이템 생성 오류:", err); + + if (err instanceof Error && err.message.includes("unique constraint")) { + return { + success: false, + message: "이미 존재하는 아이템 코드입니다", + data: null, + error: "중복 키 오류" + } + } return { success: false, @@ -546,63 +472,24 @@ export async function createOffshoreTopItem(data: OffshoreTopItemCreateData) { } } - // itemName이 없으면 "기술영업"으로 설정 - if (!data.itemName) { - data.itemName = "기술영업" - } - - // 트랜잭션 내에서 처리 - const result = await db.transaction(async (tx) => { - // 1. itemCode로 직접 쿼리 - const existRows = await tx.select().from(items) - .where(eq(items.itemCode, data.itemCode)); - const existingItem = existRows[0]; - - let itemResult: any; - - if (existingItem) { - // 기존 아이템이 있으면 업데이트하지 않고 그대로 사용 - itemResult = [existingItem]; // 배열 형태로 반환 - } else { - // 없으면 새로 생성 - // 현재 가장 큰 ID 값 가져오기 - const maxIdResult = await tx.select({ maxId: sql`MAX(id)` }).from(items); - const maxId = maxIdResult[0]?.maxId || 0; - const newId = Number(maxId) + 1; - - // 새 ID로 아이템 생성 - itemResult = await tx.insert(items).values({ - id: newId, - itemCode: data.itemCode, - itemName: data.itemName, - description: data.description, - }).returning(); - } - - const [offshoreTop] = await tx - .insert(itemOffshoreTop) - .values({ - itemCode: data.itemCode, - workType: data.workType, - itemList: data.itemList, - subItemList: data.subItemList, - createdAt: new Date(), - updatedAt: new Date() - }) - .returning(); - - return { itemData: itemResult[0], offshoreTopData: offshoreTop }; - }) + const result = await db.insert(itemOffshoreTop).values({ + itemCode: data.itemCode, + workType: data.workType, + itemList: data.itemList, + subItemList: data.subItemList, + createdAt: new Date(), + updatedAt: new Date() + }).returning(); revalidateTag("items") return { success: true, - data: result, + data: result[0], error: null } } catch (err) { - console.error("아이템 생성/업데이트 오류:", err) + console.error("아이템 생성 오류:", err) if (err instanceof Error && err.message.includes("unique constraint")) { return { @@ -635,63 +522,24 @@ export async function createOffshoreHullItem(data: OffshoreHullItemCreateData) { } } - // itemName이 없으면 "기술영업"으로 설정 - if (!data.itemName) { - data.itemName = "기술영업" - } - - // 트랜잭션 내에서 처리 - const result = await db.transaction(async (tx) => { - // 1. itemCode로 직접 쿼리 - const existRows = await tx.select().from(items) - .where(eq(items.itemCode, data.itemCode)); - const existingItem = existRows[0]; - - let itemResult: any; - - if (existingItem) { - // 기존 아이템이 있으면 업데이트하지 않고 그대로 사용 - itemResult = [existingItem]; // 배열 형태로 반환 - } else { - // 없으면 새로 생성 - // 현재 가장 큰 ID 값 가져오기 - const maxIdResult = await tx.select({ maxId: sql`MAX(id)` }).from(items); - const maxId = maxIdResult[0]?.maxId || 0; - const newId = Number(maxId) + 1; - - // 새 ID로 아이템 생성 - itemResult = await tx.insert(items).values({ - id: newId, - itemCode: data.itemCode, - itemName: data.itemName, - description: data.description, - }).returning(); - } - - const [offshoreHull] = await tx - .insert(itemOffshoreHull) - .values({ - itemCode: data.itemCode, - workType: data.workType, - itemList: data.itemList, - subItemList: data.subItemList, - createdAt: new Date(), - updatedAt: new Date() - }) - .returning(); - - return { itemData: itemResult[0], offshoreHullData: offshoreHull }; - }) + const result = await db.insert(itemOffshoreHull).values({ + itemCode: data.itemCode, + workType: data.workType, + itemList: data.itemList, + subItemList: data.subItemList, + createdAt: new Date(), + updatedAt: new Date() + }).returning(); revalidateTag("items") return { success: true, - data: result, + data: result[0], error: null } } catch (err) { - console.error("아이템 생성/업데이트 오류:", err) + console.error("아이템 생성 오류:", err) if (err instanceof Error && err.message.includes("unique constraint")) { return { @@ -716,58 +564,41 @@ export async function createOffshoreHullItem(data: OffshoreHullItemCreateData) { ----------------------------------------------------- */ // 업데이트 타입 정의 인터페이스 -interface UpdateShipbuildingItemInput extends UpdateItemSchema { +interface UpdateShipbuildingItemInput { id: number; workType?: string; shipTypes?: string; itemList?: string; itemCode?: string; - itemName?: string; - description?: string; } /** 단건 업데이트 */ export async function modifyShipbuildingItem(input: UpdateShipbuildingItemInput) { unstable_noStore(); try { - const result = await db.transaction(async (tx) => { - // 기존 아이템 조회 - const existingShipbuilding = await tx.query.itemShipbuilding.findFirst({ - where: eq(itemShipbuilding.id, input.id), - with: { - item: true - } - }); - - if (!existingShipbuilding) { - throw new Error("아이템을 찾을 수 없습니다."); - } - - // 세부 아이템 테이블만 업데이트 (items 테이블은 변경하지 않음) - const updateData: Record = {}; - - if (input.workType) updateData.workType = input.workType as '기장' | '전장' | '선실' | '배관' | '철의'; - if (input.shipTypes) updateData.shipTypes = input.shipTypes; - if (input.itemList !== undefined) updateData.itemList = input.itemList; - - if (Object.keys(updateData).length > 0) { - await tx.update(itemShipbuilding) - .set(updateData) - .where(eq(itemShipbuilding.id, input.id)); - } - - return { - data: { id: input.id }, - error: null, - success: true, - message: "아이템이 성공적으로 업데이트되었습니다." - }; - }); + const updateData: Record = {}; + + if (input.workType) updateData.workType = input.workType as '기장' | '전장' | '선실' | '배관' | '철의'; + if (input.shipTypes) updateData.shipTypes = input.shipTypes; + if (input.itemList !== undefined) updateData.itemList = input.itemList; + if (input.itemCode) updateData.itemCode = input.itemCode; + + if (Object.keys(updateData).length > 0) { + updateData.updatedAt = new Date(); + await db.update(itemShipbuilding) + .set(updateData) + .where(eq(itemShipbuilding.id, input.id)); + } // 캐시 무효화 revalidateTag("items"); - return result; + return { + data: { id: input.id }, + error: null, + success: true, + message: "아이템이 성공적으로 업데이트되었습니다." + }; } catch (err) { return { data: null, @@ -779,58 +610,41 @@ export async function modifyShipbuildingItem(input: UpdateShipbuildingItemInput) } // Offshore TOP 업데이트 타입 정의 인터페이스 -interface UpdateOffshoreTopItemInput extends UpdateItemSchema { +interface UpdateOffshoreTopItemInput { id: number; workType?: string; itemList?: string; subItemList?: string; itemCode?: string; - itemName?: string; - description?: string; } /** Offshore TOP 단건 업데이트 */ export async function modifyOffshoreTopItem(input: UpdateOffshoreTopItemInput) { unstable_noStore(); try { - const result = await db.transaction(async (tx) => { - // 기존 아이템 조회 - const existingOffshoreTop = await tx.query.itemOffshoreTop.findFirst({ - where: eq(itemOffshoreTop.id, input.id), - with: { - item: true - } - }); - - if (!existingOffshoreTop) { - throw new Error("아이템을 찾을 수 없습니다."); - } - - // 세부 아이템 테이블만 업데이트 (items 테이블은 변경하지 않음) - const updateData: Record = {}; - - if (input.workType) updateData.workType = input.workType as 'TM' | 'TS' | 'TE' | 'TP'; - if (input.itemList !== undefined) updateData.itemList = input.itemList; - if (input.subItemList !== undefined) updateData.subItemList = input.subItemList; - - if (Object.keys(updateData).length > 0) { - await tx.update(itemOffshoreTop) - .set(updateData) - .where(eq(itemOffshoreTop.id, input.id)); - } - - return { - data: { id: input.id }, - error: null, - success: true, - message: "아이템이 성공적으로 업데이트되었습니다." - }; - }); + const updateData: Record = {}; + + if (input.workType) updateData.workType = input.workType as 'TM' | 'TS' | 'TE' | 'TP'; + if (input.itemList !== undefined) updateData.itemList = input.itemList; + if (input.subItemList !== undefined) updateData.subItemList = input.subItemList; + if (input.itemCode) updateData.itemCode = input.itemCode; + + if (Object.keys(updateData).length > 0) { + updateData.updatedAt = new Date(); + await db.update(itemOffshoreTop) + .set(updateData) + .where(eq(itemOffshoreTop.id, input.id)); + } // 캐시 무효화 revalidateTag("items"); - return result; + return { + data: { id: input.id }, + error: null, + success: true, + message: "아이템이 성공적으로 업데이트되었습니다." + }; } catch (err) { return { data: null, @@ -842,58 +656,41 @@ export async function modifyOffshoreTopItem(input: UpdateOffshoreTopItemInput) { } // Offshore HULL 업데이트 타입 정의 인터페이스 -interface UpdateOffshoreHullItemInput extends UpdateItemSchema { +interface UpdateOffshoreHullItemInput { id: number; workType?: string; itemList?: string; subItemList?: string; itemCode?: string; - itemName?: string; - description?: string; } /** Offshore HULL 단건 업데이트 */ export async function modifyOffshoreHullItem(input: UpdateOffshoreHullItemInput) { unstable_noStore(); try { - const result = await db.transaction(async (tx) => { - // 기존 아이템 조회 - const existingOffshoreHull = await tx.query.itemOffshoreHull.findFirst({ - where: eq(itemOffshoreHull.id, input.id), - with: { - item: true - } - }); - - if (!existingOffshoreHull) { - throw new Error("아이템을 찾을 수 없습니다."); - } - - // 세부 아이템 테이블만 업데이트 (items 테이블은 변경하지 않음) - const updateData: Record = {}; - - if (input.workType) updateData.workType = input.workType as 'HA' | 'HE' | 'HH' | 'HM' | 'NC'; - if (input.itemList !== undefined) updateData.itemList = input.itemList; - if (input.subItemList !== undefined) updateData.subItemList = input.subItemList; - - if (Object.keys(updateData).length > 0) { - await tx.update(itemOffshoreHull) - .set(updateData) - .where(eq(itemOffshoreHull.id, input.id)); - } - - return { - data: { id: input.id }, - error: null, - success: true, - message: "아이템이 성공적으로 업데이트되었습니다." - }; - }); + const updateData: Record = {}; + + if (input.workType) updateData.workType = input.workType as 'HA' | 'HE' | 'HH' | 'HM' | 'NC'; + if (input.itemList !== undefined) updateData.itemList = input.itemList; + if (input.subItemList !== undefined) updateData.subItemList = input.subItemList; + if (input.itemCode) updateData.itemCode = input.itemCode; + + if (Object.keys(updateData).length > 0) { + updateData.updatedAt = new Date(); + await db.update(itemOffshoreHull) + .set(updateData) + .where(eq(itemOffshoreHull.id, input.id)); + } // 캐시 무효화 revalidateTag("items"); - return result; + return { + data: { id: input.id }, + error: null, + success: true, + message: "아이템이 성공적으로 업데이트되었습니다." + }; } catch (err) { return { data: null, @@ -921,11 +718,8 @@ interface DeleteItemsInput { export async function removeShipbuildingItem(input: DeleteItemInput) { unstable_noStore(); try { - await db.transaction(async (tx) => { - // 세부 아이템만 삭제 (아이템 테이블은 유지) - await tx.delete(itemShipbuilding) - .where(eq(itemShipbuilding.id, input.id)); - }); + await db.delete(itemShipbuilding) + .where(eq(itemShipbuilding.id, input.id)); revalidateTag("items"); @@ -949,13 +743,10 @@ export async function removeShipbuildingItem(input: DeleteItemInput) { export async function removeShipbuildingItems(input: DeleteItemsInput) { unstable_noStore(); try { - await db.transaction(async (tx) => { - if (input.ids.length > 0) { - // 세부 아이템만 삭제 (아이템 테이블은 유지) - await tx.delete(itemShipbuilding) - .where(inArray(itemShipbuilding.id, input.ids)); - } - }); + if (input.ids.length > 0) { + await db.delete(itemShipbuilding) + .where(inArray(itemShipbuilding.id, input.ids)); + } revalidateTag("items"); @@ -969,11 +760,8 @@ export async function removeShipbuildingItems(input: DeleteItemsInput) { export async function removeOffshoreTopItem(input: DeleteItemInput) { unstable_noStore(); try { - await db.transaction(async (tx) => { - // 세부 아이템만 삭제 (아이템 테이블은 유지) - await tx.delete(itemOffshoreTop) - .where(eq(itemOffshoreTop.id, input.id)); - }); + await db.delete(itemOffshoreTop) + .where(eq(itemOffshoreTop.id, input.id)); revalidateTag("items"); @@ -997,13 +785,10 @@ export async function removeOffshoreTopItem(input: DeleteItemInput) { export async function removeOffshoreTopItems(input: DeleteItemsInput) { unstable_noStore(); try { - await db.transaction(async (tx) => { - if (input.ids.length > 0) { - // 세부 아이템만 삭제 (아이템 테이블은 유지) - await tx.delete(itemOffshoreTop) - .where(inArray(itemOffshoreTop.id, input.ids)); - } - }); + if (input.ids.length > 0) { + await db.delete(itemOffshoreTop) + .where(inArray(itemOffshoreTop.id, input.ids)); + } revalidateTag("items"); @@ -1017,11 +802,8 @@ export async function removeOffshoreTopItems(input: DeleteItemsInput) { export async function removeOffshoreHullItem(input: DeleteItemInput) { unstable_noStore(); try { - await db.transaction(async (tx) => { - // 세부 아이템만 삭제 (아이템 테이블은 유지) - await tx.delete(itemOffshoreHull) - .where(eq(itemOffshoreHull.id, input.id)); - }); + await db.delete(itemOffshoreHull) + .where(eq(itemOffshoreHull.id, input.id)); revalidateTag("items"); @@ -1045,13 +827,10 @@ export async function removeOffshoreHullItem(input: DeleteItemInput) { export async function removeOffshoreHullItems(input: DeleteItemsInput) { unstable_noStore(); try { - await db.transaction(async (tx) => { - if (input.ids.length > 0) { - // 세부 아이템만 삭제 (아이템 테이블은 유지) - await tx.delete(itemOffshoreHull) - .where(inArray(itemOffshoreHull.id, input.ids)); - } - }); + if (input.ids.length > 0) { + await db.delete(itemOffshoreHull) + .where(inArray(itemOffshoreHull.id, input.ids)); + } revalidateTag("items"); @@ -1061,50 +840,17 @@ export async function removeOffshoreHullItems(input: DeleteItemsInput) { } } -export async function getAllShipbuildingItems(): Promise { - try { - return await findAllItems(); - } catch (error) { - console.error("Failed to get items:", error); - throw new Error("Failed to get items"); - } -} -export async function getAllOffshoreItems(): Promise<(ItemOffshoreHull | ItemOffshoreTop)[]> { - try { - return await findAllOffshoreItems(); - } catch (err) { - throw new Error("Failed to get items"); - } -} - - -// ----------------------------------------------------------- -// 기술영업을 위한 로직 -// ----------------------------------------------------------- - -// 조선 공종 타입 -export type WorkType = '기장' | '전장' | '선실' | '배관' | '철의' - -// 조선 아이템 with 공종 정보 -export interface ShipbuildingItem { - id: number - itemCode: string - workType: WorkType - itemList: string | null // 실제 아이템명 - shipTypes: string - createdAt: Date - updatedAt: Date -} +/* ----------------------------------------------------- + 5) 조회 관련 추가 함수들 +----------------------------------------------------- */ -// 공종별 아이템 조회 +// 조선 공종별 아이템 조회 export async function getShipbuildingItemsByWorkType(workType?: WorkType, shipType?: string) { try { const query = db .select({ id: itemShipbuilding.id, itemCode: itemShipbuilding.itemCode, - itemName: items.itemName, - description: items.description, workType: itemShipbuilding.workType, itemList: itemShipbuilding.itemList, shipTypes: itemShipbuilding.shipTypes, @@ -1112,7 +858,6 @@ export async function getShipbuildingItemsByWorkType(workType?: WorkType, shipTy updatedAt: itemShipbuilding.updatedAt, }) .from(itemShipbuilding) - .leftJoin(items, eq(itemShipbuilding.itemCode, items.itemCode)) const conditions = [] if (workType) { @@ -1141,14 +886,80 @@ export async function getShipbuildingItemsByWorkType(workType?: WorkType, shipTy } } +// 해양 TOP 공종별 아이템 조회 +export async function getOffshoreTopItemsByWorkType(workType?: OffshoreTopWorkType) { + try { + const query = db + .select({ + id: itemOffshoreTop.id, + itemCode: itemOffshoreTop.itemCode, + workType: itemOffshoreTop.workType, + itemList: itemOffshoreTop.itemList, + subItemList: itemOffshoreTop.subItemList, + createdAt: itemOffshoreTop.createdAt, + updatedAt: itemOffshoreTop.updatedAt, + }) + .from(itemOffshoreTop) + + if (workType) { + query.where(eq(itemOffshoreTop.workType, workType)) + } + + const result = await query + + return { + data: result as OffshoreTopTechItem[], + error: null + } + } catch (error) { + console.error("해양 TOP 아이템 조회 오류:", error) + return { + data: null, + error: error instanceof Error ? error.message : "알 수 없는 오류" + } + } +} + +// 해양 HULL 공종별 아이템 조회 +export async function getOffshoreHullItemsByWorkType(workType?: OffshoreHullWorkType) { + try { + const query = db + .select({ + id: itemOffshoreHull.id, + itemCode: itemOffshoreHull.itemCode, + workType: itemOffshoreHull.workType, + itemList: itemOffshoreHull.itemList, + subItemList: itemOffshoreHull.subItemList, + createdAt: itemOffshoreHull.createdAt, + updatedAt: itemOffshoreHull.updatedAt, + }) + .from(itemOffshoreHull) + + if (workType) { + query.where(eq(itemOffshoreHull.workType, workType)) + } + + const result = await query + + return { + data: result as OffshoreHullTechItem[], + error: null + } + } catch (error) { + console.error("해양 HULL 아이템 조회 오류:", error) + return { + data: null, + error: error instanceof Error ? error.message : "알 수 없는 오류" + } + } +} + // 아이템 검색 export async function searchShipbuildingItems(searchQuery: string, workType?: WorkType, shipType?: string) { try { const searchConditions = [ ilike(itemShipbuilding.itemCode, `%${searchQuery}%`), - ilike(items.itemName, `%${searchQuery}%`), - ilike(items.description, `%${searchQuery}%`), - ilike(itemShipbuilding.itemList, `%${searchQuery}%`) + ilike(itemShipbuilding.itemList, `%${searchQuery}%`), ] let whereCondition = or(...searchConditions) @@ -1172,8 +983,6 @@ export async function searchShipbuildingItems(searchQuery: string, workType?: Wo .select({ id: itemShipbuilding.id, itemCode: itemShipbuilding.itemCode, - itemName: items.itemName, - description: items.description, workType: itemShipbuilding.workType, itemList: itemShipbuilding.itemList, shipTypes: itemShipbuilding.shipTypes, @@ -1181,7 +990,6 @@ export async function searchShipbuildingItems(searchQuery: string, workType?: Wo updatedAt: itemShipbuilding.updatedAt, }) .from(itemShipbuilding) - .leftJoin(items, eq(itemShipbuilding.itemCode, items.itemCode)) .where(whereCondition) return { @@ -1197,6 +1005,94 @@ export async function searchShipbuildingItems(searchQuery: string, workType?: Wo } } +// 해양 TOP 아이템 검색 +export async function searchOffshoreTopItems(searchQuery: string, workType?: OffshoreTopWorkType) { + try { + const searchConditions = [ + ilike(itemOffshoreTop.itemCode, `%${searchQuery}%`), + ilike(itemOffshoreTop.itemList, `%${searchQuery}%`), + ilike(itemOffshoreTop.subItemList, `%${searchQuery}%`) + ] + + let whereCondition = or(...searchConditions) + + if (workType) { + whereCondition = and( + eq(itemOffshoreTop.workType, workType), + or(...searchConditions) + ) + } + + const result = await db + .select({ + id: itemOffshoreTop.id, + itemCode: itemOffshoreTop.itemCode, + workType: itemOffshoreTop.workType, + itemList: itemOffshoreTop.itemList, + subItemList: itemOffshoreTop.subItemList, + createdAt: itemOffshoreTop.createdAt, + updatedAt: itemOffshoreTop.updatedAt, + }) + .from(itemOffshoreTop) + .where(whereCondition) + + return { + data: result as OffshoreTopTechItem[], + error: null + } + } catch (error) { + console.error("해양 TOP 아이템 검색 오류:", error) + return { + data: null, + error: error instanceof Error ? error.message : "알 수 없는 오류" + } + } +} + +// 해양 HULL 아이템 검색 +export async function searchOffshoreHullItems(searchQuery: string, workType?: OffshoreHullWorkType) { + try { + const searchConditions = [ + ilike(itemOffshoreHull.itemCode, `%${searchQuery}%`), + ilike(itemOffshoreHull.itemList, `%${searchQuery}%`), + ilike(itemOffshoreHull.subItemList, `%${searchQuery}%`) + ] + + let whereCondition = or(...searchConditions) + + if (workType) { + whereCondition = and( + eq(itemOffshoreHull.workType, workType), + or(...searchConditions) + ) + } + + const result = await db + .select({ + id: itemOffshoreHull.id, + itemCode: itemOffshoreHull.itemCode, + workType: itemOffshoreHull.workType, + itemList: itemOffshoreHull.itemList, + subItemList: itemOffshoreHull.subItemList, + createdAt: itemOffshoreHull.createdAt, + updatedAt: itemOffshoreHull.updatedAt, + }) + .from(itemOffshoreHull) + .where(whereCondition) + + return { + data: result as OffshoreHullTechItem[], + error: null + } + } catch (error) { + console.error("해양 HULL 아이템 검색 오류:", error) + return { + data: null, + error: error instanceof Error ? error.message : "알 수 없는 오류" + } + } +} + // 모든 공종 목록 조회 export async function getWorkTypes() { return [ @@ -1208,6 +1104,27 @@ export async function getWorkTypes() { ] } +// 해양 TOP 공종 목록 조회 +export async function getOffshoreTopWorkTypes() { + return [ + { code: 'TM' as OffshoreTopWorkType, name: 'TM', description: 'Topside Manufacturing' }, + { code: 'TS' as OffshoreTopWorkType, name: 'TS', description: 'Topside Steel' }, + { code: 'TE' as OffshoreTopWorkType, name: 'TE', description: 'Topside Equipment' }, + { code: 'TP' as OffshoreTopWorkType, name: 'TP', description: 'Topside Piping' }, + ] +} + +// 해양 HULL 공종 목록 조회 +export async function getOffshoreHullWorkTypes() { + return [ + { code: 'HA' as OffshoreHullWorkType, name: 'HA', description: 'Hull Assembly' }, + { code: 'HE' as OffshoreHullWorkType, name: 'HE', description: 'Hull Equipment' }, + { code: 'HH' as OffshoreHullWorkType, name: 'HH', description: 'Hull Heating' }, + { code: 'HM' as OffshoreHullWorkType, name: 'HM', description: 'Hull Manufacturing' }, + { code: 'NC' as OffshoreHullWorkType, name: 'NC', description: 'No Category' }, + ] +} + // 특정 아이템 코드들로 아이템 조회 export async function getShipbuildingItemsByCodes(itemCodes: string[]) { try { @@ -1215,8 +1132,6 @@ export async function getShipbuildingItemsByCodes(itemCodes: string[]) { .select({ id: itemShipbuilding.id, itemCode: itemShipbuilding.itemCode, - itemName: items.itemName, - description: items.description, workType: itemShipbuilding.workType, itemList: itemShipbuilding.itemList, shipTypes: itemShipbuilding.shipTypes, @@ -1224,7 +1139,6 @@ export async function getShipbuildingItemsByCodes(itemCodes: string[]) { updatedAt: itemShipbuilding.updatedAt, }) .from(itemShipbuilding) - .leftJoin(items, eq(itemShipbuilding.itemCode, items.itemCode)) .where( or(...itemCodes.map(code => eq(itemShipbuilding.itemCode, code))) ) @@ -1242,6 +1156,68 @@ export async function getShipbuildingItemsByCodes(itemCodes: string[]) { } } +// 해양 TOP 아이템 코드별 조회 +export async function getOffshoreTopItemsByCodes(itemCodes: string[]) { + try { + const result = await db + .select({ + id: itemOffshoreTop.id, + itemCode: itemOffshoreTop.itemCode, + workType: itemOffshoreTop.workType, + itemList: itemOffshoreTop.itemList, + subItemList: itemOffshoreTop.subItemList, + createdAt: itemOffshoreTop.createdAt, + updatedAt: itemOffshoreTop.updatedAt, + }) + .from(itemOffshoreTop) + .where( + or(...itemCodes.map(code => eq(itemOffshoreTop.itemCode, code))) + ) + + return { + data: result as OffshoreTopTechItem[], + error: null + } + } catch (error) { + console.error("해양 TOP 아이템 코드별 조회 오류:", error) + return { + data: null, + error: error instanceof Error ? error.message : "알 수 없는 오류" + } + } +} + +// 해양 HULL 아이템 코드별 조회 +export async function getOffshoreHullItemsByCodes(itemCodes: string[]) { + try { + const result = await db + .select({ + id: itemOffshoreHull.id, + itemCode: itemOffshoreHull.itemCode, + workType: itemOffshoreHull.workType, + itemList: itemOffshoreHull.itemList, + subItemList: itemOffshoreHull.subItemList, + createdAt: itemOffshoreHull.createdAt, + updatedAt: itemOffshoreHull.updatedAt, + }) + .from(itemOffshoreHull) + .where( + or(...itemCodes.map(code => eq(itemOffshoreHull.itemCode, code))) + ) + + return { + data: result as OffshoreHullTechItem[], + error: null + } + } catch (error) { + console.error("해양 HULL 아이템 코드별 조회 오류:", error) + return { + data: null, + error: error instanceof Error ? error.message : "알 수 없는 오류" + } + } +} + // 전체 조선 아이템 조회 (캐싱용) export async function getAllShipbuildingItemsForCache() { try { @@ -1270,6 +1246,62 @@ export async function getAllShipbuildingItemsForCache() { } } +// 전체 해양 TOP 아이템 조회 (캐싱용) +export async function getAllOffshoreTopItemsForCache() { + try { + const result = await db + .select({ + id: itemOffshoreTop.id, + itemCode: itemOffshoreTop.itemCode, + workType: itemOffshoreTop.workType, + itemList: itemOffshoreTop.itemList, + subItemList: itemOffshoreTop.subItemList, + createdAt: itemOffshoreTop.createdAt, + updatedAt: itemOffshoreTop.updatedAt, + }) + .from(itemOffshoreTop) + + return { + data: result as OffshoreTopTechItem[], + error: null + } + } catch (error) { + console.error("전체 해양 TOP 아이템 조회 오류:", error) + return { + data: null, + error: error instanceof Error ? error.message : "알 수 없는 오류" + } + } +} + +// 전체 해양 HULL 아이템 조회 (캐싱용) +export async function getAllOffshoreHullItemsForCache() { + try { + const result = await db + .select({ + id: itemOffshoreHull.id, + itemCode: itemOffshoreHull.itemCode, + workType: itemOffshoreHull.workType, + itemList: itemOffshoreHull.itemList, + subItemList: itemOffshoreHull.subItemList, + createdAt: itemOffshoreHull.createdAt, + updatedAt: itemOffshoreHull.updatedAt, + }) + .from(itemOffshoreHull) + + return { + data: result as OffshoreHullTechItem[], + error: null + } + } catch (error) { + console.error("전체 해양 HULL 아이템 조회 오류:", error) + return { + data: null, + error: error instanceof Error ? error.message : "알 수 없는 오류" + } + } +} + // 선종 목록 가져오기 export async function getShipTypes() { try { diff --git a/lib/items-tech/table/add-items-dialog.tsx b/lib/items-tech/table/add-items-dialog.tsx index a3af0a8c..ee8ee8b8 100644 --- a/lib/items-tech/table/add-items-dialog.tsx +++ b/lib/items-tech/table/add-items-dialog.tsx @@ -46,16 +46,6 @@ const shipbuildingWorkTypes = [ { label: "철의", value: "철의" }, ] as const -// // 선종 유형 정의 -// const shipTypes = [ -// { label: "A-MAX", value: "A-MAX" }, -// { label: "S-MAX", value: "S-MAX" }, -// { label: "LNGC", value: "LNGC" }, -// { label: "VLCC", value: "VLCC" }, -// { label: "CONT", value: "CONT" }, -// { label: "OPTION", value: "OPTION" }, -// ] as const - // 해양 TOP 공종 유형 정의 const offshoreTopWorkTypes = [ { label: "TM", value: "TM" }, @@ -76,14 +66,11 @@ const offshoreHullWorkTypes = [ // 기본 아이템 스키마 const itemFormSchema = z.object({ itemCode: z.string().min(1, "아이템 코드는 필수입니다"), - itemName: z.string().min(1, "아이템 명은 필수입니다"), - description: z.string().optional(), workType: z.string().min(1, "공종은 필수입니다"), // 조선 및 해양 아이템 공통 필드 itemList: z.string().optional(), // 조선 아이템 전용 필드 shipTypes: z.string().optional(), - // 해양 아이템 전용 필드 subItemList: z.string().optional(), }) @@ -101,14 +88,11 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { const getDefaultValues = () => { const defaults: ItemFormValues = { itemCode: "", - itemName: "기술영업", - description: "", workType: getDefaultWorkType(), } if (itemType === 'shipbuilding') { defaults.shipTypes = "OPTION" - defaults.itemList = "" } else { defaults.itemList = "" defaults.subItemList = "" @@ -146,20 +130,16 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { await createShipbuildingItem({ itemCode: data.itemCode, - itemName: data.itemName, workType: data.workType, shipTypes: data.shipTypes, - description: data.description || null, - itemList: data.itemList || null + itemList: data.itemList || null, }); break; case 'offshoreTop': await createOffshoreTopItem({ itemCode: data.itemCode, - itemName: data.itemName, workType: data.workType as "TM" | "TS" | "TE" | "TP", - description: data.description || null, itemList: data.itemList || null, subItemList: data.subItemList || null }); @@ -168,9 +148,7 @@ export function AddItemDialog({ itemType }: AddItemDialogProps) { case 'offshoreHull': await createOffshoreHullItem({ itemCode: data.itemCode, - itemName: data.itemName, workType: data.workType as "HA" | "HE" | "HH" | "HM" | "NC", - description: data.description || null, itemList: data.itemList || null, subItemList: data.subItemList || null }); diff --git a/lib/items-tech/table/hull/import-item-handler.tsx b/lib/items-tech/table/hull/import-item-handler.tsx index 8c0e1cfa..aa0c7992 100644 --- a/lib/items-tech/table/hull/import-item-handler.tsx +++ b/lib/items-tech/table/hull/import-item-handler.tsx @@ -60,16 +60,14 @@ export async function processHullFileImport( try { // 필드 매핑 (한글/영문 필드명 모두 지원) - const itemCode = row["아이템 코드"] || row["itemCode"] || ""; - const itemName = row["아이템 명"] || row["itemName"] || "기술영업"; // 기본값 설정 + const itemCode = row["자재 그룹"] || row["itemCode"] || ""; const workType = row["기능(공종)"] || row["workType"] || ""; - const itemList = row["아이템 리스트"] || row["itemList"] || null; - const subItemList = row["서브 아이템 리스트"] || row["subItemList"] || null; + const itemList = row["자재명"] || row["itemList"] || null; + const subItemList = row["자재명(상세)"] || row["subItemList"] || null; // 데이터 정제 const cleanedRow = { itemCode: typeof itemCode === 'string' ? itemCode.trim() : String(itemCode).trim(), - itemName: typeof itemName === 'string' ? itemName.trim() : String(itemName).trim(), workType: typeof workType === 'string' ? workType.trim() : String(workType).trim(), itemList: itemList ? (typeof itemList === 'string' ? itemList : String(itemList)) : null, subItemList: subItemList ? (typeof subItemList === 'string' ? subItemList : String(subItemList)) : null, @@ -91,9 +89,7 @@ export async function processHullFileImport( // 해양 HULL 아이템 생성 const result = await createOffshoreHullItem({ itemCode: cleanedRow.itemCode, - itemName: cleanedRow.itemName, // Excel에서 가져온 값 또는 기본값 사용 workType: cleanedRow.workType as "HA" | "HE" | "HH" | "HM" | "NC", - description: null, itemList: cleanedRow.itemList, subItemList: cleanedRow.subItemList, }); diff --git a/lib/items-tech/table/hull/item-excel-template.tsx b/lib/items-tech/table/hull/item-excel-template.tsx index 61fddecc..13ec1973 100644 --- a/lib/items-tech/table/hull/item-excel-template.tsx +++ b/lib/items-tech/table/hull/item-excel-template.tsx @@ -18,10 +18,10 @@ export async function exportHullItemTemplate() { // 컬럼 헤더 정의 및 스타일 적용 worksheet.columns = [ - { header: '아이템 코드', key: 'itemCode', width: 15 }, + { header: '자재 그룹', key: 'itemCode', width: 15 }, { header: '기능(공종)', key: 'workType', width: 15 }, - { header: '아이템 리스트', key: 'itemList', width: 20 }, - { header: '서브 아이템 리스트', key: 'subItemList', width: 20 }, + { header: '자재명', key: 'itemList', width: 20 }, + { header: '자재명(상세)', key: 'subItemList', width: 20 }, ]; // 헤더 스타일 적용 diff --git a/lib/items-tech/table/hull/offshore-hull-table-columns.tsx b/lib/items-tech/table/hull/offshore-hull-table-columns.tsx index 7bc02173..efc6c583 100644 --- a/lib/items-tech/table/hull/offshore-hull-table-columns.tsx +++ b/lib/items-tech/table/hull/offshore-hull-table-columns.tsx @@ -112,13 +112,13 @@ export function getOffshoreHullColumns({ setRowAction }: GetColumnsProps): Colum { accessorKey: "itemCode", header: ({ column }) => ( - + ), cell: ({ row }) =>
{row.original.itemCode}
, enableSorting: true, enableHiding: true, meta: { - excelHeader: "Material Group", + excelHeader: "자재 그룹", }, }, { @@ -136,25 +136,25 @@ export function getOffshoreHullColumns({ setRowAction }: GetColumnsProps): Colum { accessorKey: "itemList", header: ({ column }) => ( - + ), cell: ({ row }) =>
{row.original.itemList || "-"}
, enableSorting: true, enableHiding: true, meta: { - excelHeader: "아이템 리스트", + excelHeader: "자재명", }, }, { accessorKey: "subItemList", header: ({ column }) => ( - + ), cell: ({ row }) =>
{row.original.subItemList || "-"}
, enableSorting: true, enableHiding: true, meta: { - excelHeader: "서브 아이템 리스트", + excelHeader: "자재명(상세)", }, }, { diff --git a/lib/items-tech/table/import-excel-button.tsx b/lib/items-tech/table/import-excel-button.tsx index 9bf4578c..3281823c 100644 --- a/lib/items-tech/table/import-excel-button.tsx +++ b/lib/items-tech/table/import-excel-button.tsx @@ -13,7 +13,6 @@ import { DialogFooter, DialogHeader, DialogTitle, - DialogTrigger, } from "@/components/ui/dialog" import { Progress } from "@/components/ui/progress" import { processFileImport } from "./ship/import-item-handler" @@ -123,22 +122,13 @@ export function ImportItemButton({ itemType, onSuccess }: ImportItemButtonProps) }); // 필수 헤더 확인 (타입별 구분) - let requiredHeaders: string[] = ["아이템 코드", "기능(공종)"]; - - // 해양 TOP 및 HULL의 경우 선종 헤더는 필요 없음 - if (itemType === "ship") { - requiredHeaders = [...requiredHeaders, "A-MAX", "S-MAX", "LNGC", "VLCC", "CONT"]; - } + const requiredHeaders: string[] = ["아이템 코드", "기능(공종)"]; const alternativeHeaders = { "아이템 코드": ["itemCode", "item_code"], - "아이템 명": ["itemName", "item_name"], "기능(공종)": ["workType"], - "설명": ["description"], - "항목1": ["itemList1"], - "항목2": ["itemList2"], - "항목3": ["itemList3"], - "항목4": ["itemList4"] + "자재명": ["itemList"], + "자재명(상세)": ["subItemList"] }; // 헤더 매핑 확인 (대체 이름 포함) diff --git a/lib/items-tech/table/ship/Items-ship-table.tsx b/lib/items-tech/table/ship/Items-ship-table.tsx index 61e8d8b4..feab288a 100644 --- a/lib/items-tech/table/ship/Items-ship-table.tsx +++ b/lib/items-tech/table/ship/Items-ship-table.tsx @@ -24,7 +24,7 @@ type ShipbuildingItem = { shipTypes: string; itemCode: string; itemName: string; - itemList: string | null; + itemList: string | null; description: string | null; createdAt: Date; updatedAt: Date; @@ -110,7 +110,7 @@ export function ItemsShipTable({ promises }: ItemsTableProps) { label: "아이템 리스트", type: "text", }, - ] + ] const { table } = useDataTable({ data: data as ShipbuildingItem[], diff --git a/lib/items-tech/table/ship/import-item-handler.tsx b/lib/items-tech/table/ship/import-item-handler.tsx index 77bed4f0..a47e451b 100644 --- a/lib/items-tech/table/ship/import-item-handler.tsx +++ b/lib/items-tech/table/ship/import-item-handler.tsx @@ -3,14 +3,13 @@ import { z } from "zod" import { createShipbuildingImportItem } from "../../service" // 아이템 생성 서버 액션 -const SHIP_TYPES = ['A-MAX', 'S-MAX', 'LNGC', 'VLCC', 'CONT'] as const; - // 아이템 데이터 검증을 위한 Zod 스키마 const itemSchema = z.object({ itemCode: z.string().min(1, "아이템 코드는 필수입니다"), workType: z.enum(["기장", "전장", "선실", "배관", "철의"], { required_error: "기능(공종)은 필수입니다", }), + shipTypes: z.string().nullable().optional(), itemList: z.string().nullable().optional(), }); @@ -58,16 +57,16 @@ export async function processFileImport( try { // 필드 매핑 (한글/영문 필드명 모두 지원) - const itemCode = row["아이템 코드"] || row["itemCode"] || ""; - const itemName = row["아이템 명"] || row["itemName"] || "기술영업"; // 기본값 설정 + const itemCode = row["자재 그룹"] || row["itemCode"] || ""; const workType = row["기능(공종)"] || row["workType"] || ""; - const itemList = row["아이템 리스트"] || row["itemList"] || null; + const shipTypes = row["선종"] || row["shipTypes"] || null; + const itemList = row["자재명"] || row["itemList"] || null; // 데이터 정제 const cleanedRow = { itemCode: typeof itemCode === 'string' ? itemCode.trim() : String(itemCode).trim(), - itemName: typeof itemName === 'string' ? itemName.trim() : String(itemName).trim(), workType: typeof workType === 'string' ? workType.trim() : String(workType).trim(), + shipTypes: shipTypes ? (typeof shipTypes === 'string' ? shipTypes.trim() : String(shipTypes).trim()) : null, itemList: itemList ? (typeof itemList === 'string' ? itemList : String(itemList)) : null, }; @@ -84,57 +83,24 @@ export async function processFileImport( continue; } - // 선종 데이터 처리 - const shipTypeEntries = SHIP_TYPES.map(type => ({ - type, - value: row[type] ? String(row[type]).toUpperCase() === 'O' : false - })).filter(entry => entry.value); - console.log('shipTypeEntries:', shipTypeEntries); - - // 선종이 없는 경우에 "option" 값을 사용 - if (shipTypeEntries.length === 0) { - // "option" 값으로 아이템 생성 - const result = await createShipbuildingImportItem({ - itemCode: cleanedRow.itemCode, - itemName: cleanedRow.itemName, // Excel에서 가져온 값 또는 기본값 사용 - workType: cleanedRow.workType as "기장" | "전장" | "선실" | "배관" | "철의", - shipTypes: { "OPTION": true }, - description: null, - itemList: cleanedRow.itemList, - }); - - if (result.success || !result.error) { - successCount++; - } else { - errors.push({ - row: rowIndex, - message: `OPTION: ${result.message || result.error || "알 수 없는 오류"}` - }); - errorCount++; - } + // 아이템 생성 + const result = await createShipbuildingImportItem({ + itemCode: cleanedRow.itemCode, + workType: cleanedRow.workType as "기장" | "전장" | "선실" | "배관" | "철의", + shipTypes: cleanedRow.shipTypes, + itemList: cleanedRow.itemList, + }); + + if (result.success || !result.error) { + successCount++; } else { - // 각 선종에 대해 아이템 생성 - for (const { type } of shipTypeEntries) { - const result = await createShipbuildingImportItem({ - itemCode: cleanedRow.itemCode, - itemName: cleanedRow.itemName, // Excel에서 가져온 값 또는 기본값 사용 - workType: cleanedRow.workType as "기장" | "전장" | "선실" | "배관" | "철의", - shipTypes: { [type]: true }, - description: null, - itemList: cleanedRow.itemList, - }); - - if (result.success || !result.error) { - successCount++; - } else { - errors.push({ - row: rowIndex, - message: `${type}: ${result.message || result.error || "알 수 없는 오류"}` - }); - errorCount++; - } - } + errors.push({ + row: rowIndex, + message: result.message || result.error || "알 수 없는 오류" + }); + errorCount++; } + } catch (error) { console.error(`${rowIndex}행 처리 오류:`, error); errors.push({ diff --git a/lib/items-tech/table/ship/item-excel-template.tsx b/lib/items-tech/table/ship/item-excel-template.tsx index f6b20b6d..401fb911 100644 --- a/lib/items-tech/table/ship/item-excel-template.tsx +++ b/lib/items-tech/table/ship/item-excel-template.tsx @@ -1,8 +1,6 @@ import * as ExcelJS from 'exceljs'; import { saveAs } from "file-saver"; -const SHIP_TYPES = ['A-MAX', 'S-MAX', 'LNGC', 'VLCC', 'CONT'] as const; - /** * 조선 아이템 데이터 가져오기를 위한 Excel 템플릿 파일 생성 및 다운로드 */ @@ -17,14 +15,10 @@ export async function exportItemTemplate() { // 컬럼 헤더 정의 및 스타일 적용 worksheet.columns = [ - { header: '아이템 코드', key: 'itemCode', width: 15 }, + { header: '자재 그룹', key: 'itemCode', width: 15 }, { header: '기능(공종)', key: 'workType', width: 15 }, - { header: '아이템 리스트', key: 'itemList', width: 30 }, - ...SHIP_TYPES.map(type => ({ - header: type, - key: type, - width: 10 - })) + { header: '선종', key: 'shipTypes', width: 15 }, + { header: '자재명', key: 'itemList', width: 30 }, ]; // 헤더 스타일 적용 @@ -52,32 +46,20 @@ export async function exportItemTemplate() { { itemCode: 'BG0001', workType: '기장', - itemList: '아이템 리스트 내용', - 'A-MAX': 'O', - 'S-MAX': 'O', - 'LNGC': 'O', - 'VLCC': ' ', - 'CONT': ' ' + shipTypes: 'A-MAX', + itemList: '자재명', }, { itemCode: 'BG0002', workType: '전장', - itemList: '아이템 리스트 내용 2', - 'A-MAX': 'O', - 'S-MAX': ' ', - 'LNGC': 'O', - 'VLCC': 'O', - 'CONT': ' ' + shipTypes: 'LNGC', + itemList: '자재명', }, { itemCode: 'BG0003', workType: '선실', - itemList: '선종 없는 아이템', - 'A-MAX': ' ', - 'S-MAX': ' ', - 'LNGC': ' ', - 'VLCC': ' ', - 'CONT': ' ' + shipTypes: 'VLCC', + itemList: '자재명', } ]; diff --git a/lib/items-tech/table/ship/items-ship-table-columns.tsx b/lib/items-tech/table/ship/items-ship-table-columns.tsx index 29e1d503..13ba2480 100644 --- a/lib/items-tech/table/ship/items-ship-table-columns.tsx +++ b/lib/items-tech/table/ship/items-ship-table-columns.tsx @@ -115,13 +115,13 @@ export function getShipbuildingColumns({ setRowAction }: GetColumnsProps): Colum { accessorKey: "itemCode", header: ({ column }) => ( - + ), cell: ({ row }) =>
{row.original.itemCode}
, enableSorting: true, enableHiding: true, meta: { - excelHeader: "Material Group", + excelHeader: "자재 그룹", }, }, { @@ -151,13 +151,13 @@ export function getShipbuildingColumns({ setRowAction }: GetColumnsProps): Colum { accessorKey: "itemList", header: ({ column }) => ( - + ), cell: ({ row }) =>
{row.original.itemList || "-"}
, enableSorting: true, enableHiding: true, meta: { - excelHeader: "아이템 리스트", + excelHeader: "자재명", }, }, { diff --git a/lib/items-tech/table/ship/items-table-toolbar-actions.tsx b/lib/items-tech/table/ship/items-table-toolbar-actions.tsx index 677173d1..e58ba135 100644 --- a/lib/items-tech/table/ship/items-table-toolbar-actions.tsx +++ b/lib/items-tech/table/ship/items-table-toolbar-actions.tsx @@ -134,9 +134,7 @@ export function ItemsTableToolbarActions({ table }: ItemsTableToolbarActionsProp {/* 선택된 로우가 있으면 삭제 다이얼로그 */} {table.getFilteredSelectedRowModel().rows.length > 0 ? ( row.original)} + items={table.getFilteredSelectedRowModel().rows.map((row) => row.original) as any} onSuccess={() => table.toggleAllRowsSelected(false)} itemType="shipbuilding" /> diff --git a/lib/items-tech/table/top/import-item-handler.tsx b/lib/items-tech/table/top/import-item-handler.tsx index e2564a91..541ec4ef 100644 --- a/lib/items-tech/table/top/import-item-handler.tsx +++ b/lib/items-tech/table/top/import-item-handler.tsx @@ -60,16 +60,14 @@ export async function processTopFileImport( try { // 필드 매핑 (한글/영문 필드명 모두 지원) - const itemCode = row["아이템 코드"] || row["itemCode"] || ""; - const itemName = row["아이템 명"] || row["itemName"] || "기술영업"; // 기본값 설정 + const itemCode = row["자재 그룹"] || row["itemCode"] || ""; const workType = row["기능(공종)"] || row["workType"] || ""; - const itemList = row["아이템 리스트"] || row["itemList"] || null; - const subItemList = row["서브 아이템 리스트"] || row["subItemList"] || null; + const itemList = row["자재명"] || row["itemList"] || null; + const subItemList = row["자재명(상세)"] || row["subItemList"] || null; // 데이터 정제 const cleanedRow = { itemCode: typeof itemCode === 'string' ? itemCode.trim() : String(itemCode).trim(), - itemName: typeof itemName === 'string' ? itemName.trim() : String(itemName).trim(), workType: typeof workType === 'string' ? workType.trim() : String(workType).trim(), itemList: itemList ? (typeof itemList === 'string' ? itemList : String(itemList)) : null, subItemList: subItemList ? (typeof subItemList === 'string' ? subItemList : String(subItemList)) : null, @@ -91,9 +89,7 @@ export async function processTopFileImport( // 해양 TOP 아이템 생성 const result = await createOffshoreTopItem({ itemCode: cleanedRow.itemCode, - itemName: cleanedRow.itemName, // Excel에서 가져온 값 또는 기본값 사용 workType: cleanedRow.workType as "TM" | "TS" | "TE" | "TP", - description: null, itemList: cleanedRow.itemList, subItemList: cleanedRow.subItemList, }); diff --git a/lib/items-tech/table/top/item-excel-template.tsx b/lib/items-tech/table/top/item-excel-template.tsx index f0e10d82..f547d617 100644 --- a/lib/items-tech/table/top/item-excel-template.tsx +++ b/lib/items-tech/table/top/item-excel-template.tsx @@ -18,10 +18,10 @@ export async function exportTopItemTemplate() { // 컬럼 헤더 정의 및 스타일 적용 worksheet.columns = [ - { header: '아이템 코드', key: 'itemCode', width: 15 }, + { header: '자재 그룹', key: 'itemCode', width: 15 }, { header: '기능(공종)', key: 'workType', width: 15 }, - { header: '아이템 리스트', key: 'itemList', width: 20 }, - { header: '서브 아이템 리스트', key: 'subItemList', width: 20 }, + { header: '자재명', key: 'itemList', width: 20 }, + { header: '자재명(상세)', key: 'subItemList', width: 20 }, ]; diff --git a/lib/items-tech/table/top/offshore-top-table-columns.tsx b/lib/items-tech/table/top/offshore-top-table-columns.tsx index 4746f226..93f27492 100644 --- a/lib/items-tech/table/top/offshore-top-table-columns.tsx +++ b/lib/items-tech/table/top/offshore-top-table-columns.tsx @@ -112,13 +112,13 @@ export function getOffshoreTopColumns({ setRowAction }: GetColumnsProps): Column { accessorKey: "itemCode", header: ({ column }) => ( - + ), cell: ({ row }) =>
{row.original.itemCode}
, enableSorting: true, enableHiding: true, meta: { - excelHeader: "Material Group", + excelHeader: "자재 그룹", }, }, { @@ -136,25 +136,25 @@ export function getOffshoreTopColumns({ setRowAction }: GetColumnsProps): Column { accessorKey: "itemList", header: ({ column }) => ( - + ), cell: ({ row }) =>
{row.original.itemList || "-"}
, enableSorting: true, enableHiding: true, meta: { - excelHeader: "아이템 리스트", + excelHeader: "자재명", }, }, { accessorKey: "subItemList", header: ({ column }) => ( - + ), cell: ({ row }) =>
{row.original.subItemList || "-"}
, enableSorting: true, enableHiding: true, meta: { - excelHeader: "서브 아이템 리스트", + excelHeader: "자재명(상세)", }, }, { diff --git a/lib/items-tech/table/update-items-sheet.tsx b/lib/items-tech/table/update-items-sheet.tsx index efab4b1a..16dfcb71 100644 --- a/lib/items-tech/table/update-items-sheet.tsx +++ b/lib/items-tech/table/update-items-sheet.tsx @@ -61,29 +61,26 @@ const offshoreHullWorkTypes = [ { value: "NC", label: "NC" }, ] as const -interface CommonItemFields { + +type ShipbuildingItem = { id: number - itemId: number itemCode: string - itemName: string - description: string | null - createdAt: Date - updatedAt: Date -} - -type ShipbuildingItem = CommonItemFields & { workType: "기장" | "전장" | "선실" | "배관" | "철의" shipTypes: string itemList: string | null } -type OffshoreTopItem = CommonItemFields & { +type OffshoreTopItem = { + id: number + itemCode: string workType: "TM" | "TS" | "TE" | "TP" itemList: string | null subItemList: string | null } -type OffshoreHullItem = CommonItemFields & { +type OffshoreHullItem = { + id: number + itemCode: string workType: "HA" | "HE" | "HH" | "HM" | "NC" itemList: string | null subItemList: string | null @@ -91,12 +88,9 @@ type OffshoreHullItem = CommonItemFields & { type UpdateItemSchema = { itemCode?: string - itemName?: string - description?: string workType?: string shipTypes?: string itemList?: string - subItemList?: string } interface UpdateItemSheetProps { @@ -112,8 +106,6 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt // 초기값 설정 const form = useForm({ defaultValues: { - itemName: item.itemName, - description: item.description || "", workType: item.workType, ...getItemTypeSpecificDefaults(item, itemType), }, @@ -127,7 +119,7 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt case 'shipbuilding': return { shipTypes: (item as ShipbuildingItem).shipTypes, - itemList: (item as ShipbuildingItem).itemList || "" + itemList: (item as ShipbuildingItem).itemList || "", }; case 'offshoreTop': case 'offshoreHull': @@ -279,25 +271,8 @@ export function UpdateItemSheet({ item, itemType, open, onOpenChange }: UpdateIt )} /> - ( - - 아이템 리스트 - - - - - - )} - /> )} - - {/* 해양 TOP 또는 HULL 아이템 전용 필드 */} - {(itemType === 'offshoreTop' || itemType === 'offshoreHull') && ( - <> )} /> - ( - - 서브 아이템 리스트 - - - - - - )} - /> - - )} diff --git a/lib/items-tech/validations.ts b/lib/items-tech/validations.ts index 09c7878b..653f0af8 100644 --- a/lib/items-tech/validations.ts +++ b/lib/items-tech/validations.ts @@ -63,23 +63,9 @@ export const offshoreHullSearchParamsCache = createSearchParamsCache({ }) -export const createItemSchema = z.object({ - itemCode: z.string(), - itemName: z.string(), - description: z.string(), -}) - -export const updateItemSchema = z.object({ - itemCode: z.string().optional(), - itemName: z.string().optional(), - description: z.string().nullish(), -}) - // 조선 아이템 업데이트 스키마 export const updateShipbuildingItemSchema = z.object({ itemCode: z.string(), - itemName: z.string().optional(), - description: z.string().optional(), workType: z.string().optional(), shipTypes: z.string().optional(), itemList: z.string().optional(), @@ -89,15 +75,11 @@ export type GetShipbuildingSchema = Awaited> export type GetOffshoreHullSchema = Awaited> -export type CreateItemSchema = z.infer -export type UpdateItemSchema = z.infer export type UpdateShipbuildingItemSchema = z.infer // 조선 아이템 스키마 export const createShipbuildingItemSchema = z.object({ itemCode: z.string(), - itemName: z.string(), - description: z.string(), workType: z.string(), shipTypes: z.string(), itemList: z.string().optional(), @@ -105,15 +87,9 @@ export const createShipbuildingItemSchema = z.object({ export type CreateShipbuildingItemSchema = z.infer -// 기본 아이템 생성 데이터 타입 -export interface ItemCreateData { - itemCode: string - itemName: string - description: string | null -} - // 조선 아이템 생성 데이터 타입 -export interface ShipbuildingItemCreateData extends ItemCreateData { +export interface ShipbuildingItemCreateData { + itemCode: string workType: string | null shipTypes: string | null itemList?: string | null @@ -125,8 +101,6 @@ export type TypedItemCreateData = ShipbuildingItemCreateData // 해양 TOP 아이템 스키마 export const createOffshoreTopItemSchema = z.object({ itemCode: z.string(), - itemName: z.string(), - description: z.string(), workType: z.enum(["TM", "TS", "TE", "TP"]), itemList: z.string().optional(), subItemList: z.string().optional(), @@ -135,8 +109,6 @@ export const createOffshoreTopItemSchema = z.object({ // 해양 HULL 아이템 스키마 export const createOffshoreHullItemSchema = z.object({ itemCode: z.string(), - itemName: z.string(), - description: z.string(), workType: z.enum(["HA", "HE", "HH", "HM", "NC"]), itemList: z.string().optional(), subItemList: z.string().optional(), @@ -148,8 +120,6 @@ export type CreateOffshoreHullItemSchema = z.infer // 해양 TOP 아이템 생성 데이터 타입 -export interface OffshoreTopItemCreateData extends ItemCreateData { +export interface OffshoreTopItemCreateData { + itemCode: string workType: "TM" | "TS" | "TE" | "TP" itemList?: string | null subItemList?: string | null } // 해양 HULL 아이템 생성 데이터 타입 -export interface OffshoreHullItemCreateData extends ItemCreateData { +export interface OffshoreHullItemCreateData { + itemCode: string workType: "HA" | "HE" | "HH" | "HM" | "NC" itemList?: string | null subItemList?: string | null -- cgit v1.2.3