fix: 模拟生成PDF

This commit is contained in:
sophie committed 2026-09-10 10:18:44 +08:00
1 parent c4a27324c8
commit 204e71b786
19 files changed
+2064 -110

No files matched your search

@@ -5,7 +5,7 @@
| **需求说明** | 产品、业务、测试 | [demand.md](demand.md) |
| **技术设计** | 研发 | [technical-design.md](technical-design.md) |
| **技术规格** | 研发、测试 | [technical.md](technical.md) |
| **原型** | 产品、业务、测试 | [accounting-voucher-check-prototype.html](accounting-voucher-check-prototype.html) · [说明](accounting-voucher-check-prototype.md) |
| **原型** | 产品、业务、测试 | [accounting-voucher-check-prototype.html](accounting-voucher-check-prototype.html) · [说明](accounting-voucher-check-prototype.md) · [最近一次检核卡片](accounting-voucher-check-latest-run-prototype.html) |
| **部署验收清单** | 运维、研发 | [ops-checklist.md](ops-checklist.md) |
**定位**:以业务方 Profile 驱动的批量资料检核;**每周二**增量处理上一个自然月。销售开票附件先落入文档库类型目录,再按 `invoice` 归入「所有归档」。
@@ -0,0 +1,409 @@
<!doctype html>
<!--
docs/features/accounting-voucher-check/accounting-voucher-check-latest-run-prototype.html
用途:立账凭证工作台「最近一次检核」卡片原型(Tab 下方、筛选栏上方)。
依赖:浏览器原生 HTML/CSS/JS,无需构建。
逻辑:默认展示最近一批终态;点「强制重检上月」切入执行中进度;原型预览可切换完成/执行中/失败。
-->
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>立账凭证 · 最近一次检核原型</title>
<style>
:root {
--ink: #142033;
--muted: #64748b;
--line: #e2e8f0;
--bg: #f4f7fb;
--panel: #fff;
--brand: #2563eb;
--brand-soft: #eff6ff;
--red: #b42318;
--green: #067647;
--amber: #b54708;
}
* { 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; }
.page { width: min(1120px, calc(100% - 32px)); margin: 24px auto 48px; }
.proto-note {
margin-bottom: 16px;
padding: 10px 12px;
border: 1px dashed #bfdbfe;
border-radius: 10px;
background: #f8fbff;
color: #334155;
font-size: 12px;
}
.proto-note b { color: var(--brand); }
.proto-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
header h1 { margin: 0; font-size: 24px; }
header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; margin: 18px 0 0; border-bottom: 1px solid var(--line); }
.tabs button {
border: 0;
border-bottom: 2px solid transparent;
margin-bottom: -1px;
padding: 10px 16px;
color: var(--muted);
background: transparent;
font-weight: 600;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.filters {
display: flex;
flex-wrap: wrap;
align-items: flex-end;
gap: 12px;
margin: 14px 0;
padding: 12px 16px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
}
.filters label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.filters select {
min-width: 76px;
padding: 6px 10px;
border: 1px solid var(--line);
border-radius: 12px;
background: #fff;
}
.btn {
display: inline-flex;
align-items: center;
gap: 6px;
border: 1px solid var(--line);
border-radius: 12px;
padding: 7px 12px;
background: #fff;
font-size: 13px;
font-weight: 650;
}
.btn.primary { border-color: var(--brand); color: #fff; background: var(--brand); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.latest {
overflow: hidden;
margin-top: 16px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
}
.latest-actions { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }
.btn.warn { border-color: #fcd34d; color: #92400e; background: #fffbeb; }
.latest-hd {
display: flex;
justify-content: space-between;
gap: 12px;
align-items: flex-start;
padding: 14px 16px 12px;
background: var(--brand-soft);
}
.latest-hd h2 { margin: 0; font-size: 15px; }
.latest-meta { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.latest-meta span { margin-right: 12px; }
.badge {
display: inline-flex;
padding: 3px 10px;
border-radius: 99px;
font-size: 12px;
font-weight: 750;
white-space: nowrap;
}
.badge.ok { color: var(--green); background: #ecfdf3; }
.badge.miss { color: var(--red); background: #fff1f2; }
.badge.run { color: #175cd3; background: #dbeafe; }
.badge.fail { color: var(--red); background: #fff1f2; }
.latest-bd { padding: 14px 16px 16px; }
.bar { height: 10px; overflow: hidden; border-radius: 99px; background: #e8eef5; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: #0f766e; transition: width .35s ease; }
.bar.fail i { background: #e11d48; }
.bar-row { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0 14px; color: var(--muted); font-size: 12px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.metric {
padding: 12px 10px;
border: 1px solid var(--line);
border-radius: 10px;
background: #f8fafc;
}
.metric b { display: block; font-size: 22px; line-height: 1.2; }
.metric span { color: var(--muted); font-size: 12px; }
.metric.warn b { color: var(--red); }
.step-line { margin: 12px 0 0; color: #334155; font-size: 13px; }
.step-line small { display: block; margin-top: 2px; color: var(--muted); }
.latest-ft { display: flex; justify-content: flex-end; margin-top: 12px; }
.link { border: 0; padding: 0; color: #175cd3; background: transparent; font-weight: 700; }
.table-wrap {
overflow: auto;
margin-top: 14px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 14px; border-bottom: 1px solid #eef2f6; text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f8fafc; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-flex; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.pill.miss { color: var(--red); background: #fff1f2; }
.pill.fail { color: #475569; background: #f1f5f9; }
.err { max-width: 240px; overflow: hidden; color: var(--red); text-overflow: ellipsis; }
.toast {
position: fixed; right: 18px; bottom: 18px;
padding: 10px 12px; border-radius: 9px; color: #fff; background: #142036;
opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; }
@media (max-width: 820px) {
.metrics { grid-template-columns: 1fr 1fr; }
.btn.warn { margin-left: 0; }
}
</style>
</head>
<body>
<div class="page">
<div class="proto-note">
这是<strong>原型</strong>,不是工作台代码。最近一次检核放在 Tab 下方、筛选栏上方:它是整页状态,不跟着年/月过滤。强制重检放在卡片上,点击后进度就在本卡更新。
<div class="proto-actions">
预览状态:
<button class="btn" type="button" data-preview="done">完成 · 缺件</button>
<button class="btn" type="button" data-preview="running">执行中</button>
<button class="btn" type="button" data-preview="failed">技术失败</button>
</div>
</div>
<header>
<h1>立账凭证检核任务</h1>
<p>每周二增量检核上一个自然月;扫描销售开票附件类型目录后按 invoice 归档,并汇总缺件。</p>
</header>
<nav class="tabs">
<button class="active" type="button">检核任务</button>
<button type="button" disabled>企微发送记录</button>
</nav>
<article class="latest" id="latest" aria-live="polite"></article>
<section class="filters">
<label>资料所属期间
<span>
<select><option>2026</option></select>
<select><option>8月</option><option>全部</option></select>
</span>
</label>
<label>状态
<select><option>全部</option><option>缺件</option><option>完整</option><option>技术失败</option></select>
</label>
<button class="btn primary" type="button">查询</button>
</section>
<section class="table-wrap">
<table>
<thead>
<tr>
<th>批次号</th>
<th>资料所属期间</th>
<th>invoice总数</th>
<th>invoice缺件数</th>
<th>缺件文件数</th>
<th>状态</th>
<th>执行时间</th>
<th>失败原因</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><b>RUN2026090801480719A3</b></td>
<td>2026-08</td>
<td>128</td>
<td>6</td>
<td>11</td>
<td><span class="pill miss">缺件</span></td>
<td>2026-09-08 09:50:19</td>
<td>—</td>
<td><button class="link" type="button">查看详情</button></td>
</tr>
<tr>
<td>RUN202609070831512538</td>
<td>2026-08</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td><span class="pill fail">技术失败</span></td>
<td>2026-09-07 16:32:10</td>
<td class="err">未配置销售开票附件文档库根目录</td>
<td><button class="link" type="button">查看详情</button></td>
</tr>
</tbody>
</table>
</section>
</div>
<div class="toast" id="toast"></div>
<script>
/**
* 原型状态机:完成 / 执行中 / 失败。强制重检走一套示意步骤,不请求后端。
*/
(() => {
const latestEl = document.getElementById("latest");
const toastEl = document.getElementById("toast");
let timer = null;
let busy = false;
const snapshots = {
done: {
title: "最近一次检核",
runNo: "RUN2026090801480719A3",
period: "2026-08",
mode: "增量",
status: "缺件",
statusClass: "miss",
barClass: "",
percent: 100,
started: "2026-09-08 09:48:07",
finished: "2026-09-08 09:50:19",
step: "本批已完成,缺件结果已写入 Excel。",
hint: "",
metrics: [128, 742, 11, 6],
},
running: {
title: "最近一次检核",
runNo: "RUN202609090605221C4B",
period: "2026-08",
mode: "全量重检",
status: "执行中",
statusClass: "run",
barClass: "",
percent: 42,
started: "2026-09-09 14:05:22",
finished: "进行中",
step: "扫描销售开票附件类型目录",
hint: "已处理 54 / 128 张 invoice",
metrics: [128, 310, 3, 2],
},
failed: {
title: "最近一次检核",
runNo: "RUN202609070831512538",
period: "2026-08",
mode: "增量",
status: "技术失败",
statusClass: "fail",
barClass: "fail",
percent: 18,
started: "2026-09-07 16:31:51",
finished: "2026-09-07 16:32:10",
step: "拉取上月销售 invoice 未完成",
hint: "未配置销售开票附件文档库根目录",
metrics: [0, 0, 0, 0],
},
};
const forceSteps = [
{ percent: 8, status: "排队中", step: "已入队强制重检上月", hint: "等待 schedule worker 领取", metrics: [0, 0, 0, 0] },
{ percent: 22, status: "执行中", step: "拉取上月销售 invoice", hint: "HXJM apa_file · 期间 2026-08", metrics: [128, 0, 0, 0] },
{ percent: 58, status: "执行中", step: "扫描销售开票附件类型目录", hint: "已处理 74 / 128 张 invoice", metrics: [128, 410, 5, 3] },
{ percent: 82, status: "执行中", step: "按 invoice 归档(同名跳过)", hint: "正在写入所有归档", metrics: [128, 690, 9, 5] },
{ percent: 100, status: "缺件", step: "本批已完成,缺件结果已写入 Excel。", hint: "", metrics: [128, 742, 11, 6], done: true },
];
function toast(message) {
toastEl.textContent = message;
toastEl.classList.add("show");
setTimeout(() => toastEl.classList.remove("show"), 2200);
}
function render(data) {
const warn = data.metrics[2] > 0 || data.metrics[3] > 0;
const labels = ["invoice总数", "已归档文件", "缺件文件数", "缺件 invoice 数"];
latestEl.innerHTML =
'<div class="latest-hd">' +
"<div><h2>" + data.title + "</h2>" +
'<p class="latest-meta"><span>批次 ' + data.runNo + "</span><span>期间 " + data.period + "</span><span>" + data.mode + "</span></p></div>" +
'<div class="latest-actions">' +
'<span class="badge ' + data.statusClass + '">' + data.status + "</span>" +
'<button class="btn warn" type="button" data-force="1"' + (busy ? " disabled" : "") + ">强制重检上月</button>" +
"</div>" +
"</div>" +
'<div class="latest-bd">' +
'<div class="bar ' + data.barClass + '"><i style="width:' + data.percent + '%"></i></div>' +
'<div class="bar-row"><span>进度 ' + data.percent + "%</span><span>开始:" + data.started + " 完成:" + data.finished + "</span></div>" +
'<div class="metrics">' +
data.metrics.map(function (value, index) {
const hot = warn && index > 1;
return '<div class="metric' + (hot ? " warn" : "") + '"><b>' + value + "</b><span>" + labels[index] + "</span></div>";
}).join("") +
"</div>" +
'<p class="step-line">' + data.step + (data.hint ? "<small>" + data.hint + "</small>" : "") + "</p>" +
(data.percent === 100 && data.statusClass !== "fail"
? '<div class="latest-ft"><button class="link" type="button">查看本批详情</button></div>'
: "") +
"</div>";
}
function show(key) {
if (timer) {
clearInterval(timer);
timer = null;
}
busy = false;
render(snapshots[key]);
}
function startForce() {
if (busy) return;
busy = true;
let index = 0;
const started = "2026-09-09 14:08:01";
const runNo = "RUN2026090906080119F2";
function paint() {
const step = forceSteps[index];
render({
title: "最近一次检核",
runNo: runNo,
period: "2026-08",
mode: "全量重检",
status: step.status,
statusClass: step.done ? "miss" : "run",
barClass: "",
percent: step.percent,
started: started,
finished: step.done ? "2026-09-09 14:10:26" : "进行中",
step: step.step,
hint: step.hint,
metrics: step.metrics,
});
if (step.done) {
clearInterval(timer);
timer = null;
busy = false;
toast("原型示意:强制重检已完成,列表稍后出现新批次。");
}
index += 1;
}
paint();
timer = setInterval(function () {
if (index >= forceSteps.length) return;
paint();
}, 900);
}
document.querySelectorAll("[data-preview]").forEach(function (button) {
button.addEventListener("click", function () {
show(button.getAttribute("data-preview"));
});
});
latestEl.addEventListener("click", function (event) {
if (event.target.closest("[data-force]")) startForce();
});
show("done");
})();
</script>
</body>
</html>
@@ -1,7 +1,7 @@
# 立账凭证资料检核需求说明
> 文档版本:v1.9
> 更新时间:2026-09-08
> 文档版本:v1.11
> 更新时间:2026-09-09
> 状态:一期销售需求确认中;采购及其它业务方待后续 Profile 配置
>
> 本文是本期需求权威。部署与冒烟见 [ops-checklist.md](ops-checklist.md)。旧共享盘存在性扫描、Chatflow Tool 与一票一状态表已移除,不得再按该口径扩展。
@@ -57,16 +57,17 @@
### 3.4 检核任务列表
检核任务列表是用户查看历史批次和进入详情的主入口。默认按最新批次展示,支持筛选后查看对应的执行明细、企业微信通知附件 Excel 和通知记录。
检核任务列表是用户查看历史批次和进入详情的主入口。默认展示**上一个自然月**的批次,支持把月份改为「全部」查看该年全部批次,再进入对应的执行明细、企业微信通知附件 Excel 和通知记录。
「最近一次检核」卡片放在 Tab 下方、筛选栏上方,只出现在「检核任务」Tab:展示**最近一批**(按执行时间,不跟年/月/状态筛选)的批次号、期间、模式、状态、进度、开始/完成时间、当前步骤,以及 invoice 总数 / 已归档 / 缺件文件 / 缺件 invoice。强制重检上月(仅管理员)放在这张卡片上,入队后进度在本卡更新。
| 区域 | 内容 |
| ------------ | ------------------------------------------------------------------------------------------------- |
| 顶部统计 | 当前筛选条件下的主体总数、已归档文件数、缺件文件数、缺件 `invoice` 数 |
| 筛选条件 | 资料所属期间、业务方、任务状态 |
| 任务列表字段 | 批次号、业务方、资料所属期间、执行时间、主体总数、已归档数、缺件文件数、缺件 `invoice` 数、状态 |
| 状态 | 缺件、已完成、技术失败、待配置 |
| 最近一次检核 | 最近一批进度与四指标;强制重检上月(全量 `force_all`,期间固定上一个自然月,不用筛选栏期间) |
| 筛选条件 | 资料所属期间(年必选、月可选「全部」;进页默认上一个自然月)、任务状态 |
| 任务列表字段 | 批次号、资料所属期间、执行时间、主体总数、缺件文件数、缺件 `invoice` 数、状态、失败原因 |
| 状态 | 排队中、执行中、缺件、完整、技术失败 |
| 操作 | 查看详情;进入该批次的执行记录,并可查看企业微信通知附件 Excel |
| 任务入口 | 支持新建任务、强制重检(仅上一个月);企微接收人从系统用户多选,可复用排程通知人选择器 |
### 3.5 企业微信发送记录
@@ -74,7 +75,7 @@
| 区域 | 内容 |
| -------- | --------------------------------------------------------------------------------------------- |
| 筛选条件 | 资料所属期间、发送状态 |
| 筛选条件 | 资料所属期间(与检核任务同一套年/月口径)、发送状态 |
| 列表字段 | 批次号、资料所属期间、invoice 总数、invoice 缺件数、缺件文件数、发送状态、未发送原因、接收人、发送时间、Excel |
| 操作 | 有附件时可下载该批 Excel;查看详情进入对应批次明细 |
@@ -0,0 +1,305 @@
"""
docs/features/accounting-voucher-check/hxops-po-sample.py
用途:用 ERP 打印件同款模拟数据生成「HXOPS 制式采购单」样张,供与 apmr900 对照。
依赖:reportlab、Windows 宋体、welltrust-logo.png(从原件抽出的页眉 Logo)。
逻辑:独立脚本,不接入周检核;数据写死自 采购单.pdf;不贴「无」图。
"""
from __future__ import annotations
from pathlib import Path
from reportlab.lib.colors import HexColor
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen import canvas
FONT = "SimSun"
FONT_PATH = Path(r"C:\Windows\Fonts\simsun.ttc")
LOGO_PATH = Path(__file__).resolve().parent / "welltrust-logo.png"
INK = HexColor("#111111")
LINE = HexColor("#333333")
SOFT = HexColor("#666666")
# 数据来自 e:\Work\Agent\立账凭证\采购单.pdf(apmr900 / Crystal Reports)
SAMPLE = {
"company_phone": "0512-63136988",
"company_fax": "",
"company_address": "江苏省苏州市吴江区经济开发区山湖西路789号",
"company_name": "苏州和信精密科技有限公司",
"maker": "梁春艳",
"page": "1/1",
"po_date": "2016/5/28",
"po_no": "5201-1605280003",
"po_type": "原料采购单",
"price_term": "A01 取核价单价",
"ship_address": "",
"pay_term": "月结一个月",
"tax_type": "进项(17%含税)",
"currency": "RMB",
"bill_address": "",
"vendor_name": "北川科技(苏州)有限公司",
"vendor_code": "VCCD00013",
"vendor_tel": "0512-62810369",
"vendor_fax": "0512-62810368",
"vendor_addr": "苏州市工业园区胜浦分区银胜路61号",
"untax_total": "4,455.50",
"tax_total": "5,212.94",
"lines": [
{
"item_no": "3450541801",
"seq": "1",
"qty": "730",
"unit": "PCS",
"arrive": "2016/6/16",
"untax_price": "3.350000",
"untax_amt": "2,445.50",
"halogen": "RoHS",
"name": "FRAME CUBE CORNER",
"spec": "H20*W36.5*L36.7",
"tax_price": "3.919500",
"tax_amt": "2,861.24",
"origin_no": "3301-1605260004",
"version": "-0001",
"vendor_item": "3450541801",
},
{
"item_no": "3450541801",
"seq": "2",
"qty": "600",
"unit": "PCS",
"arrive": "2016/6/16",
"untax_price": "3.350000",
"untax_amt": "2,010.00",
"halogen": "RoHS",
"name": "FRAME CUBE CORNER",
"spec": "H20*W36.5*L36.7",
"tax_price": "3.919500",
"tax_amt": "2,351.70",
"origin_no": "3301-1605100007",
"version": "-0001",
"vendor_item": "3450541801",
},
],
}
def _register_font() -> None:
"""注册宋体,接近鼎捷报表常用中文字形。"""
pdfmetrics.registerFont(TTFont(FONT, str(FONT_PATH), subfontIndex=0))
def _text(c: canvas.Canvas, x: float, y: float, text: str, size: float = 9, color=INK) -> None:
c.setFillColor(color)
c.setFont(FONT, size)
c.drawString(x, y, text)
def _right(c: canvas.Canvas, x: float, y: float, text: str, size: float = 8, color=INK) -> None:
"""右对齐文字,用于数量和金额。"""
c.setFillColor(color)
c.setFont(FONT, size)
c.drawRightString(x, y, text)
def _hline(c: canvas.Canvas, x1: float, x2: float, y: float, width: float = 0.4) -> None:
c.setStrokeColor(LINE)
c.setLineWidth(width)
c.line(x1, y, x2, y)
def _rect(c: canvas.Canvas, x: float, y: float, w: float, h: float, fill=None) -> None:
c.setStrokeColor(LINE)
c.setLineWidth(0.5)
if fill is not None:
c.setFillColor(fill)
c.rect(x, y, w, h, stroke=1, fill=1)
else:
c.rect(x, y, w, h, stroke=1, fill=0)
def build_pdf(out_path: Path) -> None:
"""
按 A4 竖版画出采购单样张。
核心逻辑:版心对齐原件 Crystal 报表的信息分区,不复制 Crystal 精确坐标。
"""
_register_font()
out_path.parent.mkdir(parents=True, exist_ok=True)
page_w, page_h = A4
c = canvas.Canvas(str(out_path), pagesize=A4)
c.setTitle("HXOPS 制式采购单样张")
c.setAuthor("HXOPS")
left = 16 * mm
right = page_w - 16 * mm
y = page_h - 10 * mm
# [STEP 1] Logo 在左;右侧公司名、「采购单」、地址、电话;制表者/页次单独下一行靠右。
logo_w = 52 * mm
logo_h = 14 * mm
logo_bottom = y - logo_h
if LOGO_PATH.exists():
c.drawImage(
str(LOGO_PATH),
left,
logo_bottom,
width=logo_w,
height=logo_h,
mask="auto",
preserveAspectRatio=True,
anchor="sw",
)
text_x = left + 56 * mm
block_mid = (text_x + right) / 2
c.setFont(FONT, 11)
c.setFillColor(INK)
c.drawCentredString(block_mid, y - 3.5 * mm, SAMPLE["company_name"])
c.setFont(FONT, 10)
c.drawCentredString(block_mid, y - 8.2 * mm, "采购单")
_text(c, text_x, y - 13 * mm, f"地址:{SAMPLE['company_address']}", 8)
_text(c, text_x, y - 17.5 * mm, f"公司电话:{SAMPLE['company_phone']} 公司传真:", 8)
_text(c, right - 52 * mm, y - 22.5 * mm, f"制表者: {SAMPLE['maker']}", 8)
c.setFont(FONT, 8)
c.drawRightString(right, y - 22.5 * mm, f"页次: {SAMPLE['page']}")
y = min(logo_bottom, y - 24 * mm) - 2 * mm
_hline(c, left, right, y, 0.8)
y -= 6 * mm
# [STEP 2] 原件左栏采购单号、右栏采购日期(与上一版左右对调)
col2 = left + 98 * mm
val1 = left + 22 * mm
val2 = col2 + 20 * mm
_text(c, left, y, "采购单号:")
_text(c, val1, y, f"{SAMPLE['po_no']} {SAMPLE['po_type']}")
_text(c, col2, y, "采购日期:")
_text(c, val2, y, SAMPLE["po_date"])
y -= 5.2 * mm
_text(c, left, y, "付款条件:")
_text(c, val1, y, SAMPLE["pay_term"])
_text(c, col2, y, "税 种:")
_text(c, val2, y, SAMPLE["tax_type"])
y -= 5.2 * mm
_text(c, left, y, "价格条件:")
_text(c, val1, y, SAMPLE["price_term"])
_text(c, col2, y, "币 种:")
_text(c, val2, y, SAMPLE["currency"])
y -= 5.2 * mm
_text(c, left, y, "送货地址:")
_text(c, val1, y, SAMPLE["ship_address"] or " ")
y -= 5.2 * mm
_text(c, left, y, "帐单地址:")
_text(c, val1, y, SAMPLE["bill_address"] or " ")
y -= 6 * mm
_text(c, left, y, "供应厂商:")
_text(c, val1, y, f"{SAMPLE['vendor_code']} {SAMPLE['vendor_name']}")
_text(c, left + 118 * mm, y, f"Tel: {SAMPLE['vendor_tel']}")
y -= 5 * mm
_text(c, val1, y, SAMPLE["vendor_addr"], 8)
_text(c, left + 118 * mm, y, f"Fax: {SAMPLE['vendor_fax']}")
y -= 4 * mm
_hline(c, left, right, y, 0.8)
y -= 1 * mm
# [STEP 4] 按 Crystal 原件:无满格单元格;表头三行折行;项次在最左。
x_seq = left
x_item = left + 8 * mm
x_origin = left + 50 * mm
x_arrive = left + 80 * mm
x_qty = left + 108 * mm
x_unit = left + 116 * mm
x_price = left + 142 * mm
x_amt = left + 164 * mm
x_halo = left + 168 * mm
header_h = 11 * mm
table_top = y
_hline(c, left, right, table_top, 0.7)
h1 = table_top - 3.6 * mm
h2 = table_top - 7.0 * mm
h3 = table_top - 10.2 * mm
_text(c, x_seq, h1, "项次", 7)
_text(c, x_item, h1, "料件编号", 7)
_text(c, x_item, h2, "品名/规格", 7)
_text(c, x_item, h3, "厂商料号额外品名规格说明", 6.5)
_text(c, x_origin, h1, "原始编号", 7)
_text(c, x_origin, h2, "版本", 7)
_text(c, x_origin, h3, "行序", 6.5)
_text(c, x_arrive, h1, "到货日", 7)
_text(c, x_qty - 8 * mm, h1, "数 量", 7)
_text(c, x_unit, h1, "单 位", 7)
_right(c, x_price, h1, "税前单价", 7)
_right(c, x_price, h2, "含税单价", 7)
_right(c, x_amt, h1, "税前金额", 7)
_right(c, x_amt, h2, "含税金额", 7)
_text(c, x_halo, h1, "卤素", 7)
_text(c, x_halo, h2, "管控", 7)
_text(c, x_halo + 10 * mm, h1, "环保", 7)
_text(c, x_halo + 10 * mm, h2, "等级", 7)
c.setStrokeColor(LINE)
c.setLineWidth(0.4)
c.line(x_price - 22 * mm, h2 - 1.2 * mm, x_price, h2 - 1.2 * mm)
c.line(x_amt - 22 * mm, h2 - 1.2 * mm, x_amt, h2 - 1.2 * mm)
y = table_top - header_h
_hline(c, left, right, y, 0.5)
# [STEP 5] 每笔三行:料号/品名/规格,无斑马底、无竖线格
row_h = 13 * mm
for line in SAMPLE["lines"]:
r1 = y - 3.8 * mm
r2 = y - 7.6 * mm
r3 = y - 11.2 * mm
_text(c, x_seq, r1, line["seq"], 8)
_text(c, x_item, r1, line["item_no"], 8)
_text(c, x_item, r2, line["name"], 8)
_text(c, x_item, r3, line["spec"], 8)
_text(c, x_origin, r1, line["vendor_item"], 8)
_text(c, x_origin, r2, line["origin_no"], 8)
_text(c, x_arrive, r1, line["arrive"], 8)
_right(c, x_qty, r1, line["qty"], 8)
_text(c, x_unit, r1, line["unit"], 8)
_right(c, x_price, r1, line["untax_price"], 8)
_right(c, x_price, r2, line["tax_price"], 8)
_right(c, x_amt, r1, line["untax_amt"], 8)
_right(c, x_amt, r2, line["tax_amt"], 8)
_text(c, x_halo, r1, line["halogen"], 8)
y -= row_h
# [STEP 6] 合计靠右,金额带原件那种细框
y -= 6 * mm
box_w = 22 * mm
box_h = 4.6 * mm
_text(c, x_price - 28 * mm, y, "税前金额总和:", 8)
_rect(c, x_amt - box_w, y - 1.2 * mm, box_w, box_h)
_right(c, x_amt - 1.2 * mm, y, SAMPLE["untax_total"], 8)
y -= 6 * mm
_text(c, x_price - 28 * mm, y, "含税金额总和:", 8)
_rect(c, x_amt - box_w, y - 1.2 * mm, box_w, box_h)
_right(c, x_amt - 1.2 * mm, y, SAMPLE["tax_total"], 8)
# 底部按 ERP 截图:三字在线上方均分;横线穿过 (apmr900) / (结束)
foot_y = 18 * mm
span = right - left
_text(c, left + 10 * mm, foot_y + 5 * mm, "核准", 10)
c.setFont(FONT, 10)
c.drawCentredString(left + span / 2, foot_y + 5 * mm, "审核")
c.drawRightString(right - 10 * mm, foot_y + 5 * mm, "经办")
_hline(c, left, right, foot_y, 0.7)
_text(c, left, foot_y - 1.1 * mm, "(apmr900)", 8)
c.setFont(FONT, 8)
c.drawRightString(right, foot_y - 1.1 * mm, "(结束)")
c.showPage()
c.save()
if __name__ == "__main__":
targets = [
Path(r"e:\Code\hxops\docs\features\accounting-voucher-check\采购单-hxops-sample.pdf"),
Path(r"e:\Work\Agent\立账凭证\采购单-hxops-sample.pdf"),
]
for path in targets:
try:
build_pdf(path)
print(path)
except PermissionError:
print(f"skip locked: {path}")
@@ -105,8 +105,10 @@ VOUCHER_CHECK_DMS_ROOT_FOLDER_ID=<sales-root-folder-id>
### 4.3 工作台记录页
- [ ] 打开 `/workspace/accounting-voucher-check`
- [ ] 「检核任务」可按月/状态筛选,分页可用
- [ ] 「企微发送记录」可按月/发送状态筛选,能看到接收人、未发送原因与 Excel 下载入口
- [ ] 「检核任务」Tab 下方有「最近一次检核」卡片(不跟年/月/状态筛选);排队/执行中进度会更新
- [ ] 「强制重检上月」在卡片上,仅管理员可见;确认后本卡切到排队/执行中
- [ ] 「检核任务」可按年/月/状态筛选(进页默认上月,月份「全部」看该年),分页可用
- [ ] 「企微发送记录」可按年/月/发送状态筛选,能看到接收人、未发送原因与 Excel 下载入口
- [ ] 「查看详情」进入 `/workspace/accounting-voucher-check/runs/:runId`(`runId` 为 ScheduleRun.id)
### 4.4 文档库 / ERP 故障
@@ -1,7 +1,7 @@
# 立账凭证资料检核技术设计
> 文档版本:v2.3
> 更新时间:2026-09-08
> 文档版本:v2.5
> 更新时间:2026-09-09
> 状态:销售一期引擎已落地;ERP PO / OA 打印仍待接线
> 需求基线:[demand.md](demand.md)
>
@@ -162,14 +162,17 @@ ERP/OA 打印或目录扫描的成功文件先写入类型存放目录;完成
### 6.3 检核任务列表
检核任务列表以 `voucher_check_runs` 的批次统计快照为数据源,不在列表查询时重新汇总单文件结果。支持按 `period_month`、`profile_code` 和批次状态筛选,按执行时间倒序分页。
检核任务列表以 `voucher_check_runs` 的批次统计快照为数据源,不在列表查询时重新汇总单文件结果。`period` 支持 `YYYY`(该自然年)或 `YYYY-MM`(该自然月),并可按 `profile_code` 和批次状态筛选,按执行时间倒序分页。工作台进页默认上一个自然月;月份选「全部」时传 `YYYY`。建批前失败的 `ScheduleRun` 使用同一期间口径。企微发送记录列表共用该 `period` 参数。
「最近一次检核」走独立接口 `GET /api/workspace/accounting-voucher-check/runs/latest`:按 `ScheduleRun.id` 倒序取该平台最近一条排程,join 引擎快照与 `response_summary_json.current_step`,**不跟**列表 `period`/`status`。排队中、执行中的排程必须按 `queued`/`running` 返回,不得套用建批前失败的 `technical_failed` 映射。进度百分比由步骤码估算(`scan_dms` 用已处理 invoice / 总数插值),不是精确字节进度。
| 列/操作 | 数据来源或行为 |
| --------------------------------------------------- | -------------------------------------------------------------------------- |
| 最近一次检核卡片 | `GET .../runs/latest`;强制重检按钮仅 admin,入队后前端轮询本接口 |
| 批次号、业务方、资料所属期间、执行时间 | `voucher_check_runs` |
| 主体总数、已归档数、缺件文件数、缺件 `invoice` 数 | 批次结束时固化的统计快照 |
| 状态 | `completed`、`missing`、`technical_failed`、`draft` 的前端业务映射 |
| 查看详情 | 携带 `run_id` 跳转执行记录;详情读取 `voucher_check_file_results` |
| 主体总数、已归档数、缺件文件数、缺件 `invoice` 数 | 批次结束时固化的统计快照;执行中可来自 `response_summary_json.voucher_check` |
| 状态 | 列表:`completed`、`missing`、`technical_failed`;卡片另含 `queued`、`running` |
| 查看详情 | 携带 `schedule_run_id` 跳转执行记录;详情读取 `voucher_check_file_results` |
| 通知附件 | 通过该批次的 Excel 文件标识进入企业微信通知附件 Excel 预览或下载 |
## 7. 企业微信通知附件 Excel 设计
@@ -201,7 +204,7 @@ ERP/OA 打印或目录扫描的成功文件先写入类型存放目录;完成
## 9. 实施顺序
1. **已做**:Profile、文件规则、批次/单文件结果表、上月期间、周二 cron、销售 DMS 只读、directory_scan、缺件聚合、批次企微、工作台任务列表与企微发送记录。
1. **已做**:Profile、文件规则、批次/单文件结果表、上月期间、周二 cron、销售 DMS 只读、directory_scan、缺件聚合、批次企微、工作台任务列表、最近一次检核卡片与企微发送记录。
2. **已做**:`dms_archive` 建文件夹(`SaveFolder`)+ 复制(`Item/Copy`),重复策略同名跳过;命中文件记 `archived`。
3. **已预留**:`erp_po_print`、`oa_sales_release` Adapter,周任务不调用。
4. 接入 ERP PO 打印与 OA 模拟页,作为独立抓取任务写入类型目录。
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

+1 -1
View File
@@ -218,7 +218,7 @@
| 通用 Profile + Adapter 架构 | 实施中 | 销售 Profile 与 Adapter 协议已落地;周任务扫描文档库类型目录;ERP PO / OA 销货放行单打印仅占位 |
| 单一共享盘旧检核 | 已移除 | 已删除共享盘扫描、Chatflow Tool、`voucher_check_invoice_states` / `voucher_check_run_items` |
| 增量、归档与缺件通知 | 实施中 | 每周二上月;单文件结果;归档复制同名跳过;企微每批一条汇总 |
| 工作台查询 | 已实现 | 工作台含检核任务与企微发送记录两 Tab;「强制重检上月」;`/runs`、`/notifications` 只读引擎表 |
| 工作台查询 | 已实现 | 工作台含检核任务与企微发送记录两 Tab;期间为年+月(默认上月,月份可「全部」看该年);Tab 下「最近一次检核」卡片不跟筛选;「强制重检上月」在卡片上(admin);`GET /runs/latest`、`/runs`、`/notifications` |
### 采购合同审查