fix: submit_for_confirmation按confirm_task_id绑定幂等——禁止复用其他报告的确认任务(绑定丢失导致报告无法确认)

This commit is contained in:
yumoqing 2026-08-29 15:11:32 +08:00
parent f192128f5e
commit b2c87edf74

View File

@ -141,10 +141,16 @@ async def submit_for_confirmation(report_id, note=""):
logger.warning("报告PPT生成失败(不阻塞提交): %s", str(e)[:200])
if ppt_path:
await sor.U("opp_reports", {"id": report_id, "ppt_path": ppt_path})
exist = await find_human_task(sor, rep.get("project_id", ""),
HT_REPORT_CONFIRM, status="pending")
if exist:
return True, "已有待确认任务: %s" % exist.get("id")
# 幂等:本报告已有 pending 确认任务则复用(按 confirm_task_id 绑定,
# 不复用其他报告的任务——确认是逐份报告的独立门禁,
# 且待办页按 confirm_task_id 反查报告正文,绑定丢失则报告无法被确认)
exist_id = rep.get("confirm_task_id") or ""
if exist_id:
t_recs = await sor.sqlExe(
"SELECT id, status FROM pipeline_human_tasks WHERE id=${i}$",
{"i": exist_id})
if t_recs and getattr(t_recs[0], "status", "") == "pending":
return True, "已有待确认任务: %s" % exist_id
hid = await create_human_task(
sor, rep.get("project_id", ""), HT_REPORT_CONFIRM,
"确认研发报告:%s" % rep.get("title", ""),