From b2c87edf74e140df70de64c148868fbcb219d725 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 29 Aug 2026 15:11:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20submit=5Ffor=5Fconfirmation=E6=8C=89conf?= =?UTF-8?q?irm=5Ftask=5Fid=E7=BB=91=E5=AE=9A=E5=B9=82=E7=AD=89=E2=80=94?= =?UTF-8?q?=E2=80=94=E7=A6=81=E6=AD=A2=E5=A4=8D=E7=94=A8=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E7=9A=84=E7=A1=AE=E8=AE=A4=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?(=E7=BB=91=E5=AE=9A=E4=B8=A2=E5=A4=B1=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E6=97=A0=E6=B3=95=E7=A1=AE=E8=AE=A4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_opportunity/opp_report_capability.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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", ""),