feat: 자재 분류 시스템 개선 및 상세 테이블 추가

- 모든 자재 카테고리별 상세 테이블 생성 (fitting, valve, flange, bolt, gasket, instrument)
- PIPE, FITTING, VALVE 분류 결과를 각 상세 테이블에 저장하는 로직 구현
- 프론트엔드 라우팅 정리 및 BOM 현황 페이지 기능 개선
- 자재확인 페이지 에러 처리 개선

TODO: FLANGE, BOLT, GASKET, INSTRUMENT 저장 로직 추가 필요
This commit is contained in:
Hyungi Ahn
2025-07-17 10:44:19 +09:00
parent ea111433e4
commit 5f7a6f0b3a
30 changed files with 3963 additions and 923 deletions

View File

@@ -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