diff --git a/pipeline_opportunity/opp_report_capability.py b/pipeline_opportunity/opp_report_capability.py index ff444ea..4fd20a6 100644 --- a/pipeline_opportunity/opp_report_capability.py +++ b/pipeline_opportunity/opp_report_capability.py @@ -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", ""),