分模候选方案

This commit is contained in:
2026-04-23 23:37:39 +08:00
parent 0bdfc7f7d5
commit c1f6b6e827
16 changed files with 1302 additions and 497 deletions
+44 -2
View File
@@ -62,6 +62,7 @@ class TaskQueryService:
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", [])
cavity_view = TaskQueryService._extract_cavity_view(cavity_json)
# 组装网格摘要
mesh_summary = await TaskQueryService._get_mesh_summary(db_session, stp_file.id)
@@ -78,6 +79,8 @@ class TaskQueryService:
pass
if html_file_record and html_file_record.filename:
html_file_url = f"/html/{html_file_record.filename}"
if cavity_view.get("html_file"):
html_file_url = cavity_view.get("html_file")
# 构造与内存任务兼容的任务视图
task_view = {
@@ -93,8 +96,11 @@ class TaskQueryService:
if processing_task.completed_time
else "",
"geometry_data": geometry_json,
"key_info": cavity_json,
"cavity_data": cavity_json,
"key_info": cavity_view.get("key_info"),
"cavity_data": cavity_view.get("cavity_data"),
"candidate_schemes": cavity_view.get("candidate_schemes", []),
"best_scheme_id": cavity_view.get("best_scheme_id"),
"plan_result": cavity_json,
"mesh_summary": mesh_summary,
"html_file": html_file_url,
"analysis_result": {
@@ -141,3 +147,39 @@ class TaskQueryService:
"quality": mesh_record.quality,
}
return None
@staticmethod
def _extract_cavity_view(cavity_json: Optional[Dict[str, Any]]) -> Dict[str, Any]:
"""兼容旧单方案与新多方案结果视图。"""
if not cavity_json:
return {
"cavity_data": None,
"key_info": None,
"candidate_schemes": [],
"best_scheme_id": None,
}
candidate_schemes = cavity_json.get("candidate_schemes")
if candidate_schemes:
best_scheme_id = cavity_json.get("best_scheme_id")
best_scheme = candidate_schemes[0]
if best_scheme_id:
for scheme in candidate_schemes:
if scheme.get("scheme_id") == best_scheme_id:
best_scheme = scheme
break
return {
"cavity_data": best_scheme.get("cavity_data"),
"key_info": best_scheme.get("key_info"),
"candidate_schemes": candidate_schemes,
"best_scheme_id": best_scheme_id or best_scheme.get("scheme_id"),
"html_file": best_scheme.get("html_file"),
}
return {
"cavity_data": cavity_json,
"key_info": cavity_json,
"candidate_schemes": [],
"best_scheme_id": None,
"html_file": cavity_json.get("html_file"),
}