Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -5,10 +5,11 @@ from typing import Optional, Dict, Any, List
|
|||||||
|
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
from sqlalchemy.orm import joinedload
|
||||||
|
|
||||||
from services.storage_integration_rustfs import StorageIntegrationService
|
from services.storage_integration_rustfs import StorageIntegrationService
|
||||||
from services.redis_task_manager import redis_task_manager
|
from services.redis_task_manager import redis_task_manager
|
||||||
from models.database import ProcessingTask, STPFile, MeshData
|
from models.database import ProcessingTask, STPFile, MeshData, HTMLFile
|
||||||
from utils.logger import get_logger
|
from utils.logger import get_logger
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
@@ -34,13 +35,14 @@ class TaskQueryService:
|
|||||||
# 2. 持久化任务(已完成/失败,或服务重启后的任务)
|
# 2. 持久化任务(已完成/失败,或服务重启后的任务)
|
||||||
storage_service = StorageIntegrationService()
|
storage_service = StorageIntegrationService()
|
||||||
|
|
||||||
# 查询任务和文件元数据
|
# 查询任务和文件元数据(预加载 html_file 关联)
|
||||||
result = await db_session.execute(
|
result = await db_session.execute(
|
||||||
select(ProcessingTask, STPFile)
|
select(ProcessingTask, STPFile)
|
||||||
.join(STPFile, ProcessingTask.stp_file_id == STPFile.id)
|
.join(STPFile, ProcessingTask.stp_file_id == STPFile.id)
|
||||||
.where(ProcessingTask.task_id == task_id)
|
.where(ProcessingTask.task_id == task_id)
|
||||||
|
.options(joinedload(STPFile.html_file))
|
||||||
)
|
)
|
||||||
row = result.first()
|
row = result.unique().first()
|
||||||
if not row:
|
if not row:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -64,6 +66,19 @@ class TaskQueryService:
|
|||||||
# 组装网格摘要
|
# 组装网格摘要
|
||||||
mesh_summary = await TaskQueryService._get_mesh_summary(db_session, stp_file.id)
|
mesh_summary = await TaskQueryService._get_mesh_summary(db_session, stp_file.id)
|
||||||
|
|
||||||
|
# 构造 html_file 路径(与即时分析的 /html/xxx.html 格式保持一致)
|
||||||
|
html_file_url = None
|
||||||
|
html_file_record = None
|
||||||
|
try:
|
||||||
|
html_file_record = await db_session.execute(
|
||||||
|
select(HTMLFile).where(HTMLFile.stp_file_id == stp_file.id)
|
||||||
|
)
|
||||||
|
html_file_record = html_file_record.scalar_one_or_none()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if html_file_record and html_file_record.filename:
|
||||||
|
html_file_url = f"/html/{html_file_record.filename}"
|
||||||
|
|
||||||
# 构造与内存任务兼容的任务视图
|
# 构造与内存任务兼容的任务视图
|
||||||
task_view = {
|
task_view = {
|
||||||
"task_id": processing_task.task_id,
|
"task_id": processing_task.task_id,
|
||||||
@@ -81,6 +96,7 @@ class TaskQueryService:
|
|||||||
"key_info": cavity_json,
|
"key_info": cavity_json,
|
||||||
"cavity_data": cavity_json,
|
"cavity_data": cavity_json,
|
||||||
"mesh_summary": mesh_summary,
|
"mesh_summary": mesh_summary,
|
||||||
|
"html_file": html_file_url,
|
||||||
"analysis_result": {
|
"analysis_result": {
|
||||||
"geometry_data": geometry_json,
|
"geometry_data": geometry_json,
|
||||||
"detected_features": features_json,
|
"detected_features": features_json,
|
||||||
|
|||||||
Reference in New Issue
Block a user