x
This commit is contained in:
@@ -425,11 +425,25 @@ class StorageIntegrationService:
|
||||
async def get_stp_file_with_data(self, session: AsyncSession,
|
||||
stp_file_id: int) -> Dict[str, Any]:
|
||||
"""获取STP文件及其所有关联数据"""
|
||||
|
||||
# 1. 获取STP文件记录
|
||||
stp_file = await session.get(STPFile, stp_file_id)
|
||||
if not stp_file:
|
||||
raise ValueError(f"STP文件不存在: {stp_file_id}")
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
try:
|
||||
# 1. 获取STP文件记录(使用 joinedload 预加载关联数据)
|
||||
result = await session.execute(
|
||||
select(STPFile).options(
|
||||
joinedload(STPFile.geometry_data),
|
||||
joinedload(STPFile.mesh_data),
|
||||
joinedload(STPFile.mold_cavity_data),
|
||||
joinedload(STPFile.html_file),
|
||||
joinedload(STPFile.analysis_metrics)
|
||||
).where(STPFile.id == stp_file_id)
|
||||
)
|
||||
stp_file = result.scalar_one_or_none()
|
||||
if not stp_file:
|
||||
raise ValueError(f"STP文件不存在: {stp_file_id}")
|
||||
except Exception as e:
|
||||
logger.error(f"获取STP文件记录失败: {e}")
|
||||
raise
|
||||
|
||||
result = {
|
||||
'metadata': {
|
||||
|
||||
Reference in New Issue
Block a user