feat: PIPE 분석 기능 개선 및 자재 확인 페이지 UX 향상
- 자재 확인 페이지에 뒤로가기 버튼 추가 - 상세 목록 탭에 PIPE 분석 섹션 추가 - 재질-외경-스케줄-제작방식별로 그룹화 - 동일 속성 파이프들의 길이 합산 표시 - 총 파이프 길이 및 규격 종류 수 요약 - 파일 삭제 기능 수정 (외래키 제약 조건 해결) - MaterialsPage에서 전체 자재 목록 표시 (limit 10000) - 길이 단위 변환 로직 수정 (mm 단위 유지) - 파싱 로직에 디버그 출력 추가 TODO: MAIN_NOM/RED_NOM 별도 저장을 위한 스키마 개선 필요
This commit is contained in:
@@ -497,6 +497,180 @@ async def upload_file(
|
||||
except Exception as e:
|
||||
print(f"VALVE 상세정보 저장 실패: {e}")
|
||||
|
||||
elif category == 'FLANGE' and confidence >= 0.5:
|
||||
try:
|
||||
flange_info = classification_result
|
||||
|
||||
flange_insert_query = text("""
|
||||
INSERT INTO flange_details (
|
||||
material_id, file_id, flange_type, facing_type,
|
||||
pressure_rating, material_standard, material_grade,
|
||||
size_inches, classification_confidence, additional_info
|
||||
)
|
||||
VALUES (
|
||||
(SELECT id FROM materials WHERE file_id = :file_id AND original_description = :description AND row_number = :row_number),
|
||||
:file_id, :flange_type, :facing_type,
|
||||
:pressure_rating, :material_standard, :material_grade,
|
||||
:size_inches, :classification_confidence, :additional_info
|
||||
)
|
||||
""")
|
||||
|
||||
db.execute(flange_insert_query, {
|
||||
"file_id": file_id,
|
||||
"description": material_data["original_description"],
|
||||
"row_number": material_data["row_number"],
|
||||
"flange_type": flange_info.get('flange_type', {}).get('type', ''),
|
||||
"facing_type": flange_info.get('face_finish', {}).get('finish', ''),
|
||||
"pressure_rating": flange_info.get('pressure_rating', {}).get('rating', ''),
|
||||
"material_standard": flange_info.get('material', {}).get('standard', ''),
|
||||
"material_grade": flange_info.get('material', {}).get('grade', ''),
|
||||
"size_inches": material_data.get('size_spec', ''),
|
||||
"classification_confidence": confidence,
|
||||
"additional_info": json.dumps(flange_info, ensure_ascii=False)
|
||||
})
|
||||
|
||||
print(f"FLANGE 상세정보 저장 완료: {material_data['original_description']}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"FLANGE 상세정보 저장 실패: {e}")
|
||||
|
||||
elif category == 'BOLT' and confidence >= 0.5:
|
||||
try:
|
||||
bolt_info = classification_result
|
||||
|
||||
bolt_insert_query = text("""
|
||||
INSERT INTO bolt_details (
|
||||
material_id, file_id, bolt_type, thread_type,
|
||||
diameter, length, material_standard, material_grade,
|
||||
coating_type, includes_nut, includes_washer,
|
||||
classification_confidence, additional_info
|
||||
)
|
||||
VALUES (
|
||||
(SELECT id FROM materials WHERE file_id = :file_id AND original_description = :description AND row_number = :row_number),
|
||||
:file_id, :bolt_type, :thread_type,
|
||||
:diameter, :length, :material_standard, :material_grade,
|
||||
:coating_type, :includes_nut, :includes_washer,
|
||||
:classification_confidence, :additional_info
|
||||
)
|
||||
""")
|
||||
|
||||
# BOLT 분류기 결과 구조에 맞게 데이터 추출
|
||||
bolt_details = bolt_info.get('bolt_details', {})
|
||||
material_info = bolt_info.get('material', {})
|
||||
|
||||
db.execute(bolt_insert_query, {
|
||||
"file_id": file_id,
|
||||
"description": material_data["original_description"],
|
||||
"row_number": material_data["row_number"],
|
||||
"bolt_type": bolt_details.get('type', ''),
|
||||
"thread_type": bolt_details.get('thread_type', ''),
|
||||
"diameter": bolt_details.get('diameter', ''),
|
||||
"length": bolt_details.get('length', ''),
|
||||
"material_standard": material_info.get('standard', ''),
|
||||
"material_grade": material_info.get('grade', ''),
|
||||
"coating_type": material_info.get('coating', ''),
|
||||
"includes_nut": bolt_details.get('includes_nut', False),
|
||||
"includes_washer": bolt_details.get('includes_washer', False),
|
||||
"classification_confidence": confidence,
|
||||
"additional_info": json.dumps(bolt_info, ensure_ascii=False)
|
||||
})
|
||||
|
||||
print(f"BOLT 상세정보 저장 완료: {material_data['original_description']}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"BOLT 상세정보 저장 실패: {e}")
|
||||
|
||||
elif category == 'GASKET' and confidence >= 0.5:
|
||||
try:
|
||||
gasket_info = classification_result
|
||||
|
||||
gasket_insert_query = text("""
|
||||
INSERT INTO gasket_details (
|
||||
material_id, file_id, gasket_type, gasket_subtype,
|
||||
material_type, size_inches, pressure_rating,
|
||||
thickness, temperature_range, fire_safe,
|
||||
classification_confidence, additional_info
|
||||
)
|
||||
VALUES (
|
||||
(SELECT id FROM materials WHERE file_id = :file_id AND original_description = :description AND row_number = :row_number),
|
||||
:file_id, :gasket_type, :gasket_subtype,
|
||||
:material_type, :size_inches, :pressure_rating,
|
||||
:thickness, :temperature_range, :fire_safe,
|
||||
:classification_confidence, :additional_info
|
||||
)
|
||||
""")
|
||||
|
||||
# GASKET 분류기 결과 구조에 맞게 데이터 추출
|
||||
gasket_type_info = gasket_info.get('gasket_type', {})
|
||||
material_info = gasket_info.get('material', {})
|
||||
|
||||
db.execute(gasket_insert_query, {
|
||||
"file_id": file_id,
|
||||
"description": material_data["original_description"],
|
||||
"row_number": material_data["row_number"],
|
||||
"gasket_type": gasket_type_info.get('type', ''),
|
||||
"gasket_subtype": gasket_type_info.get('subtype', ''),
|
||||
"material_type": material_info.get('type', ''),
|
||||
"size_inches": material_data.get('size_spec', ''),
|
||||
"pressure_rating": gasket_info.get('pressure_rating', ''),
|
||||
"thickness": gasket_info.get('thickness', ''),
|
||||
"temperature_range": material_info.get('temperature_range', ''),
|
||||
"fire_safe": gasket_info.get('fire_safe', False),
|
||||
"classification_confidence": confidence,
|
||||
"additional_info": json.dumps(gasket_info, ensure_ascii=False)
|
||||
})
|
||||
|
||||
print(f"GASKET 상세정보 저장 완료: {material_data['original_description']}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"GASKET 상세정보 저장 실패: {e}")
|
||||
|
||||
elif category == 'INSTRUMENT' and confidence >= 0.5:
|
||||
try:
|
||||
inst_info = classification_result
|
||||
|
||||
inst_insert_query = text("""
|
||||
INSERT INTO instrument_details (
|
||||
material_id, file_id, instrument_type, instrument_subtype,
|
||||
measurement_type, measurement_range, accuracy,
|
||||
connection_type, connection_size, body_material,
|
||||
classification_confidence, additional_info
|
||||
)
|
||||
VALUES (
|
||||
(SELECT id FROM materials WHERE file_id = :file_id AND original_description = :description AND row_number = :row_number),
|
||||
:file_id, :instrument_type, :instrument_subtype,
|
||||
:measurement_type, :measurement_range, :accuracy,
|
||||
:connection_type, :connection_size, :body_material,
|
||||
:classification_confidence, :additional_info
|
||||
)
|
||||
""")
|
||||
|
||||
# INSTRUMENT 분류기 결과 구조에 맞게 데이터 추출
|
||||
inst_type_info = inst_info.get('instrument_type', {})
|
||||
measurement_info = inst_info.get('measurement', {})
|
||||
connection_info = inst_info.get('connection', {})
|
||||
|
||||
db.execute(inst_insert_query, {
|
||||
"file_id": file_id,
|
||||
"description": material_data["original_description"],
|
||||
"row_number": material_data["row_number"],
|
||||
"instrument_type": inst_type_info.get('type', ''),
|
||||
"instrument_subtype": inst_type_info.get('subtype', ''),
|
||||
"measurement_type": measurement_info.get('type', ''),
|
||||
"measurement_range": measurement_info.get('range', ''),
|
||||
"accuracy": measurement_info.get('accuracy', ''),
|
||||
"connection_type": connection_info.get('type', ''),
|
||||
"connection_size": connection_info.get('size', ''),
|
||||
"body_material": inst_info.get('material', ''),
|
||||
"classification_confidence": confidence,
|
||||
"additional_info": json.dumps(inst_info, ensure_ascii=False)
|
||||
})
|
||||
|
||||
print(f"INSTRUMENT 상세정보 저장 완료: {material_data['original_description']}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"INSTRUMENT 상세정보 저장 실패: {e}")
|
||||
|
||||
materials_inserted += 1
|
||||
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user