feat: 자재 분류 시스템 개선 및 상세 테이블 추가
- 모든 자재 카테고리별 상세 테이블 생성 (fitting, valve, flange, bolt, gasket, instrument) - PIPE, FITTING, VALVE 분류 결과를 각 상세 테이블에 저장하는 로직 구현 - 프론트엔드 라우팅 정리 및 BOM 현황 페이지 기능 개선 - 자재확인 페이지 에러 처리 개선 TODO: FLANGE, BOLT, GASKET, INSTRUMENT 저장 로직 추가 필요
This commit is contained in:
@@ -183,7 +183,7 @@ BOLT_GRADES = {
|
||||
}
|
||||
}
|
||||
|
||||
def classify_bolt(dat_file: str, description: str, main_nom: str) -> Dict:
|
||||
def classify_bolt(dat_file: str, description: str, main_nom: str, length: float = None) -> Dict:
|
||||
"""
|
||||
완전한 BOLT 분류
|
||||
|
||||
|
||||
@@ -86,11 +86,11 @@ FITTING_TYPES = {
|
||||
},
|
||||
|
||||
"OLET": {
|
||||
"dat_file_patterns": ["SOL_", "WOL_", "TOL_", "OLET_"],
|
||||
"description_keywords": ["OLET", "올렛", "O-LET"],
|
||||
"dat_file_patterns": ["SOL_", "WOL_", "TOL_", "OLET_", "SOCK-O-LET", "WELD-O-LET"],
|
||||
"description_keywords": ["OLET", "올렛", "O-LET", "SOCK-O-LET", "WELD-O-LET", "SOCKOLET", "WELDOLET"],
|
||||
"subtypes": {
|
||||
"SOCKOLET": ["SOCK-O-LET", "SOCKOLET", "SOL"],
|
||||
"WELDOLET": ["WELD-O-LET", "WELDOLET", "WOL"],
|
||||
"SOCKOLET": ["SOCK-O-LET", "SOCKOLET", "SOL", "SOCK O-LET"],
|
||||
"WELDOLET": ["WELD-O-LET", "WELDOLET", "WOL", "WELD O-LET"],
|
||||
"THREADOLET": ["THREAD-O-LET", "THREADOLET", "TOL"],
|
||||
"ELBOLET": ["ELB-O-LET", "ELBOLET", "EOL"]
|
||||
},
|
||||
@@ -171,7 +171,7 @@ PRESSURE_RATINGS = {
|
||||
}
|
||||
|
||||
def classify_fitting(dat_file: str, description: str, main_nom: str,
|
||||
red_nom: str = None) -> Dict:
|
||||
red_nom: str = None, length: float = None) -> Dict:
|
||||
"""
|
||||
완전한 FITTING 분류
|
||||
|
||||
@@ -185,7 +185,21 @@ def classify_fitting(dat_file: str, description: str, main_nom: str,
|
||||
완전한 피팅 분류 결과
|
||||
"""
|
||||
|
||||
# 1. 재질 분류 (공통 모듈 사용)
|
||||
desc_upper = description.upper()
|
||||
dat_upper = dat_file.upper()
|
||||
|
||||
# 1. 명칭 우선 확인 (피팅 키워드가 있으면 피팅)
|
||||
fitting_keywords = ['ELBOW', 'TEE', 'REDUCER', 'CAP', 'NIPPLE', 'SWAGE', 'OLET', 'COUPLING', '엘보', '티', '리듀서', '캡', '니플', '스웨지', '올렛', '커플링', 'SOCK-O-LET', 'WELD-O-LET', 'SOCKOLET', 'WELDOLET']
|
||||
is_fitting = any(keyword in desc_upper or keyword in dat_upper for keyword in fitting_keywords)
|
||||
|
||||
if not is_fitting:
|
||||
return {
|
||||
"category": "UNKNOWN",
|
||||
"overall_confidence": 0.0,
|
||||
"reason": "피팅 키워드 없음"
|
||||
}
|
||||
|
||||
# 2. 재질 분류 (공통 모듈 사용)
|
||||
material_result = classify_material(description)
|
||||
|
||||
# 2. 피팅 타입 분류
|
||||
@@ -328,7 +342,7 @@ def classify_fitting_subtype(fitting_type: str, description: str,
|
||||
|
||||
# 2. 사이즈 분석이 필요한 경우 (TEE, REDUCER 등)
|
||||
if type_data.get("size_analysis"):
|
||||
if red_nom and red_nom.strip() and red_nom != main_nom:
|
||||
if red_nom and str(red_nom).strip() and red_nom != main_nom:
|
||||
return {
|
||||
"subtype": "REDUCING",
|
||||
"confidence": 0.85,
|
||||
@@ -343,7 +357,7 @@ def classify_fitting_subtype(fitting_type: str, description: str,
|
||||
|
||||
# 3. 두 사이즈가 필요한 경우 확인
|
||||
if type_data.get("requires_two_sizes"):
|
||||
if red_nom and red_nom.strip():
|
||||
if red_nom and str(red_nom).strip():
|
||||
confidence = 0.8
|
||||
evidence = [f"TWO_SIZES_PROVIDED: {main_nom} x {red_nom}"]
|
||||
else:
|
||||
@@ -511,11 +525,12 @@ def determine_fitting_manufacturing(material_result: Dict, connection_result: Di
|
||||
|
||||
def format_fitting_size(main_nom: str, red_nom: str = None) -> str:
|
||||
"""피팅 사이즈 표기 포맷팅"""
|
||||
|
||||
if red_nom and red_nom.strip() and red_nom != main_nom:
|
||||
return f"{main_nom} x {red_nom}"
|
||||
main_nom_str = str(main_nom) if main_nom is not None else ""
|
||||
red_nom_str = str(red_nom) if red_nom is not None else ""
|
||||
if red_nom_str.strip() and red_nom_str != main_nom_str:
|
||||
return f"{main_nom_str} x {red_nom_str}"
|
||||
else:
|
||||
return main_nom
|
||||
return main_nom_str
|
||||
|
||||
def calculate_fitting_confidence(confidence_scores: Dict) -> float:
|
||||
"""피팅 분류 전체 신뢰도 계산"""
|
||||
|
||||
@@ -10,8 +10,8 @@ from .material_classifier import classify_material, get_manufacturing_method_fro
|
||||
# ========== SPECIAL FLANGE 타입 ==========
|
||||
SPECIAL_FLANGE_TYPES = {
|
||||
"ORIFICE": {
|
||||
"dat_file_patterns": ["FLG_ORI_", "ORI_"],
|
||||
"description_keywords": ["ORIFICE", "오리피스", "유량측정"],
|
||||
"dat_file_patterns": ["FLG_ORI_", "ORI_", "ORIFICE_"],
|
||||
"description_keywords": ["ORIFICE", "오리피스", "유량측정", "구멍"],
|
||||
"characteristics": "유량 측정용 구멍",
|
||||
"special_features": ["BORE_SIZE", "FLOW_MEASUREMENT"]
|
||||
},
|
||||
@@ -164,7 +164,7 @@ FLANGE_PRESSURE_RATINGS = {
|
||||
}
|
||||
|
||||
def classify_flange(dat_file: str, description: str, main_nom: str,
|
||||
red_nom: str = None) -> Dict:
|
||||
red_nom: str = None, length: float = None) -> Dict:
|
||||
"""
|
||||
완전한 FLANGE 분류
|
||||
|
||||
@@ -178,7 +178,21 @@ def classify_flange(dat_file: str, description: str, main_nom: str,
|
||||
완전한 플랜지 분류 결과
|
||||
"""
|
||||
|
||||
# 1. 재질 분류 (공통 모듈 사용)
|
||||
desc_upper = description.upper()
|
||||
dat_upper = dat_file.upper()
|
||||
|
||||
# 1. 명칭 우선 확인 (플랜지 키워드가 있으면 플랜지)
|
||||
flange_keywords = ['FLG', 'FLANGE', '플랜지']
|
||||
is_flange = any(keyword in desc_upper or keyword in dat_upper for keyword in flange_keywords)
|
||||
|
||||
if not is_flange:
|
||||
return {
|
||||
"category": "UNKNOWN",
|
||||
"overall_confidence": 0.0,
|
||||
"reason": "플랜지 키워드 없음"
|
||||
}
|
||||
|
||||
# 2. 재질 분류 (공통 모듈 사용)
|
||||
material_result = classify_material(description)
|
||||
|
||||
# 2. SPECIAL vs STANDARD 분류
|
||||
@@ -490,11 +504,12 @@ def determine_flange_manufacturing(material_result: Dict, flange_type_result: Di
|
||||
|
||||
def format_flange_size(main_nom: str, red_nom: str = None) -> str:
|
||||
"""플랜지 사이즈 표기 포맷팅"""
|
||||
|
||||
if red_nom and red_nom.strip() and red_nom != main_nom:
|
||||
return f"{main_nom} x {red_nom}"
|
||||
main_nom_str = str(main_nom) if main_nom is not None else ""
|
||||
red_nom_str = str(red_nom) if red_nom is not None else ""
|
||||
if red_nom_str.strip() and red_nom_str != main_nom_str:
|
||||
return f"{main_nom_str} x {red_nom_str}"
|
||||
else:
|
||||
return main_nom
|
||||
return main_nom_str
|
||||
|
||||
def calculate_flange_confidence(confidence_scores: Dict) -> float:
|
||||
"""플랜지 분류 전체 신뢰도 계산"""
|
||||
|
||||
@@ -160,7 +160,7 @@ GASKET_SIZE_PATTERNS = {
|
||||
"thickness": r"THK?\s*(\d+(?:\.\d+)?)\s*MM"
|
||||
}
|
||||
|
||||
def classify_gasket(dat_file: str, description: str, main_nom: str) -> Dict:
|
||||
def classify_gasket(dat_file: str, description: str, main_nom: str, length: float = None) -> Dict:
|
||||
"""
|
||||
완전한 GASKET 분류
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ INSTRUMENT_TYPES = {
|
||||
}
|
||||
}
|
||||
|
||||
def classify_instrument(dat_file: str, description: str, main_nom: str) -> Dict:
|
||||
def classify_instrument(dat_file: str, description: str, main_nom: str, length: float = None) -> Dict:
|
||||
"""
|
||||
간단한 INSTRUMENT 분류
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ def classify_material(description: str) -> Dict:
|
||||
재질 분류 결과 딕셔너리
|
||||
"""
|
||||
|
||||
desc_upper = description.upper().strip()
|
||||
desc_upper = str(description).upper().strip() if description is not None else ""
|
||||
|
||||
# 1단계: 특수 재질 우선 확인 (가장 구체적)
|
||||
special_result = check_special_materials(desc_upper)
|
||||
|
||||
@@ -63,7 +63,7 @@ PIPE_SCHEDULE = {
|
||||
}
|
||||
|
||||
def classify_pipe(dat_file: str, description: str, main_nom: str,
|
||||
length: float = None) -> Dict:
|
||||
length: Optional[float] = None) -> Dict:
|
||||
"""
|
||||
완전한 PIPE 분류
|
||||
|
||||
@@ -77,7 +77,38 @@ def classify_pipe(dat_file: str, description: str, main_nom: str,
|
||||
완전한 파이프 분류 결과
|
||||
"""
|
||||
|
||||
# 1. 재질 분류 (공통 모듈 사용)
|
||||
desc_upper = description.upper()
|
||||
|
||||
# 1. 명칭 우선 확인 (다른 자재 타입 키워드가 있으면 파이프가 아님)
|
||||
other_material_keywords = [
|
||||
'FLG', 'FLANGE', '플랜지', # 플랜지
|
||||
'ELBOW', 'ELL', 'TEE', 'REDUCER', 'CAP', 'COUPLING', '엘보', '티', '리듀서', # 피팅
|
||||
'VALVE', 'BALL', 'GATE', 'GLOBE', 'CHECK', '밸브', # 밸브
|
||||
'BOLT', 'STUD', 'NUT', 'SCREW', '볼트', '너트', # 볼트
|
||||
'GASKET', 'GASK', '가스켓', # 가스켓
|
||||
'GAUGE', 'SENSOR', 'TRANSMITTER', 'INSTRUMENT', '계기' # 계기
|
||||
]
|
||||
|
||||
for keyword in other_material_keywords:
|
||||
if keyword in desc_upper:
|
||||
return {
|
||||
"category": "UNKNOWN",
|
||||
"overall_confidence": 0.0,
|
||||
"reason": f"다른 자재 키워드 발견: {keyword}"
|
||||
}
|
||||
|
||||
# 2. 파이프 키워드 확인
|
||||
pipe_keywords = ['PIPE', 'TUBE', '파이프', '배관']
|
||||
is_pipe = any(keyword in desc_upper for keyword in pipe_keywords)
|
||||
|
||||
if not is_pipe:
|
||||
return {
|
||||
"category": "UNKNOWN",
|
||||
"overall_confidence": 0.0,
|
||||
"reason": "파이프 키워드 없음"
|
||||
}
|
||||
|
||||
# 3. 재질 분류 (공통 모듈 사용)
|
||||
material_result = classify_material(description)
|
||||
|
||||
# 2. 제조 방법 분류
|
||||
@@ -89,8 +120,8 @@ def classify_pipe(dat_file: str, description: str, main_nom: str,
|
||||
# 4. 스케줄 분류
|
||||
schedule_result = classify_pipe_schedule(description)
|
||||
|
||||
# 5. 절단 치수 처리
|
||||
cutting_dimensions = extract_pipe_cutting_dimensions(length, description)
|
||||
# 5. 길이(절단 치수) 처리
|
||||
length_info = extract_pipe_length_info(length, description)
|
||||
|
||||
# 6. 최종 결과 조합
|
||||
return {
|
||||
@@ -124,11 +155,11 @@ def classify_pipe(dat_file: str, description: str, main_nom: str,
|
||||
"confidence": schedule_result.get('confidence', 0.0)
|
||||
},
|
||||
|
||||
"cutting_dimensions": cutting_dimensions,
|
||||
"length_info": length_info,
|
||||
|
||||
"size_info": {
|
||||
"nominal_size": main_nom,
|
||||
"length_mm": cutting_dimensions.get('length_mm')
|
||||
"length_mm": length_info.get('length_mm')
|
||||
},
|
||||
|
||||
# 전체 신뢰도
|
||||
@@ -234,10 +265,10 @@ def classify_pipe_schedule(description: str) -> Dict:
|
||||
"confidence": 0.0
|
||||
}
|
||||
|
||||
def extract_pipe_cutting_dimensions(length: float, description: str) -> Dict:
|
||||
"""파이프 절단 치수 정보 추출"""
|
||||
def extract_pipe_length_info(length: Optional[float], description: str) -> Dict:
|
||||
"""파이프 길이(절단 치수) 정보 추출"""
|
||||
|
||||
cutting_info = {
|
||||
length_info = {
|
||||
"length_mm": None,
|
||||
"source": None,
|
||||
"confidence": 0.0,
|
||||
@@ -246,31 +277,31 @@ def extract_pipe_cutting_dimensions(length: float, description: str) -> Dict:
|
||||
|
||||
# 1. LENGTH 필드에서 추출 (우선)
|
||||
if length and length > 0:
|
||||
cutting_info.update({
|
||||
length_info.update({
|
||||
"length_mm": round(length, 1),
|
||||
"source": "LENGTH_FIELD",
|
||||
"confidence": 0.95,
|
||||
"note": f"도면 명기 치수: {length}mm"
|
||||
"note": f"도면 명기 길이: {length}mm"
|
||||
})
|
||||
|
||||
# 2. DESCRIPTION에서 백업 추출
|
||||
else:
|
||||
desc_length = extract_length_from_description(description)
|
||||
if desc_length:
|
||||
cutting_info.update({
|
||||
length_info.update({
|
||||
"length_mm": desc_length,
|
||||
"source": "DESCRIPTION_PARSED",
|
||||
"confidence": 0.8,
|
||||
"note": f"설명란에서 추출: {desc_length}mm"
|
||||
})
|
||||
else:
|
||||
cutting_info.update({
|
||||
length_info.update({
|
||||
"source": "NO_LENGTH_INFO",
|
||||
"confidence": 0.0,
|
||||
"note": "절단 치수 정보 없음 - 도면 확인 필요"
|
||||
"note": "길이 정보 없음 - 도면 확인 필요"
|
||||
})
|
||||
|
||||
return cutting_info
|
||||
return length_info
|
||||
|
||||
def extract_length_from_description(description: str) -> Optional[float]:
|
||||
"""DESCRIPTION에서 길이 정보 추출"""
|
||||
@@ -318,7 +349,7 @@ def generate_pipe_cutting_plan(pipe_data: Dict) -> Dict:
|
||||
|
||||
cutting_plan = {
|
||||
"material_spec": f"{pipe_data['material']['grade']} {pipe_data['schedule']['schedule']}",
|
||||
"length_mm": pipe_data['cutting_dimensions']['length_mm'],
|
||||
"length_mm": pipe_data['length_info']['length_mm'],
|
||||
"end_preparation": pipe_data['end_preparation']['cutting_note'],
|
||||
"machining_required": pipe_data['end_preparation']['machining_required']
|
||||
}
|
||||
@@ -332,6 +363,6 @@ def generate_pipe_cutting_plan(pipe_data: Dict) -> Dict:
|
||||
가공여부: {'베벨가공 필요' if cutting_plan['machining_required'] else '직각절단만'}
|
||||
""".strip()
|
||||
else:
|
||||
cutting_plan["cutting_instruction"] = "도면 확인 후 절단 치수 입력 필요"
|
||||
cutting_plan["cutting_instruction"] = "도면 확인 후 길이 정보 입력 필요"
|
||||
|
||||
return cutting_plan
|
||||
|
||||
@@ -66,7 +66,7 @@ VALVE_TYPES = {
|
||||
|
||||
"RELIEF_VALVE": {
|
||||
"dat_file_patterns": ["RELIEF_", "RV_", "PSV_"],
|
||||
"description_keywords": ["RELIEF VALVE", "PRESSURE RELIEF", "SAFETY VALVE", "릴리프"],
|
||||
"description_keywords": ["RELIEF VALVE", "PRESSURE RELIEF", "SAFETY VALVE", "PSV", "압력 안전", "릴리프"],
|
||||
"characteristics": "안전 압력 방출용",
|
||||
"typical_connections": ["FLANGED", "THREADED"],
|
||||
"pressure_range": "150LB ~ 2500LB",
|
||||
@@ -196,20 +196,34 @@ VALVE_PRESSURE_RATINGS = {
|
||||
}
|
||||
}
|
||||
|
||||
def classify_valve(dat_file: str, description: str, main_nom: str) -> Dict:
|
||||
def classify_valve(dat_file: str, description: str, main_nom: str, length: float = None) -> Dict:
|
||||
"""
|
||||
완전한 VALVE 분류
|
||||
|
||||
Args:
|
||||
dat_file: DAT_FILE 필드
|
||||
description: DESCRIPTION 필드
|
||||
main_nom: MAIN_NOM 필드 (밸브 사이즈)
|
||||
main_nom: MAIN_NOM 필드 (사이즈)
|
||||
|
||||
Returns:
|
||||
완전한 밸브 분류 결과
|
||||
"""
|
||||
|
||||
# 1. 재질 분류 (공통 모듈 사용)
|
||||
desc_upper = description.upper()
|
||||
dat_upper = dat_file.upper()
|
||||
|
||||
# 1. 명칭 우선 확인 (밸브 키워드가 있으면 밸브)
|
||||
valve_keywords = ['VALVE', 'GATE', 'BALL', 'GLOBE', 'CHECK', 'BUTTERFLY', 'NEEDLE', 'RELIEF', 'SOLENOID', 'PLUG', '밸브', '게이트', '볼', '글로브', '체크', '버터플라이', '니들', '릴리프', '솔레노이드', '플러그']
|
||||
is_valve = any(keyword in desc_upper or keyword in dat_upper for keyword in valve_keywords)
|
||||
|
||||
if not is_valve:
|
||||
return {
|
||||
"category": "UNKNOWN",
|
||||
"overall_confidence": 0.0,
|
||||
"reason": "밸브 키워드 없음"
|
||||
}
|
||||
|
||||
# 2. 재질 분류 (공통 모듈 사용)
|
||||
material_result = classify_material(description)
|
||||
|
||||
# 2. 밸브 타입 분류
|
||||
|
||||
Reference in New Issue
Block a user