feat: 立账凭证文档更新

This commit is contained in:
sophie committed 2026-08-18 19:16:40 +08:00
1 parent 8cadc6cc17
commit 9722de1621
11 files changed
+535 -1500

No files matched your search

+1 -1
View File
@@ -183,7 +183,7 @@
- **实现状态**:一期 HXOPS 引擎/API/工作台已落地;日批 `0 6 * * *`;**Dify Chatflow 编排待完成**。
- **可靠性要求**:共享盘不可用、Oracle 查询失败或配置错误时,整批失败并告警,不得把整批票标记为缺资料;单票缺目录/缺文件才记为缺资料。
- **通知要求**:缺资料按固定接收人发送企业微信通知,并按同票同日节流。
- 技术规格见 [docs/features/accounting-voucher-check/technical.md](features/accounting-voucher-check/technical.md)。
- 技术规格见 [docs/features/accounting-voucher-check/demand.md](features/accounting-voucher-check/demand.md)。
### 3.x 货代发货通知库存源补充需求
+1 -1
View File
@@ -9,7 +9,7 @@
| [auth](auth/README.md) | Casdoor 登录与产品内平级服务无感登录 | [hxops-peer-service-sso.md](auth/hxops-peer-service-sso.md) |
| [shipping-notice](shipping-notice/README.md) | 货代发货通知 Agent | [technical.md](shipping-notice/technical.md) · [原型](shipping-notice/shipping_notice_agent_prototype.md) |
| [file-check](file-check/README.md) | 文件检核(RoHS / MSDS 等) | [technical.md](file-check/technical.md) |
| [accounting-voucher-check](accounting-voucher-check/README.md) | 立账凭证资料存在性检核 Agent | [需求与规格](accounting-voucher-check/technical.md) · [技术设计](accounting-voucher-check/technical-design.md) · [原型](accounting-voucher-check/accounting-voucher-check-prototype.html) |
| [accounting-voucher-check](accounting-voucher-check/README.md) | 立账凭证资料检核 | [需求说明](accounting-voucher-check/demand.md) · [技术设计](accounting-voucher-check/technical-design.md) · [原型](accounting-voucher-check/accounting-voucher-check-prototype.html) |
| [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(模板比对 / 单份审核) | [用户操作手册](procurement-contract/用户操作手册.md) · [demand.md](procurement-contract/demand.md) · [comprehensive-review-technical.md](procurement-contract/comprehensive-review-technical.md) · [原型](procurement-contract/procurement-contract-review-prototype.html) |
| [contract-payment-plan](contract-payment-plan/) | 合同付款计划 / 预警 Agent | [方案 V3](contract-payment-plan/contract-payment-warning-proposal-v3.md) · [原型](contract-payment-plan/contract-payment-plan-workspace-prototype-v2.html) |
@@ -2,21 +2,20 @@
| 文档 | 读者 | 路径 |
| --- | --- | --- |
| **需求与规格手册** | 产品、业务、测试 | [technical.md](technical.md) |
| **需求说明** | 产品、业务、测试 | [demand.md](demand.md) |
| **历史需求与规格手册** | 研发、运维、测试 | [technical.md](technical.md)(旧版单共享盘方案,仅供历史实现参考) |
| **技术设计** | 研发、运维、测试 | [technical-design.md](technical-design.md) |
| **迁移与部署验收清单** | 研发、运维、测试 | [ops-checklist.md](ops-checklist.md) |
| **Dify Chatflow 编排草稿** | 研发、Dify | [dify-chatflow-draft.md](dify-chatflow-draft.md) |
| **查询 Tool OpenAPI** | Dify | 在线 `GET /api/accounting-voucher-check/tools/openapi.json`;静态 [../../openapi/accounting_voucher_check_tools_openapi.json](../../openapi/accounting_voucher_check_tools_openapi.json) |
| **交互原型** | 产品、业务、测试 | [accounting-voucher-check-prototype.html](accounting-voucher-check-prototype.html) |
| **交互原型** | 产品、业务、测试 | [accounting-voucher-check-prototype.html](accounting-voucher-check-prototype.html)(Profile 驱动、多来源、归档) |
| **原型速览** | 产品、测试 | [accounting-voucher-check-prototype.md](accounting-voucher-check-prototype.md) |
**定位**:以企业 AI 工作台**对话为主入口**,**日批为主、会话可手动触发**。
**要解决的问题**:审计/复核时按发票号**快速确认共享盘配套资料在不在**(核价单、采购单等)。
**检核内容**:只做必检材料**存在性 / 齐全性**;**不核对**金额、供应商等与 ERP 是否吻合。ERP **仅用于**取当月发票号清单。
**其它**:单票状态落 **HXOPS 库**(齐全且材料未变更可跳过);缺资料推企微 textcard;**不回写 ERP、不要求 ERP 终审**。
**定位**:以业务方 Profile 驱动的批量资料检核;每周增量处理上一个自然月,按 `invoice` 集中归档。
**要解决的问题**:不同业务方从 ERP、OA、固定目录等来源获取不同必检资料,统一检核、归档、汇总缺件并通知。
**检核内容**:只做必检文件的获取、存在性和归档结果;不做文件内容解析或金额、供应商等字段一致性核对。
**结果输出**:每批生成 Excel,区分缺件文件总数和缺件 `invoice` 数,提供按文件类型、按 `invoice` 的汇总和单文件明细;同一 `invoice` 的多个缺件合并为一条企业微信通知。
**实现规格(technical Part2)**:共享盘默认目录 `vouche/{YYYY}/{MM}/{invoice_no}/`,目录模板可配置;日批按 `apa09` 取**当前自然月发票清单**,仅处理 HXJM 套账,再按可配置文件名检查文件是否存在。文件内容不读取、不使用 LLM;共享盘不可用时整批失败并告警。ERP 已可连;凭据仅 env。
**状态**:一期后端/工作台已落地实现;默认必检文件暂定为「核价单.pdf」和「采购单.pdf」,文件名仍由配置维护。日批预置 Cron `0 6 * * *`(Asia/Shanghai)。**Dify Chatflow 编排待完成**(见编排草稿)。本期暂不识别或过滤红冲、取消、作废场景。
**状态**:销售一期需求以 [demand.md](demand.md) 为准;采购二期及其它业务方通过新增 Profile 扩展。旧版已实现代码与文档尚未按新版需求改造,实施前须以 [technical-design.md](technical-design.md) 的新版设计为准。
**运维入口**:上线/验收请先走 [ops-checklist.md](ops-checklist.md)。
@@ -1,799 +1,111 @@
<!doctype html>
<!doctype html>
<!--
docs/features/accounting-voucher-check/accounting-voucher-check-prototype.html
用途:立账凭证检核 Agent 低保真原型——对话为主入口、日批为主;只查共享盘材料是否存在,不做字段吻合。
依赖:浏览器原生 HTML/CSS/JavaScript,无需构建;用于产品/业务评审。
逻辑:顶栏切换「会话 / 检核记录 / 共享盘材料 / 缺资料通知」;
会话内模拟发起检核 → 进度卡 → 单票结果卡;记录页可筛选批次与发票明细;
共享盘按发票号展示材料齐全度(必检清单占位 TBD);缺资料触发企微 textcard。
用途:展示 Profile 驱动的立账凭证资料批量检核,突出批量缺件的 Excel 汇总与按 invoice 通知。
依赖:浏览器原生 HTML/CSS/JavaScript,无需构建。
逻辑:销售 Profile 模拟周度上月增量;采购 Profile 展示待确认规则;结果以单文件明细、批次汇总和通知三个视角呈现。
-->
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>立账凭证检核 Agent · 原型</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>立账凭证资料检核 · 原型</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; }
}
:root { --ink:#142033; --muted:#64748b; --line:#dce4ef; --bg:#f4f7fb; --panel:#fff; --nav:#111c31; --brand:#2563eb; --soft:#eaf2ff; --green:#067647; --amber:#b54708; --red:#b42318; }
* { box-sizing:border-box; } body { margin:0; background:var(--bg); color:var(--ink); font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif; } button,select { font:inherit; } button { cursor:pointer; }
.top { display:flex; justify-content:space-between; gap:16px; align-items:center; padding:12px 24px; background:var(--nav); color:#fff; }.top small { color:#aac0db; margin-left:8px; }.tabs { display:flex; gap:5px; }.tabs button { border:0; border-radius:7px; padding:7px 11px; color:#c5d3e6; background:transparent; font-weight:700; font-size:12px; }.tabs button.active { color:#fff; background:var(--brand); }
main { width:min(1220px,calc(100% - 32px)); margin:auto; padding:24px 0 42px; }.view { display:none; }.view.active { display:block; }.profile { display:grid; grid-template-columns:250px 1fr auto; gap:14px; align-items:center; padding:13px 15px; border:1px solid #c9dcfb; border-radius:13px; background:linear-gradient(100deg,#edf5ff,#fff); margin-bottom:18px; } select { padding:8px; border:1px solid #b8c8dd; border-radius:8px; font-weight:700; }
.muted { color:var(--muted); font-size:12px; }.badge,.status { display:inline-flex; padding:3px 8px; border-radius:99px; font-size:11px; font-weight:800; }.blue { color:#175cd3; background:var(--soft); }.green { color:var(--green); background:#eafaf1; }.amber { color:var(--amber); background:#fff7e6; }.gray { color:#475569; background:#edf1f6; }.red { color:var(--red); background:#fff0ef; }
.hero { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; margin-bottom:15px; }.hero h1 { margin:0; font-size:24px; }.hero p { margin:5px 0; color:var(--muted); }.btn { border:1px solid var(--line); border-radius:8px; padding:8px 11px; background:#fff; font-size:12px; font-weight:750; }.btn.primary { border-color:var(--brand); color:#fff; background:var(--brand); }.btn:disabled { opacity:.5; cursor:not-allowed; }
.grid { display:grid; gap:14px; }.three { grid-template-columns:repeat(3,1fr); }.task-metrics { grid-template-columns:repeat(4,1fr); }.two { grid-template-columns:1.15fr .85fr; margin-top:14px; }.card { border:1px solid var(--line); border-radius:13px; background:#fff; overflow:hidden; }.hd { display:flex; justify-content:space-between; gap:12px; padding:13px 15px 9px; }.hd h2 { margin:0; font-size:14px; }.hd p { margin:3px 0; color:var(--muted); font-size:12px; }.bd { padding:0 15px 15px; }
.metric { padding:16px; }.metric b { display:block; font-size:27px; }.metric span { color:var(--muted); font-size:12px; }.bar { height:8px; background:#e7edf5; border-radius:9px; overflow:hidden; }.bar i { display:block; width:0; height:100%; background:linear-gradient(90deg,#2563eb,#60a5fa); transition:.3s; }.stats { display:grid; grid-template-columns:repeat(6,1fr); gap:7px; margin:12px 0; }.stat { padding:8px; text-align:center; border:1px solid var(--line); border-radius:8px; background:#fbfdff; }.stat b { display:block; font-size:17px; }.stat span { color:var(--muted); font-size:11px; }
.step { display:grid; grid-template-columns:28px 1fr auto; gap:8px; align-items:center; padding:9px; border:1px solid var(--line); border-radius:9px; margin:7px 0; }.no { display:grid; place-items:center; width:24px; height:24px; border-radius:50%; color:var(--brand); background:var(--soft); font-size:11px; font-weight:800; }.step strong { font-size:12px; }.step small { display:block; color:var(--muted); }
table { width:100%; border-collapse:collapse; font-size:12px; } th,td { padding:10px 8px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top; } th { color:var(--muted); background:#f9fbfe; } tr[data-rule],tr[data-subject] { cursor:pointer; } tr.active,tr[data-rule]:hover { background:#f1f6ff; }.source { font-weight:700; }.source.erp { color:#2563eb; }.source.oa { color:#7c3aed; }.source.dir { color:#059669; }.source.pay { color:#d97706; }
.detail { min-height:335px; }.kv { display:grid; grid-template-columns:110px 1fr; gap:10px; padding:9px 0; border-bottom:1px solid var(--line); font-size:12px; }.kv b { color:var(--muted); }.code { padding:8px; border-radius:7px; color:#dbeafe; background:#142036; font:11px ui-monospace,monospace; }.layout { display:grid; grid-template-columns:270px 1fr; gap:14px; }.menu { padding:9px; }.menu button { display:flex; justify-content:space-between; width:100%; border:1px solid transparent; border-radius:8px; padding:10px; background:transparent; text-align:left; }.menu button.active { border-color:#c9dcfb; background:var(--soft); }.result { display:grid; grid-template-columns:1fr 1.25fr auto; gap:8px; align-items:center; padding:10px; border:1px solid var(--line); border-radius:9px; margin:7px 0; }.path { color:#475569; font:11px ui-monospace,monospace; word-break:break-all; }
.kpis { display:grid; grid-template-columns:repeat(4,1fr); border-top:1px solid var(--line); border-left:1px solid var(--line); margin-bottom:14px; }.kpi { padding:10px; border-right:1px solid var(--line); border-bottom:1px solid var(--line); background:#fbfdff; }.kpi b { display:block; font-size:18px; }.kpi span { color:var(--muted); font-size:11px; }.excel-note { margin:10px 0 0; padding:9px; border-radius:8px; color:#175cd3; background:var(--soft); font-size:12px; }
.workbook { overflow:auto; border:1px solid var(--line); border-radius:10px; background:#fff; }.workbook table { min-width:1140px; }.workbook th { white-space:nowrap; }.sheet-title { margin:0; font-size:16px; }.sheet-meta { margin:4px 0 14px; color:var(--muted); font-size:12px; }.field-list { display:flex; flex-wrap:wrap; gap:7px; }.field-list span { padding:4px 7px; border:1px solid var(--line); border-radius:6px; color:#475569; background:#fbfdff; font:11px ui-monospace,monospace; }.file-ok { color:var(--green); font-weight:800; }.file-missing { color:var(--red); font-weight:800; }.file-pending { color:var(--amber); font-weight:800; }
.phone { width:360px; padding:15px; border-radius:25px; color:#fff; background:#172033; }.phone small { display:block; color:#aab9cc; text-align:center; }.notice { margin-top:10px; overflow:hidden; border-radius:10px; color:var(--ink); background:#fff; }.notice h3 { margin:0; padding:13px 14px 7px; }.notice p { min-height:190px; margin:0; padding:0 14px 13px; white-space:pre-line; color:#3d4b61; font-size:12px; }.notice button { width:100%; padding:10px; border:0; border-top:1px solid var(--line); color:var(--brand); background:#fff; font-weight:800; }.toast { position:fixed; right:18px; bottom:18px; padding:10px 12px; border-radius:9px; color:#fff; background:#142036; opacity:0; transition:.2s; }.toast.show { opacity:1; }
.filters { display:flex; flex-wrap:wrap; align-items:end; gap:10px; padding:13px 15px; margin-bottom:14px; }.filters label { display:grid; gap:4px; color:var(--muted); font-size:11px; font-weight:700; }.filters select { min-width:120px; padding:7px; font-size:12px; }.task-actions { margin-left:auto; display:flex; gap:8px; }.link { border:0; padding:0; color:#175cd3; background:transparent; font-size:12px; font-weight:800; }.task-table td { vertical-align:middle; }.task-count { color:#b42318; font-weight:800; }.task-empty { padding:30px; color:var(--muted); text-align:center; }
@media(max-width:850px) { .top,.hero { align-items:flex-start; flex-direction:column; }.profile,.two,.layout { grid-template-columns:1fr; }.three,.task-metrics,.kpis { grid-template-columns:1fr; }.stats { grid-template-columns:repeat(3,1fr); }.result { grid-template-columns:1fr; }.phone { width:100%; } }
</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>
<header class="top"><div><b>立账凭证资料检核</b><small>Profile 驱动 · 多来源获取 · 按 invoice 归档</small></div><nav class="tabs" id="tabs"><button class="active" data-v="tasks">检核任务</button><button data-v="work">检核工作台</button><button data-v="rules">文件规则</button><button data-v="records">执行记录</button><button data-v="excel">企微通知附件 Excel</button><button data-v="notice">企业微信通知</button></nav></header>
<main>
<section class="profile"><label><b>当前业务方 Profile</b><br><select id="profile"><option value="sales">销售一期 · 已确认</option><option value="procurement">采购二期 · 待确认</option></select></label><div id="profileInfo"></div><div id="profileBadge"></div></section>
<section class="view active" id="v-tasks"><div class="hero"><div><h1>检核任务</h1><p>按批次查看销售、采购等业务方的资料检核结果,并进入明细、企微通知附件和通知记录。</p></div><div><button class="btn" id="taskForce">强制重检</button> <button class="btn primary" id="taskCreate">新建任务</button></div></div><div class="grid task-metrics" id="taskMetrics"></div><article class="card filters"><label>资料所属期间<select id="taskPeriod"><option value="all">全部期间</option><option value="2026-07" selected>2026-07</option><option value="2026-06">2026-06</option><option value="2026-05">2026-05</option></select></label><label>业务方<select id="taskProfile"><option value="all">全部</option><option value="sales" selected>销售</option><option value="procurement">采购</option></select></label><label>状态<select id="taskStatus"><option value="all">全部</option><option value="missing">缺件</option><option value="complete">已完成</option><option value="failed">技术失败</option></select></label><div class="task-actions"><button class="btn primary" id="taskSearch">查询</button><button class="btn" id="taskReset">重置</button></div></article><article class="card"><div class="hd"><div><h2>任务列表</h2><p id="taskCount"></p></div></div><div class="bd" style="padding:0"><div class="workbook"><table class="task-table"><thead><tr><th>批次号</th><th>业务方</th><th>资料所属期间</th><th>执行时间</th><th>主体总数</th><th>已归档</th><th>缺件文件</th><th>缺件 invoice</th><th>状态</th><th>操作</th></tr></thead><tbody id="taskRows"></tbody></table></div></div></article></section>
<section class="view" id="v-work"><div class="hero"><div><h1 id="title"></h1><p id="desc"></p></div><div><button class="btn" id="force">强制重检上月</button> <button class="btn primary" id="run">执行本周增量检核</button></div></div><div class="grid three" id="metrics"></div><div class="grid two"><article class="card"><div class="hd"><div><h2>本周执行批次 · DCR-20260818-001</h2><p>检核期间:2026-07(上一个自然月)</p></div><span class="badge blue" id="runBadge">待执行</span></div><div class="bd"><div class="bar"><i id="bar"></i></div><div class="stats" id="stats"></div><p class="muted" id="runText"></p><button class="btn" data-go="records">查看执行明细</button> <button class="btn" id="excel">下载统一 Excel(示意)</button></div></article><article class="card"><div class="hd"><div><h2>通用执行链路</h2><p>业务差异由 Profile 与 Adapter 承担</p></div><span class="badge blue">可扩展</span></div><div class="bd"><div class="step"><b class="no">1</b><div><strong>确定上一个自然月</strong><small>每周执行,正确处理跨年</small></div><span class="badge gray">通用</span></div><div class="step"><b class="no">2</b><div><strong>加载 Profile 与文件规则</strong><small>销售、采购拥有不同文件及命名</small></div><span class="badge gray">通用</span></div><div class="step"><b class="no">3</b><div><strong>调用来源 Adapter</strong><small>ERP / OA / 固定目录 / 网盘</small></div><span class="badge blue">Adapter</span></div><div class="step"><b class="no">4</b><div><strong>归档、汇总、Excel 与通知</strong><small>同 invoice 集中归档;缺件按两个维度汇总</small></div><span class="badge green">通用</span></div></div></article></div><div class="grid two"><article class="card"><div class="hd"><div><h2>Excel 结果预览</h2><p>工作表:检核结果(逐票状态)</p></div><span class="badge amber">批量缺件</span></div><div class="bd" id="excelSummary"></div></article><article class="card"><div class="hd"><div><h2>归档原则</h2><p>临时保存 → 校验关联 → 复制归档</p></div></div><div class="bd"><p class="muted" id="archiveNote"></p><div class="code">{归档根路径}/{yyyy}/{MM}/{invoice号}/</div></div></article></div><div class="grid two"><article class="card"><div class="hd"><div><h2>本 Profile 文件覆盖</h2><p>来源与待确认状态</p></div><button class="btn" data-go="rules">完整规则</button></div><div class="bd" id="ruleSummary"></div></article><article class="card"><div class="hd"><div><h2>Excel 结果粒度</h2><p>一行一个 invoice</p></div></div><div class="bd"><p class="muted">顶部选择资料所属期间并展示执行时间;表格仅展示每个必检文件是否缺件和总体状态,全部文件均不缺时状态为“完整”。</p><button class="btn" data-go="excel">查看检核结果表</button></div></article></div></section>
<section class="view" id="v-rules"><div class="hero"><div><h1>文件规则配置</h1><p>新增业务方优先新增 Profile;新增外部系统时才增加 Adapter。</p></div></div><div class="grid two"><article class="card"><div class="bd" style="padding:0"><table><thead><tr><th>文件类型</th><th>命名方式</th><th>来源</th><th>状态</th></tr></thead><tbody id="ruleTable"></tbody></table></div></article><article class="card detail"><div class="hd"><div><h2>规则详情</h2><p>点击左侧规则查看</p></div></div><div class="bd" id="ruleDetail"></div></article></div></section>
<section class="view" id="v-records"><div class="hero"><div><h1>执行记录与归档明细</h1><p>记录粒度:invoice + 文件规则 + 文件实例;左侧显示每张 invoice 的缺件数。</p></div><button class="btn primary" data-go="excel">查看当前批次 Excel(示意)</button></div><div class="grid two"><article class="card"><div class="hd"><div><h2>本批次缺件 invoice 汇总</h2><p>用于通知和业务跟进</p></div></div><div class="bd" id="invoiceSummary"></div></article><article class="card"><div class="hd"><div><h2>按文件类型缺件汇总</h2><p>用于通知和业务跟进</p></div></div><div class="bd" id="typeSummary"></div></article></div><div class="layout" style="margin-top:14px"><aside class="card menu" id="subjects"></aside><article class="card"><div class="bd" id="subjectDetail"></div></article></div></section>
<section class="view" id="v-excel"><div class="hero"><div><h1>企业微信通知附件 Excel</h1><p>企业微信汇总通知的下载文件:<b id="excelFilename">voucher_check_sales_2026-07_DCR-20260818-001.xlsx</b> · 一张“检核结果”工作表,每行一个 invoice。</p></div><div><label class="muted">资料所属期间&nbsp;<select id="reportYear"><option>2025</option><option selected>2026</option></select> 年 <select id="reportMonth"><option>01</option><option>02</option><option>03</option><option>04</option><option>05</option><option>06</option><option selected>07</option><option>08</option><option>09</option><option>10</option><option>11</option><option>12</option></select> 月</label> <button class="btn primary" id="downloadExcel">下载企微通知附件(示意)</button></div></div><article class="card"><div class="hd"><div><h2 class="sheet-title" id="sheetTitle"></h2><p class="sheet-meta" id="sheetMeta"></p></div><span class="badge blue" id="sheetBadge"></span></div><div class="bd" id="sheetContent"></div></article></section>
<section class="view" id="v-notice"><div class="hero"><div><h1>企业微信缺件通知</h1><p>一次检核发送一条批次汇总;完整 invoice 明细通过企业微信通知附件 Excel 与执行记录查看。</p></div></div><div class="grid two"><div class="phone"><small>企业微信 · 应用消息</small><div class="notice"><h3 id="noticeTitle"></h3><p id="noticeBody"></p><button id="noticeExcel">查看企微通知附件 Excel(示意)</button></div></div><article class="card"><div class="hd"><div><h2>通知策略</h2><p>由 Profile 配置</p></div><span class="badge amber">接收人待定</span></div><div class="bd"><div class="kv"><b>触发</b><span>本批存在任一必检文件缺件</span></div><div class="kv"><b>聚合</b><span>每个检核批次合并为一条汇总通知</span></div><div class="kv"><b>内容</b><span>业务方、检核月份、批次号、主体总数、缺件文件数、缺件 invoice 数、主要缺失类型</span></div><div class="kv"><b>明细</b><span>不在消息正文逐票展开;完整 invoice 与文件明细查看企微通知附件 Excel 或执行记录</span></div><div class="kv"><b>附件</b><span>消息提供本批 Excel 附件下载入口;一行一个 invoice,展示每个文件状态和总体状态</span></div><div class="kv"><b>无接收人</b><span>不发送空通知;Excel 和日志记录未发送原因</span></div></div></article></div></section>
</main><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);
/** 原型交互:切换 Profile 后刷新规则、汇总、明细和通知;销售可模拟周度上月增量执行。 */
(() => {
const $ = (id) => document.getElementById(id);
const profiles = {
sales: {
name: '销售一期', enabled: true,
desc: '每周增量检核上一个自然月;以销售 invoice 为核心,从 ERP、OA 与固定目录获取文件并集中归档。',
metrics: [['6','必检文件规则'],['每周','执行频率'],['上月','检核范围']],
note: '缺少任一必检文件时生成双维度汇总 Excel 并发送企业微信通知;通知接收人待业务确认。',
rules: [
['PO订单','{invoice号}-{订单号}.pdf','erp','ERP 查询并打印','以 invoice 反查 PO','查询条件待补充','已确认'],
['报关资料','{invoice号}.pdf','dir','固定目录扫描','文件名含 invoice','路径待确认','待确认'],
['销货放行申请单','{invoice号}-{销货单号}.pdf','oa','OA 报表打印','OA 读取发票号和销货单号','上月 + 归档 + HXJM + 发票号非空','流程已确认'],
['发票','{invoice号}-{发票号}.pdf','dir','固定目录扫描','文件名含 invoice','路径待确认','待确认'],
['报关单','{invoice号}-{报关单号}.pdf','dir','固定目录扫描','文件名含 invoice','路径待确认','待确认'],
['提单','{invoice号}-提单.pdf','dir','固定目录扫描','文件名含 invoice','路径待确认','待确认']
],
subjects: [
['INV-202607-00128','已归档',[['PO订单','ERP 打印','archived'],['销货放行申请单','OA 打印','archived'],['报关资料','固定目录','archived'],['发票','固定目录','archived'],['报关单','固定目录','archived'],['提单','固定目录','archived']]],
['INV-202607-00135','缺 2 件',[['PO订单','ERP 打印','archived'],['报关资料','固定目录','missing'],['销货放行申请单','OA 打印','archived'],['报关单','固定目录','missing']]],
['INV-202607-00148','缺 2 件',[['PO订单','ERP 打印','archived'],['发票','固定目录','missing'],['提单','固定目录','missing']]],
['INV-202607-00141','已跳过',[['全部文件','来源指纹未变','skipped']]]
],
notice: ['销售立账凭证缺件汇总提醒','业务方:销售\n检核月份:2026-07\n批次:DCR-20260818-001\n检核主体:8 张\n缺件文件:4 项\n缺件发票:2 张\n主要缺失:报关资料、报关单、发票、提单\n\n完整缺件清单请下载本批 Excel 查看。\n\n接收人:待配置']
},
procurement: {
name: '采购二期', enabled: false,
desc: '采购复用同一引擎,加载独立 Profile;当前仅展示文件规则,主体来源、路径和 Adapter 参数待业务确认。',
metrics: [['6','拟定文件规则'],['待定','扫描路径'],['复用','归档 / Excel / 通知']],
note: '采购将复用周度上月增量、单文件结果、批量缺件汇总和按 invoice 归档;暂不执行实际检核。',
rules: [
['对账单EXCEL版','{发票号}-对账单','dir','P011采购请款单附件','发票号','路径待确认','待确认'],
['对账单盖章版','{发票号}-对账单PDF','dir','P011采购请款单附件','发票号','路径待确认','待确认'],
['核价单','{发票号}-核价单','oa','关联 OA 开票申请','通过出货单号关联','OA 条件待确认','待确认'],
['发票','{发票号}','dir','P011采购请款单附件','发票号','路径待确认','待确认'],
['送货单','{发票号}-送货单','dir','网盘仓储上传','发票号','路径待确认','待确认'],
['付款回单','{发票号}-付款回单','pay','出纳付款下载','发票号','路径待确认','待确认']
], subjects: [],
notice: ['采购立账凭证缺件汇总提醒(示意)','采购二期 Profile 尚未启用。\n\n待确认:采购 invoice 主体来源、各扫描路径、核价单 OA 关联条件、付款回单下载方式及企业微信接收人。']
}
}, 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);
})();
};
const tasks = [
{ runNo:'DCR-20260818-001', profile:'sales', period:'2026-07', executedAt:'2026-08-18 09:30', subjects:8, archived:28, missingFiles:4, missingInvoices:2, status:'missing' },
{ runNo:'DCR-20260721-001', profile:'sales', period:'2026-06', executedAt:'2026-07-21 09:00', subjects:12, archived:64, missingFiles:8, missingInvoices:5, status:'missing' },
{ runNo:'DCR-20260622-002', profile:'sales', period:'2026-05', executedAt:'2026-06-22 10:15', subjects:9, archived:54, missingFiles:0, missingInvoices:0, status:'complete' },
{ runNo:'DCR-20260622-001', profile:'sales', period:'2026-05', executedAt:'2026-06-22 10:12', subjects:10, archived:22, missingFiles:2, missingInvoices:2, status:'failed' },
{ runNo:'DCR-20260818-002', profile:'procurement', period:'2026-07', executedAt:'—', subjects:0, archived:0, missingFiles:0, missingInvoices:0, status:'draft' }
];
let profileKey = 'sales'; let selectedRule = 0; let selectedSubject = 0; let running = false;
const current = () => profiles[profileKey];
const status = (value) => { const data = { archived:['已归档','green'], missing:['缺件','amber'], skipped:['已跳过','gray'], technical_error:['技术失败','red'] }[value] || [value,'blue']; return '<span class="status ' + data[1] + '">' + data[0] + '</span>'; };
const toast = (message) => { $('toast').textContent = message; $('toast').classList.add('show'); setTimeout(() => $('toast').classList.remove('show'), 2200); };
const taskStatus = (value) => ({ missing:['缺件','amber'], complete:['已完成','green'], failed:['技术失败','red'], draft:['待配置','gray'] }[value] || [value,'blue']);
function renderTasks() { const period = $('taskPeriod').value; const profile = $('taskProfile').value; const taskState = $('taskStatus').value; const filtered = tasks.filter((task) => (period === 'all' || task.period === period) && (profile === 'all' || task.profile === profile) && (taskState === 'all' || task.status === taskState)); const subjectTotal = filtered.reduce((sum, task) => sum + task.subjects, 0); const archivedTotal = filtered.reduce((sum, task) => sum + task.archived, 0); const missingFileTotal = filtered.reduce((sum, task) => sum + task.missingFiles, 0); const missingInvoiceTotal = filtered.reduce((sum, task) => sum + task.missingInvoices, 0); $('taskMetrics').innerHTML = [[subjectTotal,'本期主体总数'],[archivedTotal,'已归档文件'],[missingFileTotal,'缺件文件数'],[missingInvoiceTotal,'缺件 invoice 数']].map(([number,label], index) => '<article class="card metric"><b class="' + (index > 1 ? 'task-count' : '') + '">' + number + '</b><span>' + label + '</span></article>').join(''); $('taskCount').textContent = '共 ' + filtered.length + ' 条任务记录'; $('taskRows').innerHTML = filtered.length ? filtered.map((task) => { const state = taskStatus(task.status); const profileName = task.profile === 'sales' ? '销售' : '采购'; return '<tr><td><b>' + task.runNo + '</b></td><td>' + profileName + '</td><td>' + task.period + '</td><td>' + task.executedAt + '</td><td>' + task.subjects + '</td><td>' + task.archived + '</td><td class="task-count">' + task.missingFiles + '</td><td class="task-count">' + task.missingInvoices + '</td><td><span class="status ' + state[1] + '">' + state[0] + '</span></td><td><button class="link" data-task="' + task.runNo + '">查看详情</button></td></tr>'; }).join('') : '<tr><td colspan="10" class="task-empty">暂无符合筛选条件的检核任务</td></tr>'; }
const getMissing = (p) => p.subjects.flatMap((subject) => subject[2].filter((item) => item[2] === 'missing').map((item) => ({ invoice:subject[0], type:item[0] })));
const renderStats = (values) => { $('stats').innerHTML = values.map(([number,label]) => '<div class="stat"><b>' + number + '</b><span>' + label + '</span></div>').join(''); };
function resetRun() { $('bar').style.width = '0%'; $('runBadge').className = 'badge blue'; $('runBadge').textContent = current().enabled ? '待执行' : 'Profile 未启用'; renderStats([['0','主体'],['0','已处理'],['0','已跳过'],['0','已归档'],['0','缺件文件'],['0','缺件 invoice']]); $('runText').textContent = current().enabled ? '等待启动:加载销售 Profile 后按 invoice 执行文件规则。' : '采购 Profile 当前仅供评审,待配置完成后启用。'; }
function renderRules() { const p = current(); const rule = p.rules[selectedRule]; $('ruleTable').innerHTML = p.rules.map((item,index) => '<tr data-rule="' + index + '" class="' + (index === selectedRule ? 'active' : '') + '"><td><b>' + item[0] + '</b></td><td>' + item[1] + '</td><td class="source ' + item[2] + '">' + item[3] + '</td><td><span class="badge ' + (item[6].includes('确认') ? 'green' : 'amber') + '">' + item[6] + '</span></td></tr>').join(''); $('ruleDetail').innerHTML = '<div class="kv"><b>文件类型</b><span>' + rule[0] + ' · 必检</span></div><div class="kv"><b>命名模板</b><span class="code">' + rule[1] + '</span></div><div class="kv"><b>来源 Adapter</b><span class="source ' + rule[2] + '">' + rule[3] + '</span></div><div class="kv"><b>主体关联</b><span>' + rule[4] + '</span></div><div class="kv"><b>扫描 / 查询</b><span>' + rule[5] + '</span></div><div class="kv"><b>归档方式</b><span>按 invoice 集中归档</span></div>' + (rule[0] === '销货放行申请单' ? '<p class="muted">关联字段不完整:直接跳过该 OA 记录,不打印、不归档、不记录字段异常。</p>' : ''); }
function renderExcelSummary() { const p = current(); if (!p.subjects.length) { $('excelSummary').innerHTML = '<p class="muted">采购 Profile 尚未启用;启用后将生成一张按 invoice 展示各文件缺件状态的“检核结果”工作表。</p>'; return; } const missing = getMissing(p); const missingInvoices = [...new Set(missing.map((item) => item.invoice))]; const typeCounts = Object.entries(missing.reduce((result,item) => { result[item.type] = (result[item.type] || 0) + 1; return result; }, {})); $('excelSummary').innerHTML = '<div class="kpis"><div class="kpi"><b>' + p.subjects.length + '</b><span>主体总数</span></div><div class="kpi"><b>28</b><span>已归档文件</span></div><div class="kpi"><b>' + missing.length + '</b><span>缺件文件总数</span></div><div class="kpi"><b>' + missingInvoices.length + '</b><span>缺件 invoice 数</span></div></div><table><thead><tr><th>缺失文件类型</th><th>缺件文件数</th><th>涉及 invoice 数</th></tr></thead><tbody>' + typeCounts.map(([type,count]) => '<tr><td><b>' + type + '</b></td><td>' + count + '</td><td>' + new Set(missing.filter((item) => item.type === type).map((item) => item.invoice)).size + '</td></tr>').join('') + '</tbody></table><p class="excel-note">下载 Excel 为一张“检核结果”表:每行一个 invoice,逐列显示每个必检文件是否缺件;全部为“否”时状态为“完整”。</p>'; }
function renderWorkbook() { const p = current(); const year = $('reportYear').value; const month = $('reportMonth').value; $('excelFilename').textContent = 'voucher_check_' + profileKey + '_' + year + '-' + month + '_DCR-20260818-001.xlsx'; if (!p.subjects.length) { $('sheetTitle').textContent = '检核结果'; $('sheetMeta').textContent = '资料所属期间:' + year + '-' + month + ';采购 Profile 尚未启用,待确认主体来源、扫描路径与 Adapter 参数。'; $('sheetBadge').textContent = '待配置'; $('sheetContent').innerHTML = '<p class="muted">启用后将按采购 Profile 的文件规则动态生成文件状态列。</p>'; return; } const fileStatus = (value) => value === 'missing' ? '<span class="file-missing">缺件</span>' : value === 'archived' ? '<span class="file-ok">有</span>' : '<span class="file-pending">未检核</span>'; $('sheetTitle').textContent = '工作表:检核结果'; $('sheetMeta').textContent = '资料所属期间:' + year + '-' + month + '(业务月份) · 执行时间:2026-08-18 09:30(本批实际检核完成时间)。'; $('sheetBadge').textContent = '逐票结果'; const columns = p.rules.map((rule) => rule[0]); $('sheetContent').innerHTML = '<p class="muted">主要字段:</p><div class="field-list"><span>invoice</span>' + columns.map((name) => '<span>' + name + '</span>').join('') + '<span>状态</span></div><div class="workbook" style="margin-top:14px"><table><thead><tr><th>invoice</th>' + columns.map((name) => '<th>' + name + '</th>').join('') + '<th>状态</th></tr></thead><tbody>' + p.subjects.map((subject) => { const resultMap = new Map(subject[2].map((item) => [item[0], item[2]])); const values = columns.map((name) => resultMap.get(name) || (subject[2][0][2] === 'skipped' ? 'skipped' : 'missing')); const hasMissing = values.includes('missing'); const hasPending = values.some((value) => value !== 'archived' && value !== 'missing'); const overall = hasMissing ? '<span class="status amber">缺件</span>' : hasPending ? '<span class="status gray">待处理</span>' : '<span class="status green">完整</span>'; return '<tr><td><b>' + subject[0] + '</b></td>' + values.map(fileStatus).map((value) => '<td>' + value + '</td>').join('') + '<td>' + overall + '</td></tr>'; }).join('') + '</tbody></table></div>'; }
function renderRecords() { const p = current(); if (!p.subjects.length) { $('subjects').innerHTML = '<p class="muted">采购 Profile 尚未启用</p>'; $('subjectDetail').innerHTML = '<p class="muted">待确认采购主体来源、扫描路径与来源 Adapter 参数后生成执行记录。</p>'; $('invoiceSummary').innerHTML = '<p class="muted">暂无批次数据</p>'; $('typeSummary').innerHTML = '<p class="muted">暂无批次数据</p>'; return; } const missing = getMissing(p); const groups = [...new Map(missing.map((item) => [item.invoice, missing.filter((other) => other.invoice === item.invoice)])).entries()]; const typeCounts = Object.entries(missing.reduce((result,item) => { result[item.type] = (result[item.type] || 0) + 1; return result; }, {})); $('invoiceSummary').innerHTML = '<table><thead><tr><th>invoice</th><th>缺件数</th><th>缺失文件</th><th>通知</th></tr></thead><tbody>' + groups.map(([invoice,items]) => '<tr><td><b>' + invoice + '</b></td><td>' + items.length + '</td><td>' + items.map((item) => item.type).join('、') + '</td><td><span class="badge amber">待配置接收人</span></td></tr>').join('') + '</tbody></table>'; $('typeSummary').innerHTML = '<table><thead><tr><th>文件类型</th><th>缺件文件数</th><th>涉及 invoice 数</th></tr></thead><tbody>' + typeCounts.map(([type,count]) => '<tr><td><b>' + type + '</b></td><td>' + count + '</td><td>' + new Set(missing.filter((item) => item.type === type).map((item) => item.invoice)).size + '</td></tr>').join('') + '</tbody></table>'; $('subjects').innerHTML = p.subjects.map((item,index) => { const count = item[2].filter((result) => result[2] === 'missing').length; return '<button data-subject="' + index + '" class="' + (index === selectedSubject ? 'active' : '') + '"><span><b>' + item[0] + '</b><br><small>' + (count ? '缺 ' + count + ' 件' : item[1]) + '</small></span>' + status(count ? 'missing' : item[2][0][2]) + '</button>'; }).join(''); const subject = p.subjects[selectedSubject]; $('subjectDetail').innerHTML = '<h2>' + subject[0] + '</h2><p class="muted">检核月份 2026-07 · 同一 invoice 集中归档</p>' + subject[2].map((item) => '<div class="result"><div><b>' + item[0] + '</b><br><small>' + item[1] + '</small></div><div class="path">' + (item[2] === 'archived' ? '{归档根路径}/2026/07/' + subject[0] + '/' : '—') + '</div>' + status(item[2]) + '</div>').join(''); }
function render() { const p = current(); selectedRule = 0; selectedSubject = 0; $('profileInfo').innerHTML = '<b>' + p.name + '</b><br><span class="muted">' + p.desc + '</span>'; $('profileBadge').innerHTML = '<span class="badge ' + (p.enabled ? 'green' : 'amber') + '">' + (p.enabled ? '一期可评审' : '待业务确认') + '</span> <span class="badge blue">上一个自然月</span>'; $('title').textContent = p.name + (p.enabled ? '资料周度增量检核' : '资料检核配置预览'); $('desc').textContent = p.desc; $('run').disabled = $('force').disabled = !p.enabled; $('run').textContent = p.enabled ? '执行本周增量检核' : '等待 Profile 启用'; $('metrics').innerHTML = p.metrics.map(([number,label]) => '<article class="card metric"><b>' + number + '</b><span>' + label + '</span></article>').join(''); $('ruleSummary').innerHTML = p.rules.map((item,index) => '<div class="step"><b class="no">' + (index + 1) + '</b><div><strong>' + item[0] + '</strong><small>' + item[1] + ' · ' + item[3] + '</small></div><span class="badge ' + (item[6].includes('确认') ? 'green' : 'amber') + '">' + item[6] + '</span></div>').join(''); $('archiveNote').textContent = p.note; $('noticeTitle').textContent = p.notice[0]; $('noticeBody').textContent = p.notice[1]; resetRun(); renderRules(); renderExcelSummary(); renderRecords(); renderWorkbook(); }
function run(force) { if (!current().enabled || running) return; running = true; $('run').disabled = $('force').disabled = true; const steps = force ? [[20,8,2,0,10,0,0,'强制模式:定位上一个自然月并加载销售 Profile。'],[60,8,6,0,28,1,1,'ERP、OA 与固定目录 Adapter 正在获取文件。'],[100,8,8,0,40,4,2,'完成:归档成功 40 项;2 个 invoice 共缺 4 件;已生成 Excel 与通知。']] : [[18,8,0,3,0,0,0,'定位 2026-07;加载 Profile 与 6 条规则。'],[60,8,4,3,18,2,1,'执行 ERP 打印、OA 报表与固定目录扫描。'],[100,8,5,3,28,4,2,'完成:3 个主体跳过;2 个 invoice 共缺 4 件,已生成汇总 Excel 与通知。']]; let index = 0; const timer = setInterval(() => { const step = steps[index++]; $('bar').style.width = step[0] + '%'; renderStats([[step[1],'主体'],[step[2],'已处理'],[step[3],'已跳过'],[step[4],'已归档'],[step[5],'缺件文件'],[step[6],'缺件 invoice']]); $('runText').textContent = step[7]; if (step[0] === 100) { clearInterval(timer); running = false; $('run').disabled = $('force').disabled = false; $('runBadge').className = 'badge amber'; $('runBadge').textContent = '完成 · 含缺件'; toast('原型示意:已生成含缺件汇总与检核明细的 Excel,并发送合并缺件通知。'); } }, 700); }
function go(view) { document.querySelectorAll('.view').forEach((item) => item.classList.toggle('active', item.id === 'v-' + view)); document.querySelectorAll('#tabs button').forEach((item) => item.classList.toggle('active', item.dataset.v === view)); }
$('profile').addEventListener('change', (event) => { profileKey = event.target.value; render(); }); $('tabs').addEventListener('click', (event) => { const button = event.target.closest('[data-v]'); if (button) go(button.dataset.v); }); $('reportYear').addEventListener('change', renderWorkbook); $('reportMonth').addEventListener('change', renderWorkbook); $('taskSearch').addEventListener('click', renderTasks); $('taskReset').addEventListener('click', () => { $('taskPeriod').value = 'all'; $('taskProfile').value = 'all'; $('taskStatus').value = 'all'; renderTasks(); }); $('taskCreate').addEventListener('click', () => { go('work'); toast('原型示意:已进入新建检核任务流程。'); }); $('taskForce').addEventListener('click', () => { go('work'); toast('原型示意:已进入强制重检配置。'); }); $('taskRows').addEventListener('click', (event) => { const button = event.target.closest('[data-task]'); if (!button) return; const task = tasks.find((item) => item.runNo === button.dataset.task); if (task && task.profile === 'sales') { profileKey = 'sales'; $('profile').value = 'sales'; render(); go('records'); toast('已打开批次 ' + task.runNo + ' 的执行明细(示意)。'); } else { toast('采购任务待 Profile 启用后查看明细。'); } }); $('run').addEventListener('click', () => run(false)); $('force').addEventListener('click', () => run(true)); $('excel').addEventListener('click', () => go('excel')); $('downloadExcel').addEventListener('click', () => toast('原型示意:下载企业微信通知附件 Excel(逐票检核结果)。')); $('noticeExcel').addEventListener('click', () => go('excel')); $('ruleTable').addEventListener('click', (event) => { const row = event.target.closest('[data-rule]'); if (row) { selectedRule = Number(row.dataset.rule); renderRules(); } }); $('subjects').addEventListener('click', (event) => { const button = event.target.closest('[data-subject]'); if (button) { selectedSubject = Number(button.dataset.subject); renderRecords(); } }); document.body.addEventListener('click', (event) => { const target = event.target.closest('[data-go]'); if (target) go(target.dataset.go); }); renderTasks(); render();
})();
</script>
</body>
</html>
@@ -1,30 +1,23 @@
# 立账凭证检核 Agent · 原型说明
# 立账凭证资料检核 · 原型说明
可交互单文件原型:
可交互原型:[accounting-voucher-check-prototype.html](./accounting-voucher-check-prototype.html)。
**[accounting-voucher-check-prototype.html](./accounting-voucher-check-prototype.html)**(浏览器直接打开)
## 核心展示
## 视图
| Tab | 内容 |
| 视图 | 内容 |
| --- | --- |
| 会话 | 日批/文字触发;进度卡(当月总数 / 本次待检 / **跳过** / 齐全 / 缺资料);单票材料齐全度卡 |
| 检核记录 | 定时/会话批次;含跳过统计;按发票号缺项明细 |
| 共享盘材料 | `\\share\立账凭证\{发票号}\`;必检材料是否存在(清单 TBD) |
| 缺资料通知 | 企微 textcard;跳转检核记录 |
| 检核任务 | 按批次查看主体数、归档数、缺件文件数、缺件 `invoice` 数和状态;支持期间、业务方、状态筛选,并可进入详情 |
| 检核工作台 | 周度上月增量、Profile 加载、来源 Adapter、归档和 Excel 汇总预览 |
| 文件规则 | 不同业务方的文件、命名、来源、关联、扫描条件和待确认项 |
| 执行记录 | `invoice + 文件规则 + 文件实例` 粒度的归档与缺失状态,以及按文件类型、按 `invoice` 的缺件汇总 |
| 企业微信通知附件 Excel | 企业微信汇总通知下载的“检核结果”工作表:每行一个 `invoice`,按 Profile 动态展示各文件“有 / 缺件 / 未检核”和总体状态 |
| 企业微信通知 | 一次检核一条批次汇总通知,展示统计与 Excel 下载入口;接收人待定 |
## 演示话术
## 业务口径
- `执行今日立账凭证检核` — **增量**:跳过已齐全且材料未变更
- `重新检核当月全部` — **强制**:不跳过
- `检核发票 INV-20260803001` — 单票强制
- `查询最新检核结果` / `查询缺资料发票`
## 已确认边界
- 以企业 AI 工作台**对话为主入口**,**日批为主、会话可手动触发**
- **只看文件在不在**,不做金额/供应商等字段吻合
- ERP 仅取当月发票号清单
- **HXOPS 落库**单票齐全状态;齐全且材料未变更 → 跳过
- **不回写 ERP、不要求 ERP 终审**
- 必检材料清单待业务确认
- 销售一期:每周增量检核上一个自然月,支持 ERP、OA 和固定目录来源,按 invoice 集中归档。
- 销货放行申请单:OA 过滤上月、归档、HXJM、发票号码非空;关联字段不完整时直接跳过,不打印、不归档、不记录字段异常。
- 采购二期:展示六类拟定文件规则;路径、主体来源和 Adapter 参数待确认,原型不执行采购检核。
- 批量缺件同时统计“缺件文件总数”和“缺件 `invoice` 数”;同一 `invoice` 缺多个文件时前者累计多个、后者只计一次。
- 统一 Excel 仅包含“检核结果”工作表:每行一个 `invoice`,直接展示各必检文件“有 / 缺件 / 未检核”和状态;全部文件均为“有”时状态为“完整”。
- 缺少必检文件时每个批次发送一条企业微信汇总通知,正文不逐票展开;完整 `invoice` 明细通过 Excel 与执行记录查看,技术失败不作为缺件通知。
@@ -0,0 +1,176 @@
# 立账凭证资料检核需求说明
> 文档版本:v1.1
> 更新时间:2026-08-18
> 状态:一期销售需求确认中;采购及其它业务方待后续 Profile 配置
## 1. 背景与目标
立账凭证资料不再从单一共享目录按固定文件名扫描。不同业务方的必检文件、文件命名、来源系统、查询条件、扫描路径和归档路径均可能不同。
系统应以业务方 **Profile** 加载对应规则,按 `invoice` 为主线批量获取、检核并归档资料;同一 `invoice` 的资料集中存放,缺件结果统一输出到 Excel,并发送企业微信通知。
## 2. 范围与边界
| 项目 | 一期 | 二期及后续 |
| --- | --- | --- |
| 业务方 | 销售 | 采购、其它业务方 |
| 规则加载 | 销售 Profile | 各业务方独立 Profile,不改通用执行引擎 |
| 检核内容 | 文件是否成功获取、是否满足必检规则、是否成功归档 | 同左 |
| 不包含 | 文件内容解析、金额/字段一致性核对、回写 ERP | 同左,除非后续单独立项 |
## 3. 通用业务规则
### 3.1 执行周期与期间口径
| 项目 | 规则 |
| --- | --- |
| 执行频率 | 每周执行一次 |
| 检核期间 | 执行日的上一个自然月;例如 2026-08-18 执行,检核 2026-07 |
| 执行方式 | 增量执行:已成功归档且来源文件/规则未变化的 `invoice + 文件规则` 可跳过;新增、缺件、规则变更或来源变更的记录重新检核 |
| 强制重检 | 支持对上一个自然月全量重检;不跳过任何主体 |
| 归档单位 | 以 `invoice` 为目录单位,同一 `invoice` 的全部已获取文件放入同一归档目录 |
### 3.2 Profile 驱动扩展
| 配置项 | 说明 |
| --- | --- |
| `profile_code` | 业务方标识,例如 `sales`、`procurement` |
| 主体来源 | 获取本期应检 `invoice` 清单的来源和关联字段 |
| 文件规则 | 文件类型、必检性、命名模板、关联字段、来源 Adapter、查询/扫描条件、临时目录、归档模板 |
| 通知规则 | 缺件通知开关、接收人、通知模板与去重策略 |
新增业务方时优先新增或调整 Profile;只有新增外部系统或获取协议时才开发新的来源 Adapter。
### 3.3 结果状态
| 状态 | 含义 | 是否计入缺件 |
| --- | --- | --- |
| 已归档 | 文件已取得、校验关联并复制到目标归档目录 | 否 |
| 缺件 | 必检文件未找到或未成功取得 | 是 |
| 已跳过 | 增量规则判定无需本次重新处理 | 否 |
| 技术失败 | 登录、查询、打印、复制等系统异常 | 否;单独告警 |
### 3.4 检核任务列表
检核任务列表是用户查看历史批次和进入详情的主入口。默认按最新批次展示,支持筛选后查看对应的执行明细、企业微信通知附件 Excel 和通知记录。
| 区域 | 内容 |
| --- | --- |
| 顶部统计 | 当前筛选条件下的主体总数、已归档文件数、缺件文件数、缺件 `invoice` 数 |
| 筛选条件 | 资料所属期间、业务方、任务状态 |
| 任务列表字段 | 批次号、业务方、资料所属期间、执行时间、主体总数、已归档数、缺件文件数、缺件 `invoice` 数、状态 |
| 状态 | 缺件、已完成、技术失败、待配置 |
| 操作 | 查看详情;进入该批次的执行记录,并可查看企业微信通知附件 Excel |
| 任务入口 | 支持新建任务、强制重检;强制重检仍只针对上一个自然月 |
## 4. 销售一期文件规则
| 文件类型 | 命名方式 | 获取方式 | `invoice` 关联 | 扫描/查询条件 | 路径状态 |
| --- | --- | --- | --- | --- | --- |
| PO 订单 | `{invoice号}-{订单号}.pdf` | ERP 查询对应 PO 后打印 PDF | 以销售 `invoice` 反查 PO | ERP 具体查询字段待补充 | 临时/归档路径待确认 |
| 报关资料 | `{invoice号}.pdf` | 固定目录扫描 | 文件名含 `invoice` | 扫描上月对应文件 | 扫描路径待确认 |
| 销货放行申请单 | `{invoice号}-{销货单号}.pdf` | OA 自定义报表逐条打印 PDF | OA 列表读取发票号、销货单号 | 见 5.1 | 临时/归档路径待确认 |
| 发票 | `{invoice号}-{发票号}.pdf` | 固定目录扫描 | 文件名含 `invoice` | 扫描上月对应文件 | 扫描路径待确认 |
| 报关单 | `{invoice号}-{报关单号}.pdf` | 固定目录扫描 | 文件名含 `invoice` | 扫描上月对应文件 | 扫描路径待确认 |
| 提单 | `{invoice号}-提单.pdf` | 固定目录扫描 | 文件名含 `invoice` | 扫描上月对应文件 | 扫描路径待确认 |
> 各路径确认前不得虚构实际目录。文件命名、路径和查询条件均由销售 Profile 配置。
## 5. 销售文件获取与归档
### 5.1 销货放行申请单(OA)
| 步骤 | 操作与规则 |
| --- | --- |
| 1 | 在 OA 进入“报表 → 流程报表 → 自定义报表”,选择“销货放行单” |
| 2 | 过滤申请日期为检核期间(上一个自然月) |
| 3 | 过滤流程状态为“归档”、账套为 `HXJM`、发票号码不为空 |
| 4 | 从结果列表读取发票号和销货单号,以二者关联并生成文件名 |
| 5 | 对关联字段完整的每条申请单逐条打印并保存为 PDF |
| 6 | 关联字段不完整时直接丢弃该 OA 记录:不打印、不归档、不记录字段异常 |
| 7 | 校验后复制至对应 `invoice` 的归档目录 |
```mermaid
flowchart TD
A[进入 OA 销货放行单自定义报表] --> B[过滤上月申请日期、归档、HXJM、发票号码非空]
B --> C[读取发票号与销货单号]
C --> D{关联字段完整?}
D -- 否 --> E[直接丢弃,不记录字段异常]
D -- 是 --> F[逐条打印并保存 PDF]
F --> G[按 invoice 校验命名并归档]
```
### 5.2 PO 订单(ERP)
| 步骤 | 操作与规则 |
| --- | --- |
| 1 | 以上月销售 `invoice` 清单为入口 |
| 2 | 在 ERP 查询并反查对应 PO 订单 |
| 3 | 每个 PO 订单打印并保存一个 PDF |
| 4 | 按 `invoice + 订单号` 命名,复制至对应 `invoice` 归档目录 |
| 5 | ERP 查询字段、过滤条件和具体路径待业务补充 |
### 5.3 通用归档流程
```mermaid
flowchart TD
A[每周任务启动] --> B[确定上一个自然月]
B --> C[加载业务方 Profile 和本期 invoice 清单]
C --> D[按文件规则调用来源 Adapter]
D --> E[获取或打印至临时目录]
E --> F[校验 invoice 关联和命名]
F --> G[建立 invoice 归档目录]
G --> H[复制文件并记录单文件结果]
H --> I[汇总缺件与技术失败]
I --> J[生成统一 Excel 并发送通知]
```
归档目录模板:`{归档根路径}/{yyyy}/{MM}/{invoice号}/`。同一 `invoice` 的多个文件必须集中在同一目录下。
## 6. 批量缺件汇总与企业微信通知
### 6.1 汇总口径
一个批次中可有多个 `invoice` 缺件,且同一 `invoice` 可同时缺少多个必检文件。必须同时统计以下两个不可混用的指标:
| 指标 | 定义 |
| --- | --- |
| 缺件文件总数 | 所有状态为“缺件”的必检文件规则/文件实例数量;同一 `invoice` 缺两种文件计为 2 项 |
| 缺件 invoice 数 | 至少存在一个缺件文件的不同 `invoice` 数量;同一 `invoice` 只计 1 张 |
系统还应按“文件类型”和“`invoice`”两个维度汇总,便于识别高频缺失资料及跟进对象。
### 6.2 企业微信通知
| 项目 | 规则 |
| --- | --- |
| 触发 | 本批存在必检文件缺件 |
| 聚合 | 一个检核批次发送一条汇总通知;不在企业微信中逐票展开缺失明细 |
| 内容 | 业务方、检核月份、批次号、主体总数、缺件文件总数、缺件 `invoice` 数、主要缺失文件类型、Excel 下载入口 |
| 明细查看 | 全部缺件 `invoice`、缺失文件列表和处理状态以 Excel 与执行记录为准 |
| 接收人 | 待业务确认;未配置接收人时不发送空通知,并在 Excel 和执行记录标记未发送原因 |
| 技术失败 | 不作为缺件通知;按技术告警规则单独处理 |
## 7. 企业微信通知附件 Excel
每个批次生成一份**企业微信通知附件 Excel**,由该批次的企业微信汇总通知提供下载入口;它不是另一份独立的通用报表。Excel 采用**一张“检核结果”工作表**,一行对应一个 `invoice`,以业务方 Profile 的必检文件规则动态展开文件状态列。
| 字段类别 | 字段 | 说明 |
| --- | --- | --- |
| 报表筛选 | 资料所属期间(年份、月份) | 在 Excel 报告顶部选择;表示本次资料检核对应的业务月份,例如 `2026-07`,不是执行日期 |
| 报表元信息 | 执行时间 | 展示本批任务实际完成检核的日期和时间,与资料所属期间明确区分 |
| 主体 | `invoice` | 本行检核对象 |
| 必检文件状态 | `{文件类型}` | 每个 Profile 文件规则生成一列;值为“有”(文件已取得)、“缺件”(该文件缺失)或“未检核”(技术失败/跳过) |
| 总体结论 | 状态 | 该 `invoice` 的所有必检文件均为“有”时为“完整”;存在任一“缺件”时为“缺件”;存在未完成检核时为“待处理” |
销售一期示例列:`invoice`、`PO订单`、`报关资料`、`销货放行申请单`、`发票`、`报关单`、`提单`、`状态`。资料所属期间和执行时间显示在报表顶部,不在每一行重复。
## 8. 验收要点
1. 每周任务仅处理上一个自然月,支持跨年期间计算和增量跳过。
2. 同一 `invoice` 缺少多个文件时,Excel 的“缺件文件总数”正确累计,“缺件 invoice 数”只计一次。
3. Excel 报告顶部可按资料所属期间选择年月,并单独展示执行时间;每个 `invoice` 一行,直接展示各必检文件为“有 / 缺件 / 未检核”和总体状态;全部必检文件均为“有”时状态为“完整”。
4. 企业微信每批仅发送一条缺件汇总通知,并提供本批 Excel 下载入口;完整 `invoice` 明细不在消息正文展开。
5. OA 关联字段不完整记录被直接丢弃,不进入异常、缺件、打印或归档结果。
6. 路径、ERP 查询条件等待确认项保持待确认,系统通过 Profile 配置承接,不能写死在通用逻辑中。
@@ -1,737 +1,209 @@
# 立账凭证检核 Agent 技术设计
# 立账凭证资料检核技术设计
> 文档版本:v1.0
> 更新时间:2026-08-05
> 状态:一期代码已落地;Dify Chatflow 编排仍待完成
> 需求基线:[technical.md](technical.md)
> 适用范围:一期后端、排程、Tool API、进度卡、工作台记录页、企微通知与部署
> 文档版本:v2.0
> 更新时间:2026-08-18
> 状态:目标设计,销售一期待实施;替代旧版“当月 + 单一共享盘 + 固定文件名”方案
> 需求基线:[demand.md](demand.md)
## 1. 设计结论
## 1. 设计目标
一期采用“**现有排程底座 + 独立凭证检核领域服务**”方案:
建立一个可扩展的批量资料检核引擎:业务差异由 Profile 和文件规则配置承接,ERP、OA、目录等外部来源由 Adapter 承接;通用引擎负责期间计算、增量、结果持久化、归档、缺件汇总、Excel 和通知。
- 复用 `ScheduleTask`、`ScheduleRun`、`platform_job`、对话批次绑定、进度轮询和 Excel 下载能力。
- 新增 `accounting-voucher-check` 平台 Job,不使用通用 SRM `data_pipeline`,也不调用 Dify Workflow 做文件判定。
- 新增单票最新状态表和批次明细表,支撑增量跳过、缺件查询、通知节流和审计。
- Oracle 只读取 HXJM 套账 `apa_file`;共享盘只读取目录和文件元数据。
- 文件判定采用可配置的**完整文件名精确匹配**,允许一个材料配置多个精确候选文件名,不支持模糊匹配、OCR 或内容读取。
- 共享盘健康检查失败时整批失败;根目录健康但单票目录或必检文件不存在时,才记为业务缺资料。
- “缺资料”属于正常业务结果,不计入 `ScheduleRun.failed_count`;`failed_count` 仅统计技术异常。
| 目标 | 设计约束 |
| --- | --- |
| 支持多业务方 | 新业务方优先新增 Profile,不在通用流程中增加销售/采购分支 |
| 支持多来源 | 新文件来源通过 Adapter 接入,不将查询、打印、目录扫描逻辑写死在引擎中 |
| 支持周度增量 | 每周处理上一个自然月;以 `invoice + 文件规则` 的来源指纹和结果判断是否跳过 |
| 可审计 | 保存批次、单文件结果、归档结果、缺件汇总、通知状态与配置快照 |
| 可汇总 | 明确区分缺件文件总数和缺件 `invoice` 数;通知 Excel 以 `invoice` 为行、以文件规则为动态状态列 |
## 2. 目标与非目标
### 2.1 目标
1. 每日按当前自然月查询 ERP 发票集合。
2. 按 `{root}/{YYYY}/{MM}/{invoice_no}/` 定位共享盘目录。
3. 按配置文件名判断必检材料是否存在。
4. 保存批次、单票结论、缺项、目录指纹和通知记录。
5. 支持日批增量、强制全量和指定发票检核。
6. 支持对话查询进度、最新结果、缺资料票和 Excel。
7. 共享盘、Oracle 或配置异常时提供明确失败状态和告警。
### 2.2 非目标
- 不读取、解析或复制文件内容。
- 不做金额、供应商、采购单号等 ERP 字段吻合。
- 不使用 LLM 判断材料类型或齐全性。
- 不回写 ERP。
- 不扫描非当前自然月。
- 不处理其它账套。
- 不自动追溯上月补录数据。
## 3. 总体架构
## 2. 总体架构
```mermaid
flowchart LR
Cron["ScheduleTask Cron"] --> Job["accounting-voucher-check platform_job"]
Chat["Dify Chatflow"] --> ExistingTool["现有 file-check 启动/状态 Tool"]
ExistingTool --> Job
Job --> ERP["Oracle apa_file Repository"]
Job --> ShareHealth["共享盘健康检查"]
Job --> Scanner["目录与文件名扫描器"]
Job --> State["凭证最新状态表"]
Job --> RunItems["批次明细表"]
Job --> Excel["ScheduleRun Excel"]
Job --> Notify["企微缺件/失败通知"]
Progress["工作台进度卡"] --> ScheduleRun["ScheduleRun + response_summary_json"]
QueryTool["凭证缺件查询 Tool"] --> State
QueryUI["工作台记录查询 API"] --> RunItems
Scheduler[周度排程 / 手动触发] --> Period[上月期间计算]
Period --> Profile[加载已发布 Profile 快照]
Profile --> Subjects[主体清单 Adapter]
Profile --> Rules[文件规则]
Subjects --> Engine[批量检核引擎]
Rules --> Engine
Engine --> Adapters[来源 Adapter: ERP / OA / 目录 / 网盘]
Adapters --> Staging[临时文件区]
Staging --> Archive[关联校验与 invoice 归档]
Archive --> Details[单文件结果]
Details --> Aggregator[缺件汇总器]
Aggregator --> Excel[统一 Excel]
Aggregator --> WeCom[企业微信缺件通知]
Details --> Audit[(批次、明细、状态、通知审计)]
```
### 3.1 复用能力
## 3. Profile 与 Adapter 边界
| 现有能力 | 复用方式 |
| --- | --- |
| 排程管理 | 注册 `accounting-voucher-check` 到 `job_registry` |
| Cron 执行 | `hxops-schedule-worker` 进程内执行平台 Job |
| 手动触发 | 复用 `/api/file-check/tools/tasks/run`,增加通用 `run_options` 透传 |
| 防重复启动 | 复用同 `schedule_task_id` 的 running 检查和 PostgreSQL advisory lock |
| 对话绑定 | 复用 `ChatToolRun` / `chat_log.run_id` 绑定链路 |
| 进度轮询 | 复用 `/api/workspace/file-check/runs/*` |
| Excel 下载 | 复用 `ScheduleRun.excel_file_data` 与既有下载接口 |
| 任务接收人 | 复用 `ScheduleTask.notify_user_ids_json` |
### 3.2 不复用通用 SRM 检核执行器的原因
通用 `data_pipeline` 执行器以 SQL Server、Dify Workflow 和写回为中心。本域使用 Oracle、共享盘确定性扫描且禁止 Dify 判定,因此应实现独立 `platform_job`,避免在通用执行器中加入账套、路径和文件名分支。
## 4. 模块划分
建议新增:
### 3.1 Profile 配置模型
```text
backend/app/
models/
voucher_check.py
services/
voucher_check/
__init__.py
config.py
erp_repository.py
share_scanner.py
fingerprint.py
runner.py
persistence.py
excel_rows.py
notification.py
query_service.py
schedule/
voucher_check_job.py
api/
tools/
voucher_check.py
workspace/
voucher_check.py
backend/tests/
voucher_check/
backend/migrations/versions/
<revision>_add_voucher_check_tables.py
business_profiles/
sales/
profile.yaml
rules.yaml
procurement/
profile.yaml
rules.yaml
```
各模块职责:
生产配置应存放于数据库或受控配置中心,以上目录仅表示逻辑结构;发布后的 Profile 必须生成不可变快照并绑定批次。
| 模块 | 职责 |
| 配置项 | 说明 |
| --- | --- |
| `config.py` | 解析环境变量与 `ScheduleTask.job_params`,验证目录模板和文件名规则 |
| `erp_repository.py` | 初始化 Oracle Client、参数化查询当前自然月发票集合 |
| `share_scanner.py` | 健康检查、路径构造、目录枚举、精确文件名匹配 |
| `fingerprint.py` | 对直接子文件的名称、大小、修改时间生成 SHA-256 |
| `runner.py` | 编排预检、增量、扫描、持久化、进度和通知 |
| `persistence.py` | 单票状态与批次明细的事务写入 |
| `excel_rows.py` | 把批次明细转换为通用 Excel 导出行 |
| `notification.py` | 固定接收人、同票同日节流、失败告警 |
| `query_service.py` | 查询某批次/月份/发票的齐全与缺件记录 |
| `voucher_check_job.py` | `platform_job` 薄封装,返回 `ScheduleExecuteResult` |
| `profile_code` / `profile_version` | 业务方及发布版本,例如 `sales:v1` |
| `subject_adapter` | 获取本期 `invoice` 主体清单的 Adapter 和参数 |
| `file_rules` | 必检标识、命名模板、关联字段、来源 Adapter、查询/扫描条件、临时/归档模板 |
| `notification` | 企业微信接收人、启用开关、模板、去重策略 |
| `incremental_policy` | 指纹字段、可跳过状态、强制重检规则 |
## 5. 配置设计
### 3.2 Adapter 契约
### 5.1 敏感环境变量
| Adapter | 责任 | 统一输出 |
| --- | --- | --- |
| `subject_adapter` | 获取期间内应检主体及关联信息 | `invoice`、主体属性、来源指纹 |
| `erp_print_adapter` | 查询业务单据并打印 PDF | 文件临时路径、关联字段、来源指纹 |
| `oa_report_adapter` | 按 OA 报表条件查询、逐条打印 PDF | 文件临时路径、关联字段、来源指纹 |
| `directory_scan_adapter` | 扫描目录并匹配命名模板 | 匹配文件、扫描路径、来源指纹 |
| `cloud_drive_adapter` | 按接口检索和下载文件 | 文件临时路径、关联字段、来源指纹 |
```bash
VOUCHER_CHECK_ERP_DSN=<oracle-dsn>
VOUCHER_CHECK_ERP_USERNAME=<read-only-user>
VOUCHER_CHECK_ERP_PASSWORD=<secret>
Adapter 不负责归档、Excel 或通知;引擎不理解 ERP/OA 的具体页面、SQL、目录规则。
VOUCHER_CHECK_SHARE_UNC=<share-unc-root>
VOUCHER_CHECK_LOCAL_ROOT=/mnt/hxops-voucher-check-test
VOUCHER_CHECK_SHARE_HEALTHCHECK_RELATIVE_PATH=.hxops-share-ready
## 4. 周度上月增量流程
```mermaid
flowchart TD
A[周度任务启动] --> B[计算上一个自然月]
B --> C[加载 Profile 发布快照]
C --> D[获取 invoice 主体清单]
D --> E[展开 invoice × 文件规则]
E --> F{增量条件满足?}
F -- 是 --> G[写入已跳过结果]
F -- 否 --> H[调用来源 Adapter 获取文件]
H --> I[校验 invoice 关联、命名和必填字段]
I --> J{成功取得文件?}
J -- 是 --> K[复制至 invoice 归档目录]
J -- 否,业务未找到 --> L[写入缺件]
J -- 否,技术异常 --> M[写入技术失败]
K --> N[写入已归档]
G --> O[聚合批次结果]
L --> O
M --> O
N --> O
O --> P[生成 Excel 与企业微信通知]
```
约束:
### 4.1 增量判定
- 密码不得进入 `job_params`、数据库日志、Excel 或错误响应。
- Linux/Test/Prod 必须使用 `LOCAL_ROOT`,不能依赖容器直接访问 UNC。
- 生产必须配置共享盘健康标记文件。标记缺失视为共享盘不可用,避免宿主机挂载丢失后把空目录误判为业务缺件。
可跳过的最小单元为 `profile + period + invoice + file_rule`。仅当上次结果为“已归档”,且 Profile 版本、规则版本、主体来源指纹、文件来源指纹和归档文件校验均未变化时,才可跳过。上次缺件、技术失败、规则变更、来源变更或归档文件缺失均必须重检。
### 5.2 平台 Job 参数
`force_all` 模式不使用增量跳过逻辑。
`ScheduleTask.job_params`:
### 4.2 销售 OA 特殊规则
```json
{
"scope_code": "HXJM",
"directory_template": "{root}/{YYYY}/{MM}/{invoice_no}",
"required_files": [
{
"code": "price_check_sheet",
"name": "核价单",
"required": true,
"accepted_filenames": ["核价单.pdf"]
},
{
"code": "purchase_order",
"name": "采购单",
"required": true,
"accepted_filenames": ["采购单.pdf"]
}
],
"filename_case_sensitive": true,
"notify_missing_enabled": true,
"notify_failure_enabled": true,
"same_day_dedup_enabled": true
}
```
OA 销货放行申请单 Adapter 固定使用:上月申请日期、流程状态“归档”、账套 `HXJM`、发票号码非空。读取发票号和销货单号后,关联字段不完整的记录直接丢弃:不打印、不归档、不记录字段异常;字段完整的记录才进入 PDF 打印与后续归档。
规则:
## 5. 归档与结果模型
- `scope_code` 一期固定为 `HXJM`。
- 模板只允许 `{root}`、`{YYYY}`、`{MM}`、`{invoice_no}` 四个占位符。
- `required_files` 至少包含一个必检项。
- `accepted_filenames` 是完整文件名候选集合,必须包含扩展名;任一候选精确命中即视为该材料存在。
- 禁止 `*`、正则、前缀、后缀或包含匹配。
- 候选文件名不能包含 `/`、`\`、`..` 或控制字符。
### 5.1 归档规则
### 5.3 Job Registry
Job key:`accounting-voucher-check`。
`params_schema` 建议:
| key | type | required | 默认值 |
| --- | --- | --- | --- |
| `scope_code` | `select` | 是 | `HXJM` |
| `directory_template` | `text` | 是 | `{root}/{YYYY}/{MM}/{invoice_no}` |
| `required_files` | `json` | 是 | 核价单.pdf、采购单.pdf 示例 |
| `filename_case_sensitive` | `boolean` | 是 | `true` |
| `notify_missing_enabled` | `boolean` | 否 | `true` |
| `notify_failure_enabled` | `boolean` | 否 | `true` |
| `same_day_dedup_enabled` | `boolean` | 否 | `true` |
## 6. 数据模型
数据库结构变化必须配套 Alembic 迁移。
### 6.1 `voucher_check_invoice_states`
保存一个账套、月份、发票号的最新业务状态。
| 字段 | 类型 | 约束/说明 |
| --- | --- | --- |
| `id` | bigint | PK |
| `scope_code` | varchar(32) | 一期 `HXJM` |
| `period_month` | date | 固定存当月第一天 |
| `invoice_no` | varchar(128) | `TRIM(apa08)` |
| `invoice_date` | date | `TRUNC(apa09)` |
| `status` | varchar(24) | `complete` / `missing` |
| `folder_path` | varchar(1024) | 相对业务路径,禁止存凭据 |
| `folder_exists` | boolean | 单票目录是否存在 |
| `material_fingerprint` | varchar(64) | SHA-256;目录不存在时为空 |
| `matched_files_json` | json | `{material_code: filename}` |
| `missing_materials_json` | json | 缺失材料 code/name 列表 |
| `last_actual_run_id` | bigint FK | 最近实际扫描批次,不因 skip 改写 |
| `last_checked_at` | datetime | 最近实际扫描时间 |
| `last_seen_erp_at` | datetime | 最近出现在 ERP 集合的时间 |
| `last_missing_notified_on` | date | 同票同日节流 |
| `created_at` | datetime | 创建时间 |
| `updated_at` | datetime | 更新时间 |
约束和索引:
- Unique:`scope_code + period_month + invoice_no`。
- Index:`period_month + status`。
- Index:`invoice_no`。
- Index:`last_missing_notified_on`。
### 6.2 `voucher_check_run_items`
保存每个 `ScheduleRun` 的完整单票快照,包括跳过项。
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `id` | bigint | PK |
| `schedule_run_id` | bigint FK | 关联 `schedule_runs.id` |
| `invoice_state_id` | bigint FK nullable | 首次持久化前允许为空 |
| `scope_code` | varchar(32) | 账套 |
| `period_month` | date | 期间 |
| `invoice_no` | varchar(128) | 发票号 |
| `invoice_date` | date | 发票日期 |
| `result` | varchar(24) | `complete` / `missing` / `skipped` / `technical_error` |
| `folder_path` | varchar(1024) | 业务路径 |
| `folder_exists` | boolean | 目录是否存在 |
| `material_fingerprint` | varchar(64) | 本批看到的元数据指纹 |
| `matched_files_json` | json | 命中文件 |
| `missing_materials_json` | json | 缺项 |
| `error_code` | varchar(64) nullable | 单票技术错误码 |
| `error_message` | text nullable | 脱敏错误摘要 |
| `checked_at` | datetime nullable | skip 时为空 |
| `created_at` | datetime | 创建时间 |
约束和索引:
- Unique:`schedule_run_id + invoice_no`。
- Index:`schedule_run_id + result`。
- Index:`period_month + result`。
### 6.3 为什么需要两张表
- 最新状态表用于快速增量判断、缺件查询和通知节流。
- 批次明细表保留历史快照,避免后续补件覆盖审计证据。
- 仅把详情放在 Excel 或 `response_summary_json` 无法可靠分页、筛选和长期审计。
## 7. ERP 查询设计
### 7.1 期间计算
在应用时区 `Asia/Shanghai` 计算:
文件先放入临时目录,完成 `invoice` 关联、命名和文件完整性校验后,复制到:
```text
period_start = 当前日期所在月第一天 00:00:00
next_period_start = 下月第一天 00:00:00
{archive_root}/{yyyy}/{MM}/{invoice}/
```
将两个时间作为绑定参数传给 Oracle,不使用数据库 `SYSDATE`,保证手动触发、测试和跨时区行为一致。
同一 `invoice` 的所有成功资料必须集中在同一目录。复制失败属于技术失败,不可降级为缺件。
### 7.2 SQL
### 5.2 建议持久化实体
```sql
SELECT DISTINCT
TRIM(apa08) AS invoice_no,
TRUNC(apa09) AS invoice_date
FROM apa_file
WHERE apa09 >= :period_start
AND apa09 < :next_period_start
AND TRIM(apa08) IS NOT NULL
ORDER BY TRUNC(apa09), TRIM(apa08)
```
### 7.3 ERP 状态过滤
本期不识别、不区分、也不排除红冲、取消、作废等状态。只按 `apa09` 的当前自然月范围查询 `apa08` 发票号,并按既定 HXJM 账套范围取数。后续若业务需要增加状态过滤,应通过新增配置和经过评审的字段白名单实现,不能在 SQL 中拼接任意字段或值。
### 7.4 Oracle 连接
- 使用已有 `oracledb` 依赖。
- 复用 `Text2SQLService._init_oracle_client()` 初始化 Instant Client。
- 设置连接和查询超时。
- 使用只读账号;禁止执行 DML/DDL。
- 错误日志只记录 DSN、错误类型和 `request_id`,不记录密码。
## 8. 共享盘扫描设计
### 8.1 健康检查
每批在任何单票判定前完成:
1. `VOUCHER_CHECK_LOCAL_ROOT` 已配置。
2. 根路径存在且为目录。
3. 能成功执行一次 `os.scandir(root)`。
4. 配置的健康标记文件存在。
5. 对根目录执行一次轻量 `stat`,超时或 I/O 错误即失败。
失败抛出 `ServiceUnavailableError(code="VOUCHER_CHECK.SHARE_UNAVAILABLE")`。此时:
- 整批 `failed`。
- 不写任何新的单票状态或批次明细。
- 不发送缺资料通知。
- 可发送共享盘失败告警。
根目录健康但 `{YYYY}/{MM}` 不存在时:
- ERP 无发票:批次空成功。
- ERP 有发票:各发票目录均按业务缺资料处理。
### 8.2 路径安全
- `invoice_no` 只去除首尾空白,不做其它业务清洗。
- 若包含 `/`、`\`、NUL 或解析后逃逸月目录,则该票记 `technical_error`,不能当作缺资料。
- 模板渲染后的绝对路径必须位于 `LOCAL_ROOT` 内。
- 报告优先保存相对路径,避免暴露宿主机目录结构。
### 8.3 文件扫描范围
- 只扫描发票目录的直接子文件。
- 忽略子目录、隐藏临时文件和非普通文件。
- 不打开文件句柄读取内容。
- 对每个文件只获取名称、大小、修改时间和类型。
### 8.4 精确匹配
对于一个必检项:
```json
{
"code": "price_check_sheet",
"accepted_filenames": ["核价单.pdf", "核价单.PDF"]
}
```
目录中只要存在一个精确候选文件名即命中。大小为 0、内容损坏或无法被阅读器打开仍按“存在”处理。
### 8.5 指纹
对直接子文件生成稳定序列:
```text
[(filename, size, mtime_ns), ...] # 按 filename 排序
```
用 UTF-8 JSON 序列化后计算 SHA-256。指纹只用于判断目录元数据是否变化,不代表文件内容一致。
## 9. 批次执行流程
### 9.1 运行参数
扩展现有文件检核启动 Tool,允许可选 `run_options`:
```json
{
"task_id": 123,
"run_options": {
"mode": "incremental",
"invoice_no": null
}
}
```
`mode`:
- `incremental`:默认日批/今日检核。
- `force_all`:当前自然月全部重扫。
- `single`:只处理指定 `invoice_no`,必须在 ERP 当前月集合中。
`run_options` 写入 `ScheduleRun.api_request_json`,平台 Job 从该字段读取;其他文件检核任务忽略该字段。
### 9.2 两阶段执行
为保证共享盘失败不会污染现有单票状态,执行分两阶段:
**阶段 A:只读预检与计算**
1. 校验任务配置。
2. 查询 ERP 当前月集合。
3. 校验共享盘健康。
4. 构造月目录和单票路径。
5. 扫描目录元数据、生成指纹和判定结果。
6. 在内存中形成完整结果集。
**阶段 B:事务落库**
1. 单事务写入全部 `voucher_check_run_items`。
2. 对非 `skipped` 且非 `technical_error` 项 upsert 最新状态。
3. `skipped` 只更新 `last_seen_erp_at`,不改 `last_checked_at` 和 `last_actual_run_id`。
4. 写入 `ScheduleRun.response_summary_json` 的领域摘要。
如果阶段 A 出现批次级异常,不进入阶段 B。阶段 B 任一写入失败则整体回滚。
### 9.3 增量决策
```text
force_all / single -> 实际扫描
无历史状态 -> 实际扫描
历史 status=missing -> 实际扫描
历史 status=complete 且指纹相同 -> skipped
历史 status=complete 且指纹变化 -> 实际扫描
```
即使最终跳过,仍需枚举目录元数据以获得当前指纹;“跳过”表示跳过材料规则重算和最新状态改写,不表示完全不访问共享盘。
### 9.4 计数口径
现有 `ScheduleRun` 技术计数映射:
| 字段 | 本域含义 |
| --- | --- |
| `total_count` | ERP 当前范围发票数 |
| `success_count` | 实际处理成功数,包括 `complete + missing` |
| `failed_count` | 单票技术异常数,不包括缺资料 |
| `skipped_count` | 增量跳过数 |
因此:
```text
processed_count = success_count + failed_count + skipped_count
success_count = complete_count + missing_count
```
批次包含缺资料但无技术错误时,`ScheduleRun.status=success`。业务结论从领域摘要读取,不能依据 `failed_count` 判断缺资料。
### 9.5 `response_summary_json`
```json
{
"voucher_check": {
"scope_code": "HXJM",
"period": "2026-08",
"mode": "incremental",
"complete_count": 80,
"missing_count": 12,
"scan_count": 92,
"skipped_count": 20,
"technical_error_count": 0,
"missing_notification_count": 12
},
"file_judgement": {
"qualified_count": 80,
"unqualified_count": 12,
"manual_count": 0,
"system_error_count": 0
},
"current_step": {
"step": "scan_share",
"label": "扫描共享盘文件名",
"processed_count": 45
}
}
```
`file_judgement` 是对现有进度卡的兼容投影;领域真相源为 `voucher_check`。
## 10. Excel 设计
复用通用 `export_schedule_result_excel()`,handler 返回的 `details` 每票一行:
| 字段 | 中文表头 |
| --- | --- |
| `period` | 检核月份 |
| `scope_code` | 账套 |
| `invoice_no` | 发票号 |
| `invoice_date` | 发票日期 |
| `result` | 结论 |
| `folder_exists` | 发票目录是否存在 |
| `folder_path` | 共享盘相对路径 |
| `matched_files` | 已找到材料 |
| `missing_materials` | 缺失材料 |
| `material_fingerprint` | 目录元数据指纹 |
| `checked_at` | 实际检核时间 |
| `error_code` | 技术错误码 |
| `error_message` | 技术错误摘要 |
文件名建议:`voucher_check_{period}_{run_no}.xlsx`。如通用导出器暂不支持自定义文件名,可在本域 handler 内生成 Excel,写入 `ScheduleRun.excel_*`,并避免被通用终结流程覆盖;实施时优先给通用导出器增加可选文件名前缀参数。
## 11. 通知设计
### 11.1 接收人
复用 `ScheduleTask.notify_user_ids_json`。接收用户必须已绑定 `wecom_userid`。
### 11.2 缺资料通知
- 当批存在 `missing` 且 `notify_missing_enabled=true` 时发送合并 textcard。
- 同一发票同一自然日已成功通知时不重复发送。
- 发送成功后才更新 `last_missing_notified_on`。
- 发送失败不更新节流字段,允许下次重试。
- textcard 展示批次、月份、缺资料票数和部分发票号,完整清单通过 HXOPS 记录页/Excel 查看。
### 11.3 批次失败告警
共享盘、Oracle、配置或数据库异常时发送失败告警,正文包含:
- 任务名和批次号。
- 失败阶段。
- 脱敏错误码。
- `request_id` / `run_id`。
- 运维检查建议。
### 11.4 与通用排程通知的关系
本域由 `notification.py` 管理缺件节流和失败告警。`response_summary_json.domain_notification_managed=true` 时,通用 `_notify_schedule_run_wecom()` 跳过重复发送;否则会同时收到领域通知和通用完成通知。
## 12. API 与 Dify Tool 设计
### 12.1 复用接口
| 接口 | 用途 |
| --- | --- |
| `POST /api/file-check/tools/tasks/run` | 启动增量/强制/单票检核 |
| `GET /api/file-check/tools/runs/{run_id}` | 查询批次状态 |
| `GET /api/file-check/tools/tasks/{task_id}/latest-run` | 查询最新批次 |
| `GET /api/file-check/tools/runs/{run_id}/excel` | 下载 Excel |
| `GET /api/workspace/file-check/runs/for-log` | 对话消息绑定进度 |
| `GET /api/workspace/file-check/runs/{run_id}` | 工作台轮询 |
### 12.2 新增领域 Tool API
前缀:`/api/accounting-voucher-check/tools`,沿用 Tool API 的非 envelope 契约。
| 方法 | 路径 | 用途 |
| 实体 | 粒度 | 核心字段 |
| --- | --- | --- |
| GET | `/tasks/{task_id}/missing` | 查询当前月或指定月缺资料票 |
| GET | `/runs/{run_id}/items` | 查询批次明细,可按 result 过滤 |
| GET | `/invoices/{invoice_no}/latest` | 查询指定发票最新状态 |
| `voucher_check_profiles` | Profile 版本 | `profile_code`、`version`、`definition_json`、发布状态 |
| `voucher_check_runs` | 一次执行批次 | `run_no`、`profile_snapshot`、`period_month`、模式、统计快照 |
| `voucher_check_subjects` | 批次中的 `invoice` | `run_id`、`invoice`、主体来源字段、主体指纹 |
| `voucher_check_file_results` | `invoice + 文件规则 + 文件实例` | 文件规则、期望名、来源、临时/归档路径、状态、缺件/错误原因、指纹 |
| `voucher_check_notifications` | 一次批次通知 | `run_id`、汇总统计、主要缺失文件类型、Excel 文件标识/下载入口、接收人、发送状态、失败原因 |
### 12.3 工作台 API
`voucher_check_file_results` 是缺件统计和 Excel 明细的真相源;不得仅保存 `invoice` 级结论,否则无法正确统计同一 `invoice` 的多个缺件。
前缀:`/api/workspace/accounting-voucher-check`,使用标准 `{success,data|error,request_id}` envelope。
## 6. 批量缺件统计
| 方法 | 路径 | 用途 |
### 6.1 统计口径
| 指标 | 计算方式 | 示例 |
| --- | --- | --- |
| GET | `/runs/{run_id}/items` | 分页查看批次明细 |
| GET | `/states` | 按月份、状态、发票号筛选最新状态 |
| GET | `/states/{invoice_no}` | 查看单票最近状态和历史批次 |
| 缺件文件总数 | `status=missing` 的单文件结果数量 | A 票缺报关单和提单,计 2 |
| 缺件 `invoice` 数 | 存在至少一条缺件单文件结果的去重 `invoice` 数 | A 票缺 2 件,仍只计 1 |
| 已归档数 | `status=archived` 的单文件结果数量 | 每个成功文件计 1 |
| 已跳过数 | `status=skipped` 的单文件结果数量 | 跳过的是文件规则结果,不是笼统批次状态 |
| 技术失败数 | `status=technical_error` 的单文件结果数量 | 不计入缺件 |
一期若不开发独立记录页面,工作台 API 可先实现供对话/后续页面使用。
聚合器应输出:
### 12.4 Tool 错误码
1. **批次总览**:主体总数、规则数、已归档数、已跳过数、技术失败数、缺件文件总数、缺件 `invoice` 数。
2. **按文件类型汇总**:文件类型、缺件文件数、涉及 `invoice` 数、缺失占比。
3. **按 `invoice` 汇总**:`invoice`、缺件文件数、缺失文件列表、通知状态、未发送原因。
| error_code | HTTP | 含义 |
| --- | --- | --- |
| `voucher_check_config_invalid` | 400 | 目录模板或文件规则非法 |
| `voucher_check_invoice_required` | 400 | single 模式缺发票号 |
| `voucher_check_invoice_not_in_period` | 404 | 指定发票不在当前月 ERP 集合 |
| `voucher_check_share_unavailable` | 503 | 共享盘不可用 |
| `voucher_check_erp_unavailable` | 503 | Oracle 不可用 |
| `voucher_check_run_not_found` | 404 | 批次不存在 |
### 6.2 通知聚合
标准工作台 API 对应使用 `VOUCHER_CHECK.*` 错误码;新增码时同步四语言 `errors.json`。
通知以 `run_id` 聚合:一个检核批次仅生成一条企业微信汇总消息,展示业务方、检核月份、批次号、主体总数、缺件文件总数、缺件 `invoice` 数和主要缺失文件类型,并提供该批 Excel 下载入口。消息正文不得逐票展开全部 `invoice` 或缺失文件;完整清单由 Excel 和执行记录承载。未配置接收人时不发送空消息,保存未发送原因。技术失败进入独立运维告警,不混入缺件通知。
### 12.5 Dify 意图映射
### 6.3 检核任务列表
| 用户意图 | Tool 调用 |
检核任务列表以 `voucher_check_runs` 的批次统计快照为数据源,不在列表查询时重新汇总单文件结果。支持按 `period_month`、`profile_code` 和批次状态筛选,按执行时间倒序分页。
| 列/操作 | 数据来源或行为 |
| --- | --- |
| 执行今日检核 | start,`mode=incremental` |
| 重新检核当月全部 | start,`mode=force_all` |
| 检核发票 xxx | start,`mode=single`、`invoice_no=xxx` |
| 查询最新结果 | latest-run |
| 查询缺资料发票 | voucher missing Tool |
| 查询批次 xxx | run detail |
| 批次号、业务方、资料所属期间、执行时间 | `voucher_check_runs` |
| 主体总数、已归档数、缺件文件数、缺件 `invoice` 数 | 批次结束时固化的统计快照 |
| 状态 | `completed`、`missing`、`technical_failed`、`draft` 的前端业务映射 |
| 查看详情 | 携带 `run_id` 跳转执行记录;详情读取 `voucher_check_file_results` |
| 通知附件 | 通过该批次的 Excel 文件标识进入企业微信通知附件 Excel 预览或下载 |
Dify 只负责识别上述意图和解释结构化结果,禁止自行判断文件是否齐全。
## 7. 企业微信通知附件 Excel 设计
## 13. 进度卡设计
每个批次生成 `voucher_check_{profile}_{period}_{run_no}.xlsx`,作为该批次**企业微信汇总通知的附件/下载文件**。该 Excel 仅包含一张 `检核结果` 工作表,便于业务人员逐票查看资料是否缺失。
现有通用进度卡固定显示“合格/不合格/人工判定”。本域需要显示“齐全/缺资料”,建议增加可选领域指标:
| 列类别 | 列名/生成规则 | 值与计算规则 |
| --- | --- | --- |
| 报表顶部元信息 | `资料所属期间`、`执行时间` | 前者为用户选择的业务检核月份,后者为批次实际执行完成时间;二者不得混用 |
| 固定列 | `invoice` | 从主体记录取得 |
| 动态文件列 | `{文件规则名称}` | 每个已发布必检文件规则生成一列;`有`=该规则已归档,`缺件`=至少一条该规则结果缺件,`未检核`=技术失败或跳过 |
| 固定结论列 | `状态` | 所有动态文件列为`有` → `完整`;任一列为`缺件` → `缺件`;否则 → `待处理` |
```json
{
"progress_metrics": [
{"key": "total", "label_key": "chat.voucherCheck.total", "value": 112},
{"key": "scan", "label_key": "chat.voucherCheck.scanned", "value": 92},
{"key": "skip", "label_key": "chat.voucherCheck.skipped", "value": 20},
{"key": "complete", "label_key": "chat.voucherCheck.complete", "value": 80},
{"key": "missing", "label_key": "chat.voucherCheck.missing", "value": 12}
]
}
```
销售一期导出列为:`invoice`、`PO订单`、`报关资料`、`销货放行申请单`、`发票`、`报关单`、`提单`、`状态`。`资料所属期间`和`执行时间`置于报表顶部,不作为逐票重复列。
前端 `ToolRunProgressCard.vue`:存在 `progress_metrics` 时按服务端顺序渲染;不存在时保持原文件检核八格布局,避免影响 RoHS/MSDS。新增文案同步四语言。
统计聚合仍在批次记录和企业微信消息中保存“缺件文件总数”“缺件 `invoice` 数”等指标,但不要求在下载 Excel 中额外生成汇总/明细工作表。
## 14. 并发、幂等与恢复
## 8. 失败处理与安全
- 启动时继续按 `schedule_task_id` 检查 running 批次。
- runner 再使用 `task_id + period + mode` 计算 advisory lock,防止 Cron 与会话同时进入。
- `voucher_check_run_items` 唯一键保证同一批次单票不重复。
- 状态 upsert 只接受本批事务内结果。
- worker 崩溃留下的 running 批次由现有超时回收机制标记失败。
- 手动重试创建新 `ScheduleRun`,不复用失败批次,保证审计链完整。
| 场景 | 处理 |
| --- | --- |
| 文件未找到 | 写入缺件;纳入 Excel 汇总与批次级企业微信汇总通知 |
| OA 关联字段不完整 | 直接丢弃;不打印、不归档、不写字段异常或缺件 |
| 查询、登录、打印、下载、复制异常 | 写入技术失败;不计为缺件,发送独立告警 |
| 批次级依赖不可用 | 标记批次失败;禁止将空结果批量判为缺件 |
| 接收人未配置 | 不发送空通知;记录未发送原因并在 Excel 显示 |
## 15. 安全与审计
路径、账号、密码、Token 和外部系统地址必须来自受控配置或环境变量,不得进入 Profile 导出、日志、Excel 或错误响应。
- Oracle 账号必须只读。
- CIFS 挂载优先只读;若现网 CIFS `ro` 有兼容问题,容器 bind 仍必须 `:ro`。
- 不把文件内容上传 MinIO、Dify 或知识库。
- 日志不得记录密码、完整 UNC 凭据或文件内容。
- 文件路径对普通用户只返回业务相对路径。
- 每次手动触发记录 `trigger_type`、触发用户、会话和批次绑定。
- 默认关闭 `kb_sync_enabled`,因为本域不需要把财务文件或报告自动进入知识库。
## 9. 实施顺序
## 16. 部署设计
1. 建立 Profile、文件规则、批次、单文件结果和通知审计模型,并提供销售 Profile 配置。
2. 实现通用期间计算、增量决策、归档器、统计聚合器和 Excel 生成器。
3. 接入销售主体、OA 销货放行申请单、ERP PO 和目录扫描 Adapter;路径/ERP 条件确认后发布。
4. 接入企业微信通知和执行记录工作台。
5. 采购通过新增 Profile 和 Adapter 参数接入;新来源系统再新增 Adapter。
### 16.1 Docker Compose 影响
## 10. 验收重点
以下服务必须注入相同环境变量并挂载同一个只读目录:
- `hxops-backend`
- `hxops-schedule-worker`
示意:
```yaml
environment:
- VOUCHER_CHECK_LOCAL_ROOT=${VOUCHER_CHECK_LOCAL_ROOT:-}
volumes:
- /mnt/hxops-voucher-check-test:/mnt/hxops-voucher-check-test:ro
- /mnt/hxops-voucher-check-prod:/mnt/hxops-voucher-check-prod:ro
```
### 16.2 挂载流程
1. 宿主机使用专用只读 SMB 账号挂载 `ai_file` 或 `vouche`。
2. bind 到环境独立目录。
3. 在共享根创建健康标记文件。
4. recreate backend 和 schedule-worker。
5. 两个容器分别验证根目录、健康标记和当前月目录。
### 16.3 健康检查
部署验收必须包含:
```bash
docker exec hxops-backend test -f /mnt/hxops-voucher-check-test/.hxops-share-ready
docker exec hxops-schedule-worker test -f /mnt/hxops-voucher-check-test/.hxops-share-ready
```
实际路径按环境替换。
## 17. 测试设计
### 17.1 单元测试
- 当前自然月起止时间计算。
- 目录模板占位符校验和路径逃逸阻断。
- 文件名候选精确匹配、大小写配置。
- 文件存在但 0 字节仍为齐全。
- 子目录中的同名文件不算命中。
- 元数据指纹稳定性和变化检测。
- complete/missing/skipped 增量决策。
- 缺资料不计入 `failed_count`。
- 同票同日通知节流。
### 17.2 Repository 测试
- Oracle SQL 使用绑定参数。
- `apa08` trim、distinct、空值过滤。
- Oracle 连接失败映射为 `VOUCHER_CHECK.ERP_UNAVAILABLE`。
- 状态表 upsert 与批次明细唯一约束。
- 阶段 A 失败时不产生状态写入。
### 17.3 集成测试
- 临时共享目录模拟齐全、缺目录、缺文件和目录变化。
- 健康标记缺失导致整批失败。
- 当前月无 ERP 数据时空成功。
- single 模式发票不在当前月时返回 404。
- force_all 忽略历史指纹。
- 进度摘要、Excel 和批次明细计数一致。
- Chat Tool 启动后可通过 `for-log` 找到批次。
### 17.4 部署验收
- backend 与 schedule-worker 均可访问共享盘。
- Oracle Client 和 HXJM 只读连接可用。
- Cron 在 `Asia/Shanghai` 每日 06:00 触发。
- 共享盘断开后批次失败且不产生批量缺件。
- 缺资料通知发送到固定接收人并同日去重。
## 18. 实施顺序
1. 新增模型与 Alembic 迁移。
3. 实现配置、Oracle Repository、扫描器和指纹。
4. 实现两阶段 runner 与平台 Job 注册。
5. 扩展通用启动 Tool 的 `run_options` 透传。
6. 实现领域查询 Tool、工作台 API 和 Excel 表头。
7. 实现领域通知与通用通知去重开关。
8. 扩展进度卡领域指标并补齐四语言。
9. 修改 Compose、环境变量和挂载文档。
10. 完成单元、集成和部署验收后启用 Cron。
## 19. 研发评审检查点
- [ ] 本期 SQL 未增加红冲、取消、作废状态过滤;后续扩展须通过评审后的配置和字段白名单实现。
- [x] 必检材料暂定「核价单.pdf」「采购单.pdf」(可配置)。
- [ ] 共享根健康标记方案已由运维接受(当前共享盘尚未挂载)。
- [x] 缺资料业务结果不进入技术失败计数。
- [x] 共享盘不可用不会写单票 missing。
- [x] 两阶段事务保证批次级失败不污染最新状态。
- [x] backend 和 schedule-worker Compose 已增加只读挂载位(宿主机需完成 CIFS)。
- [x] 新表已配套 Alembic 迁移。
- [x] 新错误码和进度文案已补齐四语言。
- [x] 财务文件内容不会进入日志、MinIO、Dify 或知识库。
## 20. 待完成
- [ ] **Dify Chatflow 编排**:见草稿 [dify-chatflow-draft.md](dify-chatflow-draft.md);意图映射到 Tool 后改状态为已落地。
- [ ] 运维完成共享盘 CIFS → `VOUCHER_CHECK_LOCAL_ROOT`,并放置 `.hxops-share-ready`(验收清单 [ops-checklist.md](ops-checklist.md))。
- [ ] 配置 `VOUCHER_CHECK_ERP_*` 与排程接收人 `notify_user_ids_json`。
- 一次批次中多个 `invoice` 缺件、且单个 `invoice` 缺多个文件时,两个缺件指标均正确。
- Excel 报告以“资料所属期间”筛选,顶部单独展示“执行时间”;每个 `invoice` 一行,动态文件列与 Profile 必检规则一致;所有文件列均为“有”时状态为“完整”。
- 企业微信每批发送一条汇总通知并提供 Excel 下载入口;完整 `invoice` 明细仅在 Excel 和执行记录中查看。
- 周度任务仅处理上一个自然月;增量、强制重检和跨年期间计算正确。
- 新增采购或其它业务方无需修改通用检核、汇总、Excel 和通知逻辑。
@@ -1,4 +1,6 @@
# 立账凭证检核 — 完整文档
# 立账凭证检核 — 历史方案归档
> **已废弃**:本文记录旧版“当前自然月 + 单一共享盘 + 固定文件名”的实现方案,不再作为需求或技术设计依据。当前业务需求见 [demand.md](demand.md),新版技术设计见 [technical-design.md](technical-design.md)。
> **维护说明**:本文件为立账凭证检核域的权威手册,分为“业务需求”和“实现规格”两部分。本文明确一期的业务边界、数据口径、目录规则、判定规则、失败处理和验收要求;Chatflow / Tool API 的接口细节待正式开发时补充。
>
@@ -0,0 +1,81 @@
# 合同付款预警待办清单
> 用途:记录合同付款预警当前需求与代码之间的未完成事项。后续开发优先按本清单补齐,并在完成后更新状态、验收结果和关联文件。
>
> 依据:`demand.md` V1.2,以及当前后端、前端和测试实现核对结果。
## 一、P0:必须优先补齐
| 状态 | 待办事项 | 当前问题 | 完成标准 |
| --- | --- | --- | --- |
| [ ] | 将预警扫描与企业微信发送解耦 | 当前扫描时直接发送单条消息 | 每日扫描只生成 `pending` 预警记录,不直接发送 |
| [ ] | 实现每周五 18:00 汇总发送 | 当前没有周汇总发送逻辑 | 仅周五 18:00 执行发送;无待发送事项时不发送 |
| [ ] | 按收件岗位聚合预警 | 当前一条预警对应一条企业微信消息 | 同一收件人在同一周期只收到一条汇总消息 |
| [ ] | 生成企业微信 Excel 明细 | 当前没有付款预警 Excel 生成能力 | 每个收件岗位生成对应明细 Excel,并作为附件发送 |
| [ ] | 保存汇总批次和附件审计 | 当前仅有单条预警发送记录 | 可追溯汇总批次、收件人、发送时间、Excel 文件和发送结果 |
| [ ] | 补齐周汇总调度任务 | 当前只有同步和预警扫描任务 | 新增周汇总 Job,并配置为周五 18:00 执行 |
## 二、P1:核心业务闭环
| 状态 | 待办事项 | 当前问题 | 完成标准 |
| --- | --- | --- | --- |
| [ ] | 完成 OA 厂商预付款请款作业真实联调 | 当前依赖可配置 URL 和通用 JSON 解析,未完成真实页面/接口联调 | 能稳定获取请求 ID、合同号、采购单号、付款阶段、流程状态和申请时间 |
| [ ] | 明确“已请款”流程状态口径 | 当前存在记录即停止提醒,业务状态尚未最终确认 | 按业务确认的发起/审批通过等状态执行,并保留原始状态 |
| [ ] | 完善 OA 增量同步 | 当前未形成明确的时间窗口、分页和游标机制 | 重复运行不重复入库,新增和状态变化可被增量同步 |
| [ ] | 完善验收归档节点处理 | 当前主要更新已有验收款/质保款节点 | 验收事件先到、节点后生成时仍能正确建立和计算节点 |
| [ ] | 完善缺失事实和冲突处理 | 部分逻辑已有 `needs_review`,但展示和状态链路不完整 | 缺交货日、验收日、质保期或字段冲突时不生成不可靠预警,并进入待复核 |
| [ ] | 保证请款后只停止未发送轮次 | 现有逻辑需要结合汇总发送状态重新验证 | 已发送记录保留,后续未发送轮次停止且可审计 |
## 三、P1:工作台和权限
| 状态 | 待办事项 | 当前问题 | 完成标准 |
| --- | --- | --- | --- |
| [ ] | 增加合同付款专项权限校验 | 当前主要是登录校验,未体现专项权限 | 无合同付款预警权限的用户不能查看、同步或触发扫描 |
| [ ] | 补齐工作台字段 | 当前缺少金额/比例、逾期天数、收件岗位、汇总批次等 | 满足需求文档 8.1、8.2 的展示字段 |
| [ ] | 增加本周待发送和下次发送时间 | 当前页面没有真实周汇总状态 | 展示本周待发送笔数和下一次周五 18:00 发送时间 |
| [ ] | 增加异常待处理视图 | 当前异常状态未形成独立处理入口 | 可查看缺字段、关联失败、收件人未配置、发送失败等异常 |
| [ ] | 增加 Excel 下载和汇总记录查看 | 当前无对应 API | 管理员可查看历史汇总并下载附件 |
## 四、P2:可靠性和运维
| 状态 | 待办事项 | 当前问题 | 完成标准 |
| --- | --- | --- | --- |
| [ ] | 增加发送失败重试 | 当前失败记录可保存,但缺少完整重试流程 | 失败可重试,且不造成重复发送 |
| [ ] | 增加 OA、企微和文件生成失败审计 | 当前主要依赖日志和单表字段 | 工作台可查看失败原因、时间和重试状态 |
| [ ] | 统一旧方案文档规则 | `proposal-v3.md` 仍有旧的提前 14 天等描述 | 方案文档与 `demand.md` 的最新规则完全一致 |
| [ ] | 增加配置诊断和上线检查 | 当前配置缺失时主要记录日志 | 可明确显示 OA、收件人、企微和存储配置是否完整 |
| [ ] | 处理节假日发送策略 | 需求尚未明确周五遇节假日的处理方式 | 业务确认后实现原日发送或顺延策略 |
## 五、测试补齐清单
| 状态 | 测试范围 | 必测场景 |
| --- | --- | --- |
| [ ] | 日期规则 | 四阶段三轮日期、自然日计算、逾期补发 |
| [ ] | 扫描幂等 | 同日重复扫描不重复生成预警 |
| [ ] | 请款停止 | 请款同步后仅停止未发送轮次,历史记录保留 |
| [ ] | 收件人升级 | 第一、二、三轮分别使用采购负责人、采购部负责人、采购分管领导 |
| [ ] | 周汇总 | 周一至周四只生成待发送记录,周五 18:00 才发送 |
| [ ] | 收件人聚合 | 同一收件人多笔事项只发送一条消息 |
| [ ] | Excel | 字段完整、按逾期优先排序、不同收件人数据隔离 |
| [ ] | 空汇总 | 无待发送事项时不发送消息和空 Excel |
| [ ] | 失败重试 | OA、Excel、企微发送失败可审计并安全重试 |
| [ ] | 权限 | 无权限用户不能查询或触发合同付款任务 |
## 六、业务确认项
| 状态 | 编号 | 待确认事项 |
| --- | --- | --- |
| [ ] | Q-01 | OA 厂商预付款请款作业的真实列表/接口和字段名 |
| [ ] | Q-02 | 付款阶段字段如何区分预付款与出货款 |
| [ ] | Q-03 | 哪些流程状态视为“已请款” |
| [ ] | Q-04 | 采购部负责人和采购分管领导的岗位用户映射维护方式 |
| [ ] | Q-05 | 企业微信消息类型、附件发送方式和跳转权限 |
| [ ] | Q-06 | Excel 和附件的存储位置、保留期限 |
| [ ] | Q-07 | 周五 18:00 遇节假日时是否顺延 |
## 七、完成记录
| 日期 | 完成事项 | 关联文件 | 验证结果 |
| --- | --- | --- | --- |
| | | | |
+1 -1
View File
@@ -175,7 +175,7 @@
| 功能项 | 状态 | 说明 |
| --- | --- | --- |
| 需求、规格与技术设计 | 已文档化 | [需求规格](features/accounting-voucher-check/technical.md) · [技术设计](features/accounting-voucher-check/technical-design.md);当前自然月从 ERP `apa_file` 取 `apa08`/`apa09`,仅处理 HXJM 套账 |
| 需求、规格与技术设计 | 需求更新中 | [需求说明](features/accounting-voucher-check/demand.md) · [技术设计](features/accounting-voucher-check/technical-design.md);销售一期每周增量检核上月,按 Profile 从 ERP、OA、目录等来源获取并归档资料,采购二期待配置 |
| 共享盘文件存在性检核 | 已实现 | platform Job `accounting-voucher-check`;默认 `vouche/{YYYY}/{MM}/{invoice_no}/`;暂定必检「核价单.pdf」「采购单.pdf」;不读内容、不用 LLM |
| 增量批次与异常告警 | 已实现 | 齐全且目录元数据指纹未变更可跳过;共享盘不可用整批失败并告警;缺资料企微 textcard(同票同日节流) |
| 日批排程 | 已实现 | 预置 `SCH-ACCOUNTING-VOUCHER-CHECK`,Cron `0 6 * * *`(Asia/Shanghai) |
+1 -1
View File
@@ -188,7 +188,7 @@ PDF 证据锚定优先使用现有 `pypdfium2` 逐字文本坐标定位,并由
- 共享盘默认路径为 `vouche/{YYYY}/{MM}/{invoice_no}/`,通过目录模板配置支持调整;必检文件名通过配置维护。
- 扫描器只读取目录和文件元数据判断文件是否存在,不读取内容、不调用 LLM;齐全票可基于元数据指纹增量跳过。
- 共享盘不可用时批次失败并告警,不生成缺资料结论;单票缺目录或缺必检文件才记缺资料。
- 详细业务规格见 [docs/features/accounting-voucher-check/technical.md](features/accounting-voucher-check/technical.md),研发落地设计见 [docs/features/accounting-voucher-check/technical-design.md](features/accounting-voucher-check/technical-design.md)。
- 详细业务需求见 [docs/features/accounting-voucher-check/demand.md](features/accounting-voucher-check/demand.md),研发落地设计见 [docs/features/accounting-voucher-check/technical-design.md](features/accounting-voucher-check/technical-design.md)。
### 2.x 货代发货通知批次库存能力