feat: SWG 가스켓 전체 구성 정보 표시 개선
Some checks failed
SonarQube Analysis / SonarQube Scan (push) Has been cancelled
Some checks failed
SonarQube Analysis / SonarQube Scan (push) Has been cancelled
- H/F/I/O SS304/GRAPHITE/CS/CS 패턴에서 4개 구성요소 모두 표시 - 기존 SS304 + GRAPHITE → SS304/GRAPHITE/CS/CS로 완전한 구성 표시 - 외부링/필러/내부링/추가구성 모든 정보 포함 - 구매수량 계산 모달에서 정확한 재질 정보 확인 가능
This commit is contained in:
@@ -12,7 +12,11 @@ from pathlib import Path
|
||||
import json
|
||||
|
||||
from ..database import get_db
|
||||
from ..utils.logger import get_logger
|
||||
from app.services.material_classifier import classify_material
|
||||
|
||||
# 로거 설정
|
||||
logger = get_logger(__name__)
|
||||
from app.services.integrated_classifier import classify_material_integrated, should_exclude_material
|
||||
from app.services.bolt_classifier import classify_bolt
|
||||
from app.services.flange_classifier import classify_flange
|
||||
@@ -664,10 +668,15 @@ async def upload_file(
|
||||
else:
|
||||
gasket_type = str(gasket_type_info) if gasket_type_info else "UNKNOWN"
|
||||
|
||||
# 가스켓 소재 (GRAPHITE, PTFE 등)
|
||||
# 가스켓 소재 - SWG의 경우 메탈 부분을 우선으로
|
||||
material_type = ""
|
||||
if isinstance(gasket_material_info, dict):
|
||||
material_type = gasket_material_info.get("material", "UNKNOWN")
|
||||
# SWG 상세 정보가 있으면 메탈 부분을 material_type으로 사용
|
||||
swg_details = gasket_material_info.get("swg_details", {})
|
||||
if swg_details and swg_details.get("outer_ring"):
|
||||
material_type = swg_details.get("outer_ring", "UNKNOWN") # SS304
|
||||
else:
|
||||
material_type = gasket_material_info.get("material", "UNKNOWN")
|
||||
else:
|
||||
material_type = str(gasket_material_info) if gasket_material_info else "UNKNOWN"
|
||||
|
||||
@@ -978,7 +987,7 @@ async def get_files(
|
||||
try:
|
||||
query = """
|
||||
SELECT id, filename, original_filename, job_no, revision,
|
||||
description, file_size, parsed_count, created_at, is_active
|
||||
description, file_size, parsed_count, upload_date, is_active
|
||||
FROM files
|
||||
WHERE is_active = TRUE
|
||||
"""
|
||||
@@ -988,7 +997,7 @@ async def get_files(
|
||||
query += " AND job_no = :job_no"
|
||||
params["job_no"] = job_no
|
||||
|
||||
query += " ORDER BY created_at DESC"
|
||||
query += " ORDER BY upload_date DESC"
|
||||
|
||||
result = db.execute(text(query), params)
|
||||
files = result.fetchall()
|
||||
@@ -1003,7 +1012,7 @@ async def get_files(
|
||||
"description": file.description,
|
||||
"file_size": file.file_size,
|
||||
"parsed_count": file.parsed_count,
|
||||
"created_at": file.created_at,
|
||||
"created_at": file.upload_date,
|
||||
"is_active": file.is_active
|
||||
}
|
||||
for file in files
|
||||
@@ -1012,6 +1021,47 @@ async def get_files(
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"파일 목록 조회 실패: {str(e)}")
|
||||
|
||||
@router.get("/stats")
|
||||
async def get_files_stats(db: Session = Depends(get_db)):
|
||||
"""파일 및 자재 통계 조회"""
|
||||
try:
|
||||
# 총 파일 수
|
||||
files_query = text("SELECT COUNT(*) FROM files WHERE is_active = true")
|
||||
total_files = db.execute(files_query).fetchone()[0]
|
||||
|
||||
# 총 자재 수
|
||||
materials_query = text("SELECT COUNT(*) FROM materials")
|
||||
total_materials = db.execute(materials_query).fetchone()[0]
|
||||
|
||||
# 최근 업로드 (최근 5개)
|
||||
recent_query = text("""
|
||||
SELECT f.original_filename, f.upload_date, f.parsed_count, j.job_name
|
||||
FROM files f
|
||||
LEFT JOIN jobs j ON f.job_no = j.job_no
|
||||
WHERE f.is_active = true
|
||||
ORDER BY f.upload_date DESC
|
||||
LIMIT 5
|
||||
""")
|
||||
recent_uploads = db.execute(recent_query).fetchall()
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"totalFiles": total_files,
|
||||
"totalMaterials": total_materials,
|
||||
"recentUploads": [
|
||||
{
|
||||
"filename": upload.original_filename,
|
||||
"created_at": upload.upload_date,
|
||||
"parsed_count": upload.parsed_count or 0,
|
||||
"project_name": upload.job_name or "Unknown"
|
||||
}
|
||||
for upload in recent_uploads
|
||||
]
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"통계 조회 실패: {str(e)}")
|
||||
|
||||
@router.delete("/files/{file_id}")
|
||||
async def delete_file(file_id: int, db: Session = Depends(get_db)):
|
||||
"""파일 삭제"""
|
||||
|
||||
Reference in New Issue
Block a user