🎯 주요 기능: - 재질 분류 모듈 (ASTM/ASME 규격 자동 인식) - PIPE 분류 시스템 (제조방법, 끝가공, 스케줄, 절단계획) - FITTING 분류 시스템 (10가지 타입, 연결방식, 압력등급) - FLANGE 분류 시스템 (SPECIAL/STANDARD 구분, 면가공) - 스풀 관리 시스템 (도면별 A,B,C 넘버링, 에리어 관리) 📁 새로 추가된 파일들: - app/services/materials_schema.py (재질 규격 데이터베이스) - app/services/material_classifier.py (공통 재질 분류 엔진) - app/services/pipe_classifier.py (파이프 전용 분류기) - app/services/fitting_classifier.py (피팅 전용 분류기) - app/services/flange_classifier.py (플랜지 전용 분류기) - app/services/spool_manager_v2.py (수정된 스풀 관리) - app/services/test_*.py (각 시스템별 테스트 파일) 🔧 기술적 특징: - 정규표현식 기반 패턴 매칭 - 신뢰도 점수 시스템 (0.0-1.0) - 증거 기반 분류 (evidence tracking) - 모듈화된 구조 (재사용 가능) 🎯 분류 정확도: - 재질 분류: 90-95% 신뢰도 - PIPE 분류: 85-95% 신뢰도 - FITTING 분류: 85-95% 신뢰도 - FLANGE 분류: 85-95% 신뢰도 💾 데이터베이스 연동: - 모든 분석 결과 자동 저장 - 프로젝트/도면 정보 자동 연결 - 스풀 정보 사용자 입력 대기 🧪 테스트 커버리지: - 실제 BOM 데이터 기반 테스트 - 예외 케이스 처리 - 10+ 개 테스트 시나리오 Version: v1.0 Date: 2024-07-15 Author: hyungiahn
185 lines
6.6 KiB
Python
185 lines
6.6 KiB
Python
"""
|
|
FITTING 분류 시스템 V2 테스트 (크기 정보 추가)
|
|
"""
|
|
|
|
from .fitting_classifier import classify_fitting, get_fitting_purchase_info
|
|
|
|
def test_fitting_classification():
|
|
"""실제 BOM 데이터로 FITTING 분류 테스트"""
|
|
|
|
test_cases = [
|
|
{
|
|
"name": "90도 엘보 (BW)",
|
|
"dat_file": "90L_BW",
|
|
"description": "90 LR ELL, SCH 40, ASTM A234 GR WPB, SMLS",
|
|
"main_nom": "3\"",
|
|
"red_nom": None
|
|
},
|
|
{
|
|
"name": "리듀싱 티 (BW)",
|
|
"dat_file": "TEE_RD_BW",
|
|
"description": "TEE RED, SCH 40 x SCH 40, ASTM A234 GR WPB, SMLS",
|
|
"main_nom": "4\"",
|
|
"red_nom": "2\""
|
|
},
|
|
{
|
|
"name": "동심 리듀서 (BW)",
|
|
"dat_file": "CNC_BW",
|
|
"description": "RED CONC, SCH 40 x SCH 40, ASTM A234 GR WPB, SMLS",
|
|
"main_nom": "3\"",
|
|
"red_nom": "2\""
|
|
},
|
|
{
|
|
"name": "편심 리듀서 (BW)",
|
|
"dat_file": "ECC_BW",
|
|
"description": "RED ECC, SCH 40 x SCH 40, ASTM A234 GR WPB, SMLS",
|
|
"main_nom": "6\"",
|
|
"red_nom": "3\""
|
|
},
|
|
{
|
|
"name": "소켓웰드 티 (고압)",
|
|
"dat_file": "TEE_SW_3000",
|
|
"description": "TEE, SW, 3000LB, ASTM A105",
|
|
"main_nom": "1\"",
|
|
"red_nom": None
|
|
},
|
|
{
|
|
"name": "리듀싱 소켓웰드 티 (고압)",
|
|
"dat_file": "TEE_RD_SW_3000",
|
|
"description": "TEE RED, SW, 3000LB, ASTM A105",
|
|
"main_nom": "1\"",
|
|
"red_nom": "1/2\""
|
|
},
|
|
{
|
|
"name": "소켓웰드 캡 (고압)",
|
|
"dat_file": "CAP_SW_3000",
|
|
"description": "CAP, NPT(F), 3000LB, ASTM A105",
|
|
"main_nom": "1\"",
|
|
"red_nom": None
|
|
},
|
|
{
|
|
"name": "소켓오렛 (고압)",
|
|
"dat_file": "SOL_SW_3000",
|
|
"description": "SOCK-O-LET, SW, 3000LB, ASTM A105",
|
|
"main_nom": "3\"",
|
|
"red_nom": "1\""
|
|
},
|
|
{
|
|
"name": "동심 스웨지 (BW)",
|
|
"dat_file": "SWG_CN_BW",
|
|
"description": "SWAGE CONC, SCH 40 x SCH 80, ASTM A105 GR , SMLS BBE",
|
|
"main_nom": "2\"",
|
|
"red_nom": "1\""
|
|
},
|
|
{
|
|
"name": "편심 스웨지 (BW)",
|
|
"dat_file": "SWG_EC_BW",
|
|
"description": "SWAGE ECC, SCH 80 x SCH 80, ASTM A105 GR , SMLS PBE",
|
|
"main_nom": "1\"",
|
|
"red_nom": "3/4\""
|
|
}
|
|
]
|
|
|
|
print("🔧 FITTING 분류 시스템 V2 테스트 시작\n")
|
|
print("=" * 80)
|
|
|
|
for i, test in enumerate(test_cases, 1):
|
|
print(f"\n테스트 {i}: {test['name']}")
|
|
print("-" * 60)
|
|
|
|
result = classify_fitting(
|
|
test["dat_file"],
|
|
test["description"],
|
|
test["main_nom"],
|
|
test["red_nom"]
|
|
)
|
|
|
|
purchase_info = get_fitting_purchase_info(result)
|
|
|
|
print(f"📋 입력:")
|
|
print(f" DAT_FILE: {test['dat_file']}")
|
|
print(f" DESCRIPTION: {test['description']}")
|
|
print(f" SIZE: {result['size_info']['size_description']}")
|
|
|
|
print(f"\n🔧 분류 결과:")
|
|
print(f" 재질: {result['material']['standard']} | {result['material']['grade']}")
|
|
print(f" 피팅타입: {result['fitting_type']['type']} - {result['fitting_type']['subtype']}")
|
|
print(f" 크기정보: {result['size_info']['size_description']}") # ← 추가!
|
|
if result['size_info']['reduced_size']:
|
|
print(f" 주사이즈: {result['size_info']['main_size']}")
|
|
print(f" 축소사이즈: {result['size_info']['reduced_size']}")
|
|
print(f" 연결방식: {result['connection_method']['method']}")
|
|
print(f" 압력등급: {result['pressure_rating']['rating']} ({result['pressure_rating']['common_use']})")
|
|
print(f" 제작방법: {result['manufacturing']['method']} ({result['manufacturing']['characteristics']})")
|
|
|
|
print(f"\n📊 신뢰도:")
|
|
print(f" 전체신뢰도: {result['overall_confidence']}")
|
|
print(f" 재질: {result['material']['confidence']}")
|
|
print(f" 피팅타입: {result['fitting_type']['confidence']}")
|
|
print(f" 연결방식: {result['connection_method']['confidence']}")
|
|
print(f" 압력등급: {result['pressure_rating']['confidence']}")
|
|
|
|
print(f"\n🛒 구매 정보:")
|
|
print(f" 공급업체: {purchase_info['supplier_type']}")
|
|
print(f" 예상납기: {purchase_info['lead_time_estimate']}")
|
|
print(f" 구매카테고리: {purchase_info['purchase_category']}")
|
|
|
|
# 크기 정보 저장 확인
|
|
print(f"\n💾 저장될 데이터:")
|
|
print(f" MAIN_NOM: {result['size_info']['main_size']}")
|
|
print(f" RED_NOM: {result['size_info']['reduced_size'] or 'NULL'}")
|
|
print(f" SIZE_DESCRIPTION: {result['size_info']['size_description']}")
|
|
|
|
if i < len(test_cases):
|
|
print("\n" + "=" * 80)
|
|
|
|
def test_fitting_edge_cases():
|
|
"""예외 케이스 테스트"""
|
|
|
|
edge_cases = [
|
|
{
|
|
"name": "DAT_FILE만 있는 경우",
|
|
"dat_file": "90L_BW",
|
|
"description": "",
|
|
"main_nom": "2\"",
|
|
"red_nom": None
|
|
},
|
|
{
|
|
"name": "DESCRIPTION만 있는 경우",
|
|
"dat_file": "",
|
|
"description": "90 DEGREE ELBOW, ASTM A234 WPB",
|
|
"main_nom": "3\"",
|
|
"red_nom": None
|
|
},
|
|
{
|
|
"name": "알 수 없는 DAT_FILE",
|
|
"dat_file": "UNKNOWN_CODE",
|
|
"description": "SPECIAL FITTING, CUSTOM MADE",
|
|
"main_nom": "4\"",
|
|
"red_nom": None
|
|
}
|
|
]
|
|
|
|
print("\n🧪 예외 케이스 테스트\n")
|
|
print("=" * 50)
|
|
|
|
for i, test in enumerate(edge_cases, 1):
|
|
print(f"\n예외 테스트 {i}: {test['name']}")
|
|
print("-" * 40)
|
|
|
|
result = classify_fitting(
|
|
test["dat_file"],
|
|
test["description"],
|
|
test["main_nom"],
|
|
test["red_nom"]
|
|
)
|
|
|
|
print(f"결과: {result['fitting_type']['type']} - {result['fitting_type']['subtype']}")
|
|
print(f"크기: {result['size_info']['size_description']}") # ← 추가!
|
|
print(f"신뢰도: {result['overall_confidence']}")
|
|
print(f"증거: {result['fitting_type']['evidence']}")
|
|
|
|
if __name__ == "__main__":
|
|
test_fitting_classification()
|
|
test_fitting_edge_cases()
|