diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-03 02:50:02 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-03 02:50:02 +0000 |
| commit | 766f95945a7ca0fdb258d6a83229593e4fcccfa6 (patch) | |
| tree | 3374364b5a90b2704d7ebd18ab404bf6e8fe69e2 /lib/items-tech/service.ts | |
| parent | e4b2bef735e6aab6a5ecae9a017c5c618a6d3a4b (diff) | |
(최겸) 기술영업 RFQ 견적 프로젝트별 생성 기능 추가
Diffstat (limited to 'lib/items-tech/service.ts')
| -rw-r--r-- | lib/items-tech/service.ts | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/lib/items-tech/service.ts b/lib/items-tech/service.ts index be65f5dd..0cc08d23 100644 --- a/lib/items-tech/service.ts +++ b/lib/items-tech/service.ts @@ -13,21 +13,21 @@ import { GetShipbuildingSchema, GetOffshoreTopSchema, GetOffshoreHullSchema, Shi import { itemShipbuilding, itemOffshoreTop, itemOffshoreHull } from "@/db/schema/items";
// 타입 정의 추가
-type WorkType = '기장' | '전장' | '선실' | '배관' | '철의';
-type OffshoreTopWorkType = 'TM' | 'TS' | 'TE' | 'TP';
-type OffshoreHullWorkType = 'HA' | 'HE' | 'HH' | 'HM' | 'NC';
+export type ShipbuildingWorkType = '기장' | '전장' | '선실' | '배관' | '철의';
+export type OffshoreTopWorkType = 'TM' | 'TS' | 'TE' | 'TP';
+export type OffshoreHullWorkType = 'HA' | 'HE' | 'HH' | 'HM' | 'NC';
-interface ShipbuildingItem {
+export interface ShipbuildingItem {
id: number;
itemCode: string;
- workType: WorkType;
+ workType: ShipbuildingWorkType;
itemList: string;
shipTypes: string;
createdAt: Date;
updatedAt: Date;
}
-interface OffshoreTopTechItem {
+export interface OffshoreTopTechItem {
id: number;
itemCode: string;
workType: OffshoreTopWorkType;
@@ -37,7 +37,7 @@ interface OffshoreTopTechItem { updatedAt: Date;
}
-interface OffshoreHullTechItem {
+export interface OffshoreHullTechItem {
id: number;
itemCode: string;
workType: OffshoreHullWorkType;
@@ -409,14 +409,19 @@ export async function createShipbuildingImportItem(input: { }
}
- // 기존 아이템 확인
+ // 기존 아이템 및 선종 확인
const existingItem = await db.select().from(itemShipbuilding)
- .where(eq(itemShipbuilding.itemCode, input.itemCode));
+ .where(
+ and(
+ eq(itemShipbuilding.itemCode, input.itemCode),
+ eq(itemShipbuilding.shipTypes, input.shipTypes || '')
+ )
+ );
if (existingItem.length > 0) {
return {
success: false,
- message: "이미 존재하는 아이템 코드입니다",
+ message: "이미 존재하는 아이템 코드 및 선종입니다",
data: null,
error: "중복 키 오류"
}
@@ -444,7 +449,7 @@ export async function createShipbuildingImportItem(input: { if (err instanceof Error && err.message.includes("unique constraint")) {
return {
success: false,
- message: "이미 존재하는 아이템 코드입니다",
+ message: "이미 존재하는 아이템 코드 및 선종입니다",
data: null,
error: "중복 키 오류"
}
@@ -845,7 +850,7 @@ export async function removeOffshoreHullItems(input: DeleteItemsInput) { ----------------------------------------------------- */
// 조선 공종별 아이템 조회
-export async function getShipbuildingItemsByWorkType(workType?: WorkType, shipType?: string) {
+export async function getShipbuildingItemsByWorkType(workType?: ShipbuildingWorkType, shipType?: string) {
try {
const query = db
.select({
@@ -955,7 +960,7 @@ export async function getOffshoreHullItemsByWorkType(workType?: OffshoreHullWork }
// 아이템 검색
-export async function searchShipbuildingItems(searchQuery: string, workType?: WorkType, shipType?: string) {
+export async function searchShipbuildingItems(searchQuery: string, workType?: ShipbuildingWorkType, shipType?: string) {
try {
const searchConditions = [
ilike(itemShipbuilding.itemCode, `%${searchQuery}%`),
@@ -1096,32 +1101,32 @@ export async function searchOffshoreHullItems(searchQuery: string, workType?: Of // 모든 공종 목록 조회
export async function getWorkTypes() {
return [
- { code: '기장' as WorkType, name: '기장', description: '기계 장치' },
- { code: '전장' as WorkType, name: '전장', description: '전기 장치' },
- { code: '선실' as WorkType, name: '선실', description: '선실' },
- { code: '배관' as WorkType, name: '배관', description: '배관' },
- { code: '철의' as WorkType, name: '철의', description: '선체 강재' },
+ { code: '기장' as ShipbuildingWorkType, name: '기장'},
+ { code: '전장' as ShipbuildingWorkType, name: '전장'},
+ { code: '선실' as ShipbuildingWorkType, name: '선실'},
+ { code: '배관' as ShipbuildingWorkType, name: '배관'},
+ { code: '철의' as ShipbuildingWorkType, name: '철의'},
]
}
// 해양 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' },
+ { code: 'TM' as OffshoreTopWorkType, name: 'TM'},
+ { code: 'TS' as OffshoreTopWorkType, name: 'TS'},
+ { code: 'TE' as OffshoreTopWorkType, name: 'TE'},
+ { code: 'TP' as OffshoreTopWorkType, name: 'TP'},
]
}
// 해양 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' },
+ { code: 'HA' as OffshoreHullWorkType, name: 'HA'},
+ { code: 'HE' as OffshoreHullWorkType, name: 'HE'},
+ { code: 'HH' as OffshoreHullWorkType, name: 'HH'},
+ { code: 'HM' as OffshoreHullWorkType, name: 'HM'},
+ { code: 'NC' as OffshoreHullWorkType, name: 'NC'},
]
}
|
