x
This commit is contained in:
+20
-3
@@ -1,6 +1,6 @@
|
||||
# api/routes.py
|
||||
from fastapi import APIRouter, UploadFile, File, HTTPException, BackgroundTasks, Request, Depends
|
||||
from typing import Optional, Dict, Any
|
||||
from typing import Optional, Dict, Any, List
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@@ -151,6 +151,8 @@ async def get_status(task_id: str, db_session: AsyncSession = Depends(get_db_ses
|
||||
geometry_json = geo_raw
|
||||
|
||||
cavity_json: Optional[Dict[str, Any]] = file_with_data.get("mold_cavity_data")
|
||||
features_json: List[Dict[str, Any]] = file_with_data.get("features", [])
|
||||
recommendations_json: List[Dict[str, Any]] = file_with_data.get("recommendations", [])
|
||||
|
||||
# 组装网格摘要:从 MeshData 表中读出摘要字段,避免把完整网格 JSON 丢给前端
|
||||
mesh_summary = None
|
||||
@@ -180,10 +182,16 @@ async def get_status(task_id: str, db_session: AsyncSession = Depends(get_db_ses
|
||||
if processing_task.completed_time
|
||||
else "",
|
||||
"geometry_data": geometry_json,
|
||||
# key_info 沿用之前的结构,直接使用详细型腔 JSON,前端已按该结构解析
|
||||
"key_info": cavity_json,
|
||||
"cavity_data": cavity_json,
|
||||
"mesh_summary": mesh_summary,
|
||||
"analysis_result": None,
|
||||
"analysis_result": {
|
||||
"geometry_data": geometry_json,
|
||||
"detected_features": features_json,
|
||||
"design_recommendations": recommendations_json,
|
||||
"quality_metrics": {},
|
||||
"analysis_summary": "分析完成"
|
||||
} if features_json or recommendations_json else None,
|
||||
"error": processing_task.error_message or stp_file.error_message or None,
|
||||
}
|
||||
|
||||
@@ -636,6 +644,15 @@ async def process_file_core(
|
||||
# 9. 分析模具设计
|
||||
analysis_result = geometry_analyzer.analyze_mold_design(geometry_data)
|
||||
|
||||
# 9.5 保存特征和建议到数据库
|
||||
if analysis_result:
|
||||
await storage_service.save_features_and_recommendations(
|
||||
db_session,
|
||||
stp_file_id,
|
||||
analysis_result.get("detected_features", []),
|
||||
analysis_result.get("design_recommendations", [])
|
||||
)
|
||||
|
||||
# 10. 完成处理
|
||||
await storage_service.update_stp_file_status(db_session, stp_file_id, "completed")
|
||||
await storage_service.update_task_status(
|
||||
|
||||
Reference in New Issue
Block a user