fix(contact): 优化合同审核误报
This commit is contained in:
1 parent
74745a9d10
commit
6b96d5a14f
16 files changed
+2218
-18
No files matched your search
@@ -55,6 +55,9 @@ _CRITICAL_VALUE_PATTERNS = (
|
||||
r"\d+\s*(?:套|台|件|个|只|箱|批|吨|千克|KG|kg|台)",
|
||||
r"(?=[A-Za-z0-9-]{5,})(?=[A-Za-z0-9-]*[A-Za-z])(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]+",
|
||||
)
|
||||
_MATERIAL_DIRECTION_TERMS = (
|
||||
"不得", "无须", "无需", "不承担", "无权", "有权", "免除", "免责", "赔偿", "解除", "终止",
|
||||
)
|
||||
|
||||
|
||||
def _compact_text(value: Any) -> str:
|
||||
@@ -87,23 +90,69 @@ def _eligible_location_field(item: dict[str, Any]) -> str | None:
|
||||
|
||||
def _eligible_high_similarity_field(item: dict[str, Any]) -> bool:
|
||||
"""
|
||||
判断无稳定字段标签的高相似 modify 是否可进入视觉 OCR 复核。
|
||||
判断无稳定字段标签的条款 modify 是否可进入双边同源 OCR 复核。
|
||||
|
||||
核心逻辑:仅允许长文本中的少量字符识别差异;金额、日期、比例、数量、型号和
|
||||
明确的关键字段始终保留确定性 Diff,不能借 OCR 一致自动忽略。
|
||||
核心逻辑:混合 PDF 的初始文本可能来自“原生文字层 vs 扫描 OCR”,因此付款、交期、
|
||||
质保等关键条款也允许进入候选;但只有双方已抽取的数字、型号及权利义务方向完全一致时
|
||||
才执行视觉复核。最终仍须两份 PDF 命中页使用同一 OCR 后文本完全一致,才会忽略差异。
|
||||
|
||||
Args:
|
||||
item: analyze_compare 生成的单条 modify 差异。
|
||||
|
||||
Returns:
|
||||
True 表示该条款可进行命中页双边 OCR;关键业务事实已变化时返回 False。
|
||||
"""
|
||||
if str(item.get("change_type") or "") != "modify":
|
||||
return False
|
||||
old_key = _compact_text(item.get("old_text"))
|
||||
new_key = _compact_text(item.get("new_text"))
|
||||
old_text = str(item.get("old_text") or "")
|
||||
new_text = str(item.get("new_text") or "")
|
||||
old_key = _compact_text(old_text)
|
||||
new_key = _compact_text(new_text)
|
||||
if min(len(old_key), len(new_key)) < 8 or old_key == new_key:
|
||||
return False
|
||||
blob = "\n".join(str(item.get(key) or "") for key in ("title", "old_text", "new_text"))
|
||||
if any(hint in blob for hint in _CRITICAL_VALUE_HINTS):
|
||||
|
||||
# [STEP 1] 数字、比例、日期、型号任一变化都保留原 Diff,不以 OCR 复核自动撤销。
|
||||
if _critical_fact_tokens(old_text) != _critical_fact_tokens(new_text):
|
||||
return False
|
||||
if any(re.search(pattern, blob, re.IGNORECASE) for pattern in _CRITICAL_VALUE_PATTERNS):
|
||||
|
||||
# [STEP 2] 否定、免责、赔偿和解除等方向变化属于实质权利义务变化。
|
||||
old_directions = {term for term in _MATERIAL_DIRECTION_TERMS if term in old_text}
|
||||
new_directions = {term for term in _MATERIAL_DIRECTION_TERMS if term in new_text}
|
||||
if old_directions != new_directions:
|
||||
return False
|
||||
return SequenceMatcher(None, old_key, new_key).ratio() >= 0.85
|
||||
|
||||
# [STEP 3] 候选门槛只用于控制 OCR 成本;是否忽略仍由双边视觉文本完全一致决定。
|
||||
similarity = SequenceMatcher(None, old_key, new_key).ratio()
|
||||
return similarity >= (0.55 if min(len(old_key), len(new_key)) >= 24 else 0.78)
|
||||
|
||||
|
||||
def _critical_fact_tokens(value: str) -> dict[str, tuple[str, ...]]:
|
||||
"""
|
||||
提取不能被视觉 OCR 自动忽略的合同业务事实。
|
||||
|
||||
核心逻辑:统一全半角并移除开头条款序号,分别收集数字、百分比/千分比和字母数字型号;
|
||||
比较候选资格时要求两侧 token 完全一致,避免把 24 小时改成 48 小时等真实变化吞掉。
|
||||
|
||||
Args:
|
||||
value: 单侧差异原文。
|
||||
|
||||
Returns:
|
||||
按 numbers、rates、models 分类并排序的不可变 token 字典。
|
||||
"""
|
||||
normalized = unicodedata.normalize("NFKC", str(value or ""))
|
||||
normalized = re.sub(r"^\s*(?:第\s*)?[一二三四五六七八九十百千万\d]+(?:条|款|项)?[.、::))\s]+", "", normalized)
|
||||
number_matches = tuple(re.findall(r"\d+(?:[,.]\d+)*", normalized))
|
||||
rates = tuple(re.findall(r"\d+(?:\.\d+)?\s*(?:%|‰)|(?:百分之|千分之)[零〇一二两三四五六七八九十百千万点\d.]+", normalized))
|
||||
models = tuple(
|
||||
token.lower()
|
||||
for token in re.findall(r"(?=[A-Za-z0-9-]{4,})(?=[A-Za-z0-9-]*[A-Za-z])(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]+", normalized)
|
||||
)
|
||||
critical_context = any(
|
||||
hint in normalized
|
||||
for hint in _CRITICAL_VALUE_HINTS + ("天", "日", "个月", "月", "年", "小时", "工作日", "期限")
|
||||
)
|
||||
numbers = number_matches if critical_context or rates else ()
|
||||
return {"numbers": numbers, "rates": rates, "models": models}
|
||||
|
||||
|
||||
def _pdf_text_profile(pdf_bytes: bytes) -> dict[str, int] | None:
|
||||
@@ -220,18 +269,31 @@ def _matching_field_line(lines: list[dict[str, Any]], field_label: str) -> str:
|
||||
|
||||
|
||||
def _matching_similar_line(lines: list[dict[str, Any]], expected_text: str) -> str:
|
||||
"""从 OCR 行及相邻行窗口中选出最接近原始差异文本的视觉行,供无标签短差异复核。"""
|
||||
"""
|
||||
从 OCR 行及相邻行窗口中选出最接近原始差异文本的视觉条款。
|
||||
|
||||
核心逻辑:扫描合同中的一个完整条款通常跨越多行,因此窗口会随预期文本长度扩大到八行;
|
||||
只有与初始差异文本达到最低相似度的窗口才返回,避免误取同页页眉或相邻条款。
|
||||
|
||||
Args:
|
||||
lines: 同一 PDF 页面按阅读顺序排列的 OCR 行。
|
||||
expected_text: 初始 Diff 中该侧的条款文本。
|
||||
|
||||
Returns:
|
||||
最接近的 OCR 行窗口;无可靠候选时返回空字符串。
|
||||
"""
|
||||
expected_key = _compact_text(expected_text)
|
||||
texts = [str(line.get("text") or "").strip() for line in lines if isinstance(line, dict)]
|
||||
best_text = ""
|
||||
best_score = 0.0
|
||||
for window_size in (1, 2, 3):
|
||||
max_window = min(8, max(3, len(expected_key) // 22 + 2))
|
||||
for window_size in range(1, max_window + 1):
|
||||
for start in range(0, max(0, len(texts) - window_size + 1)):
|
||||
candidate = "".join(texts[start : start + window_size])
|
||||
score = SequenceMatcher(None, expected_key, _compact_text(candidate)).ratio()
|
||||
if score > best_score:
|
||||
best_text, best_score = candidate, score
|
||||
return best_text[:500] if best_score >= 0.65 else ""
|
||||
return best_text[:500] if best_score >= 0.55 else ""
|
||||
|
||||
|
||||
def _line_bounds(line: dict[str, Any]) -> tuple[float, float, float, float] | None:
|
||||
@@ -624,7 +686,7 @@ def suppress_mixed_extraction_ocr_noise(
|
||||
"clause_no": item.get("clause_no"),
|
||||
"title": str(item.get("title") or "")[:200],
|
||||
"validation_type": validation_type,
|
||||
"field_label": field_label or "高相似非关键文本",
|
||||
"field_label": field_label or "同源 OCR 条款复核",
|
||||
"original_extraction_mode": str((original_extraction_meta or {}).get("mode") or ""),
|
||||
"returned_extraction_mode": str((returned_extraction_meta or {}).get("mode") or ""),
|
||||
"original_page_no": original_page,
|
||||
@@ -775,7 +837,7 @@ def suppress_mixed_extraction_ocr_noise(
|
||||
result,
|
||||
status="complete",
|
||||
mixed_extraction=True,
|
||||
checked=len(pending_locations) + (1 if equipment_items else 0),
|
||||
checked=len(pending_text_candidates) + (1 if equipment_items else 0),
|
||||
ignored=ignored,
|
||||
kept=kept,
|
||||
items=diagnostic_items,
|
||||
|
||||
@@ -215,6 +215,48 @@ def test_same_visual_ocr_removes_high_similarity_noncritical_noise(monkeypatch):
|
||||
assert diagnostic["items"][0]["validation_type"] == "high_similarity_text"
|
||||
|
||||
|
||||
def test_same_visual_ocr_removes_multiline_warranty_clause_noise(monkeypatch):
|
||||
"""混合 PDF 中质保条款仅因 OCR 断行/漏标点产生差异时,应由双方同源 OCR 复核后移除。"""
|
||||
item = {
|
||||
"clause_no": "9",
|
||||
"title": "质保与售后变更",
|
||||
"change_type": "modify",
|
||||
"change_class": "obligation",
|
||||
"risk_level": "medium",
|
||||
"old_text": "1.乙方自本设备安装并经验收合格之日起,免费提供保固壹年。于保固期间内,如甲方发现设备有瑕疵或不符合验收标准时,乙方应于接到甲方通知后,至迟24小时内,立即派员进行电话、邮件、微信等在线支持或赴现场实地勘查处理,并应于7天内处理完毕。",
|
||||
"new_text": "1.乙方自本设备安装并经验收合格之日起,免费提供保固壹年。于保固期间内,如甲方发现设备有瑕疵或不符合验收标准时,乙方应于接到甲方通知后,至迟 24 小时内,立即派员进行邮件、微信等在线支持或赴现场实地勘查处理,并应于 7 天内处理完毕。",
|
||||
}
|
||||
visual_text = [
|
||||
"1.乙方自本设备安装并经验收合格之日起,免费提供保固壹年。",
|
||||
"于保固期间内,如甲方发现设备有瑕疵或不符合验收标准时,乙方应于接到甲方通知后,",
|
||||
"至迟24小时内,立即派员进行电话、邮件、微信等在线支持或赴现场实地勘查处理,",
|
||||
"并应于7天内处理完毕。",
|
||||
]
|
||||
result = _run(
|
||||
monkeypatch,
|
||||
_compare_result(item),
|
||||
original_ocr="".join(visual_text),
|
||||
returned_ocr="".join(visual_text),
|
||||
)
|
||||
result = analyze.rebuild_result(result)
|
||||
|
||||
assert result["clauses_json"] == []
|
||||
quality = result["summary_json"]["comparison_quality"]
|
||||
assert quality["visual_ocr_rechecks"]["checked"] == 1
|
||||
assert quality["visual_ocr_rechecks"]["items"][0]["reason"] == "same_visual_ocr"
|
||||
|
||||
|
||||
def test_warranty_deadline_change_is_not_eligible_for_auto_ocr_suppression():
|
||||
"""质保期限等关键数字变化不得因高相似文本而进入自动忽略。"""
|
||||
item = {
|
||||
"change_type": "modify",
|
||||
"old_text": "质保期满12个月后支付",
|
||||
"new_text": "质保期满24个月后支付",
|
||||
}
|
||||
|
||||
assert visual_ocr_validation._eligible_high_similarity_field(item) is False
|
||||
|
||||
|
||||
def test_numeric_field_is_never_auto_ignored(monkeypatch):
|
||||
"""金额等关键数值字段即使双边 OCR 相同,也不得进入地点字段白名单。"""
|
||||
item = {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
| [shipping-notice](shipping-notice/README.md) | 货代发货通知 Agent | [technical.md](shipping-notice/technical.md) |
|
||||
| [file-check](file-check/README.md) | 文件检核(RoHS / MSDS 等) | [technical.md](file-check/technical.md) |
|
||||
| [fixed-assets](fixed-assets/README.md) | 固资快照同步与本地查询 | [technical.md](fixed-assets/technical.md) · [履历挂载命令](fixed-assets/history-share-mount.md) |
|
||||
| [procurement-contract](procurement-contract/README.md) | 采购合同审查 Agent(模板比对 / 单份审核) | [demand.md](procurement-contract/demand.md) · [comprehensive-review-technical.md](procurement-contract/comprehensive-review-technical.md) · [原型](../prototype/procurement-contract-review-prototype.html) |
|
||||
| [procurement-contract](procurement-contract/README.md) | 采购合同审查 Agent(模板比对 / 单份审核) | [用户操作手册](procurement-contract/用户操作手册.md) · [demand.md](procurement-contract/demand.md) · [comprehensive-review-technical.md](procurement-contract/comprehensive-review-technical.md) · [原型](../prototype/procurement-contract-review-prototype.html) |
|
||||
|
||||
**平台级**设计(跨域)见 [platform/](../platform/README.md)。
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# 立账凭证检核(accounting-voucher-check)
|
||||
|
||||
| 文档 | 读者 | 路径 |
|
||||
| --- | --- | --- |
|
||||
| **技术手册(Part1 产品原型)** | 产品、业务、研发评审、测试 | [technical.md](technical.md) |
|
||||
| **交互原型** | 产品、业务、测试 | [../../prototype/accounting-voucher-check-prototype.html](../../prototype/accounting-voucher-check-prototype.html) |
|
||||
| **原型速览** | 产品、测试 | [../../prototype/accounting-voucher-check-prototype.md](../../prototype/accounting-voucher-check-prototype.md) |
|
||||
|
||||
**定位**:以企业 AI 工作台**对话为主入口**,**日批为主、会话可手动触发**。
|
||||
**要解决的问题**:审计/复核时按发票号**快速确认共享盘配套资料在不在**(核价单、采购单等)。
|
||||
**检核内容**:只做必检材料**存在性 / 齐全性**;**不核对**金额、供应商等与 ERP 是否吻合。ERP **仅用于**取当月发票号清单。
|
||||
**其它**:单票状态落 **HXOPS 库**(齐全且材料未变更可跳过);缺资料推企微 textcard;**不回写 ERP、不要求 ERP 终审**。
|
||||
|
||||
**状态**:产品原型阶段(HTML + 本文 Part1)。必检材料清单、ERP 表名与发票号字段、通知节流细则等标注 **TBD**。
|
||||
@@ -0,0 +1,420 @@
|
||||
# 立账凭证检核 — 完整文档
|
||||
|
||||
> **维护说明**:本文件为立账凭证检核域的权威手册。当前仅交付 **第一部分:产品原型设计**(含当月范围与增量跳过策略)。Chatflow / Tool API / 部署 / 运维等实现细节待正式开发时写入第二部分。
|
||||
>
|
||||
> **交互原型**:[accounting-voucher-check-prototype.html](../../prototype/accounting-voucher-check-prototype.html) · [原型速览](../../prototype/accounting-voucher-check-prototype.md)
|
||||
>
|
||||
> **相近域参考**:交互壳与 `async_batch` 进度卡对齐 [文件检核(MSDS/RoHS)](../file-check/technical.md);共享盘挂载思路对齐 [固资履历](../fixed-assets/history-share-mount.md)。
|
||||
|
||||
## 阅读指南
|
||||
|
||||
| 读者 | 建议章节 |
|
||||
| --- | --- |
|
||||
| 产品 / 业务 / 测试 | [第一部分:产品原型设计](#第一部分产品原型设计) |
|
||||
| 研发 / Dify / 运维 | 第二部分(待写) |
|
||||
|
||||
## 总目录
|
||||
|
||||
**第一部分 [产品原型](#第一部分产品原型设计)**:需求缘起 · 功能清单 · 业务流程 · **当月范围与增量跳过** · 规格 · 测试案例 · 占位与边界
|
||||
|
||||
**第二部分 [Chatflow 编排与部署](待写)**:部署 · 编排 · Tool API · 运维
|
||||
|
||||
---
|
||||
|
||||
## 第一部分:产品原型设计
|
||||
|
||||
| 项目 | 说明 |
|
||||
|------|------|
|
||||
| 文档版本 | v0.2(原型:仅材料存在性,不做字段吻合) |
|
||||
| 读者 | 产品负责人、财务/立账业务、研发评审、测试验收 |
|
||||
| 产品名称 | 立账凭证检核 Agent |
|
||||
| 交互原型 | [accounting-voucher-check-prototype.html](../../prototype/accounting-voucher-check-prototype.html) |
|
||||
| 进度底座 | [Agent 进度管理原型](../../prototype/agent_progress_prototype.md)(`view_type=async_batch`) |
|
||||
|
||||
---
|
||||
|
||||
### 目录
|
||||
|
||||
- [一、需求缘起和要解决的问题](#一需求缘起和要解决的问题)
|
||||
- [二、需求输出设计](#二需求输出设计)
|
||||
- [三、当月范围与增量跳过策略](#三当月范围与增量跳过策略)(**已钉死**)
|
||||
- [四、规格需求](#四规格需求)
|
||||
- [五、测试场景案例](#五测试场景案例)
|
||||
- [六、补充说明与本期不做](#六补充说明与本期不做)
|
||||
|
||||
---
|
||||
|
||||
### 一、需求缘起和要解决的问题
|
||||
|
||||
#### 1.1 需求缘起
|
||||
|
||||
审计或复核时,需要按立账凭证(发票号)**快速找到共享盘中的配套资料**(核价单、采购单等),确认「该有的文件在不在」。
|
||||
**本期不做**金额、供应商、采购单号等业务字段是否与 ERP 吻合的核对——ERP 仅用于查出**当月发票号清单**,材料侧只做**存在性 / 齐全性**检查。
|
||||
|
||||
**人工标准作业(AI Agent 上线前,示意)**
|
||||
|
||||
| 步骤 | 作业内容 |
|
||||
|------|----------|
|
||||
| 1 | 从 ERP 导出或查询当月立账凭证(发票号集合) |
|
||||
| 2 | 按发票号到共享盘打开对应子目录 |
|
||||
| 3 | **只看**必检材料文件是否在目录中(有/无),**不打开核对金额、供应商等字段** |
|
||||
| 4 | 齐全 → 记为齐全;缺文件或缺目录 → 催补件 |
|
||||
| 5 | 结果多落在 Excel/台账或口头同步,跨日复盘、审计抽查费时 |
|
||||
|
||||
引入 Agent 后:以企业 AI 工作台**对话为主入口**,**日批为主、会话可手动触发**;系统拉取 ERP 当月发票号集合、扫描共享盘是否具备必检材料,输出齐全/缺资料结论与报告;**不回写 ERP、不要求 ERP 侧终审**。缺资料时通过企微 textcard 通知补件;检核记录可查,便于审计快速定位资料。
|
||||
|
||||
**主要使用人群**:财务立账 / 凭证资料归档与审计配合岗位。
|
||||
**协同角色**:材料归档责任人(补件)、IT/数据运维(ERP 取数、共享盘挂载)。
|
||||
|
||||
#### 1.2 现存核心痛点
|
||||
|
||||
> 以下描述 **Agent 上线前** 的人工作业痛点。
|
||||
|
||||
##### 1.2.1 业务痛点
|
||||
|
||||
- 当月立账凭证体量大,审计/复核时逐票进共享盘找文件耗时长。
|
||||
- 「文件在不在」依赖人工翻目录,缺件发现滞后,抽查效率低。
|
||||
- 缺件清单与催办过程缺少结构化留痕,跨日难复盘。
|
||||
- 已齐全票若每日全量重扫,重复劳动大;若完全不扫,又难以及时发现补件或目录变更。
|
||||
|
||||
##### 1.2.2 用户痛点
|
||||
|
||||
- ERP、共享盘、本地 Excel 多系统切换,操作路径长。
|
||||
- 难以一眼回答「当月多少票、今日新扫多少、跳过多少、缺资料几张、缺的是什么」。
|
||||
- 缺资料催办靠口头/零散消息,难追溯「哪几张票、缺什么、是否已提醒」。
|
||||
|
||||
##### 1.2.3 技术与运营痛点
|
||||
|
||||
- 缺少统一的「当月发票集合 + 单票材料齐全状态」落库,无法支撑可靠的增量跳过。
|
||||
- 无统一批次进度与 Excel 报告入口,审计信息分散。
|
||||
|
||||
#### 1.3 原型开发目标与边界
|
||||
|
||||
针对上述痛点,原型通过 AI Agent + 后台异步批次,对 ERP **当月全部**立账凭证执行**共享盘必检材料存在性检核**,输出结论与报告;**不核对 ERP 业务字段,不回写 ERP**。日批与会话触发共用同一引擎;日批默认**增量**(见 [§三](#三当月范围与增量跳过策略))。
|
||||
|
||||
| 人工 SOP(上线前) | Agent 上线后 |
|
||||
|--------------------|--------------|
|
||||
| ERP 查当月发票号 | 任务引擎拉取 ERP 当月发票号集合(表/字段 TBD;**仅作清单**) |
|
||||
| 共享盘按发票号翻目录看文件在不在 | Agent 扫描 `\share\立账凭证\{发票号}\`,判定必检材料是否存在 |
|
||||
| (人工不做字段核对) | **同样不做**金额/供应商等字段吻合检核 |
|
||||
| 缺件口头催办 | 企微 textcard 通知(含节流策略 TBD) |
|
||||
| Excel/台账自建 | 批次 Excel + HXOPS 检核记录可查(服务审计快速找资料) |
|
||||
| (无增量) | 单票状态落库;齐全且材料未变更 → **跳过** |
|
||||
|
||||
##### 目标
|
||||
|
||||
提供「立账凭证检核 Agent」:以企业 AI 工作台**对话为主入口**,**日批为主、会话可手动触发**,统一承载:
|
||||
|
||||
> 日批(主)/ 会话(辅)发起检核 → `async_batch` 进度(含跳过)→ 报告与记录 → 缺资料通知 → 查询历史/缺资料票
|
||||
|
||||
**入口与触发(勿混为一谈)**:
|
||||
|
||||
| 维度 | 约定 |
|
||||
|------|------|
|
||||
| 工作台入口 | 对话(用户在 HXOPS Agent 会话中查看进度、查询结果、必要时手动触发) |
|
||||
| 检核触发 | **日批为主**(默认每日定时跑当月增量);会话文字触发为辅(加急单票 / 强制重检当月等) |
|
||||
|
||||
**执行模型**:触发后 HXOPS 后台异步执行批次;对话侧通过助手消息下挂 **进度卡** 展示「当月总数 / 本次待检 / 跳过 / 齐全 / 缺资料」等;完成后可下载 Excel、查看检核记录。
|
||||
|
||||
**判定职责边界**:
|
||||
|
||||
| 组件 | 职责 |
|
||||
|------|------|
|
||||
| 材料存在性检核(规则/轻量识别,实现 TBD) | 按必检清单判断文件是否存在;输出 **齐全 / 缺资料 / 人工判定**(命名无法识别时) |
|
||||
| Dify Chatflow(实现 TBD) | 意图识别、调用 Tool、组织自然语言回复;不自行做终态判定 |
|
||||
| HXOPS 任务引擎(实现 TBD) | 拉 ERP 当月发票清单、增量判定、扫共享盘、写单票状态、生成 Excel、发缺资料通知;**不回写 ERP、不做字段吻合** |
|
||||
|
||||
##### 原型范围内
|
||||
|
||||
- 对话主入口:自然语言发起增量检核、强制重检当月全部、单票检核、查询结果/缺资料
|
||||
- 日批为主(默认每日 09:00,可配置)+ 会话文字手动触发
|
||||
- 异步批次 + `async_batch` 进度卡(统计含 **跳过**)
|
||||
- 检核记录可查(定时/会话批次、按发票号明细)
|
||||
- 共享盘材料视图(按发票号;必检清单可配置占位)
|
||||
- 缺资料企微 textcard 示意
|
||||
- **当月范围 + HXOPS 落库增量跳过**(本文 §三)
|
||||
|
||||
##### 原型范围外 / 本期不做
|
||||
|
||||
- 正式后端/前端实现、Dify 部署手册、真实 ERP 表对接
|
||||
- 浏览器 localStorage 作为单票状态源(**禁止**;状态必须落 HXOPS 库)
|
||||
- ERP 终审、回写 ERP
|
||||
- **金额 / 供应商 / 采购单号等业务字段与 ERP 的吻合核对**(明确不做)
|
||||
- 移动端原生 App
|
||||
|
||||
---
|
||||
|
||||
### 二、需求输出设计
|
||||
|
||||
#### 2.1 整体设计思路
|
||||
|
||||
产品由**用户触点**、**智能层**、**业务层**协作:对话承载意图与进度卡;智能层做意图与回复;业务层负责 ERP 取发票清单、增量判定、共享盘材料存在性扫描、落库、Excel 与企微通知。
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
Trigger["日批 Cron 或会话文字触发"] --> ERP["ERP 查出当月发票号清单"]
|
||||
ERP --> State{"HXOPS 单票状态 + 材料指纹"}
|
||||
State -->|齐全且材料未变更| Skip["计入跳过"]
|
||||
State -->|新票或需再检| Share["共享盘:发票号子目录"]
|
||||
Share --> Materials{"必检材料文件是否存在"}
|
||||
Materials -->|缺资料| Notify["企微通知补件"]
|
||||
Materials -->|齐全| Ok["记齐全并落库"]
|
||||
Ok --> Report["进度卡含跳过数 + Excel + 记录"]
|
||||
Skip --> Report
|
||||
Notify --> Report
|
||||
```
|
||||
|
||||
**设计原则**
|
||||
|
||||
1. **对话驱动、后台异步**:发起后立即返回,进度卡轮询,不阻塞对话。
|
||||
2. **日批与会话同一引擎**:会话「执行今日检核」与 Cron 走同一套增量逻辑。
|
||||
3. **当月全集 + 单票增量**:队列永远是 ERP 当月发票清单;是否重扫目录由 HXOPS 单票状态与材料指纹决定。
|
||||
4. **跳过计入进度**:进度卡与批次摘要必须展示「跳过」计数,避免误以为未处理。
|
||||
5. **强制模式可关闭跳过**:会话「重新检核当月全部」或指定发票 → 强制重扫。
|
||||
6. **只判存在性、不回写 ERP**:输出齐全/缺资料/人工判定 + 报告;**不做字段吻合**。
|
||||
7. **缺资料可通知、可查询**:企微 textcard + 检核记录筛选。
|
||||
8. **状态落库、禁止浏览器本地缓存作源**:单票结论与指纹存 HXOPS DB。
|
||||
|
||||
##### 2.1.1 操作界面形态(原型四 Tab)
|
||||
|
||||
| Tab | 内容 |
|
||||
| --- | --- |
|
||||
| 会话 | 日批/文字触发;进度卡;单票结果卡 |
|
||||
| 检核记录 | 定时/会话批次;含跳过统计;按发票号明细 |
|
||||
| 共享盘材料 | `\\share\立账凭证\{发票号}\`;必检材料占位 |
|
||||
| 缺资料通知 | 企微 textcard;跳转检核记录 |
|
||||
|
||||
以企业 AI 工作台**对话为主入口**,**日批为主、会话可手动触发**;其余 Tab 为原型示意的运维/业务辅助视图(正式产品中部分能力也可能收敛到对话 + 后台配置)。
|
||||
|
||||
**进度卡片信息架构(`async_batch`)**
|
||||
|
||||
| 区域 | 内容 |
|
||||
|------|------|
|
||||
| 标题区 | 任务名称、批次号、状态(执行中/已完成/含缺资料等) |
|
||||
| 进度条 | 百分比 |
|
||||
| 统计格 | **当月总数**、**本次待检**、**跳过**、齐全、缺资料 |
|
||||
| 当前阶段 | 拉取 ERP 发票清单 → 增量判定 → 扫共享盘材料是否存在 → 通知/汇总 |
|
||||
| 操作区 | 下载 Excel;查看缺资料通知(有缺资料时) |
|
||||
|
||||
示意文案:`当月 N 票 · 新检 x · 跳过 y`。
|
||||
|
||||
##### 2.1.2 与工作台进度通用底座的关系
|
||||
|
||||
本 Agent 进度属于 **`async_batch`** 视图,协议见 [agent_progress_prototype.md](../../prototype/agent_progress_prototype.md)。相对 RoHS/MSDS:本域是**资料齐套扫描**(非字段合规检核);进度卡强化「跳过」与「当月总数 / 本次待检」;无 ERP 回写、无字段吻合。
|
||||
|
||||
#### 2.2 核心功能清单
|
||||
|
||||
| 编号 | 功能名称 | 用户价值 | 主要输入 | 主要输出 |
|
||||
|------|----------|----------|----------|----------|
|
||||
| F1 | 日批检核(增量) | 无人值守消化当月队列 | Cron(默认 09:00) | 批次、进度卡、跳过统计、Excel、记录 |
|
||||
| F2 | 会话执行今日检核(增量) | 与日批同引擎的手动触发 | 「执行今日立账凭证检核」 | 同 F1 |
|
||||
| F3 | 重新检核当月全部(强制) | 全量重跑、不跳过 | 「重新检核当月全部」 | 跳过=0 的全量批次 |
|
||||
| F4 | 单票强制检核 | 加急/指定发票 | 「检核发票 INV-xxx」 | 该票结论与结果卡 |
|
||||
| F5 | 实时进度展示 | 观测进展与跳过 | `progress_id` 轮询 | `async_batch` 进度卡 |
|
||||
| F6 | 查询最新/批次结果 | 快速复盘 | 「查询最新检核结果」 | 摘要 + Excel + 记录入口 |
|
||||
| F7 | 查询缺资料发票 | 催补件 | 「查询缺资料发票」 | 缺资料清单 + 通知入口 |
|
||||
| F8 | 检核记录可查 | 审计快速定位资料与缺件 | 记录 Tab / 查询话术 | 批次列表、发票明细、缺项清单、筛选(缺资料等) |
|
||||
| F9 | 共享盘材料视图 | 核对目录与必检齐全度 | 发票号目录 | 材料列表、缺项标记(清单 TBD) |
|
||||
| F10 | 缺资料企微通知 | 触达补件人 | 检核结论=缺资料 | textcard(节流 TBD) |
|
||||
| F11 | 能力说明与兜底 | 降低误用 | 「你能做什么」 | 能力列表、引导话术 |
|
||||
|
||||
#### 2.3 核心业务流程
|
||||
|
||||
##### 2.3.1 意图分支(会话,示意)
|
||||
|
||||
| 意图 | 示例话术 | 行为 |
|
||||
|------|----------|------|
|
||||
| 增量检核 | 执行今日立账凭证检核 | 与日批同逻辑:可跳过 |
|
||||
| 强制全量 | 重新检核当月全部 | 当月全部强制检核,不跳过 |
|
||||
| 单票强制 | 检核发票 INV-20260803001 | 指定发票强制检核 |
|
||||
| 查结果 | 查询最新检核结果 | 摘要 + 链接/记录入口 |
|
||||
| 查缺资料 | 查询缺资料发票 | 缺资料清单 |
|
||||
| 能力说明 | 你能做什么 | 能力列表 |
|
||||
|
||||
##### 2.3.2 单批次执行阶段(示意)
|
||||
|
||||
| 阶段 | 系统行为 | 用户可见 |
|
||||
|------|----------|----------|
|
||||
| fetch_erp | 拉取 ERP **当月**立账凭证发票号集合 | 拉取 ERP 当月立账凭证 |
|
||||
| incremental_filter | 读 HXOPS 单票状态 + 材料指纹,划分跳过 / 待检(强制模式则全待检) | 状态比对 · 跳过 N |
|
||||
| scan_share | 对待检票扫描共享盘子目录,按必检清单判文件是否存在 | 扫描共享盘 · 看文件在不在 |
|
||||
| conclude | 齐全 / 缺资料 / 人工判定(命名无法识别) | 写结论 |
|
||||
| notify | 缺资料票按节流策略发企微 | 缺资料已推送(如有) |
|
||||
| persist | 写单票状态、批次明细、Excel | 完成 · 新检 x / 跳过 y |
|
||||
|
||||
批次级状态:`running` → `success` / `partial`(如含缺资料)/ `failed` 等(实现时与文件检核任务引擎对齐)。
|
||||
|
||||
**系统结论类型**
|
||||
|
||||
| 结论 | 含义 |
|
||||
|------|------|
|
||||
| 齐全 | 必检材料文件均存在(进度卡可与「合格」同义展示) |
|
||||
| 缺资料 | 共享盘缺发票号目录,或缺一项/多项必检材料 |
|
||||
| 人工判定 | 目录内文件命名无法判断是否对应必检类型(需人看) |
|
||||
| 跳过 | 本批未重扫:已齐全且材料指纹未变(仅进度统计) |
|
||||
|
||||
---
|
||||
|
||||
### 三、当月范围与增量跳过策略
|
||||
|
||||
> 本节为已确认产品决策,实现与测试须以此为准。
|
||||
|
||||
#### 3.1 检核范围(已钉死)
|
||||
|
||||
| 项 | 结论 |
|
||||
| --- | --- |
|
||||
| 日批默认范围 | **每日检核 ERP 当月全部立账凭证**(会计月 = 当前自然月对应的立账会计月;跨月日批自动切到新月集合) |
|
||||
| 队列来源 | ERP 当月立账凭证集合(**表名/字段 TBD**) |
|
||||
| 材料来源 | 共享盘按**发票号**子目录(路径占位:`\\share\立账凭证\{发票号}\`;挂载方式对齐固资 CIFS 思路) |
|
||||
| 会话默认「今日检核」 | 与日批同一范围、同一增量引擎 |
|
||||
| 非默认范围 | 仅通过「指定发票」或后续扩展话术覆盖;一期不提供任意自定义 SQL 筛月 |
|
||||
|
||||
#### 3.2 增量策略原则(已钉死)
|
||||
|
||||
**不每天把当月已齐全票全量重扫共享盘。**
|
||||
在 **HXOPS 数据库**保存单票材料齐全状态(**不是**浏览器 localStorage)。日批/会话增量模式:先取当月发票清单,再按单票状态与**材料指纹**决定跳过或再扫。
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
MonthSet["ERP 当月发票号清单"] --> Each{"逐票判定"}
|
||||
Each -->|强制模式| Force["重扫"]
|
||||
Each -->|已齐全且材料指纹未变| Skip["跳过"]
|
||||
Each -->|新票| Check["扫描"]
|
||||
Each -->|上次缺资料/人工判定| Recheck["再扫"]
|
||||
Each -->|材料指纹变| Recheck
|
||||
```
|
||||
|
||||
#### 3.3 日批 / 增量模式下的行为表
|
||||
|
||||
| 情形 | 日批 /「执行今日检核」行为 |
|
||||
| --- | --- |
|
||||
| 已 **齐全**,材料指纹未变 | **跳过**(进度卡「跳过」+1) |
|
||||
| **新票**(当月首次出现) | **扫描** |
|
||||
| 上次为 **缺资料 / 人工判定** | **再扫** |
|
||||
| 材料目录有变更(指纹变) | **再扫** |
|
||||
| 会话指定发票 | **强制扫描**(忽略跳过) |
|
||||
| 会话「重新检核当月全部」 | **强制扫描当月全部**(跳过=0) |
|
||||
|
||||
#### 3.4 单票状态落库(示意字段)
|
||||
|
||||
实现时表结构可调整,但产品语义至少覆盖:
|
||||
|
||||
| 字段语义 | 说明 |
|
||||
|----------|------|
|
||||
| 发票号 | 业务主键之一 |
|
||||
| 会计月 | 与「当月集合」对齐 |
|
||||
| 最近结论 | 齐全 / 缺资料 / 人工判定 等 |
|
||||
| 最近批次号 | 关联批次审计 |
|
||||
| 检核时间 | 最近一次实际扫描(非跳过)时间 |
|
||||
| 材料指纹 | 共享盘子目录内容指纹(算法实现 TBD) |
|
||||
| 缺项快照 | 最近一次缺资料时的缺失材料列表(便于通知与审计) |
|
||||
| 缺资料通知节流标记 | 支持同票同日不重复刷屏(细则 TBD) |
|
||||
|
||||
**跳过**时:更新批次统计中的跳过计数;**不**无故清空历史齐全结论;材料指纹以库内值为准。
|
||||
|
||||
> ERP 侧**不**保存「金额/供应商等比对 hash」——本期无字段吻合逻辑。
|
||||
|
||||
#### 3.5 通知节流(默认意向)
|
||||
|
||||
| 规则 | 说明 |
|
||||
|------|------|
|
||||
| 默认 | 同票**同日**持续缺资料,不重复刷屏企微 |
|
||||
| 再提醒 | 补件后再次检核仍缺资料,可再次提醒 |
|
||||
| 细则 | 合并多票卡片 vs 单票卡片、接收人、跳转链等 **TBD** |
|
||||
|
||||
#### 3.6 与 MSDS / 文件检核的差异摘要
|
||||
|
||||
| 维度 | 文件检核(RoHS/MSDS) | 立账凭证检核 |
|
||||
|------|----------------------|--------------|
|
||||
| 队列来源 | SRM 未检核等 | ERP **当月**立账凭证全集 |
|
||||
| 材料 | SRM/附件等 | **共享盘**发票号子目录 |
|
||||
| 检核内容 | 字段/规则合规 | **仅材料文件是否存在** |
|
||||
| 增量 | 以队列状态为主 | **HXOPS 单票状态 + 材料指纹**,齐全未变更可跳过 |
|
||||
| 缺资料 | 视检核类型 | 明确结论类型 + **企微通知** |
|
||||
| 回写业务系统 | 不自动审 SRM | **不回写 ERP** |
|
||||
| 进度卡 | 含跳过 | 含跳过,并强调当月总数 / 本次待检 |
|
||||
|
||||
---
|
||||
|
||||
### 四、规格需求
|
||||
|
||||
#### 4.1 原型占位(默认值)
|
||||
|
||||
| 占位项 | 默认值 | 状态 |
|
||||
| --- | --- | --- |
|
||||
| 日批时间 | 每日 09:00 | 可配置 |
|
||||
| 范围 | 当月立账凭证 | **已钉死** |
|
||||
| 必检材料 | 核价单、采购单必检;发票扫描件 | **TBD**(原型可配置占位清单) |
|
||||
| ERP 用途 | 仅取当月**发票号清单**(及定位会计月所需字段) | 表名 **TBD**;**不做**金额/供应商等吻合 |
|
||||
| 结论枚举 | 齐全 / 缺资料 / 人工判定 / 跳过 | 跳过为批次统计态 |
|
||||
| 共享盘根路径 | `\\share\立账凭证\` | 占位 |
|
||||
| 企微通知 | textcard,可跳转检核记录 | 文案与接收人 **TBD** |
|
||||
|
||||
#### 4.2 非功能(原型级)
|
||||
|
||||
- 进度展示不阻塞对话发送(除可配置的运行中锁定)。
|
||||
- 单票状态与批次明细须可支撑「检核记录」筛选与审计导出(实现阶段细化)。
|
||||
- 不得将单票增量状态仅存在前端。
|
||||
|
||||
#### 4.3 验收要点(产品)
|
||||
|
||||
- [ ] 日批/「执行今日检核」进度卡出现 **当月总数、本次待检、跳过**,且增量场景下跳过 > 0 有合理示意。
|
||||
- [ ] 「重新检核当月全部」跳过 = 0,当月票均进入待检。
|
||||
- [ ] 指定发票强制检核,不受历史合格跳过影响。
|
||||
- [ ] 缺资料票可在记录中筛选,并有企微通知示意。
|
||||
- [ ] 文案与帮助中明确:**只查文件在不在**;**不核对金额/供应商等字段**;**不回写 ERP**;状态落 HXOPS。
|
||||
- [ ] 必检材料清单在原型/文档中标注 TBD,不假装已最终确认。
|
||||
|
||||
---
|
||||
|
||||
### 五、测试场景案例
|
||||
|
||||
| 编号 | 场景 | 前置 | 操作 | 期望 |
|
||||
|------|------|------|------|------|
|
||||
| T1 | 增量日批大量跳过 | 当月 28 票中 22 票已齐全且材料指纹未变 | 日批或「执行今日立账凭证检核」 | 待检 6、跳过 22;跳过票不重扫 |
|
||||
| T2 | 新票入月 | 当月新增发票 | 增量检核 | 新票进入待检并出齐全/缺资料 |
|
||||
| T3 | 缺资料再扫 | 上次缺资料,今日仍缺 | 增量检核 | 再扫 → 仍缺资料;通知按节流规则 |
|
||||
| T4 | 补件后齐全 | 上次缺资料,今日必检文件已齐 | 增量检核 | 再扫 → 齐全,并更新库内状态 |
|
||||
| T5 | 材料变更 | 已齐全但共享盘文件变更(指纹变) | 增量检核 | 再扫,不跳过 |
|
||||
| T6 | 强制全量 | 存在大量可跳过票 | 「重新检核当月全部」 | 跳过 0,全部重扫 |
|
||||
| T7 | 单票强制 | 该票本可跳过 | 「检核发票 INV-xxx」 | 强制出结论 |
|
||||
| T8 | 查缺资料 | 批次含缺资料 | 「查询缺资料发票」 | 列出缺资料发票及缺项 |
|
||||
| T9 | 不做字段吻合 | 材料齐全 | 检核完成 | 报告无金额/供应商比对项 |
|
||||
| T10 | 不回写 ERP | 任意结论 | 检核完成 | 无 ERP 写回;仅 HXOPS 记录 + 报告 |
|
||||
|
||||
---
|
||||
|
||||
### 六、补充说明与本期不做
|
||||
|
||||
#### 6.1 文档与原型索引
|
||||
|
||||
| 产物 | 路径 |
|
||||
|------|------|
|
||||
| 本 Part1 | `docs/features/accounting-voucher-check/technical.md` |
|
||||
| 域 README | `docs/features/accounting-voucher-check/README.md` |
|
||||
| HTML 原型 | `docs/prototype/accounting-voucher-check-prototype.html` |
|
||||
| 原型速览 | `docs/prototype/accounting-voucher-check-prototype.md` |
|
||||
|
||||
#### 6.2 待业务确认(TBD)
|
||||
|
||||
- 必检材料最终清单(发票扫描件是否必检等)
|
||||
- ERP 表名、会计月字段、发票号字段与取数方式(**仅清单,无比对字段集**)
|
||||
- 材料指纹算法与「变更」粒度
|
||||
- 企微接收人、textcard 字段、同日节流/合并细则
|
||||
- 跨月、红冲、作废票等特殊凭证是否纳入当月集合
|
||||
|
||||
#### 6.3 第二部分预留
|
||||
|
||||
正式开发启动后,于本文续写:
|
||||
|
||||
- 部署与环境变量、共享盘挂载
|
||||
- Dify Chatflow / Workflow 编排
|
||||
- Tool API / OpenAPI
|
||||
- 单票状态表迁移与任务引擎细节
|
||||
- 验证与排错
|
||||
|
||||
#### 6.4 本期明确不做
|
||||
|
||||
- 正式后端/前端实现、Dify 部署手册、真实 ERP 表对接
|
||||
- 浏览器 localStorage 作为状态源
|
||||
- ERP 终审与回写
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
| 项 | 说明 |
|
||||
| --- | --- |
|
||||
| **用户操作手册** | [用户操作手册.md](用户操作手册.md) · [Word 版](采购合同审查智能体_用户操作手册.docx)(登录、双模式操作、结果说明) |
|
||||
| **需求** | [demand.md](demand.md) |
|
||||
| **当前方案 / 技术** | [comprehensive-review-technical.md](comprehensive-review-technical.md) |
|
||||
| **旧版 MVP** | [technical.md](technical.md) |
|
||||
|
||||
@@ -0,0 +1,593 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
docs/features/procurement-contract/_gen_user_manual_docx.py
|
||||
|
||||
用途:将采购合同审查用户操作手册生成为带截图的 Word(.docx)。
|
||||
依赖:python-docx;读取同目录 assets/ 下操作截图。
|
||||
逻辑:本地维护用脚本;输出 采购合同审查智能体_用户操作手册.docx。
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from docx import Document
|
||||
from docx.enum.table import WD_TABLE_ALIGNMENT
|
||||
from docx.enum.text import WD_ALIGN_PARAGRAPH
|
||||
from docx.oxml import OxmlElement
|
||||
from docx.oxml.ns import qn
|
||||
from docx.shared import Cm, Inches, Pt, RGBColor
|
||||
|
||||
BASE = Path(__file__).resolve().parent
|
||||
ASSETS = BASE / "assets"
|
||||
OUT = BASE / "采购合同审查智能体_用户操作手册.docx"
|
||||
|
||||
|
||||
def set_run_font(run, size=None, bold=None, color=None):
|
||||
"""
|
||||
统一设置 Run 为微软雅黑及字号/加粗/颜色。
|
||||
|
||||
Args:
|
||||
run: python-docx Run 对象。
|
||||
size: 字号(磅),可选。
|
||||
bold: 是否加粗,可选。
|
||||
color: RGBColor,可选。
|
||||
"""
|
||||
run.font.name = "微软雅黑"
|
||||
run._element.rPr.rFonts.set(qn("w:eastAsia"), "微软雅黑")
|
||||
if size is not None:
|
||||
run.font.size = Pt(size)
|
||||
if bold is not None:
|
||||
run.bold = bold
|
||||
if color is not None:
|
||||
run.font.color.rgb = color
|
||||
|
||||
|
||||
def add_para(doc, text, *, bold=False, size=11, space_after=6, align=None, color=None):
|
||||
"""
|
||||
向文档追加一段正文。
|
||||
|
||||
Args:
|
||||
doc: Document。
|
||||
text: 段落文本。
|
||||
bold / size / space_after / align / color: 样式参数。
|
||||
|
||||
Returns:
|
||||
新建的 Paragraph。
|
||||
"""
|
||||
p = doc.add_paragraph()
|
||||
if align is not None:
|
||||
p.alignment = align
|
||||
p.paragraph_format.space_after = Pt(space_after)
|
||||
run = p.add_run(text)
|
||||
set_run_font(run, size=size, bold=bold, color=color)
|
||||
return p
|
||||
|
||||
|
||||
def add_bullet(doc, text, level=0):
|
||||
"""
|
||||
追加项目符号段落。
|
||||
|
||||
Args:
|
||||
doc: Document。
|
||||
text: 条文内容。
|
||||
level: 缩进层级,0 起。
|
||||
"""
|
||||
p = doc.add_paragraph(style="List Bullet")
|
||||
p.clear()
|
||||
run = p.add_run(text)
|
||||
set_run_font(run, size=11)
|
||||
p.paragraph_format.left_indent = Cm(0.75 + level * 0.5)
|
||||
|
||||
|
||||
def shade_cell(cell, hex_color):
|
||||
"""为表格单元格设置背景色(hex,无 #)。"""
|
||||
tc = cell._tc
|
||||
tcPr = tc.get_or_add_tcPr()
|
||||
shd = OxmlElement("w:shd")
|
||||
shd.set(qn("w:fill"), hex_color)
|
||||
shd.set(qn("w:val"), "clear")
|
||||
tcPr.append(shd)
|
||||
|
||||
|
||||
def set_cell_text(cell, text, *, bold=False, size=10, center=False):
|
||||
"""写入单元格文本并设置基础样式。"""
|
||||
cell.text = ""
|
||||
p = cell.paragraphs[0]
|
||||
if center:
|
||||
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
||||
run = p.add_run(text)
|
||||
set_run_font(run, size=size, bold=bold)
|
||||
tc = cell._tc
|
||||
tcPr = tc.get_or_add_tcPr()
|
||||
tcMar = OxmlElement("w:tcMar")
|
||||
for m in ("top", "left", "bottom", "right"):
|
||||
node = OxmlElement(f"w:{m}")
|
||||
node.set(qn("w:w"), "60")
|
||||
node.set(qn("w:type"), "dxa")
|
||||
tcMar.append(node)
|
||||
tcPr.append(tcMar)
|
||||
|
||||
|
||||
def add_table(doc, headers, rows, col_widths=None):
|
||||
"""
|
||||
追加带表头样式的表格。
|
||||
|
||||
Args:
|
||||
doc: Document。
|
||||
headers: 表头列表。
|
||||
rows: 二维数据行。
|
||||
col_widths: 各列宽度(厘米),可选。
|
||||
"""
|
||||
table = doc.add_table(rows=1 + len(rows), cols=len(headers))
|
||||
table.style = "Table Grid"
|
||||
table.alignment = WD_TABLE_ALIGNMENT.CENTER
|
||||
for i, h in enumerate(headers):
|
||||
set_cell_text(table.rows[0].cells[i], h, bold=True, size=10, center=True)
|
||||
shade_cell(table.rows[0].cells[i], "1F4E79")
|
||||
for p in table.rows[0].cells[i].paragraphs:
|
||||
for r in p.runs:
|
||||
r.font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
|
||||
for r_idx, row in enumerate(rows):
|
||||
for c_idx, val in enumerate(row):
|
||||
set_cell_text(table.rows[r_idx + 1].cells[c_idx], str(val), size=10)
|
||||
if r_idx % 2 == 1:
|
||||
shade_cell(table.rows[r_idx + 1].cells[c_idx], "F2F2F2")
|
||||
if col_widths:
|
||||
for row in table.rows:
|
||||
for i, w in enumerate(col_widths):
|
||||
row.cells[i].width = Cm(w)
|
||||
doc.add_paragraph()
|
||||
|
||||
|
||||
def add_image(doc, path, width_inches=5.8, caption=None):
|
||||
"""居中插入图片及可选图注。"""
|
||||
path = Path(path)
|
||||
if not path.exists():
|
||||
add_para(doc, f"【缺图】{path}", color=RGBColor(0xC0, 0x00, 0x00))
|
||||
return
|
||||
p = doc.add_paragraph()
|
||||
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
||||
p.add_run().add_picture(str(path), width=Inches(width_inches))
|
||||
if caption:
|
||||
cp = doc.add_paragraph()
|
||||
cp.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
||||
r = cp.add_run(caption)
|
||||
set_run_font(r, size=9, color=RGBColor(0x66, 0x66, 0x66))
|
||||
|
||||
|
||||
def add_note(doc, text):
|
||||
"""追加「说明:」灰字提示段。"""
|
||||
p = doc.add_paragraph()
|
||||
p.paragraph_format.space_before = Pt(4)
|
||||
p.paragraph_format.space_after = Pt(8)
|
||||
r1 = p.add_run("说明:")
|
||||
set_run_font(r1, size=10, bold=True, color=RGBColor(0x1F, 0x4E, 0x79))
|
||||
r2 = p.add_run(text)
|
||||
set_run_font(r2, size=10, color=RGBColor(0x44, 0x44, 0x44))
|
||||
|
||||
|
||||
def build_document() -> Path:
|
||||
"""
|
||||
生成完整 Word 操作手册并写入 OUT。
|
||||
|
||||
Returns:
|
||||
输出文件 Path。
|
||||
"""
|
||||
# [STEP 1] 清理可能因编码错误留下的乱码文件名 docx(保留 demand.docx)
|
||||
for f in BASE.glob("*.docx"):
|
||||
if f.name != "demand.docx" and "用户操作手册" not in f.name:
|
||||
# 仅删除本脚本上次错误生成的乱码文件
|
||||
if f.stat().st_size < 500_000 and "demand" not in f.name.lower():
|
||||
try:
|
||||
f.unlink()
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
doc = Document()
|
||||
style = doc.styles["Normal"]
|
||||
style.font.name = "微软雅黑"
|
||||
style.font.size = Pt(11)
|
||||
style._element.rPr.rFonts.set(qn("w:eastAsia"), "微软雅黑")
|
||||
style.paragraph_format.space_after = Pt(6)
|
||||
style.paragraph_format.line_spacing = 1.15
|
||||
|
||||
for i in range(1, 4):
|
||||
hs = doc.styles[f"Heading {i}"]
|
||||
hs.font.name = "微软雅黑"
|
||||
hs._element.rPr.rFonts.set(qn("w:eastAsia"), "微软雅黑")
|
||||
hs.font.color.rgb = RGBColor(0x1F, 0x4E, 0x79)
|
||||
hs.font.size = Pt({1: 18, 2: 14, 3: 12}[i])
|
||||
|
||||
# [STEP 2] 封面
|
||||
for _ in range(3):
|
||||
doc.add_paragraph()
|
||||
add_para(
|
||||
doc,
|
||||
"采购合同审查智能体",
|
||||
bold=True,
|
||||
size=28,
|
||||
align=WD_ALIGN_PARAGRAPH.CENTER,
|
||||
space_after=12,
|
||||
)
|
||||
add_para(
|
||||
doc,
|
||||
"用户操作手册",
|
||||
bold=True,
|
||||
size=22,
|
||||
align=WD_ALIGN_PARAGRAPH.CENTER,
|
||||
space_after=24,
|
||||
color=RGBColor(0x1F, 0x4E, 0x79),
|
||||
)
|
||||
add_para(doc, "版本:v1.0", size=12, align=WD_ALIGN_PARAGRAPH.CENTER, space_after=4)
|
||||
add_para(
|
||||
doc,
|
||||
"适用对象:采购、业务等日常使用人员",
|
||||
size=12,
|
||||
align=WD_ALIGN_PARAGRAPH.CENTER,
|
||||
space_after=4,
|
||||
)
|
||||
add_para(
|
||||
doc,
|
||||
"结果定位:采购风险提示,不作为法律意见;重要条款请人工核实",
|
||||
size=11,
|
||||
align=WD_ALIGN_PARAGRAPH.CENTER,
|
||||
color=RGBColor(0xC0, 0x00, 0x00),
|
||||
space_after=12,
|
||||
)
|
||||
doc.add_page_break()
|
||||
|
||||
# [STEP 3] 正文各章
|
||||
doc.add_heading("1. 环境与登录", level=1)
|
||||
doc.add_heading("1.1 访问地址", level=2)
|
||||
add_table(
|
||||
doc,
|
||||
["环境", "地址"],
|
||||
[
|
||||
["测试环境", "http://192.168.100.192:8890/"],
|
||||
["正式环境", "http://192.168.100.230:8881/"],
|
||||
],
|
||||
col_widths=[3.5, 12],
|
||||
)
|
||||
add_note(
|
||||
doc,
|
||||
"请在公司内网访问。日常试用、培训建议使用测试环境;正式业务审查使用正式环境。",
|
||||
)
|
||||
|
||||
doc.add_heading("1.2 账号密码", level=2)
|
||||
add_table(
|
||||
doc,
|
||||
["项", "说明"],
|
||||
[
|
||||
["用户名", "本人工号"],
|
||||
["密码", "123456(默认密码;若已修改请使用当前密码)"],
|
||||
],
|
||||
col_widths=[3.5, 12],
|
||||
)
|
||||
|
||||
doc.add_heading("1.3 进入智能体", level=2)
|
||||
add_bullet(doc, "浏览器打开对应环境地址并登录。")
|
||||
add_bullet(doc, "在工作台中进入「采购合同审查」智能体。")
|
||||
add_bullet(doc, "进入后可见欢迎语:「你好,您已进入 采购合同审查 智能体」。")
|
||||
|
||||
doc.add_heading("2. 界面说明", level=1)
|
||||
add_para(doc, "主操作界面如下(以「合同比对」模式为例):")
|
||||
add_image(
|
||||
doc,
|
||||
ASSETS / "01-chat-home.png",
|
||||
width_inches=5.6,
|
||||
caption="图 1 主界面:合同比对模式",
|
||||
)
|
||||
add_table(
|
||||
doc,
|
||||
["区域", "说明"],
|
||||
[
|
||||
["顶部欢迎区", "确认已进入采购合同审查智能体"],
|
||||
["模式切换", "合同比对 / 单份审核,二选一"],
|
||||
["操作提示", "随模式变化,提示需要上传哪些文件"],
|
||||
["输入框", "可输入补充说明或提问(占位文案:「问我任何事…」)"],
|
||||
["上传按钮", "按模式显示「我方原合同」「卖方回传/待审合同」等入口"],
|
||||
["发送按钮", "右侧纸飞机图标,发起审查"],
|
||||
["页脚提示", "「AI 可能会犯错,请核实重要信息。」"],
|
||||
],
|
||||
col_widths=[3.5, 12],
|
||||
)
|
||||
add_para(doc, "两种模式怎么选?", bold=True, size=11)
|
||||
add_table(
|
||||
doc,
|
||||
["模式", "适用场景", "需要上传"],
|
||||
[
|
||||
[
|
||||
"合同比对",
|
||||
"我方已发出合同,卖方回传了修改稿,需要找出改了什么、风险多大",
|
||||
"我方原合同 + 卖方回传合同",
|
||||
],
|
||||
[
|
||||
"单份审核",
|
||||
"仅有卖方自有合同 / 单份待审合同,检查是否触碰采购红线",
|
||||
"1 份待审合同",
|
||||
],
|
||||
],
|
||||
col_widths=[2.8, 8.2, 4.5],
|
||||
)
|
||||
add_para(
|
||||
doc,
|
||||
"支持的文件类型:pdf、doc、docx、txt、md。建议优先使用 Word 或可检索(可选中文字)的 PDF;纯扫描件可能解析失败或耗时更长。",
|
||||
)
|
||||
|
||||
doc.add_heading("3. 合同比对 — 操作步骤", level=1)
|
||||
doc.add_heading("3.1 操作流程", level=2)
|
||||
for i, s in enumerate(
|
||||
[
|
||||
"在底部模式区点击「合同比对」(选中后为浅蓝高亮)。",
|
||||
"确认提示文案为:「请分别上传我方原合同和卖方回传合同」。",
|
||||
"点击「上传我方原合同」,选择我方发出稿(底稿)。",
|
||||
"点击「上传卖方回传合同」,选择卖方回传稿。",
|
||||
"(可选)在输入框填写说明,例如「重点看质保和付款条款」;不填也可直接发送。",
|
||||
"点击右侧发送(纸飞机)图标。",
|
||||
"系统创建审查并返回审查编号(如 CR-20260730-22E4),结果卡会展示进度步骤;等待至显示「审查完成」。",
|
||||
],
|
||||
1,
|
||||
):
|
||||
p = doc.add_paragraph()
|
||||
set_run_font(p.add_run(f"{i}. {s}"), size=11)
|
||||
add_note(
|
||||
doc,
|
||||
"比对模式必须同时上传两份合同;只上传其中一份无法发起比对审查。审查为异步执行,大文件可能需等待数分钟;请勿重复点击发送。",
|
||||
)
|
||||
|
||||
doc.add_heading("3.2 比对结果怎么看", level=2)
|
||||
add_para(doc, "审查完成后,结果卡示例如下:")
|
||||
add_image(
|
||||
doc,
|
||||
ASSETS / "02-compare-result.png",
|
||||
width_inches=5.8,
|
||||
caption="图 2 合同比对结果示例",
|
||||
)
|
||||
doc.add_heading("(1)页眉信息", level=3)
|
||||
add_table(
|
||||
doc,
|
||||
["字段", "含义"],
|
||||
[
|
||||
["审查完成 · CR-…", "系统审查编号,便于沟通与追溯(不是业务合同编号)"],
|
||||
["对方合同", "卖方回传合同文件名"],
|
||||
["合同编号", "从合同正文自动抽取的业务编号(若能识别)"],
|
||||
["供应商", "从合同正文自动抽取的对方名称(若能识别)"],
|
||||
["我方原合同", "比对底稿文件名;「用户上传」表示本次由您上传,非库内模板"],
|
||||
["右上角红标", "如「含高风险 N 项」,一眼提示是否存在高风险"],
|
||||
],
|
||||
col_widths=[3.8, 11.7],
|
||||
)
|
||||
doc.add_heading("(2)统计卡片", level=3)
|
||||
add_table(
|
||||
doc,
|
||||
["指标", "含义"],
|
||||
[
|
||||
["改动项", "相对我方原合同,卖方稿中存在的实质变更条数(增/删/改)"],
|
||||
["高风险", "高风险改动或风险项数量(红色)"],
|
||||
["中风险", "中风险数量(橙色)"],
|
||||
["低风险", "低风险数量"],
|
||||
],
|
||||
col_widths=[3.5, 12],
|
||||
)
|
||||
add_note(doc, "空格、标点、编号等非实质差异一般不会计入改动项。")
|
||||
|
||||
doc.add_heading("(3)「合同改动项」明细表", level=3)
|
||||
add_table(
|
||||
doc,
|
||||
["列", "说明"],
|
||||
[
|
||||
["条款", "改动所属主题(如「质保与售后变更」),并可能标注原文页码"],
|
||||
["类型", "常见为「修改」;亦可能为新增、删除等"],
|
||||
[
|
||||
"变更对照",
|
||||
"粉色区为我方原文(删除或被改内容常带删除线);绿色区为对方合同(新增或改后内容高亮)",
|
||||
],
|
||||
["风险", "圆标:高(红)/ 中(橙)/ 低"],
|
||||
],
|
||||
col_widths=[3.5, 12],
|
||||
)
|
||||
add_para(
|
||||
doc,
|
||||
"读图示例(质保期限):原文「18 个月」被划掉,对方改为「12 个月」→ 质保期缩短,通常评为中风险,需采购确认是否可接受。",
|
||||
)
|
||||
|
||||
doc.add_heading("(4)如何处理比对结论", level=3)
|
||||
add_bullet(doc, "先看右上角是否有高风险角标。")
|
||||
add_bullet(doc, "再按统计卡片从高到低过一遍改动项。")
|
||||
add_bullet(
|
||||
doc,
|
||||
"对照粉色/绿色文本,确认对方是否实质性削弱了我方权益(付款、质保、交期、管辖、违约金等)。",
|
||||
)
|
||||
add_bullet(doc, "需要对外沟通或归档时,使用结果区底部的下载按钮(见第 5 节)。")
|
||||
|
||||
doc.add_heading("4. 单份审核 — 操作步骤", level=1)
|
||||
doc.add_heading("4.1 操作流程", level=2)
|
||||
for i, s in enumerate(
|
||||
[
|
||||
"在底部模式区点击「单份审核」。",
|
||||
"按提示上传 1 份待审卖方合同(界面不再要求「我方原合同」)。",
|
||||
"(可选)在输入框补充关注点后,点击发送。",
|
||||
"等待结果卡进度至「审查完成」,查看独立风险项与建议。",
|
||||
],
|
||||
1,
|
||||
):
|
||||
p = doc.add_paragraph()
|
||||
set_run_font(p.add_run(f"{i}. {s}"), size=11)
|
||||
|
||||
doc.add_heading("4.2 单份审核结果怎么看", level=2)
|
||||
add_para(doc, "单份审核完成后,结果卡示例如下:")
|
||||
add_image(
|
||||
doc,
|
||||
ASSETS / "03-solo-result.png",
|
||||
width_inches=5.8,
|
||||
caption="图 3 单份审核结果示例",
|
||||
)
|
||||
doc.add_heading("(1)页眉与统计", level=3)
|
||||
add_para(
|
||||
doc,
|
||||
"与比对模式类似:审查编号、对方合同文件名、合同编号、供应商、高风险角标,以及「改动项 / 高 / 中 / 低」统计。",
|
||||
)
|
||||
add_note(
|
||||
doc,
|
||||
"单份模式重点看「独立风险项」(是否触碰采购红线),而不是两稿文字 Diff。",
|
||||
)
|
||||
|
||||
doc.add_heading("(2)「独立风险项」明细表", level=3)
|
||||
add_table(
|
||||
doc,
|
||||
["列", "说明"],
|
||||
[
|
||||
["条款", "风险主题,如「付款前置条件不足」"],
|
||||
["类型", "常见为「采购红线」"],
|
||||
[
|
||||
"命中原文",
|
||||
"系统在合同中定位到的相关原文(绿色底高亮);若条款缺失,会明确说明「未识别到…」",
|
||||
],
|
||||
["修改建议", "面向采购的改稿方向(提示性,非自动改合同)"],
|
||||
["风险", "右侧圆标,红「高」/ 橙「中」/ 低风险等"],
|
||||
],
|
||||
col_widths=[3.5, 12],
|
||||
)
|
||||
add_para(
|
||||
doc,
|
||||
"系统重点关注的采购维度包括(「五问」类硬规则,叠加启用中的红线规则):",
|
||||
)
|
||||
add_table(
|
||||
doc,
|
||||
["关注点", "说明"],
|
||||
[
|
||||
["付款前置条件", "大额付款是否与交货、安装调试、验收、合规发票等挂钩"],
|
||||
["交货期限", "是否约定明确交期"],
|
||||
["质保期限", "是否有清晰质保约定"],
|
||||
["争议管辖", "是否对采购方不利(如约定卖方所在地法院)"],
|
||||
["逾期违约金", "卖方逾期交付违约金是否达到日合同总价 ≥ 5‰ 等要求"],
|
||||
],
|
||||
col_widths=[3.5, 12],
|
||||
)
|
||||
add_para(doc, "读图示例:", bold=True)
|
||||
add_bullet(
|
||||
doc,
|
||||
"付款前置条件不足(高):命中质保/定金相关原文 → 建议将主要付款与交货、验收、发票等绑定。",
|
||||
)
|
||||
add_bullet(
|
||||
doc,
|
||||
"争议管辖对采购方不利(高):原文「由乙方所在地人民法院仲裁」→ 建议改为买方所在地人民法院管辖。",
|
||||
)
|
||||
add_bullet(
|
||||
doc,
|
||||
"逾期交付违约责任缺失(高):未识别到卖方逾期违约金 → 建议约定日 5‰ 并保留索赔权利。",
|
||||
)
|
||||
|
||||
doc.add_heading("5. 下载与后续动作", level=1)
|
||||
add_table(
|
||||
doc,
|
||||
["按钮", "用途"],
|
||||
[
|
||||
[
|
||||
"下载审查报告",
|
||||
"下载结构化审查报告(一般为 Word/docx),便于转发、归档、会签",
|
||||
],
|
||||
[
|
||||
"下载标注合同",
|
||||
"在原 PDF 上带风险/改动标注(主要适用于 PDF);便于对照原文页码查看",
|
||||
],
|
||||
],
|
||||
col_widths=[3.5, 12],
|
||||
)
|
||||
add_para(doc, "建议流程:", bold=True)
|
||||
add_bullet(doc, "下载报告,与业务/供应商沟通改稿点。")
|
||||
add_bullet(doc, "有 PDF 时再下载标注合同,在原文中定位条款。")
|
||||
add_bullet(doc, "人工确认后修改合同并重新上传审查(如需)。")
|
||||
|
||||
doc.add_heading("6. 常见问题(FAQ)", level=1)
|
||||
add_table(
|
||||
doc,
|
||||
["问题", "说明与处理"],
|
||||
[
|
||||
[
|
||||
"发送后一直在转圈?",
|
||||
"审查异步进行,大文件或扫描件较慢;可等待进度条走完。前端等待约有上限,超时后可刷新会话查看是否已完成。",
|
||||
],
|
||||
[
|
||||
"提示解析失败?",
|
||||
"文件可能损坏、加密或无法抽正文。请改用 Word 或可选中文字的 PDF 后重试。",
|
||||
],
|
||||
[
|
||||
"只想聊天提问、不审查?",
|
||||
"不上传合同附件时,发送纯文字会走智能体引导对话,不会创建正式审查任务。",
|
||||
],
|
||||
[
|
||||
"合同编号/供应商为空?",
|
||||
"正文未能自动抽取时可能为空,不影响已识别的改动项与风险项查看。",
|
||||
],
|
||||
[
|
||||
"AI 结论能否直接签字盖章?",
|
||||
"不能。结论仅为采购风险提示,须人工核实重要信息后再决策。",
|
||||
],
|
||||
[
|
||||
"测试环境与正式环境数据互通吗?",
|
||||
"不互通。请按用途选择环境,正式业务请在正式环境操作。",
|
||||
],
|
||||
],
|
||||
col_widths=[5, 10.5],
|
||||
)
|
||||
|
||||
doc.add_heading("7. 操作速查", level=1)
|
||||
add_para(doc, "登录(工号 / 123456)", bold=True)
|
||||
add_bullet(doc, "进入「采购合同审查」")
|
||||
add_bullet(doc, "选模式")
|
||||
add_bullet(
|
||||
doc,
|
||||
"合同比对:上传「我方原合同」+「卖方回传合同」→ 发送 → 看「合同改动项」+ 风险等级 → 下载报告/标注合同",
|
||||
level=1,
|
||||
)
|
||||
add_bullet(
|
||||
doc,
|
||||
"单份审核:上传 1 份待审合同 → 发送 → 看「独立风险项」+ 修改建议 → 下载报告/标注合同",
|
||||
level=1,
|
||||
)
|
||||
|
||||
doc.add_heading("8. 免责声明", level=1)
|
||||
add_bullet(doc, "AI 可能误判、漏判或表述不准确,请核实重要信息。")
|
||||
add_bullet(
|
||||
doc,
|
||||
"本智能体输出用于采购风险辅助判断,不构成法律意见或合规终裁。",
|
||||
)
|
||||
add_bullet(
|
||||
doc,
|
||||
"系统不会自动改合同、不会盖章,也不会回写 OA/SRM;最终合同内容以人工确认版本为准。",
|
||||
)
|
||||
|
||||
for section in doc.sections:
|
||||
section.top_margin = Cm(2.2)
|
||||
section.bottom_margin = Cm(2.2)
|
||||
section.left_margin = Cm(2.5)
|
||||
section.right_margin = Cm(2.5)
|
||||
|
||||
# [STEP 4] 若已存在正确文件名则覆盖;并清理乱码残留
|
||||
doc.save(OUT)
|
||||
for f in BASE.glob("*.docx"):
|
||||
if f.resolve() == OUT.resolve():
|
||||
continue
|
||||
if f.name == "demand.docx":
|
||||
continue
|
||||
# 删除非目标、非 demand 的旧手册残留
|
||||
if "操作手册" in f.name or f.stat().st_size == OUT.stat().st_size:
|
||||
continue
|
||||
# 乱码文件名通常不含「采购」正确编码
|
||||
try:
|
||||
name_ok = "采购合同审查" in f.name
|
||||
except Exception:
|
||||
name_ok = False
|
||||
if not name_ok:
|
||||
try:
|
||||
f.unlink()
|
||||
except OSError:
|
||||
pass
|
||||
return OUT
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
out = build_document()
|
||||
print(f"OK: {out}")
|
||||
print(f"size: {out.stat().st_size}")
|
||||
print(f"name_ok: {'采购合同审查智能体_用户操作手册.docx' == out.name}")
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
@@ -179,7 +179,7 @@
|
||||
|
||||
- 输入:我方原合同全文 + 卖方回传全文。
|
||||
- 空格、换行、标点、编号及高相似 OCR 噪声 **不得** 计为合同改动。
|
||||
- 一侧为原生文字 PDF、另一侧为扫描 PDF 时,对地点类 `modify` 和高相似非关键文本 `modify` 疑似差异复核双方命中页;同源 OCR 视觉文本一致才可忽略。金额、日期、比例、数量、型号及 `insert/delete` 必须保留原判断。
|
||||
- 一侧为原生文字 PDF、另一侧为扫描 PDF 时,对地点类及高相似条款 `modify` 疑似差异复核双方命中页;付款、交期、质保、违约和管辖等条款只有数字、比例、日期、期限、型号、数量及权利义务方向一致时才可进入复核。同源 OCR 视觉文本一致才可忽略;金额、日期、比例、数量、型号及 `insert/delete` 必须保留原判断。
|
||||
- 设备清单出现表格差异时,须按视觉坐标比较设备名称、品牌、型号、数量、单价和总价;空品牌列不得导致型号及后续列左移,业务字段完全一致时可移除同一表格产生的修改和无对照新增项。
|
||||
- 日期/金额/比例/期限出现圈号、错字或不确定 OCR 字形 → 仅可进待确认(实现上比对主列表可不展示待确认)。
|
||||
- 同一条款类别下不同事实变化须分别保留(如预付款比例与付款期限不可合并为一项)。
|
||||
|
||||
@@ -445,9 +445,10 @@ PDF 保留原始分页;Word 和旧 `.doc` 通过现有 LibreOffice 能力转 P
|
||||
期限、型号、功率和数量仍按正常差异处理。
|
||||
|
||||
当两份 PDF 一侧有原生文字层、另一侧为纯图片扫描件时,Worker 对已产生的地点类 `modify`
|
||||
及高相似非关键文本 `modify` 疑似差异执行双边同源 OCR 复核。地点字段白名单包含设备使用地、设备安装地、交货/交付地点、
|
||||
及高相似条款 `modify` 疑似差异执行双边同源 OCR 复核;高相似候选覆盖付款、交期、质保、违约和管辖等主题,
|
||||
但只有两侧数字、比例、日期、期限、型号、数量及权利义务方向均一致时才允许进入复核。地点字段白名单包含设备使用地、设备安装地、交货/交付地点、
|
||||
安装/使用地点;无稳定标签的候选仅限少量字符差异且排除金额、日期、比例、数量、型号等关键值。先用原生字符坐标或持久化 OCR 行框定位双方页面,再按相同 1.25 倍渲染比例
|
||||
和 RapidOCR 参数只识别命中页。双方字段行归一化后完全一致才移除该项,并累计
|
||||
和 RapidOCR 参数只识别命中页;长条款按最多 8 行窗口重建视觉文本。双方字段行或条款窗口归一化后完全一致才移除该项,并累计
|
||||
`comparison_quality.ignored_ocr_noise`;金额、日期、比例、数量、型号及 `insert/delete` 均不
|
||||
自动忽略。页面定位或 OCR 失败时保留原差异,不阻断审核。
|
||||
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
# 采购合同审查智能体 — 用户操作手册
|
||||
|
||||
|
||||
| 项目 | 说明 |
|
||||
| -------- | ---------------------------------------------------- |
|
||||
| 文档版本 | v1.0 |
|
||||
| 适用对象 | 采购、业务等日常使用人员 |
|
||||
| 关联文档 | [需求说明](demand.md) · [域 README](README.md) |
|
||||
| 结果定位 | **采购风险提示**,不作为法律意见;重要条款请人工核实 |
|
||||
|
||||
---
|
||||
|
||||
## 1. 环境与登录
|
||||
|
||||
### 1.1 访问地址
|
||||
|
||||
|
||||
| 环境 | 地址 |
|
||||
| -------- | ---------------------------- |
|
||||
| 测试环境 | http://192.168.100.192:8890/ |
|
||||
| 正式环境 | http://192.168.100.230:8881/ |
|
||||
|
||||
> 请在公司内网访问。日常试用、培训建议使用**测试环境**;正式业务审查使用**正式环境**。
|
||||
|
||||
### 1.2 账号密码
|
||||
|
||||
|
||||
| 项 | 说明 |
|
||||
| ------ | -------------------------------------------- |
|
||||
| 用户名 | 本人**工号** |
|
||||
| 密码 | `123456`(默认密码;若已修改请使用当前密码) |
|
||||
|
||||
### 1.3 进入智能体
|
||||
|
||||
1. 浏览器打开对应环境地址并登录。
|
||||
2. 在工作台中进入 **「采购合同审查」** 智能体。
|
||||
3. 进入后可见欢迎语:「你好,您已进入 **采购合同审查** 智能体」。
|
||||
|
||||
---
|
||||
|
||||
## 2. 界面说明
|
||||
|
||||
主操作界面如下(以「合同比对」模式为例):
|
||||
|
||||

|
||||
|
||||
|
||||
| 区域 | 说明 |
|
||||
| ---------- | --------------------------------------------------- |
|
||||
| 顶部欢迎区 | 确认已进入采购合同审查智能体 |
|
||||
| 模式切换 | **合同比对** / **单份审核**,二选一 |
|
||||
| 操作提示 | 随模式变化,提示需要上传哪些文件 |
|
||||
| 输入框 | 可输入补充说明或提问(占位文案:「问我任何事…」) |
|
||||
| 上传按钮 | 按模式显示「我方原合同」「卖方回传/待审合同」等入口 |
|
||||
| 发送按钮 | 右侧纸飞机图标,发起审查 |
|
||||
| 页脚提示 | 「AI 可能会犯错,请核实重要信息。」 |
|
||||
|
||||
**两种模式怎么选?**
|
||||
|
||||
|
||||
| 模式 | 适用场景 | 需要上传 |
|
||||
| ------------ | ------------------------------------------------------------ | ------------------------- |
|
||||
| **合同比对** | 我方已发出合同,卖方回传了修改稿,需要找出改了什么、风险多大 | 我方原合同 + 卖方回传合同 |
|
||||
| **单份审核** | 仅有卖方自有合同 / 单份待审合同,检查是否触碰采购红线 | 1 份待审合同 |
|
||||
|
||||
**支持的文件类型**:`pdf`、`doc`、`docx`、`txt`、`md`。
|
||||
建议优先使用 **Word** 或 **可检索(可选中文字)的 PDF**;纯扫描件可能解析失败或耗时更长。
|
||||
|
||||
---
|
||||
|
||||
## 3. 合同比对 — 操作步骤
|
||||
|
||||
### 3.1 操作流程
|
||||
|
||||
1. 在底部模式区点击 **「合同比对」**(选中后为浅蓝高亮)。
|
||||
2. 确认提示文案为:「请分别上传我方原合同和卖方回传合同」。
|
||||
3. 点击 **「上传我方原合同」**,选择我方发出稿(底稿)。
|
||||
4. 点击 **「上传卖方回传合同」**,选择卖方回传稿。
|
||||
5. (可选)在输入框填写说明;不填也可直接发送。
|
||||
6. 点击右侧 **发送**(纸飞机)图标。
|
||||
7. 系统创建审查并返回审查编号(如 `CR-20260730-22E4`),结果卡会展示进度步骤;等待至显示 **「审查完成」**。
|
||||
|
||||
> 比对模式**必须**同时上传两份合同;只上传其中一份无法发起比对审查。
|
||||
> 审查为异步执行,大文件可能需等待数分钟;请勿重复疯狂点击发送。
|
||||
|
||||
### 3.2 比对结果怎么看
|
||||
|
||||
审查完成后,结果卡示例如下:
|
||||
|
||||

|
||||
|
||||
#### (1)页眉信息
|
||||
|
||||
|
||||
| 字段 | 含义 |
|
||||
| ------------------ | -------------------------------------------------------- |
|
||||
| 审查完成 ·`CR-…` | 系统审查编号,便于沟通与追溯(不是业务合同编号) |
|
||||
| 对方合同 | 卖方回传合同文件名 |
|
||||
| 合同编号 | 从合同正文自动抽取的业务编号(若能识别) |
|
||||
| 供应商 | 从合同正文自动抽取的对方名称(若能识别) |
|
||||
| 我方原合同 | 比对底稿文件名;「用户上传」表示本次由您上传,非库内模板 |
|
||||
| 右上角红标 | 如「含高风险 N 项」,一眼提示是否存在高风险 |
|
||||
|
||||
#### (2)统计卡片
|
||||
|
||||
|
||||
| 指标 | 含义 |
|
||||
| ---------- | ------------------------------------------------------ |
|
||||
| **改动项** | 相对我方原合同,卖方稿中存在的实质变更条数(增/删/改) |
|
||||
| **高风险** | 高风险改动或风险项数量(红色) |
|
||||
| **中风险** | 中风险数量(橙色) |
|
||||
| **低风险** | 低风险数量 |
|
||||
|
||||
> 空格、标点、编号等非实质差异一般不会计入改动项。
|
||||
|
||||
#### (3)「合同改动项」明细表
|
||||
|
||||
|
||||
| 列 | 说明 |
|
||||
| ------------ | ----------------------------------------------------------------------------------------------------- |
|
||||
| **条款** | 改动所属主题(如「质保与售后变更」),并可能标注原文页码 |
|
||||
| **类型** | 常见为「修改」;亦可能为新增、删除等 |
|
||||
| **变更对照** | 粉色区为**模板原文/我方原文**(删除或被改内容常带删除线);绿色区为**对方合同**(新增或改后内容高亮) |
|
||||
| **风险** | 圆标:**高**(红)/ **中**(橙)/ **低** |
|
||||
|
||||
**读图示例(质保期限)**:原文「18 个月」被划掉,对方改为「12 个月」→ 质保期缩短,通常评为中风险,需采购确认是否可接受。
|
||||
|
||||
#### (4)如何处理比对结论
|
||||
|
||||
1. 先看右上角是否有 **高风险** 角标。
|
||||
2. 再按统计卡片从高到低过一遍改动项。
|
||||
3. 对照粉色/绿色文本,确认对方是否实质性削弱了我方权益(付款、质保、交期、管辖、违约金等)。
|
||||
4. 需要对外沟通或归档时,使用结果区底部的下载按钮(见第 5 节)。
|
||||
|
||||
---
|
||||
|
||||
## 4. 单份审核 — 操作步骤
|
||||
|
||||
### 4.1 操作流程
|
||||
|
||||
1. 在底部模式区点击 **「单份审核」**。
|
||||
2. 按提示上传 **1 份** 待审卖方合同(界面不再要求「我方原合同」)。
|
||||
3. (可选)在输入框补充关注点后,点击 **发送**。
|
||||
4. 等待结果卡进度至 **「审查完成」**,查看独立风险项与建议。
|
||||
|
||||
### 4.2 单份审核结果怎么看
|
||||
|
||||
单份审核完成后,结果卡示例如下:
|
||||
|
||||

|
||||
|
||||
#### (1)页眉与统计
|
||||
|
||||
与比对模式类似:审查编号、对方合同文件名、合同编号、供应商、高风险角标,以及「改动项 / 高 / 中 / 低」统计。
|
||||
|
||||
> 单份模式重点看 **独立风险项**(是否触碰采购红线),而不是两稿文字 Diff。
|
||||
|
||||
#### (2)「独立风险项」明细表
|
||||
|
||||
|
||||
| 列 | 说明 |
|
||||
| ------------ | -------------------------------------------------------------------------------- |
|
||||
| **条款** | 风险主题,如「付款前置条件不足」 |
|
||||
| **类型** | 常见为**采购红线** |
|
||||
| **命中原文** | 系统在合同中定位到的相关原文(绿色底高亮);若条款缺失,会明确说明「未识别到…」 |
|
||||
| **修改建议** | 面向采购的改稿方向(提示性,非自动改合同) |
|
||||
| **风险** | 右侧圆标,红「高」/ 橙「中」/ 低风险等 |
|
||||
|
||||
系统重点关注的采购维度包括(「五问」类硬规则,叠加启用中的红线规则):
|
||||
|
||||
|
||||
| 关注点 | 说明 |
|
||||
| ------------ | ----------------------------------------------------- |
|
||||
| 付款前置条件 | 大额付款是否与交货、安装调试、验收、合规发票等挂钩 |
|
||||
| 交货期限 | 是否约定明确交期 |
|
||||
| 质保期限 | 是否有清晰质保约定 |
|
||||
| 争议管辖 | 是否对采购方不利(如约定卖方所在地法院) |
|
||||
| 逾期违约金 | 卖方逾期交付违约金是否达到日合同总价**≥ 5‰** 等要求 |
|
||||
|
||||
**读图示例**:
|
||||
|
||||
1. **付款前置条件不足(高)**:命中质保/定金相关原文 → 建议将主要付款与交货、验收、发票等绑定。
|
||||
2. **争议管辖对采购方不利(高)**:原文「由乙方所在地人民法院仲裁」→ 建议改为买方所在地人民法院管辖。
|
||||
3. **逾期交付违约责任缺失(高)**:未识别到卖方逾期违约金 → 建议约定日 5‰ 并保留索赔权利。
|
||||
|
||||
---
|
||||
|
||||
## 5. 下载与后续动作
|
||||
|
||||
审查完成后,结果区底部通常提供:
|
||||
|
||||
|
||||
| 按钮 | 用途 |
|
||||
| ---------------- | ---------------------------------------------------------------------- |
|
||||
| **下载审查报告** | 下载结构化审查报告(一般为 Word/docx),便于转发、归档、会签 |
|
||||
| **下载标注合同** | 在原 PDF 上带风险/改动标注(**主要适用于 PDF**);便于对照原文页码查看 |
|
||||
|
||||
建议流程:
|
||||
|
||||
1. 下载报告,与业务/供应商沟通改稿点。
|
||||
2. 有 PDF 时再下载标注合同,在原文中定位条款。
|
||||
3. 人工确认后修改合同并重新上传审查(如需)。
|
||||
|
||||
---
|
||||
|
||||
## 6. 常见问题(FAQ)
|
||||
|
||||
|
||||
| 问题 | 说明与处理 |
|
||||
| ------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
||||
| 发送后一直在转圈? | 审查异步进行,大文件或扫描件较慢;可等待进度条走完。前端等待约有上限,超时后可刷新会话查看是否已完成。 |
|
||||
| 提示解析失败? | 文件可能损坏、加密或无法抽正文。请改用 Word 或可选中文字的 PDF 后重试。 |
|
||||
| 只想聊天提问、不审查? | 不上传合同附件时,发送纯文字会走智能体引导对话,**不会**创建正式审查任务。 |
|
||||
| 合同编号/供应商为空? | 正文未能自动抽取时可能为空,不影响已识别的改动项与风险项查看。 |
|
||||
| AI 结论能否直接签字盖章? | **不能**。结论仅为采购风险提示,须人工核实重要信息后再决策。 |
|
||||
| 测试环境与正式环境数据互通吗? | **不互通**。请按用途选择环境,正式业务请在正式环境操作。 |
|
||||
|
||||
---
|
||||
|
||||
## 7. 操作速查
|
||||
|
||||
```text
|
||||
登录(工号 / 123456)
|
||||
→ 进入「采购合同审查」
|
||||
→ 选模式
|
||||
├─ 合同比对:上传「我方原合同」+「卖方回传合同」→ 发送
|
||||
│ → 看「合同改动项」+ 风险等级 → 下载报告/标注合同
|
||||
└─ 单份审核:上传 1 份待审合同 → 发送
|
||||
→ 看「独立风险项」+ 修改建议 → 下载报告/标注合同
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. 免责声明
|
||||
|
||||
- AI 可能误判、漏判或表述不准确,**请核实重要信息**。
|
||||
- 本智能体输出用于采购风险辅助判断,**不构成法律意见或合规终裁**。
|
||||
- 系统不会自动改合同、不会盖章,也不会回写 OA/SRM;最终合同内容以人工确认版本为准。
|
||||
Binary file not shown.
@@ -0,0 +1,799 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
docs/prototype/accounting-voucher-check-prototype.html
|
||||
用途:立账凭证检核 Agent 低保真原型——对话为主入口、日批为主;只查共享盘材料是否存在,不做字段吻合。
|
||||
依赖:浏览器原生 HTML/CSS/JavaScript,无需构建;用于产品/业务评审。
|
||||
逻辑:顶栏切换「会话 / 检核记录 / 共享盘材料 / 缺资料通知」;
|
||||
会话内模拟发起检核 → 进度卡 → 单票结果卡;记录页可筛选批次与发票明细;
|
||||
共享盘按发票号展示材料齐全度(必检清单占位 TBD);缺资料触发企微 textcard。
|
||||
-->
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>立账凭证检核 Agent · 原型</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #f7f9fc; --panel: #ffffff; --line: #d8e0ec; --line-strong: #a7b3c5;
|
||||
--text: #172033; --muted: #667792; --brand: #2f80d1; --brand-soft: #eaf4ff;
|
||||
--success: #067647; --success-soft: #ecfdf3; --warning: #b54708; --warning-soft: #fffaeb;
|
||||
--danger: #b42318; --danger-soft: #fef3f2; --info: #175cd3; --info-soft: #eff8ff;
|
||||
--shadow: 0 14px 36px rgba(23, 32, 51, 0.08);
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
|
||||
font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; }
|
||||
button, input, select, textarea { font: inherit; }
|
||||
button { cursor: pointer; }
|
||||
.proto-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px;
|
||||
padding: 10px 18px; background: #0f172a; color: #e2e8f0; flex-wrap: wrap; position: sticky; top: 0; z-index: 20; }
|
||||
.proto-bar strong { color: #fff; font-size: 13px; }
|
||||
.proto-meta { color: #94a3b8; font-size: 12px; margin-left: 8px; }
|
||||
.view-tabs { display: flex; gap: 6px; background: #1e293b; padding: 4px; border-radius: 10px; flex-wrap: wrap; }
|
||||
.view-tabs button { border: 0; border-radius: 8px; padding: 8px 14px; background: transparent; color: #cbd5e1; font-weight: 600; font-size: 13px; }
|
||||
.view-tabs button.active { background: var(--brand); color: #fff; }
|
||||
.view { display: none; min-height: calc(100vh - 52px); }
|
||||
.view.active { display: grid; }
|
||||
.chat-shell { grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 52px); }
|
||||
.sidebar { display: flex; flex-direction: column; gap: 16px; padding: 18px 16px; border-right: 1px solid var(--line); background: var(--panel); }
|
||||
.agent-name { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
|
||||
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0; }
|
||||
.new-chat { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #f8fbff; font-weight: 600; }
|
||||
.side-label { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
|
||||
.hist-item { padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; margin-bottom: 6px; cursor: pointer; }
|
||||
.hist-item:hover { background: #f5f8fc; }
|
||||
.hist-item.active { background: var(--brand-soft); border-color: #c8dff8; }
|
||||
.hist-item .t { font-weight: 600; font-size: 13px; }
|
||||
.hist-item .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
|
||||
.hint-box { padding: 12px 14px; border-radius: 12px; background: var(--info-soft); border: 1px solid #b2ddff; color: var(--info); font-size: 12px; line-height: 1.5; }
|
||||
.chat-main { display: grid; grid-template-rows: 1fr auto; min-height: calc(100vh - 52px); background: linear-gradient(180deg, #f4f7fb 0%, #eef3f9 100%); }
|
||||
.chat-scroll { overflow: auto; padding: 20px 22px 8px; }
|
||||
.chat-welcome { display: none; place-items: center; padding: 48px 24px 24px; text-align: center; }
|
||||
.chat-welcome.show { display: grid; }
|
||||
.chat-welcome h1 { margin: 0; font-size: 26px; font-weight: 650; }
|
||||
.chat-welcome h1 em { font-style: normal; color: var(--brand); }
|
||||
.chat-welcome p { margin: 10px 0 0; color: var(--muted); font-size: 13px; max-width: 520px; }
|
||||
.quick-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; max-width: 640px; }
|
||||
.quick-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; font-size: 12px; font-weight: 650; color: var(--text); }
|
||||
.quick-chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
|
||||
.msg-list { max-width: 920px; margin: 0 auto; display: grid; gap: 14px; }
|
||||
.msg { display: grid; gap: 8px; max-width: 860px; }
|
||||
.msg.user { justify-items: end; margin-left: auto; }
|
||||
.msg.assistant { justify-items: start; }
|
||||
.bubble { padding: 12px 14px; border-radius: 14px; background: #fff; border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(23, 32, 51, 0.04); white-space: pre-line; line-height: 1.55; font-size: 13px; }
|
||||
.msg.user .bubble { background: var(--brand); color: #fff; border-color: transparent; }
|
||||
.msg-meta { font-size: 11px; color: var(--muted); }
|
||||
.progress-card, .result-card { width: min(640px, 100%); border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); overflow: hidden; }
|
||||
.progress-card .hd, .result-card .hd { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fbfdff; }
|
||||
.progress-card .hd strong, .result-card .hd h3 { margin: 0; font-size: 13px; }
|
||||
.result-card .hd { align-items: flex-start; }
|
||||
.result-card .hd p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
|
||||
.status { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
|
||||
.status.running { background: var(--info-soft); color: var(--info); }
|
||||
.status.done { background: var(--success-soft); color: var(--success); }
|
||||
.status.partial { background: var(--warning-soft); color: var(--warning); }
|
||||
.progress-card .bd, .result-card .bd { padding: 14px; display: grid; gap: 12px; }
|
||||
.bar-wrap { height: 8px; border-radius: 999px; background: #e8eef6; overflow: hidden; }
|
||||
.bar { height: 100%; width: 0; background: linear-gradient(90deg, #2f80d1, #56a3e8); transition: width 0.35s ease; }
|
||||
.counters { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
|
||||
.counter.skip .n { color: #475569; }
|
||||
.counter { border: 1px solid var(--line); border-radius: 10px; padding: 8px 6px; text-align: center; background: #fafcff; }
|
||||
.counter .n { font-size: 16px; font-weight: 750; }
|
||||
.counter .l { font-size: 11px; color: var(--muted); margin-top: 2px; }
|
||||
.counter.ok .n { color: var(--success); }
|
||||
.counter.fail .n { color: var(--danger); }
|
||||
.counter.miss .n { color: var(--warning); }
|
||||
.progress-sub { font-size: 12px; color: var(--muted); }
|
||||
.progress-actions { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.btn { height: 34px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 650; font-size: 12px; }
|
||||
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
|
||||
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
|
||||
.pill.ok { background: var(--success-soft); color: var(--success); }
|
||||
.pill.fail { background: var(--danger-soft); color: var(--danger); }
|
||||
.pill.miss { background: var(--warning-soft); color: var(--warning); }
|
||||
.pill.human { background: #f4f3ff; color: #5925dc; }
|
||||
.pill.cron { background: #eef2f7; color: #475569; }
|
||||
.pill.chat { background: var(--brand-soft); color: var(--brand); }
|
||||
.field-table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
||||
.field-table th, .field-table td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
|
||||
.field-table th { color: var(--muted); font-weight: 650; background: #fafcff; }
|
||||
.mat-list { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.mat-chip { font-size: 11px; font-weight: 650; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: #f8fafc; }
|
||||
.mat-chip.ok { border-color: #abefc6; background: var(--success-soft); color: var(--success); }
|
||||
.mat-chip.miss { border-color: #f7c948; background: var(--warning-soft); color: var(--warning); }
|
||||
.composer { padding: 10px 22px 16px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.96); }
|
||||
.composer-dock { max-width: 920px; margin: 0 auto; }
|
||||
.composer-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
|
||||
.composer-meta .hint { font-size: 12px; color: var(--muted); }
|
||||
.composer-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; border: 1px solid var(--line); border-radius: 18px; padding: 8px 10px; background: #fff; box-shadow: var(--shadow); }
|
||||
.composer-box textarea { border: 0; outline: none; resize: none; min-height: 44px; max-height: 120px; padding: 8px 6px; width: 100%; background: transparent; }
|
||||
.send-btn { height: 40px; min-width: 72px; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 700; }
|
||||
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }
|
||||
.page-shell { grid-template-columns: 1fr; padding: 20px 22px 32px; max-width: 1180px; margin: 0 auto; width: 100%; gap: 16px; align-content: start; }
|
||||
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
|
||||
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; }
|
||||
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
|
||||
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
|
||||
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
|
||||
.stat .n { font-size: 22px; font-weight: 750; }
|
||||
.stat .l { font-size: 12px; color: var(--muted); margin-top: 4px; }
|
||||
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
|
||||
.filters { display: flex; flex-wrap: wrap; gap: 6px; background: #eef2f7; padding: 4px; border-radius: 10px; }
|
||||
.filters button { border: 0; border-radius: 8px; padding: 7px 12px; background: transparent; color: var(--muted); font-weight: 650; font-size: 12px; }
|
||||
.filters button.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(23, 32, 51, 0.08); }
|
||||
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 4px 18px rgba(23, 32, 51, 0.04); }
|
||||
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
table.data th, table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
|
||||
table.data th { background: #fafcff; color: var(--muted); font-weight: 650; font-size: 12px; }
|
||||
table.data tr:last-child td { border-bottom: 0; }
|
||||
table.data tbody tr { cursor: pointer; }
|
||||
table.data tbody tr:hover { background: #f8fbff; }
|
||||
table.data tbody tr.active { background: var(--brand-soft); }
|
||||
.muted { color: var(--muted); font-size: 12px; }
|
||||
.detail-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; }
|
||||
.card-block { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
|
||||
.card-block h3 { margin: 0 0 10px; font-size: 14px; }
|
||||
.path-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px 14px; line-height: 1.6; overflow: auto; white-space: pre-wrap; }
|
||||
.folder-list { display: grid; gap: 8px; }
|
||||
.folder-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafcff; cursor: pointer; }
|
||||
.folder-item:hover, .folder-item.active { border-color: #c8dff8; background: var(--brand-soft); }
|
||||
.folder-item .name { font-weight: 700; font-size: 13px; }
|
||||
.folder-item .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
|
||||
.file-rows { display: grid; gap: 8px; }
|
||||
.file-row-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
|
||||
.file-row-item .fn { font-weight: 650; font-size: 13px; }
|
||||
.file-row-item .fs { font-size: 12px; color: var(--muted); margin-top: 2px; }
|
||||
.tbd-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--warning-soft); border: 1px solid #f7c948; color: var(--warning); font-size: 12px; line-height: 1.5; }
|
||||
.wecom-stage { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 24px; gap: 18px; justify-items: center; }
|
||||
.phone { width: 360px; border-radius: 28px; background: #111827; padding: 16px 14px 22px; box-shadow: var(--shadow); }
|
||||
.phone-bar { color: #94a3b8; font-size: 12px; text-align: center; margin-bottom: 14px; }
|
||||
.wecom-card { background: #fff; border-radius: 12px; overflow: hidden; color: var(--text); }
|
||||
.wecom-card .hd { padding: 14px 16px 8px; font-weight: 750; font-size: 15px; }
|
||||
.wecom-card .bd { padding: 0 16px 14px; color: #334155; font-size: 13px; line-height: 1.55; white-space: pre-line; }
|
||||
.wecom-card .ft { border-top: 1px solid #e2e8f0; padding: 12px 16px; color: var(--brand); font-weight: 700; font-size: 13px; cursor: pointer; }
|
||||
.wecom-side { width: min(420px, 100%); display: grid; gap: 10px; }
|
||||
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; min-width: 240px; max-width: 360px; padding: 12px 14px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: 0.2s ease; font-size: 13px; font-weight: 600; }
|
||||
.toast.show { opacity: 1; transform: translateY(0); }
|
||||
@media (max-width: 900px) {
|
||||
.chat-shell { grid-template-columns: 1fr; }
|
||||
.sidebar { display: none; }
|
||||
.stats, .counters { grid-template-columns: 1fr 1fr; }
|
||||
.detail-grid { grid-template-columns: 1fr; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="proto-bar">
|
||||
<div>
|
||||
<strong>立账凭证检核 Agent · 原型</strong>
|
||||
<span class="proto-meta">对话为主入口 · 日批为主 · 只查文件在不在 · 不回写 ERP</span>
|
||||
</div>
|
||||
<div class="view-tabs" id="topTabs">
|
||||
<button type="button" data-view="chat" class="active">会话</button>
|
||||
<button type="button" data-view="records">检核记录</button>
|
||||
<button type="button" data-view="share">共享盘材料</button>
|
||||
<button type="button" data-view="wecom">缺资料通知</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="view chat-shell active" id="view-chat">
|
||||
<aside class="sidebar">
|
||||
<div class="agent-name">
|
||||
<div class="avatar">凭</div>
|
||||
<div>
|
||||
<div>立账凭证检核</div>
|
||||
<div class="muted">每日 09:00 自动检核</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="new-chat" id="btnNewChat">新建会话</button>
|
||||
<div>
|
||||
<p class="side-label">最近会话</p>
|
||||
<div class="hist-item active"><div class="t">今日日批检核</div><div class="s">定时 · 09:00 · 含 2 票缺资料</div></div>
|
||||
<div class="hist-item"><div class="t">加急:INV-20260802018</div><div class="s">会话手动 · 昨日</div></div>
|
||||
<div class="hist-item"><div class="t">查询缺资料发票</div><div class="s">会话 · 上周</div></div>
|
||||
</div>
|
||||
<div class="hint-box">审计找资料:只查文件在不在。已齐全且材料未变更 → 跳过;缺资料/新票/目录有变更 → 再扫。ERP 只取发票清单。</div>
|
||||
</aside>
|
||||
<div class="chat-main">
|
||||
<div class="chat-scroll" id="chatScroll">
|
||||
<div class="chat-welcome show" id="chatWelcome">
|
||||
<div>
|
||||
<h1>立账凭证<em>检核助手</em></h1>
|
||||
<p>每日按当月发票号扫描共享盘:只看必检材料在不在,不核对金额/供应商。已齐全且材料未变更则跳过。也可会话手动触发。</p>
|
||||
<div class="quick-row" id="quickRow">
|
||||
<button type="button" class="quick-chip" data-q="执行今日立账凭证检核">执行今日立账凭证检核(增量)</button>
|
||||
<button type="button" class="quick-chip" data-q="重新检核当月全部">重新检核当月全部</button>
|
||||
<button type="button" class="quick-chip" data-q="检核发票 INV-20260803001">检核发票 INV-20260803001</button>
|
||||
<button type="button" class="quick-chip" data-q="查询最新检核结果">查询最新检核结果</button>
|
||||
<button type="button" class="quick-chip" data-q="查询缺资料发票">查询缺资料发票</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="msg-list" id="msgList"></div>
|
||||
</div>
|
||||
<div class="composer">
|
||||
<div class="composer-dock">
|
||||
<div class="composer-meta">
|
||||
<span class="pill cron">绑定日批任务</span>
|
||||
<span class="hint">只查材料存在性 · 不做字段吻合 · 单票状态落库 · 必检清单 TBD</span>
|
||||
</div>
|
||||
<div class="composer-box">
|
||||
<textarea id="composerInput" rows="2" placeholder="例如:执行今日立账凭证检核 / 重新检核当月全部 / 检核发票 INV-xxx"></textarea>
|
||||
<button type="button" class="send-btn" id="btnSend">发送</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="view page-shell" id="view-records">
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>检核记录</h1>
|
||||
<p>定时与会话触发统一落库;日批默认增量(齐全且材料未变更计入跳过);可按缺资料筛选</p>
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;flex-wrap:wrap;">
|
||||
<button type="button" class="btn" id="btnGotoWecom">查看缺资料通知</button>
|
||||
<button type="button" class="btn primary" id="btnMockExport">下载批次 Excel(示意)</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stats" id="recordStats"></div>
|
||||
<div class="toolbar">
|
||||
<div class="filters" id="recordFilters">
|
||||
<button type="button" data-filter="all" class="active">全部批次</button>
|
||||
<button type="button" data-filter="cron">定时</button>
|
||||
<button type="button" data-filter="chat">会话</button>
|
||||
<button type="button" data-filter="missing">含缺资料</button>
|
||||
</div>
|
||||
<span class="muted" id="recordCount">共 0 批</span>
|
||||
</div>
|
||||
<div class="detail-grid">
|
||||
<div class="panel">
|
||||
<table class="data">
|
||||
<thead><tr><th>批次</th><th>触发</th><th>时间</th><th>统计</th><th>状态</th></tr></thead>
|
||||
<tbody id="batchTable"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-block" id="batchDetail"><h3>批次明细</h3><p class="muted">选择左侧批次查看按发票号结果</p></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="view page-shell" id="view-share">
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<h1>共享盘材料</h1>
|
||||
<p>每个发票号一个子目录;Agent 只判断必检材料文件是否存在(不做字段核对)</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="path-box">\\192.168.x.x\立账凭证\{发票号}\
|
||||
├─ 核价单.*
|
||||
├─ 采购单.*
|
||||
└─ 发票扫描件.* ← 第三项是否必检:TBD</div>
|
||||
<div class="detail-grid">
|
||||
<div class="card-block">
|
||||
<h3>发票文件夹</h3>
|
||||
<div class="folder-list" id="folderList"></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<h3 id="folderTitle">材料预览</h3>
|
||||
<div class="file-rows" id="fileRows"></div>
|
||||
<div class="tbd-note">必检材料清单尚未最终确认。当前原型默认:核价单、采购单为必检;发票扫描件暂标「待确认」。</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<h3>ERP 用途(占位)</h3>
|
||||
<p class="muted" style="margin:0 0 10px;">ERP 只提供当月立账凭证的<strong>发票号清单</strong>,用于定位共享盘子目录。不核对金额、供应商等字段是否吻合。</p>
|
||||
<table class="data">
|
||||
<thead><tr><th>示意字段</th><th>用途</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>发票号</td><td>当月清单主键 → 共享盘文件夹名</td></tr>
|
||||
<tr><td>会计月(TBD)</td><td>限定「当月」集合</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="view" id="view-wecom">
|
||||
<div class="wecom-stage">
|
||||
<div class="phone">
|
||||
<div class="phone-bar">企业微信 · 应用消息</div>
|
||||
<div class="wecom-card">
|
||||
<div class="hd" id="wecomTitle">立账凭证缺资料提醒</div>
|
||||
<div class="bd" id="wecomBody"></div>
|
||||
<div class="ft" id="wecomJump">查看检核记录</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wecom-side">
|
||||
<div class="card-block">
|
||||
<h3>通知规则(示意)</h3>
|
||||
<p class="muted" style="margin:0;line-height:1.6;">
|
||||
• 日批或会话检核发现「缺资料」时推送<br>
|
||||
• 收件人:排程负责人 / 可配置抄送(TBD)<br>
|
||||
• 卡片跳转:HXOPS 检核记录对应批次<br>
|
||||
• 同一发票同日重复缺资料:合并或节流(TBD)
|
||||
</p>
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;flex-wrap:wrap;">
|
||||
<button type="button" class="btn primary" id="btnSimulateNotify">模拟推送下一条</button>
|
||||
<button type="button" class="btn" id="btnOpenRecordsFromWecom">打开检核记录</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="toast" id="toast"></div>
|
||||
<script>
|
||||
/**
|
||||
* 立账凭证检核 HTML 原型交互(演示数据,不接真实 API)。
|
||||
*/
|
||||
(function () {
|
||||
const REQUIRED_MATERIALS = [
|
||||
{ key: "pricing", label: "核价单", required: true },
|
||||
{ key: "po", label: "采购单", required: true },
|
||||
{ key: "invoice_scan", label: "发票扫描件", required: false, tbd: true },
|
||||
];
|
||||
|
||||
const FOLDERS = [
|
||||
{
|
||||
invoiceNo: "INV-20260803001",
|
||||
vendor: "煜英精密",
|
||||
files: [
|
||||
{ key: "pricing", name: "核价单_煜英_0803.pdf", present: true },
|
||||
{ key: "po", name: "采购单_PO26080301.pdf", present: true },
|
||||
{ key: "invoice_scan", name: "发票扫描件.jpg", present: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
invoiceNo: "INV-20260803012",
|
||||
vendor: "华信材料",
|
||||
files: [
|
||||
{ key: "pricing", name: "", present: false },
|
||||
{ key: "po", name: "采购单_PO26080312.pdf", present: true },
|
||||
{ key: "invoice_scan", name: "", present: false },
|
||||
],
|
||||
},
|
||||
{
|
||||
invoiceNo: "INV-20260803018",
|
||||
vendor: "南通机电",
|
||||
files: [
|
||||
{ key: "pricing", name: "核价单.pdf", present: true },
|
||||
{ key: "po", name: "采购单.pdf", present: true },
|
||||
{ key: "invoice_scan", name: "发票.pdf", present: true },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const BATCHES = [
|
||||
{
|
||||
id: "AVR-20260803-001",
|
||||
trigger: "cron",
|
||||
time: "2026-08-03 09:00",
|
||||
status: "done",
|
||||
stats: { total: 28, todo: 6, skip: 22, ok: 3, human: 0, missing: 2, human: 0 },
|
||||
rows: [
|
||||
{ invoiceNo: "INV-20260803001", conclusion: "ok", note: "必检材料齐全(今日增量跳过)" },
|
||||
{ invoiceNo: "INV-20260803012", conclusion: "missing", note: "缺核价单;发票扫描件待确认" },
|
||||
{ invoiceNo: "INV-20260803015", conclusion: "human", note: "目录内文件命名无法识别是否为核价单" },
|
||||
{ invoiceNo: "INV-20260803018", conclusion: "ok", note: "必检材料齐全(今日增量可跳过)" },
|
||||
{ invoiceNo: "INV-20260803021", conclusion: "missing", note: "共享盘无此发票号文件夹" },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "AVR-20260802-003",
|
||||
trigger: "chat",
|
||||
time: "2026-08-02 15:22",
|
||||
status: "done",
|
||||
stats: { total: 1, todo: 1, skip: 0, ok: 1, human: 0, missing: 0, human: 0 },
|
||||
rows: [{ invoiceNo: "INV-20260802018", conclusion: "ok", note: "会话加急单票检核通过" }],
|
||||
},
|
||||
{
|
||||
id: "AVR-20260802-001",
|
||||
trigger: "cron",
|
||||
time: "2026-08-02 09:00",
|
||||
status: "done",
|
||||
stats: { total: 9, todo: 9, skip: 0, ok: 7, fail: 0, missing: 2, human: 0 },
|
||||
rows: [
|
||||
{ invoiceNo: "INV-20260802003", conclusion: "missing", note: "缺采购单" },
|
||||
{ invoiceNo: "INV-20260802007", conclusion: "missing", note: "共享盘无发票号文件夹" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const MISSING_NOTIFY_QUEUE = [
|
||||
{
|
||||
title: "立账凭证缺资料提醒",
|
||||
body: "批次:AVR-20260803-001\n发票号:INV-20260803012\n供应商:华信材料\n缺失材料:核价单\n共享路径:\\\\share\\立账凭证\\INV-20260803012\\\n请尽快补齐后可回复「检核发票 INV-20260803012」重跑。",
|
||||
},
|
||||
{
|
||||
title: "立账凭证缺资料提醒",
|
||||
body: "批次:AVR-20260803-001\n发票号:INV-20260803021\n缺失材料:共享盘无发票号文件夹\n共享路径:\\\\share\\立账凭证\\INV-20260803021\\\n请创建目录并放入核价单、采购单后重检。",
|
||||
},
|
||||
];
|
||||
|
||||
let selectedBatchId = BATCHES[0].id;
|
||||
let selectedFolder = FOLDERS[0].invoiceNo;
|
||||
let notifyIndex = 0;
|
||||
let running = false;
|
||||
let progressTimer = null;
|
||||
|
||||
function $(id) { return document.getElementById(id); }
|
||||
|
||||
function toast(text) {
|
||||
const el = $("toast");
|
||||
el.textContent = text;
|
||||
el.classList.add("show");
|
||||
clearTimeout(toast._t);
|
||||
toast._t = setTimeout(function () { el.classList.remove("show"); }, 2200);
|
||||
}
|
||||
|
||||
function switchView(name) {
|
||||
document.querySelectorAll(".view").forEach(function (v) { v.classList.remove("active"); });
|
||||
document.querySelectorAll("#topTabs button").forEach(function (b) {
|
||||
b.classList.toggle("active", b.dataset.view === name);
|
||||
});
|
||||
const view = $("view-" + name);
|
||||
if (view) view.classList.add("active");
|
||||
}
|
||||
|
||||
function conclusionPill(c) {
|
||||
const map = {
|
||||
ok: ["齐全", "ok"],
|
||||
missing: ["缺资料", "miss"],
|
||||
human: ["人工判定", "human"],
|
||||
};
|
||||
const pair = map[c] || ["未知", "human"];
|
||||
return '<span class="pill ' + pair[1] + '">' + pair[0] + "</span>";
|
||||
}
|
||||
|
||||
function triggerPill(t) {
|
||||
return t === "cron"
|
||||
? '<span class="pill cron">定时</span>'
|
||||
: '<span class="pill chat">会话</span>';
|
||||
}
|
||||
|
||||
function hideWelcome() { $("chatWelcome").classList.remove("show"); }
|
||||
function scrollChat() {
|
||||
const sc = $("chatScroll");
|
||||
sc.scrollTop = sc.scrollHeight;
|
||||
}
|
||||
|
||||
function appendUser(text) {
|
||||
hideWelcome();
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = "msg user";
|
||||
wrap.innerHTML = '<div class="bubble"></div><div class="msg-meta">我 · 刚刚</div>';
|
||||
wrap.querySelector(".bubble").textContent = text;
|
||||
$("msgList").appendChild(wrap);
|
||||
scrollChat();
|
||||
}
|
||||
|
||||
function appendAssistant(html) {
|
||||
hideWelcome();
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = "msg assistant";
|
||||
wrap.innerHTML = html + '<div class="msg-meta">立账凭证检核 · 刚刚</div>';
|
||||
$("msgList").appendChild(wrap);
|
||||
scrollChat();
|
||||
return wrap;
|
||||
}
|
||||
|
||||
function buildProgressCard(runId) {
|
||||
return (
|
||||
'<div class="progress-card" data-run="' + runId + '">' +
|
||||
'<div class="hd"><strong>检核批次 ' + runId + '</strong><span class="status running">进行中</span></div>' +
|
||||
'<div class="bd"><div class="bar-wrap"><div class="bar" style="width:8%"></div></div>' +
|
||||
'<div class="counters">' +
|
||||
'<div class="counter"><div class="n" data-k="total">28</div><div class="l">当月总数</div></div>' +
|
||||
'<div class="counter"><div class="n" data-k="todo">0</div><div class="l">本次待检</div></div>' +
|
||||
'<div class="counter skip"><div class="n" data-k="skip">0</div><div class="l">跳过</div></div>' +
|
||||
'<div class="counter ok"><div class="n" data-k="ok">0</div><div class="l">齐全</div></div>' +
|
||||
'<div class="counter miss"><div class="n" data-k="missing">0</div><div class="l">缺资料</div></div>' +
|
||||
'<div class="counter"><div class="n" data-k="human">0</div><div class="l">人工判定</div></div>' +
|
||||
'</div><div class="progress-sub" data-step>阶段:拉取 ERP 当月立账凭证…</div>' +
|
||||
'<div class="progress-actions">' +
|
||||
'<button type="button" class="btn" data-act="records" disabled>查看记录</button>' +
|
||||
'<button type="button" class="btn" data-act="excel" disabled>下载 Excel</button>' +
|
||||
'<button type="button" class="btn" data-act="notify" disabled>查看缺资料通知</button>' +
|
||||
'</div></div></div>'
|
||||
);
|
||||
}
|
||||
|
||||
function buildResultCard() {
|
||||
return (
|
||||
'<div class="result-card"><div class="hd"><div><h3>INV-20260803012 · 华信材料</h3>' +
|
||||
'<p>共享盘:\\\\share\\立账凭证\\INV-20260803012\\ · 只查文件在不在</p></div>' + conclusionPill("missing") + "</div>" +
|
||||
'<div class="bd"><div><div class="muted" style="margin-bottom:6px;">必检材料是否存在(不做金额/供应商核对)</div><div class="mat-list">' +
|
||||
'<span class="mat-chip miss">核价单 · 缺失</span><span class="mat-chip ok">采购单 · 已找到</span>' +
|
||||
'<span class="mat-chip miss">发票扫描件 · 缺失(TBD)</span></div></div>' +
|
||||
'<p class="muted" style="margin:0;">审计用途:快速定位缺件;补齐后可再扫该票或等日批增量。</p>' +
|
||||
'<div class="progress-actions">' +
|
||||
'<button type="button" class="btn primary" data-act="notify">已发企微补件通知</button>' +
|
||||
'<button type="button" class="btn" data-act="records">打开检核记录</button></div></div></div>'
|
||||
);
|
||||
}
|
||||
|
||||
function simulateRun(mode, invoiceHint) {
|
||||
if (running) { toast("检核进行中,请先查看当前进度"); return; }
|
||||
running = true;
|
||||
$("btnSend").disabled = true;
|
||||
const runId = mode === "single" ? "AVR-MANUAL-" + Date.now().toString().slice(-6) : "AVR-20260803-RUN";
|
||||
let intro;
|
||||
if (mode === "single") {
|
||||
intro = ["已接收单票检核请求:" + (invoiceHint || "指定发票") + "。", "强制扫描该票(忽略跳过),正在检查共享盘必检材料是否存在…"].join(String.fromCharCode(10));
|
||||
} else if (mode === "force") {
|
||||
intro = ["已启动「重新检核当月全部」(强制模式)。", "将忽略历史齐全状态,对当月全部发票重新扫描材料是否存在…"].join(String.fromCharCode(10));
|
||||
} else {
|
||||
intro = ["已启动今日立账凭证检核(增量模式,与日批同一引擎)。", "拉取 ERP 当月集合后,已齐全且材料未变更的票将跳过…"].join(String.fromCharCode(10));
|
||||
}
|
||||
appendAssistant('<div class="bubble">' + intro + "</div>");
|
||||
const cardWrap = appendAssistant(buildProgressCard(runId));
|
||||
const card = cardWrap.querySelector(".progress-card");
|
||||
let steps;
|
||||
if (mode === "single") {
|
||||
card.querySelector('[data-k="total"]').textContent = "1";
|
||||
card.querySelector('[data-k="todo"]').textContent = "1";
|
||||
card.querySelector('[data-k="skip"]').textContent = "0";
|
||||
steps = [
|
||||
{ pct: 35, todo: 1, skip: 0, ok: 0, human: 0, missing: 0, text: "阶段:定位共享盘 · " + (invoiceHint || "INV-xxx") },
|
||||
{ pct: 70, todo: 1, skip: 0, ok: 0, human: 0, missing: 0, text: "阶段:检查必检材料是否存在" },
|
||||
{ pct: 100, todo: 1, skip: 0, ok: 0, human: 0, missing: 1, text: "阶段:完成 · 结论:缺资料(已通知)" },
|
||||
];
|
||||
} else if (mode === "force") {
|
||||
card.querySelector('[data-k="total"]').textContent = "28";
|
||||
steps = [
|
||||
{ pct: 20, todo: 28, skip: 0, ok: 4, human: 0, missing: 1, text: "阶段:强制重检 · 不跳过历史合格票" },
|
||||
{ pct: 55, todo: 28, skip: 0, ok: 14, human: 0, missing: 2, text: "阶段:材料齐全度进行中…" },
|
||||
{ pct: 100, todo: 28, skip: 0, ok: 24, human: 0, missing: 2, text: "阶段:完成 · 当月 28 票全部重检(跳过 0)" },
|
||||
];
|
||||
} else {
|
||||
card.querySelector('[data-k="total"]').textContent = "28";
|
||||
steps = [
|
||||
{ pct: 15, todo: 6, skip: 22, ok: 0, human: 0, missing: 0, text: "阶段:状态比对 · 当月 28 票,跳过已齐全未变更 22 票" },
|
||||
{ pct: 45, todo: 6, skip: 22, ok: 2, human: 0, missing: 1, text: "阶段:检核待办票 · 当前 INV-20260803012(缺核价单)" },
|
||||
{ pct: 75, todo: 6, skip: 22, ok: 3, human: 0, missing: 2, text: "阶段:检核待办票 · 当前 INV-20260803015" },
|
||||
{ pct: 100, todo: 6, skip: 22, ok: 3, human: 0, missing: 2, text: "阶段:完成 · 新检 6 / 跳过 22 · 缺资料已推送企微" },
|
||||
];
|
||||
}
|
||||
let i = 0;
|
||||
clearInterval(progressTimer);
|
||||
progressTimer = setInterval(function () {
|
||||
const s = steps[i++];
|
||||
if (!s) return;
|
||||
card.querySelector(".bar").style.width = s.pct + "%";
|
||||
card.querySelector('[data-k="todo"]').textContent = String(s.todo);
|
||||
card.querySelector('[data-k="skip"]').textContent = String(s.skip);
|
||||
card.querySelector('[data-k="ok"]').textContent = String(s.ok);
|
||||
card.querySelector('[data-k="human"]').textContent = String(s.human);
|
||||
card.querySelector('[data-k="missing"]').textContent = String(s.missing);
|
||||
card.querySelector("[data-step]").textContent = s.text;
|
||||
if (s.pct >= 100) {
|
||||
clearInterval(progressTimer);
|
||||
const st = card.querySelector(".status");
|
||||
st.textContent = s.missing > 0 ? "完成(含缺资料)" : "已完成";
|
||||
st.className = "status " + (s.missing > 0 ? "partial" : "done");
|
||||
card.querySelectorAll("[data-act]").forEach(function (b) { b.disabled = false; });
|
||||
running = false;
|
||||
$("btnSend").disabled = false;
|
||||
const summary = [
|
||||
"检核完成。当月 " + card.querySelector('[data-k="total"]').textContent +
|
||||
" 票 · 本次待检 " + s.todo + " · 跳过 " + s.skip +
|
||||
" · 齐全 " + s.ok + " · 缺资料 " + s.missing + " · 人工判定 " + s.human + "。",
|
||||
(s.skip > 0 ? "已齐全且材料未变更的票未重复扫描。" : "本次为强制全量,未跳过。")
|
||||
].concat(s.missing > 0 ? ["缺资料发票已发送企微通知。"] : []).join(String.fromCharCode(10));
|
||||
appendAssistant('<div class="bubble">' + summary + "</div>" + ((mode === "single" || s.missing > 0) ? buildResultCard() : ""));
|
||||
renderWecom(0);
|
||||
}
|
||||
}, 700);
|
||||
}
|
||||
|
||||
function handleQuery(text) {
|
||||
const t = text.trim();
|
||||
if (!t) return;
|
||||
appendUser(t);
|
||||
if (/缺资料/.test(t)) {
|
||||
appendAssistant(
|
||||
'<div class="bubble">最近一批(AVR-20260803-001)缺资料发票:\n\n• INV-20260803012 — 缺核价单\n• INV-20260803021 — 共享盘无文件夹\n\n已对企业微信推送补件提醒。</div>' +
|
||||
'<div class="progress-actions" style="margin-top:8px;">' +
|
||||
'<button type="button" class="btn primary" data-act="records">打开检核记录</button>' +
|
||||
'<button type="button" class="btn" data-act="notify">查看企微卡片</button></div>'
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (/最新|结果|记录/.test(t) && !/执行|检核发票/.test(t)) {
|
||||
const b = BATCHES[0];
|
||||
appendAssistant(
|
||||
'<div class="bubble">最新批次 ' + b.id + "(定时 · " + b.time + ")\n总数 " + b.stats.total +
|
||||
" · 跳过 " + (b.stats.skip || 0) + " · 齐全 " + b.stats.ok + " · 缺资料 " + b.stats.missing + "\n\n可下载 Excel,或到「检核记录」查看按发票号明细。</div>" +
|
||||
'<div class="progress-actions" style="margin-top:8px;">' +
|
||||
'<button type="button" class="btn primary" data-act="records">打开检核记录</button>' +
|
||||
'<button type="button" class="btn" data-act="excel">下载 Excel(示意)</button></div>'
|
||||
);
|
||||
return;
|
||||
}
|
||||
const m = t.match(/INV-[\w-]+/i);
|
||||
if (/检核发票|单票/.test(t) || (m && /检核/.test(t))) {
|
||||
simulateRun("single", m ? m[0].toUpperCase() : "INV-20260803012");
|
||||
return;
|
||||
}
|
||||
if (/重新检核当月|强制重检|全量检核/.test(t)) {
|
||||
simulateRun("force");
|
||||
return;
|
||||
}
|
||||
if (/执行|今日|日批|开始检核|立账凭证检核/.test(t)) {
|
||||
simulateRun("batch");
|
||||
return;
|
||||
}
|
||||
appendAssistant(
|
||||
'<div class="bubble">我可以帮你:\n1)执行今日立账凭证检核(增量:跳过已齐全且材料未变更)\n2)重新检核当月全部(强制重扫)\n3)检核指定发票号\n4)查询最新结果 / 缺资料发票\n\n只查文件在不在;不做金额/供应商核对。</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function renderRecordStats() {
|
||||
const agg = BATCHES.reduce(function (a, b) {
|
||||
a.batches += 1; a.total += b.stats.total; a.missing += b.stats.missing; a.fail += b.stats.fail;
|
||||
a.skip += (b.stats.skip || 0); return a;
|
||||
}, { batches: 0, total: 0, missing: 0, fail: 0, skip: 0 });
|
||||
$("recordStats").innerHTML =
|
||||
'<div class="stat"><div class="n">' + agg.batches + '</div><div class="l">历史批次</div></div>' +
|
||||
'<div class="stat"><div class="n">' + agg.total + '</div><div class="l">批次覆盖票数</div></div>' +
|
||||
'<div class="stat"><div class="n" style="color:#475569">' + agg.skip + '</div><div class="l">累计跳过</div></div>' +
|
||||
'<div class="stat"><div class="n" style="color:var(--warning)">' + agg.missing + '</div><div class="l">缺资料票数</div></div>';
|
||||
}
|
||||
|
||||
function filteredBatches() {
|
||||
const active = document.querySelector("#recordFilters button.active");
|
||||
const f = active ? active.dataset.filter : "all";
|
||||
return BATCHES.filter(function (b) {
|
||||
if (f === "cron") return b.trigger === "cron";
|
||||
if (f === "chat") return b.trigger === "chat";
|
||||
if (f === "missing") return b.stats.missing > 0;
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function renderBatchDetail() {
|
||||
const b = BATCHES.find(function (x) { return x.id === selectedBatchId; });
|
||||
const box = $("batchDetail");
|
||||
if (!b) { box.innerHTML = "<h3>批次明细</h3><p class=\"muted\">无数据</p>"; return; }
|
||||
box.innerHTML =
|
||||
'<div style="display:flex;justify-content:space-between;gap:10px;align-items:flex-start;flex-wrap:wrap;">' +
|
||||
"<div><h3 style=\"margin:0;\">" + b.id + "</h3><p class=\"muted\" style=\"margin:6px 0 0;\">" +
|
||||
b.time + " · " + (b.trigger === "cron" ? "定时日批" : "会话手动") + "</p></div>" + triggerPill(b.trigger) + "</div>" +
|
||||
'<table class="data" style="margin-top:12px;"><thead><tr><th>发票号</th><th>结论</th><th>说明</th></tr></thead><tbody>' +
|
||||
b.rows.map(function (r) {
|
||||
return "<tr><td><strong>" + r.invoiceNo + "</strong></td><td>" + conclusionPill(r.conclusion) +
|
||||
'</td><td class="muted">' + r.note + "</td></tr>";
|
||||
}).join("") +
|
||||
'</tbody></table><div class="progress-actions" style="margin-top:12px;">' +
|
||||
'<button type="button" class="btn primary" id="btnDetailExcel">下载本批 Excel</button>' +
|
||||
(b.stats.missing > 0 ? '<button type="button" class="btn" id="btnDetailNotify">缺资料通知</button>' : "") +
|
||||
"</div>";
|
||||
const ex = $("btnDetailExcel");
|
||||
if (ex) ex.onclick = function () { toast("原型示意:将下载 " + b.id + ".xlsx"); };
|
||||
const nt = $("btnDetailNotify");
|
||||
if (nt) nt.onclick = function () { renderWecom(0); switchView("wecom"); };
|
||||
}
|
||||
|
||||
function renderBatches() {
|
||||
const list = filteredBatches();
|
||||
$("recordCount").textContent = "共 " + list.length + " 批";
|
||||
$("batchTable").innerHTML = list.map(function (b) {
|
||||
return '<tr data-id="' + b.id + '" class="' + (b.id === selectedBatchId ? "active" : "") + '">' +
|
||||
"<td><strong>" + b.id + "</strong></td><td>" + triggerPill(b.trigger) + "</td><td>" + b.time +
|
||||
'</td><td class="muted">合' + b.stats.ok + " / 不" + b.stats.fail + " / 缺" + b.stats.missing +
|
||||
'</td><td><span class="pill ok">完成</span></td></tr>';
|
||||
}).join("");
|
||||
if (!list.find(function (b) { return b.id === selectedBatchId; }) && list[0]) selectedBatchId = list[0].id;
|
||||
renderBatchDetail();
|
||||
}
|
||||
|
||||
function renderFiles() {
|
||||
const f = FOLDERS.find(function (x) { return x.invoiceNo === selectedFolder; }) || FOLDERS[0];
|
||||
$("folderTitle").textContent = "材料预览 · " + f.invoiceNo;
|
||||
$("fileRows").innerHTML = REQUIRED_MATERIALS.map(function (m) {
|
||||
const file = f.files.find(function (x) { return x.key === m.key; });
|
||||
const present = file && file.present;
|
||||
const name = present ? file.name : "(未找到)";
|
||||
const tag = m.tbd ? '<span class="pill human">待确认是否必检</span>'
|
||||
: present ? '<span class="pill ok">已找到</span>' : '<span class="pill miss">缺失</span>';
|
||||
return '<div class="file-row-item"><div><div class="fn">' + m.label + (m.required ? " · 必检" : "") +
|
||||
'</div><div class="fs">' + name + "</div></div>" + tag + "</div>";
|
||||
}).join("");
|
||||
}
|
||||
|
||||
function renderFolders() {
|
||||
$("folderList").innerHTML = FOLDERS.map(function (f) {
|
||||
const missing = f.files.filter(function (x) {
|
||||
return !x.present && REQUIRED_MATERIALS.find(function (m) { return m.key === x.key && m.required; });
|
||||
});
|
||||
const label = missing.length ? "缺 " + missing.length + " 项必检" : "必检齐全";
|
||||
return '<div class="folder-item ' + (f.invoiceNo === selectedFolder ? "active" : "") +
|
||||
'" data-inv="' + f.invoiceNo + '"><div><div class="name">' + f.invoiceNo +
|
||||
'</div><div class="sub">' + f.vendor + "</div></div>" +
|
||||
(missing.length ? '<span class="pill miss">' + label + "</span>" : '<span class="pill ok">' + label + "</span>") +
|
||||
"</div>";
|
||||
}).join("");
|
||||
renderFiles();
|
||||
}
|
||||
|
||||
function renderWecom(index) {
|
||||
notifyIndex = index % MISSING_NOTIFY_QUEUE.length;
|
||||
const item = MISSING_NOTIFY_QUEUE[notifyIndex];
|
||||
$("wecomTitle").textContent = item.title;
|
||||
$("wecomBody").textContent = item.body;
|
||||
}
|
||||
|
||||
document.querySelectorAll("#topTabs button").forEach(function (btn) {
|
||||
btn.addEventListener("click", function () { switchView(btn.dataset.view); });
|
||||
});
|
||||
$("quickRow").addEventListener("click", function (e) {
|
||||
const chip = e.target.closest("[data-q]");
|
||||
if (!chip) return;
|
||||
$("composerInput").value = chip.dataset.q;
|
||||
handleQuery(chip.dataset.q);
|
||||
});
|
||||
$("btnSend").addEventListener("click", function () {
|
||||
const v = $("composerInput").value;
|
||||
$("composerInput").value = "";
|
||||
handleQuery(v);
|
||||
});
|
||||
$("composerInput").addEventListener("keydown", function (e) {
|
||||
if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); $("btnSend").click(); }
|
||||
});
|
||||
$("btnNewChat").addEventListener("click", function () {
|
||||
if (running) { toast("检核进行中,暂不新建"); return; }
|
||||
$("msgList").innerHTML = "";
|
||||
$("chatWelcome").classList.add("show");
|
||||
toast("已新建会话");
|
||||
});
|
||||
document.body.addEventListener("click", function (e) {
|
||||
const act = e.target.closest("[data-act]");
|
||||
if (!act) return;
|
||||
const a = act.dataset.act;
|
||||
if (a === "records") switchView("records");
|
||||
if (a === "notify") { renderWecom(0); switchView("wecom"); }
|
||||
if (a === "excel") toast("原型示意:下载检核报告 Excel");
|
||||
});
|
||||
$("recordFilters").addEventListener("click", function (e) {
|
||||
const btn = e.target.closest("button[data-filter]");
|
||||
if (!btn) return;
|
||||
$("recordFilters").querySelectorAll("button").forEach(function (b) { b.classList.remove("active"); });
|
||||
btn.classList.add("active");
|
||||
renderBatches();
|
||||
});
|
||||
$("batchTable").addEventListener("click", function (e) {
|
||||
const tr = e.target.closest("tr[data-id]");
|
||||
if (!tr) return;
|
||||
selectedBatchId = tr.dataset.id;
|
||||
renderBatches();
|
||||
});
|
||||
$("folderList").addEventListener("click", function (e) {
|
||||
const item = e.target.closest("[data-inv]");
|
||||
if (!item) return;
|
||||
selectedFolder = item.dataset.inv;
|
||||
renderFolders();
|
||||
});
|
||||
$("btnGotoWecom").addEventListener("click", function () { switchView("wecom"); });
|
||||
$("btnMockExport").addEventListener("click", function () { toast("原型示意:导出当前筛选批次 Excel"); });
|
||||
$("btnSimulateNotify").addEventListener("click", function () {
|
||||
renderWecom(notifyIndex + 1);
|
||||
toast("已切换到下一条缺资料通知");
|
||||
});
|
||||
$("btnOpenRecordsFromWecom").addEventListener("click", function () { switchView("records"); });
|
||||
$("wecomJump").addEventListener("click", function () {
|
||||
selectedBatchId = "AVR-20260803-001";
|
||||
renderBatches();
|
||||
switchView("records");
|
||||
toast("已跳转检核记录(示意)");
|
||||
});
|
||||
|
||||
renderRecordStats();
|
||||
renderBatches();
|
||||
renderFolders();
|
||||
renderWecom(0);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,30 @@
|
||||
# 立账凭证检核 Agent · 原型说明
|
||||
|
||||
可交互单文件原型:
|
||||
|
||||
**[accounting-voucher-check-prototype.html](./accounting-voucher-check-prototype.html)**(浏览器直接打开)
|
||||
|
||||
## 视图
|
||||
|
||||
| Tab | 内容 |
|
||||
| --- | --- |
|
||||
| 会话 | 日批/文字触发;进度卡(当月总数 / 本次待检 / **跳过** / 齐全 / 缺资料);单票材料齐全度卡 |
|
||||
| 检核记录 | 定时/会话批次;含跳过统计;按发票号缺项明细 |
|
||||
| 共享盘材料 | `\\share\立账凭证\{发票号}\`;必检材料是否存在(清单 TBD) |
|
||||
| 缺资料通知 | 企微 textcard;跳转检核记录 |
|
||||
|
||||
## 演示话术
|
||||
|
||||
- `执行今日立账凭证检核` — **增量**:跳过已齐全且材料未变更
|
||||
- `重新检核当月全部` — **强制**:不跳过
|
||||
- `检核发票 INV-20260803001` — 单票强制
|
||||
- `查询最新检核结果` / `查询缺资料发票`
|
||||
|
||||
## 已确认边界
|
||||
|
||||
- 以企业 AI 工作台**对话为主入口**,**日批为主、会话可手动触发**
|
||||
- **只看文件在不在**,不做金额/供应商等字段吻合
|
||||
- ERP 仅取当月发票号清单
|
||||
- **HXOPS 落库**单票齐全状态;齐全且材料未变更 → 跳过
|
||||
- **不回写 ERP、不要求 ERP 终审**
|
||||
- 必检材料清单待业务确认
|
||||
Reference in new issue
Block a user