diff options
Diffstat (limited to 'db')
| -rw-r--r-- | db/schema/avl/avl.ts | 121 | ||||
| -rw-r--r-- | db/schema/avl/vendor-pool.ts | 109 | ||||
| -rw-r--r-- | db/schema/index.ts | 6 |
3 files changed, 235 insertions, 1 deletions
diff --git a/db/schema/avl/avl.ts b/db/schema/avl/avl.ts new file mode 100644 index 00000000..addbba94 --- /dev/null +++ b/db/schema/avl/avl.ts @@ -0,0 +1,121 @@ +import { pgTable, text, boolean, integer, timestamp, varchar, decimal } from "drizzle-orm/pg-core"; +import { createInsertSchema, createSelectSchema } from "drizzle-zod"; + +// AVL 리스트 테이블 (프로젝트 AVL 및 선종별 표준 AVL 리스트) +export const avlList = pgTable("avl_list", { + // 기본 식별자 + id: integer("id").primaryKey().generatedAlwaysAsIdentity(), + + // 구분자 + isTemplate: boolean("is_template").default(false), // false: 프로젝트 AVL, true: 표준 AVL + + // 기본 정보 + constructionSector: varchar("construction_sector", { length: 10 }).notNull(), // 조선/해양 + projectCode: varchar("project_code", { length: 50 }), // 프로젝트코드 (프로젝트 AVL일 경우) + shipType: varchar("ship_type", { length: 50 }), // 선종 + avlKind: varchar("avl_kind", { length: 50 }), // AVL 종류 + htDivision: varchar("ht_division", { length: 10 }), // H=Hull, T=Top, 공통 + rev: integer("rev").default(1), // 리비전 정보 + + // 타임스탬프 + createdAt: timestamp("created_at").defaultNow(), // 등재일 + createdBy: varchar("created_by", { length: 50 }), // 등재자 + updatedAt: timestamp("updated_at").defaultNow(), // 최종변경일 + updatedBy: varchar("updated_by", { length: 50 }), // 최종변경자 +}); + +// AVL별 자재그룹 취급사 정보 테이블 +export const avlVendorInfo = pgTable("avl_vendor_info", { + // 기본 식별자 + id: integer("id").primaryKey().generatedAlwaysAsIdentity(), + + projectCode: varchar("project_code", { length: 50 }), // 프로젝트코드 (프로젝트 AVL일 경우) + + // AVL 리스트와의 관계 (외래키) + avlListId: integer("avl_list_id").references(() => avlList.id), + + // 제안방향 + ownerSuggestion: boolean("owner_suggestion").default(false), // 선주 제안사인 경우 + shiSuggestion: boolean("shi_suggestion").default(false), // SHI 제안사인 경우 + + // 설계 정보 + equipBulkDivision: varchar("equip_bulk_division", { length: 1 }), // E 또는 B + disciplineCode: varchar("discipline_code", { length: 10 }), // 설계공종코드 + disciplineName: varchar("discipline_name", { length: 50 }), // 설계공종명 + + // 자재 정보 + materialNameCustomerSide: varchar("material_name_customer_side", { length: 100 }), // 고객사 AVL 자재명 + + // 패키지 정보 + packageCode: varchar("package_code", { length: 50 }), // 패키지 코드 + packageName: varchar("package_name", { length: 100 }), // 패키지 명 + + // 자재그룹 정보 + materialGroupCode: varchar("material_group_code", { length: 50 }), // 자재그룹 코드 + materialGroupName: varchar("material_group_name", { length: 100 }), // 자재그룹 명 + + // 협력업체 정보 + vendorId: integer("vendor_id"), // 협력업체 ID (nullable - 없는 경우도 있음) + vendorName: varchar("vendor_name", { length: 100 }), // 협력업체 명 + vendorCode: varchar("vendor_code", { length: 50 }), // 협력업체 코드 + + // AVL 정보 + avlVendorName: varchar("avl_vendor_name", { length: 100 }), // AVL 등재업체명 + tier: varchar("tier", { length: 20 }), // 등급 + + // FA 정보 + faTarget: boolean("fa_target").default(false), // FA 대상 + faStatus: varchar("fa_status", { length: 50 }), // FA 현황 + + // Agent 정보 + isAgent: boolean("is_agent").default(false), // Agent 여부 + + // 계약 서명주체 + contractSignerId: integer("contract_signer_id"), // 계약서명주체 ID (nullable) + contractSignerName: varchar("contract_signer_name", { length: 100 }), // 계약서명주체 명 + contractSignerCode: varchar("contract_signer_code", { length: 50 }), // 계약서명주체 코드 + + // 위치 정보 + headquarterLocation: varchar("headquarter_location", { length: 50 }), // 본사 위치 (국가) + manufacturingLocation: varchar("manufacturing_location", { length: 50 }), // 제작/선적지 (국가) + + // SHI Qualification + hasAvl: boolean("has_avl").default(false), // AVL + isBlacklist: boolean("is_blacklist").default(false), // Blacklist + isBcc: boolean("is_bcc").default(false), // BCC + + // 기술영업 견적결과 + techQuoteNumber: varchar("tech_quote_number", { length: 50 }), // 기술영업 견적번호 + quoteCode: varchar("quote_code", { length: 50 }), // 견적서 Code + quoteVendorId: integer("quote_vendor_id"), // 견적 협력업체 ID (nullable) + quoteVendorName: varchar("quote_vendor_name", { length: 100 }), // 견적 협력업체 명 + quoteVendorCode: varchar("quote_vendor_code", { length: 50 }), // 견적 협력업체 코드 + quoteCountry: varchar("quote_country", { length: 50 }), // 국가 + quoteTotalAmount: decimal("quote_total_amount", { precision: 15, scale: 2 }), // 총 금액 + quoteReceivedDate: varchar("quote_received_date", { length: 10 }), // 견적접수일 (YYYY-MM-DD) + + // 업체 실적 현황 + recentQuoteDate: varchar("recent_quote_date", { length: 10 }), // 최근견적일 (YYYY-MM-DD) + recentQuoteNumber: varchar("recent_quote_number", { length: 50 }), // 최근견적번호 + recentOrderDate: varchar("recent_order_date", { length: 10 }), // 최근발주일 (YYYY-MM-DD) + recentOrderNumber: varchar("recent_order_number", { length: 50 }), // 최근발주번호 + + // 기타 + remark: varchar("remark", { length: 1000 }), // 비고 + + // 타임스탬프 + createdAt: timestamp("created_at").defaultNow(), + updatedAt: timestamp("updated_at").defaultNow(), +}); + +// Zod 스키마 생성 +export const insertAvlListSchema = createInsertSchema(avlList); +export const selectAvlListSchema = createSelectSchema(avlList); +export const insertAvlVendorInfoSchema = createInsertSchema(avlVendorInfo); +export const selectAvlVendorInfoSchema = createSelectSchema(avlVendorInfo); + +// 타입 추론 +export type AvlList = typeof avlList.$inferSelect; +export type NewAvlList = typeof avlList.$inferInsert; +export type AvlVendorInfo = typeof avlVendorInfo.$inferSelect; +export type NewAvlVendorInfo = typeof avlVendorInfo.$inferInsert; diff --git a/db/schema/avl/vendor-pool.ts b/db/schema/avl/vendor-pool.ts new file mode 100644 index 00000000..62f9dace --- /dev/null +++ b/db/schema/avl/vendor-pool.ts @@ -0,0 +1,109 @@ +import { pgTable, text, boolean, integer, timestamp, varchar } from "drizzle-orm/pg-core"; +import { createInsertSchema, createSelectSchema } from "drizzle-zod"; + +// Vendor Pool 테이블 +// 자재그룹코드 + 벤더 복합키 형태로 관리되는 테이블 +export const vendorPool = pgTable("vendor_pool", { + // 기본 식별자 + id: integer("id").primaryKey().generatedAlwaysAsIdentity(), + + // 기본 정보 + constructionSector: varchar("construction_sector", { length: 10 }).notNull(), // 조선/해양 + htDivision: varchar("ht_division", { length: 10 }).notNull(), // H 또는 T 또는 공통 + + // 설계 정보 + designCategoryCode: varchar("design_category_code", { length: 2 }).notNull(), // 2자리 영문대문자 + designCategory: varchar("design_category", { length: 50 }).notNull(), // 전장 등 + equipBulkDivision: varchar("equip_bulk_division", { length: 1 }).notNull(), // E 또는 B + + // 패키지 정보 + packageCode: varchar("package_code", { length: 50 }), // 패키지 코드 + packageName: varchar("package_name", { length: 100 }), // 패키지 명 + + // 자재그룹 정보 + materialGroupCode: varchar("material_group_code", { length: 50 }), // 자재그룹 코드 + materialGroupName: varchar("material_group_name", { length: 100 }), // 자재그룹 명 + + // 자재 관련 정보 + smCode: varchar("sm_code", { length: 50 }), + similarMaterialNamePurchase: varchar("similar_material_name_purchase", { length: 100 }), // 유사자재명 (구매) + similarMaterialNameOther: varchar("similar_material_name_other", { length: 100 }), // 유사자재명 (구매 외) + + // 협력업체 정보 + vendorCode: varchar("vendor_code", { length: 50 }), // 협력업체 코드 + vendorName: varchar("vendor_name", { length: 100 }), // 협력업체 명 + + // 사업 및 인증 정보 + taxId: varchar("tax_id", { length: 50 }), // 사업자번호 + faTarget: boolean("fa_target").default(false), // FA대상 + faStatus: varchar("fa_status", { length: 50 }), // FA현황 + faRemark: varchar("fa_remark", { length: 200 }), // FA상세 + tier: varchar("tier", { length: 20 }), // 등급 + isAgent: boolean("is_agent").default(false), // Agent 여부 + + // 계약 정보 + contractSignerCode: varchar("contract_signer_code", { length: 50 }), // 계약서명주체 코드 + contractSignerName: varchar("contract_signer_name", { length: 100 }), // 계약서명주체 명 + + // 위치 정보 + headquarterLocation: varchar("headquarter_location", { length: 50 }), // 본사 위치 (국가) + manufacturingLocation: varchar("manufacturing_location", { length: 50 }), // 제작/선적지 (국가) + + // AVL 관련 정보 + avlVendorName: varchar("avl_vendor_name", { length: 100 }), // AVL 등재업체명 + similarVendorName: varchar("similar_vendor_name", { length: 100 }), // 유사업체명(기술영업) + hasAvl: boolean("has_avl").default(false), // AVL 존재여부 + + // 상태 정보 + isBlacklist: boolean("is_blacklist").default(false), // Blacklist + isBcc: boolean("is_bcc").default(false), // BCC + purchaseOpinion: varchar("purchase_opinion", { length: 500 }), // 구매의견 + + // AVL 적용 선종(조선) + shipTypeCommon: boolean("ship_type_common").default(false), // 공통 + shipTypeAmax: boolean("ship_type_amax").default(false), // A-max + shipTypeSmax: boolean("ship_type_smax").default(false), // S-max + shipTypeVlcc: boolean("ship_type_vlcc").default(false), // VLCC + shipTypeLngc: boolean("ship_type_lngc").default(false), // LNGC + shipTypeCont: boolean("ship_type_cont").default(false), // CONT + + // AVL 적용 선종(해양) + offshoreTypeCommon: boolean("offshore_type_common").default(false), // 공통 + offshoreTypeFpso: boolean("offshore_type_fpso").default(false), // FPSO + offshoreTypeFlng: boolean("offshore_type_flng").default(false), // FLNG + offshoreTypeFpu: boolean("offshore_type_fpu").default(false), // FPU + offshoreTypePlatform: boolean("offshore_type_platform").default(false), // Platform + offshoreTypeWtiv: boolean("offshore_type_wtiv").default(false), // WTIV + offshoreTypeGom: boolean("offshore_type_gom").default(false), // GOM + + // eVCP 미등록 정보 + picName: varchar("pic_name", { length: 50 }), // PIC(담당자) + picEmail: varchar("pic_email", { length: 100 }), // PIC(E-mail) + picPhone: varchar("pic_phone", { length: 20 }), // PIC(Phone) + agentName: varchar("agent_name", { length: 50 }), // Agent(담당자) + agentEmail: varchar("agent_email", { length: 100 }), // Agent(E-mail) + agentPhone: varchar("agent_phone", { length: 20 }), // Agent(Phone) + + // 업체 실적 현황 + recentQuoteDate: varchar("recent_quote_date", { length: 10 }), // 최근견적일 (YYYY-MM-DD) + recentQuoteNumber: varchar("recent_quote_number", { length: 50 }), // 최근견적번호 + recentOrderDate: varchar("recent_order_date", { length: 10 }), // 최근발주일 (YYYY-MM-DD) + recentOrderNumber: varchar("recent_order_number", { length: 50 }), // 최근발주번호 + + // 업데이트 히스토리 + registrationDate: timestamp("registration_date").defaultNow(), // 등재일 + registrant: varchar("registrant", { length: 50 }), // 등재자 + lastModifiedDate: timestamp("last_modified_date").defaultNow(), // 최종변경일 + lastModifier: varchar("last_modifier", { length: 50 }), // 최종변경자 +}); + +// 복합키 인덱스 (자재그룹코드 + 벤더코드) +// 구매 의도상은 복합키가 맞는 것 같은데, 요구사항 불명확하므로 별도 제약조건 없이 개발 후 요구 나오면 수정 + +// Zod 스키마 생성 +export const insertVendorPoolSchema = createInsertSchema(vendorPool); +export const selectVendorPoolSchema = createSelectSchema(vendorPool); + +// 타입 추론 +export type VendorPool = typeof vendorPool.$inferSelect; +export type NewVendorPool = typeof vendorPool.$inferInsert; diff --git a/db/schema/index.ts b/db/schema/index.ts index 4724c8b5..aca969fe 100644 --- a/db/schema/index.ts +++ b/db/schema/index.ts @@ -67,4 +67,8 @@ export * from './knox/approvals'; // Knox 결재 - eVCP 에서 상신한 결재 export * from './risks/risks'; // === S-ERP 스키마 === -export * from './S_ERP/s_erp';
\ No newline at end of file +// export * from './S_ERP/s_erp'; + +// AVL 스키마 +export * from './avl/avl'; +export * from './avl/vendor-pool';
\ No newline at end of file |
