1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
import { pgTable, varchar, text, timestamp, serial, integer, unique, pgView } from "drizzle-orm/pg-core"
import { MATERIAL_GROUP_MASTER } from "./MDG/mdg"
// 자재 아이템 정보 테이블 (items) - 기존 CMCTB_MAT_CLAS 테이블 매핑 (SOAP 연결 시 컬럼이 추가/삭제될 수 있음)
export const items = pgTable("items", {
id: serial("id").primaryKey(), // 고유 식별자 (신규 추가)
ProjectNo: varchar("project_no", { length: 100 }).notNull(), // CLAS_CD - 아이템 코드 (자재 클래스 코드)
itemCode: varchar("item_code", { length: 100 }).notNull(), // CLAS_CD - 아이템 코드 (자재 클래스 코드) - unique 제거
itemName: varchar("item_name", { length: 255 }).notNull(), // CLAS_NM - 아이템명 (자재 클래스명)
packageCode: varchar("package_code", { length: 255 }).notNull(), // CLAS_NM - 아이템명 (자재 클래스명)
smCode: varchar("sm_code", { length: 255 }), // CLAS_NM - 아이템명 (자재 클래스명)
description: text("description"), // CLAS_DTL - 아이템 상세 설명 (클래스 내역)
parentItemCode: varchar("parent_item_code", { length: 18 }), // PRNT_CLAS_CD - 부모 아이템 코드 (부모 클래스 코드)
itemLevel: integer("item_level"), // CLAS_LVL - 아이템 레벨 (클래스 레벨)
deleteFlag: varchar("delete_flag", { length: 1 }), // DEL_ORDR - 삭제 지시자 (Y/N)
unitOfMeasure: varchar("unit_of_measure", { length: 3 }), // UOM - 단위 (UOM)
steelType: varchar("steel_type", { length: 2 }), // STYPE - 강종 (Steel Type)
gradeMaterial: varchar("grade_material", { length: 50 }), // GRD_MATL - 등급 재질 (Grade Material)
changeDate: varchar("change_date", { length: 8 }), // CHG_DT - 수정일자 (YYYYMMDD)
baseUnitOfMeasure: varchar("base_unit_of_measure", { length: 3 }), // BSE_UOM - 기준 단위 (Base UOM)
createdAt: timestamp("created_at").defaultNow().notNull(), // 생성일시 (신규 추가)
updatedAt: timestamp("updated_at").defaultNow().notNull(), // 수정일시 (신규 추가)
}, (table) => ({
// ProjectNo와 itemCode의 복합 unique constraint
projectItemUnique: unique("project_item_unique").on(table.ProjectNo, table.itemCode),
}));
export const materials = pgTable("materials", {
id: serial("id").primaryKey(), // 고유 식별자 (신규 추가)
itemCode: varchar("item_code", { length: 100 }).unique(), // CLAS_CD - 아이템 코드 (자재 클래스 코드)
itemName: varchar("item_name", { length: 255 }).notNull(), // CLAS_NM - 아이템명 (자재 클래스명)
description: text("description"), // CLAS_DTL - 아이템 상세 설명 (클래스 내역)
parentItemCode: varchar("parent_item_code", { length: 18 }), // PRNT_CLAS_CD - 부모 아이템 코드 (부모 클래스 코드)
itemLevel: integer("item_level"), // CLAS_LVL - 아이템 레벨 (클래스 레벨)
deleteFlag: varchar("delete_flag", { length: 1 }), // DEL_ORDR - 삭제 지시자 (Y/N)
unitOfMeasure: varchar("unit_of_measure", { length: 3 }), // UOM - 단위 (UOM)
steelType: varchar("steel_type", { length: 2 }), // STYPE - 강종 (Steel Type)
gradeMaterial: varchar("grade_material", { length: 50 }), // GRD_MATL - 등급 재질 (Grade Material)
changeDate: varchar("change_date", { length: 8 }), // CHG_DT - 수정일자 (YYYYMMDD)
baseUnitOfMeasure: varchar("base_unit_of_measure", { length: 3 }), // BSE_UOM - 기준 단위 (Base UOM)
createdAt: timestamp("created_at").defaultNow().notNull(), // 생성일시 (신규 추가)
updatedAt: timestamp("updated_at").defaultNow().notNull(), // 수정일시 (신규 추가)
});
export type Item = typeof items.$inferSelect
export type Materials = typeof materials.$inferSelect
//조선 아이템 테이블
//아이템코드(:자재그룹코드), 아이템이름(:아이템리스트), 공종(:workType), 선종, createdAt(:생성일), updatedAt(:수정일)
export const itemShipbuilding = pgTable("item_shipbuilding", {
id: serial("id").primaryKey(),
itemCode: varchar("item_code", { length: 100 }),
workType: varchar("work_type", { length: 20 }),
itemList: text("item_list"),
shipTypes: text("ship_types").notNull().default('OPTION'),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
export type ItemShipbuilding = typeof itemShipbuilding.$inferSelect;
//해양 TOP 아이템 테이블
export const itemOffshoreTop = pgTable("item_offshore_top", {
id: serial("id").primaryKey(),
itemCode: varchar("item_code", { length: 100 }),
workType: varchar("work_type", { length: 20 }),
itemList: text("item_list"),
subItemList: text("sub_item_list"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
//해양 HULL 아이템 테이블
export const itemOffshoreHull = pgTable("item_offshore_hull", {
id: serial("id").primaryKey(),
itemCode: varchar("item_code", { length: 100 }),
workType: varchar("work_type", { length: 20 }),
itemList: text("item_list"),
subItemList: text("sub_item_list"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
export type ItemOffshoreTop = typeof itemOffshoreTop.$inferSelect;
export type ItemOffshoreHull = typeof itemOffshoreHull.$inferSelect;
//각 테이블별 컬럼 변경(itemid -> itemCode)
|