feat: 밸브 분류 시스템 및 구매 관리 시스템 기초 구현
✅ 밸브 분류 시스템: - VALVE 상세 정보 저장 로직 추가 (backend/app/routers/files.py) - 프론트엔드 밸브 사양서 표시 로직 추가 (MaterialsPage.jsx) - 밸브 분류기 테스트 스크립트 및 데이터 (test_valve_classifier.py, test_valve_bom.csv) 🛒 구매 관리 시스템: - 구매 관리 테이블 스키마 (08_create_purchase_tables.sql) - 구매확정 페이지 컴포넌트 (PurchaseConfirmationPage.jsx) - MaterialsPage에 구매확정 버튼 추가 🎯 주요 기능: - 밸브 타입, 연결방식, 압력등급, 재질 분류 - 구매 품목 마스터, 주문 관리, 리비전 추적 - 파이프 절단손실 및 6M 단위 계산 준비
This commit is contained in:
@@ -770,6 +770,105 @@ async def upload_file(
|
||||
})
|
||||
|
||||
print(f"BOLT 상세 정보 저장 완료: {bolt_type} - {material_standard} {material_grade}")
|
||||
|
||||
# VALVE 분류 결과인 경우 상세 정보 저장
|
||||
if classification_result.get("category") == "VALVE":
|
||||
print("VALVE 상세 정보 저장 시작")
|
||||
|
||||
# 밸브 타입 정보
|
||||
valve_type_info = classification_result.get("valve_type", {})
|
||||
connection_info = classification_result.get("connection_method", {})
|
||||
pressure_info = classification_result.get("pressure_rating", {})
|
||||
material_info = classification_result.get("material", {})
|
||||
|
||||
# 밸브 타입 (GATE_VALVE, BALL_VALVE 등)
|
||||
valve_type = ""
|
||||
if isinstance(valve_type_info, dict):
|
||||
valve_type = valve_type_info.get("type", "UNKNOWN")
|
||||
else:
|
||||
valve_type = str(valve_type_info) if valve_type_info else "UNKNOWN"
|
||||
|
||||
# 밸브 서브타입 (특수 기능)
|
||||
valve_subtype = ""
|
||||
special_features = classification_result.get("special_features", [])
|
||||
if special_features:
|
||||
valve_subtype = ", ".join(special_features)
|
||||
|
||||
# 작동 방식
|
||||
actuator_type = "MANUAL" # 기본값
|
||||
actuation_info = classification_result.get("actuation", {})
|
||||
if isinstance(actuation_info, dict):
|
||||
actuator_type = actuation_info.get("method", "MANUAL")
|
||||
|
||||
# 연결 방식 (FLANGED, THREADED 등)
|
||||
connection_method = ""
|
||||
if isinstance(connection_info, dict):
|
||||
connection_method = connection_info.get("method", "UNKNOWN")
|
||||
else:
|
||||
connection_method = str(connection_info) if connection_info else "UNKNOWN"
|
||||
|
||||
# 압력 등급 (150LB, 300LB 등)
|
||||
pressure_rating = ""
|
||||
if isinstance(pressure_info, dict):
|
||||
pressure_rating = pressure_info.get("rating", "UNKNOWN")
|
||||
else:
|
||||
pressure_rating = str(pressure_info) if pressure_info else "UNKNOWN"
|
||||
|
||||
# 재질 정보
|
||||
body_material = ""
|
||||
trim_material = ""
|
||||
if isinstance(material_info, dict):
|
||||
body_material = material_info.get("grade", "")
|
||||
# 트림 재질은 일반적으로 바디와 동일하거나 별도 명시
|
||||
trim_material = body_material
|
||||
|
||||
# 사이즈 정보
|
||||
size_inches = material_data.get("main_nom") or material_data.get("size_spec", "")
|
||||
|
||||
# 특수 기능 (Fire Safe, Anti-Static 등)
|
||||
fire_safe = any("FIRE" in feature.upper() for feature in special_features)
|
||||
low_temp_service = any("CRYO" in feature.upper() or "LOW" in feature.upper() for feature in special_features)
|
||||
|
||||
# 추가 정보 JSON 생성
|
||||
additional_info = {
|
||||
"characteristics": valve_type_info.get("characteristics", "") if isinstance(valve_type_info, dict) else "",
|
||||
"typical_connections": valve_type_info.get("typical_connections", []) if isinstance(valve_type_info, dict) else [],
|
||||
"special_features": special_features,
|
||||
"manufacturing": classification_result.get("manufacturing", {}),
|
||||
"evidence": valve_type_info.get("evidence", []) if isinstance(valve_type_info, dict) else []
|
||||
}
|
||||
additional_info_json = json.dumps(additional_info, ensure_ascii=False)
|
||||
|
||||
db.execute(text("""
|
||||
INSERT INTO valve_details (
|
||||
material_id, file_id, valve_type, valve_subtype,
|
||||
actuator_type, connection_method, pressure_rating,
|
||||
body_material, trim_material, size_inches,
|
||||
fire_safe, low_temp_service, classification_confidence, additional_info
|
||||
) VALUES (
|
||||
:material_id, :file_id, :valve_type, :valve_subtype,
|
||||
:actuator_type, :connection_method, :pressure_rating,
|
||||
:body_material, :trim_material, :size_inches,
|
||||
:fire_safe, :low_temp_service, :classification_confidence, :additional_info
|
||||
)
|
||||
"""), {
|
||||
"material_id": material_id,
|
||||
"file_id": file_id,
|
||||
"valve_type": valve_type,
|
||||
"valve_subtype": valve_subtype,
|
||||
"actuator_type": actuator_type,
|
||||
"connection_method": connection_method,
|
||||
"pressure_rating": pressure_rating,
|
||||
"body_material": body_material,
|
||||
"trim_material": trim_material,
|
||||
"size_inches": size_inches,
|
||||
"fire_safe": fire_safe,
|
||||
"low_temp_service": low_temp_service,
|
||||
"classification_confidence": classification_result.get("overall_confidence", 0.0),
|
||||
"additional_info": additional_info_json
|
||||
})
|
||||
|
||||
print(f"VALVE 상세 정보 저장 완료: {valve_type} - {connection_method} - {pressure_rating}")
|
||||
|
||||
db.commit()
|
||||
print(f"자재 저장 완료: {materials_inserted}개")
|
||||
|
||||
Reference in New Issue
Block a user