fix(kb-ingest): 待办置完成改用suggestion_id精确匹配(防同名文件误伤)

This commit is contained in:
ymq 2026-09-04 16:33:15 +08:00
parent ae3967c3b0
commit 0aa632dd28

View File

@ -169,14 +169,15 @@ async def decide_kb_ingest(suggestion_id, approve, operator_id, comment=""):
if owner and str(operator_id) != str(owner):
return False, "仅项目 owner 可批准/驳回入库建议"
# 关联人工待办置为已处理(避免待办重复出现)
# 关联人工待办置为已处理(避免待办重复出现)——用 form_schema 里唯一的
# suggestion_id 精确匹配description LIKE 文件名会误伤同名文件的待办)
await sor.sqlExe(
"UPDATE pipeline_human_tasks SET status='done', submitted_by=${o}$, submitted_at=NOW(), "
"result_data=${rd}$ WHERE task_type='kb_ingest_confirm' AND status='pending' "
"AND description LIKE ${pat}$",
"AND form_schema LIKE ${pat}$",
{"o": operator_id, "rd": json.dumps({"suggestion_id": suggestion_id,
"approve": bool(approve)}, ensure_ascii=False),
"pat": "%" + str(sg.get("file_name", "")) + "%"})
"pat": "%\"suggestion_id\": \"" + str(suggestion_id) + "\"%"})
await sor.sqlExe("COMMIT", {})
if not approve: