From 227471d51433dc4b6b592031ed2aeb061e0643e7 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 17 Sep 2026 10:11:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(mirror):=20=E7=AB=A0=E8=8A=82=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=8F=98=E6=9B=B4=E5=90=8C=E6=AD=A5=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=96=87=E4=BB=B6(2026-09-16=E5=AE=9E=E6=B5=8B:=E5=BA=93approv?= =?UTF-8?q?ed=20v8/=E9=95=9C=E5=83=8F=E5=A4=B4=E4=BB=8Dwriting=20v7,?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9C=8B=E6=96=87=E4=BB=B6=E8=AF=AF=E5=88=A4?= =?UTF-8?q?)=E2=80=94=E2=80=94=E8=AF=84=E5=AE=A1=E9=80=9A=E8=BF=87/?= =?UTF-8?q?=E6=9D=90=E6=96=99=E7=BC=BA=E5=A4=B1=E6=94=BE=E8=A1=8C/?= =?UTF-8?q?=E4=BA=BA=E5=B7=A5=E9=80=9A=E8=BF=87/=E9=80=80=E5=9B=9E/score?= =?UTF-8?q?=5Freject=E4=BA=94=E4=B8=AA=E8=90=BD=E7=82=B9=E8=A1=A5sync=5Fch?= =?UTF-8?q?apter=5Fmirror,=E5=A4=B1=E8=B4=A5=E4=BB=85=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E4=B8=8D=E9=98=BB=E6=96=AD=E4=B8=BB=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_bidding/bid_review_capability.py | 15 +++++++++++++++ pipeline_bidding/bid_score_capability.py | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/pipeline_bidding/bid_review_capability.py b/pipeline_bidding/bid_review_capability.py index 20d30e8..64952bf 100644 --- a/pipeline_bidding/bid_review_capability.py +++ b/pipeline_bidding/bid_review_capability.py @@ -112,6 +112,7 @@ async def review_chapter(chapter_id, score, max_score="", comments="", detail="" from_state=c.get("status"), to_state=CH_APPROVED, who=who, agent_id=agent_id, detail="%.2f/%.2f (%.0f%%)" % (sc, ms, ratio * 100)) + await _sync_mirror(sor, pid, chapter_id) return True, ("章节「%s」评审通过 %.2f/%.2f(%.0f%%,门限 %.0f%%)" % (c.get("title"), sc, ms, ratio * 100, th["chapter_pass_ratio"] * 100)) @@ -147,6 +148,7 @@ async def review_chapter(chapter_id, score, max_score="", comments="", detail="" % (c.get("chapter_no"), c.get("title"), sc, ms, (comments or "")[:1500])), assignee_role="owner.superuser", dedup_by_title=True) await sor.sqlExe("COMMIT", {}) + await _sync_mirror(sor, pid, chapter_id) return True, ("章节「%s」评审 %.2f/%.2f:失分全部因实体材料缺失(非写作缺陷)," "已如实披露放行 + 发信息流供料待办「%s」,不阻塞标书推进。" % (c.get("title"), sc, ms, title)) @@ -206,6 +208,17 @@ async def review_chapter(chapter_id, score, max_score="", comments="", detail="" th["chapter_pass_ratio"] * 100, revise)) +async def _sync_mirror(sor, project_id, chapter_id): + """章节状态变更后同步工作空间镜像文件(元数据/版本/状态一致,2026-09-16: + 镜像只在 write_chapter 同步 → 评审通过后文件头仍显示 written 旧版,用户 + 看文件误判状态)。失败只记日志,不阻断评审/通过主流程。""" + try: + from .bid_chapter_mirror import sync_chapter_mirror + await sync_chapter_mirror(sor, project_id, chapter_id) + except Exception as e: # noqa: BLE001 + logger.warning("章节镜像同步失败(不阻断): chapter=%s err=%s", chapter_id, e) + + async def approve_chapter(chapter_id, comment="", who=None, agent_id=None): """人工/评审直接通过章节(written/reviewing/rejected → approved)。""" db, dbname = get_db() @@ -223,6 +236,7 @@ async def approve_chapter(chapter_id, comment="", who=None, agent_id=None): await record(sor, c.get("project_id"), TABLE, chapter_id, "approve", from_state=c.get("status"), to_state=CH_APPROVED, who=who, agent_id=agent_id, detail=comment) + await _sync_mirror(sor, c.get("project_id"), chapter_id) return True, "章节「%s」已通过" % c.get("title") @@ -245,6 +259,7 @@ async def reject_chapter(chapter_id, comment="", who=None, agent_id=None): from_state=c.get("status"), to_state=CH_REJECTED, who=who, agent_id=agent_id, detail=comment[:480]) return True, "章节「%s」已退回重写(第 %d 次)" % (c.get("title"), revise) + await _sync_mirror(sor, c.get("project_id"), chapter_id) async def list_reviews(project_id, scope="", chapter_id="", limit=50): diff --git a/pipeline_bidding/bid_score_capability.py b/pipeline_bidding/bid_score_capability.py index cc394e0..5b7fee2 100644 --- a/pipeline_bidding/bid_score_capability.py +++ b/pipeline_bidding/bid_score_capability.py @@ -284,6 +284,12 @@ async def finalize_bid_score(review_id, comments="", who=None, agent_id=None): await record(sor, pid, "bid_chapters", cid, "score_reject", from_state=c.get("status"), to_state=CH_REJECTED, who=who, agent_id=agent_id, detail=(s.get("improvement") or "")[:400]) + # 退回也同步镜像(文件头状态/评审分/改进意见要与库一致,2026-09-16) + try: + from .bid_chapter_mirror import sync_chapter_mirror + await sync_chapter_mirror(sor, pid, cid) + except Exception as e: # noqa: BLE001 + logger.warning("章节镜像同步失败(不阻断): chapter=%s err=%s", cid, e) touched += 1 if touched == 0 and weak: await create_human_task(