deving
This commit is contained in:
+31
-5
@@ -116,14 +116,40 @@ async def upload_stp(
|
|||||||
|
|
||||||
@router.get("/status/{task_id}")
|
@router.get("/status/{task_id}")
|
||||||
@router.post("/status/{task_id}")
|
@router.post("/status/{task_id}")
|
||||||
async def get_status(task_id: str):
|
async def get_status(task_id: str, db_session: AsyncSession = Depends(get_db_session)):
|
||||||
"""获取任务状态"""
|
"""获取任务状态"""
|
||||||
if task_id not in tasks:
|
from sqlalchemy import select
|
||||||
|
from models.database import ProcessingTask, STPFile
|
||||||
|
|
||||||
|
# 从数据库查询任务详情
|
||||||
|
result = await db_session.execute(
|
||||||
|
select(ProcessingTask, STPFile)
|
||||||
|
.join(STPFile, ProcessingTask.stp_file_id == STPFile.id)
|
||||||
|
.where(ProcessingTask.task_id == task_id)
|
||||||
|
)
|
||||||
|
|
||||||
|
task_record = result.first()
|
||||||
|
|
||||||
|
if not task_record:
|
||||||
raise HTTPException(404, "任务不存在")
|
raise HTTPException(404, "任务不存在")
|
||||||
|
|
||||||
task = tasks[task_id]
|
task, stp_file = task_record
|
||||||
logger.info(f"返回任务状态: {task_id} - {task['status']}")
|
|
||||||
return task
|
# 构建任务详情数据
|
||||||
|
task_data = {
|
||||||
|
"task_id": task.task_id,
|
||||||
|
"filename": stp_file.original_filename if stp_file else "",
|
||||||
|
"file_size": stp_file.file_size if stp_file else 0,
|
||||||
|
"status": task.status,
|
||||||
|
"progress": task.progress,
|
||||||
|
"current_step": task.current_step,
|
||||||
|
"upload_time": task.created_time.isoformat() if task.created_time else "",
|
||||||
|
"completed_at": task.completed_time.isoformat() if task.completed_time else "",
|
||||||
|
"error": task.error_message if task.error_message else ""
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(f"返回任务状态: {task_id} - {task.status}")
|
||||||
|
return task_data
|
||||||
|
|
||||||
|
|
||||||
@router.get("/debug/tasks")
|
@router.get("/debug/tasks")
|
||||||
|
|||||||
@@ -152,8 +152,8 @@
|
|||||||
<div class="result-container">
|
<div class="result-container">
|
||||||
<div class="header-nav">
|
<div class="header-nav">
|
||||||
<div>
|
<div>
|
||||||
<h1>📊 分析结果详情</h1>
|
<h1>📊 历史记录 - 分析结果详情</h1>
|
||||||
<p>查看STP文件的详细分析结果</p>
|
<p>查看历史记录中STP文件的详细分析结果</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav-buttons">
|
<div class="nav-buttons">
|
||||||
<button class="upload-btn" onclick="location.href='/history'">
|
<button class="upload-btn" onclick="location.href='/history'">
|
||||||
|
|||||||
Reference in New Issue
Block a user