✅ 주요 완성 기능: - 프로젝트 생성 API (project_name 필드 포함) - 엑셀 파일 업로드 및 파싱 시스템 - 자재 DB 저장 (2837개 자재 성공 저장) - 자재 조회 및 요약 통계 API - 외래키 관계 정상 동작 (projects -> files -> materials) 📊 테스트 결과: - MP7 PIPING PROJECT Rev.2 프로젝트 생성 - 00.MP7 PIPING R.2_BOM.XLS 파일 업로드 성공 - NIPPLE, PIPE 등 자재 분류 및 재질 추출 - ASTM A106, SCH 80, 1인치 사이즈 등 정확 파싱 🛠️ 기술 스택: - FastAPI + PostgreSQL + SQLAlchemy - pandas를 활용한 엑셀 파싱 - 외래키 제약조건 적용된 정규화 DB 설계
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
from pydantic import BaseModel, Field
|
|
from datetime import datetime
|
|
from typing import Optional, List
|
|
|
|
# Project Schemas (project_name 추가)
|
|
class ProjectBase(BaseModel):
|
|
official_project_code: str = Field(..., description="공식 프로젝트 코드")
|
|
project_name: str = Field(..., description="프로젝트명") # 추가
|
|
design_project_code: Optional[str] = Field(None, description="설계 프로젝트 코드")
|
|
is_code_matched: bool = Field(False, description="코드 매칭 여부")
|
|
status: str = Field("active", description="프로젝트 상태")
|
|
|
|
class ProjectCreate(ProjectBase):
|
|
pass
|
|
|
|
class ProjectResponse(ProjectBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
# File Schemas (기존 유지)
|
|
class FileResponse(BaseModel):
|
|
id: int
|
|
filename: str
|
|
original_filename: str
|
|
file_path: str
|
|
project_id: int
|
|
project_code: Optional[str] = None
|
|
revision: str = "Rev.0"
|
|
description: Optional[str] = None
|
|
upload_date: datetime
|
|
parsed_count: int = 0
|
|
is_active: bool = True
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class FileUploadResponse(BaseModel):
|
|
success: bool
|
|
message: str
|
|
file_id: int
|
|
filename: str
|
|
parsed_materials_count: int
|
|
file_path: str
|