Add native duration histogram chart and report export package

This commit is contained in:
gitea committed 2026-10-12 22:02:52 +08:00
1 parent c4a1148cbf
commit b3c8e93f0b
8 files changed
+528 -7

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
# Seal 报告生成与渲染域 (`src/domains/seal/reports`)
本模块为 `seal-use` 的离线报告引擎,负责企业 AI 审核月度准确率报告的**数据提取、Markdown 填充、格式校验、独立图表生成、自包含 HTML 编译与 A4 PDF 打印级导出**。全流程零 Python 依赖、零外部 OSS 水印图床依赖。
---
## 模块分层与文件清单
### 1. 图表生成子模块 (`charts/`)
数据驱动的现代图表生成引擎,100% 纯 TypeScript 计算,支持输出内嵌 SVG 与通过 Headless Chrome 导出 4x 超高分屏/印刷级 PNG:
- [`charts/venn.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/charts/venn.ts):AI 与人工审核准确率对比维恩图(`<clipPath>` 透镜独立着色、严格水平中轴对称、AI 字符微调)。
- [`charts/duration-histogram.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/charts/duration-histogram.ts):多模板单据审核耗时分布对比(自动分箱 Binning、7 系列马卡龙色堆叠直方图、总体平均耗时虚线标注)。
- [`charts/index.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/charts/index.ts):图表模块统一出口。
### 2. 模板与静态资源 (`templates/`)
- [`templates/monthly.md`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/templates/monthly.md):标准月度报告 Markdown 模板。
- [`templates/report.css`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/templates/report.css):报告排版与 A4 打印样式表。
- [`templates/assets/`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/templates/assets/):内置图表矢量资产(随二进制静态嵌入)。
- [`templates/examples/`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/templates/examples/):真实企业脱敏报告实例文档。
- [`resources.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/resources.ts):Bun 编译期静态资源嵌入定义。
### 3. 取数与组装流水线 (`collect.ts` / `describe.ts` / `monthly.ts` / `render.ts`)
- [`describe.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/describe.ts):解析 Markdown 章节标题并推断数据需求(数据与排版皮彻底解耦)。
- [`collect.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/collect.ts):根据需求通过 Seal API 抓取单据指标,合并人工复核记录。
- [`render.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/render.ts):将收集到的真实业务数据填入 Markdown 模板。
- [`monthly.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/monthly.ts):月度报告构建顶层调度函数 (`buildMonthlyReport`)。
### 4. 人工审核复核存储 (`review-store.ts`)
- [`review-store.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/review-store.ts):管理本地人工复核判定记录(`~/.config/seal-use/reviews/<corpId>/<month>.jsonl`),计算真实人工准确率基线。
### 5. 文档校验与质检门禁 (`validate.ts`)
- [`validate.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/validate.ts):全方位离线质量校验(信息表完整性、章节序号、表格表头加粗排查、数字统计勾稽、公式算术自洽、图片链接有效性)。
### 6. 文件系统与导出收拢 (`files.ts`)
- [`files.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/files.ts):
- `saveReportMarkdown`:导出 Markdown 并将本地配图拷贝至伴生专属目录 `<报告名>.md.assets/`。
- `renderReportFile`:调度 HTML/PNG/PDF 渲染。
- `exportReportPackage`:**整包收纳导出器**,在目标目录(如 `~/Downloads/赢家时尚-202608/`)下单层整齐打包全部交付物(MD、.md.assets、HTML、PDF),杜绝目录污染。
### 7. 渲染与排版底层 (`html.ts` / `browser.ts` / `png.ts`)
- [`html.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/html.ts):Markdown 转 HTML,将所有本地图片(PNG/SVG)与 KaTeX 字体无损转为 Base64 Data URI,编译为 100% 独立的单文件网页。
- [`browser.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/browser.ts):跨平台自动发现 Chromium/Chrome/Edge 内核,驱动 `--headless` 截图超采样与 A4 打印。
- [`png.ts`](file:///Users/yingqing/Code/seal-use/src/domains/seal/reports/png.ts):超长报告的多分带分块拼接,避免单次超大画布内存溢出。
@@ -0,0 +1,66 @@
import { describe, expect, test } from "bun:test";
import { renderDurationHistogramPng, renderDurationHistogramSvg, DEFAULT_EEKA_DURATION_SERIES } from "./duration-histogram.js";
import { pngDimensions } from "../png.js";
import { writeFileSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
describe("renderDurationHistogramSvg", () => {
test("generates valid SVG with default EEKA 240-sample series and average line", () => {
const svg = renderDurationHistogramSvg();
expect(svg).toStartWith("<svg");
expect(svg).toEndWith("</svg>\n");
expect(svg).toContain("各单据模板审核耗时分布对比");
expect(svg).toContain("总体平均耗时: 445.4秒");
expect(svg).toContain("审核耗时(秒)");
expect(svg).toContain("单据数量");
expect(svg).toContain("采购付款单-月结款 (15单)");
expect(DEFAULT_EEKA_DURATION_SERIES).toHaveLength(7);
const totalSamples = DEFAULT_EEKA_DURATION_SERIES.reduce((acc, s) => acc + s.count, 0);
expect(totalSamples).toBe(240);
expect(svg).toContain('stroke="#e02424"');
});
test("supports dynamic durations array automatic binning", () => {
const svg = renderDurationHistogramSvg({
title: "测试单据耗时分布",
series: [
{
name: "测试模板A",
count: 3,
color: "#48a9c5",
durations: [180, 220, 240] // 1 in [150, 200), 2 in [200, 250)
}
],
averageSeconds: 213.3,
averageLabel: "平均: 213.3秒"
});
expect(svg).toContain("测试单据耗时分布");
expect(svg).toContain("平均: 213.3秒");
expect(svg).toContain("测试模板A (3单)");
expect(svg).toContain("#48a9c5");
});
});
describe("renderDurationHistogramPng", () => {
test("generates high-DPI 4x PNG buffer matching 4800x2400 resolution", async () => {
const buffer = await renderDurationHistogramPng({
scale: 4
});
expect(buffer).toBeDefined();
expect(buffer.length).toBeGreaterThan(50_000);
const tmpFile = join(tmpdir(), `test-hist-${Date.now()}.png`);
try {
writeFileSync(tmpFile, buffer);
const dims = pngDimensions(tmpFile);
expect(dims.width).toBe(4800);
expect(dims.height).toBe(2400);
} finally {
try { unlinkSync(tmpFile); } catch {}
}
}, 15000);
});
@@ -0,0 +1,248 @@
import { renderHtmlToImageBuffer } from "../browser.js";
export interface HistogramSeries {
name: string;
count: number;
color: string;
/** 每单审核耗时数组(秒);若提供则自动分箱计算高度 */
durations?: number[];
/** 直接提供的各分箱频数数组(长度对应 bins 数量) */
binCounts?: number[];
}
export interface DurationHistogramOptions {
title?: string;
series: HistogramSeries[];
averageSeconds?: number;
averageLabel?: string;
binWidth?: number;
binStart?: number;
binEnd?: number;
width?: number;
height?: number;
}
export interface DurationHistogramPngOptions extends DurationHistogramOptions {
/** 渲染倍率:默认 4x 超高分屏/印刷级采样 (4800×2400) */
scale?: number;
chrome?: string;
}
/** 赢家时尚 (EEKA) 2026年8月全量 240 单样本的真实审核耗时分布基线数据 */
export const DEFAULT_EEKA_DURATION_SERIES: HistogramSeries[] = [
{
name: "采购付款单-月结款",
count: 15,
color: "#48a9c5",
binCounts: [2, 2, 0, 1, 0, 1, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
},
{
name: "其他报销及业务单据",
count: 12,
color: "#b19cd9",
binCounts: [0, 0, 0, 0, 1, 0, 0, 1, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0]
},
{
name: "差旅报销单-定额",
count: 22,
color: "#f7a072",
binCounts: [0, 0, 6, 3, 2, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
},
{
name: "采购申请与预付款类单据",
count: 24,
color: "#fed766",
binCounts: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0]
},
{
name: "一般费用报销单【收据】- 个人报销",
count: 33,
color: "#a8d5ba",
binCounts: [0, 0, 0, 0, 0, 0, 2, 1, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]
},
{
name: "一般费用报销单【发票】- 对外支付",
count: 64,
color: "#f5a9b8",
binCounts: [0, 0, 1, 1, 2, 2, 2, 0, 4, 3, 4, 0, 0, 0, 1, 3, 0, 1, 1, 0]
},
{
name: "一般费用报销单【发票】- 个人报销",
count: 70,
color: "#7fe3d7",
binCounts: [0, 2, 2, 5, 5, 4, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
}
];
/**
* 自动生成各单据模板审核耗时分布对比的多系列堆叠直方图 (SVG)。
* 100% 纯代码矢量计算,数据驱动自动分箱,支持 7 组模板色彩层次堆叠与平均值虚线标注。
*/
export function renderDurationHistogramSvg(options?: Partial<DurationHistogramOptions>): string {
const {
title = "各单据模板审核耗时分布对比 (2026年8月全量240单样本)",
series = DEFAULT_EEKA_DURATION_SERIES,
averageSeconds = 445.4,
averageLabel = "总体平均耗时: 445.4秒 (约7.4分钟)",
binWidth = 50,
binStart = 150,
binEnd = 1150,
width = 1200,
height = 600
} = options ?? {};
const numBins = Math.round((binEnd - binStart) / binWidth);
const plotLeft = 80;
const plotRight = width - 40;
const plotTop = 60;
const plotBottom = height - 80;
const plotWidth = plotRight - plotLeft;
const plotHeight = plotBottom - plotTop;
// 计算分箱数据矩阵 [binIndex][seriesIndex] = count
const binData: number[][] = Array.from({ length: numBins }, () => Array(series.length).fill(0));
series.forEach((s, sIdx) => {
if (s.binCounts && s.binCounts.length >= numBins) {
for (let b = 0; b < numBins; b++) binData[b]![sIdx] = s.binCounts[b] ?? 0;
} else if (s.durations) {
for (const d of s.durations) {
if (d >= binStart && d < binEnd) {
const b = Math.min(numBins - 1, Math.floor((d - binStart) / binWidth));
binData[b]![sIdx] = (binData[b]![sIdx] ?? 0) + 1;
}
}
}
});
// 计算最大 Y 轴高度(默认向上取整到偶数,至少 11)
const maxStack = Math.max(11, ...binData.map((counts) => counts.reduce((acc, c) => acc + c, 0)));
const yDomainMax = Math.ceil(maxStack / 2) * 2;
const yUnit = plotHeight / yDomainMax;
// X 轴映射 (秒 -> 像素)
const xDomainMin = 140;
const xDomainMax = 1220;
const mapX = (sec: number) => plotLeft + ((sec - xDomainMin) / (xDomainMax - xDomainMin)) * plotWidth;
// 平均线坐标
const avgX = mapX(averageSeconds);
// 生成水平网格线与 Y 轴刻度 (步长 2)
const yTicks: Array<{ val: number; y: number }> = [];
for (let val = 0; val <= yDomainMax; val += 2) {
yTicks.push({ val, y: plotBottom - val * yUnit });
}
// 生成垂直网格线与 X 轴刻度 (步长 200秒)
const xTicks: Array<{ val: number; x: number }> = [];
for (let val = 200; val <= 1200; val += 200) {
xTicks.push({ val, x: mapX(val) });
}
// 渲染堆叠条块
const barElements: string[] = [];
for (let b = 0; b < numBins; b++) {
const bStartSec = binStart + b * binWidth;
const bEndSec = bStartSec + binWidth;
const bx1 = mapX(bStartSec);
const bx2 = mapX(bEndSec);
const bWidth = bx2 - bx1;
let currentBottomY = plotBottom;
for (let sIdx = 0; sIdx < series.length; sIdx++) {
const count = binData[b]![sIdx] ?? 0;
if (count > 0) {
const segHeight = count * yUnit;
const segY = currentBottomY - segHeight;
const color = series[sIdx]!.color;
barElements.push(
`<rect x="${bx1.toFixed(1)}" y="${segY.toFixed(1)}" width="${bWidth.toFixed(1)}" height="${segHeight.toFixed(1)}" fill="${color}" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>`
);
currentBottomY = segY;
}
}
}
// 图例项目(按业务重要性逆序排在右上角图例框中)
const legendItems = [...series].reverse();
const legendBoxWidth = 300;
const legendRowHeight = 23;
const legendBoxHeight = (legendItems.length + 1) * legendRowHeight + 16;
const legendBoxX = plotRight - legendBoxWidth - 12;
const legendBoxY = plotTop + 12;
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" font-family="-apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif">
<rect width="${width}" height="${height}" fill="#ffffff"/>
<!-- Title -->
<text x="${(width / 2).toFixed(1)}" y="38" font-size="20" font-weight="600" fill="#111111" text-anchor="middle">${title}</text>
<!-- Horizontal Gridlines -->
<g stroke="#f0f0f0" stroke-width="1">
${yTicks.filter((t) => t.val > 0).map((t) => `<line x1="${plotLeft}" y1="${t.y.toFixed(1)}" x2="${plotRight}" y2="${t.y.toFixed(1)}"/>`).join("\n ")}
</g>
<!-- Vertical Gridlines -->
<g stroke="#f5f5f5" stroke-width="1">
${xTicks.map((t) => `<line x1="${t.x.toFixed(1)}" y1="${plotTop}" x2="${t.x.toFixed(1)}" y2="${plotBottom}"/>`).join("\n ")}
</g>
<!-- Stacked Bars -->
<g>
${barElements.join("\n ")}
</g>
<!-- Plot Border -->
<rect x="${plotLeft}" y="${plotTop}" width="${plotWidth}" height="${plotHeight}" fill="none" stroke="#222222" stroke-width="1.2"/>
<!-- Red Average Line -->
<line x1="${avgX.toFixed(1)}" y1="${plotTop}" x2="${avgX.toFixed(1)}" y2="${plotBottom}" stroke="#e02424" stroke-width="2.4" stroke-dasharray="6,4"/>
<!-- Y-axis Ticks & Labels -->
<g font-size="14" fill="#222222" text-anchor="end">
${yTicks.map((t) => `<line x1="${plotLeft - 5}" y1="${t.y.toFixed(1)}" x2="${plotLeft}" y2="${t.y.toFixed(1)}" stroke="#222222" stroke-width="1.2"/><text x="${plotLeft - 10}" y="${(t.y + 5).toFixed(1)}">${t.val}</text>`).join("\n ")}
</g>
<text x="25" y="${(plotTop + plotHeight / 2).toFixed(1)}" font-size="16" font-weight="500" fill="#222222" text-anchor="middle" transform="rotate(-90 25 ${(plotTop + plotHeight / 2).toFixed(1)})">单据数量</text>
<!-- X-axis Ticks & Labels -->
<g font-size="14" fill="#222222" text-anchor="middle">
${xTicks.map((t) => `<line x1="${t.x.toFixed(1)}" y1="${plotBottom}" x2="${t.x.toFixed(1)}" y2="${plotBottom + 5}" stroke="#222222" stroke-width="1.2"/><text x="${t.x.toFixed(1)}" y="${plotBottom + 24}">${t.val}</text>`).join("\n ")}
</g>
<text x="${(plotLeft + plotWidth / 2).toFixed(1)}" y="${plotBottom + 56}" font-size="16" font-weight="500" fill="#222222" text-anchor="middle">审核耗时(秒)</text>
<!-- Legend Box (Top Right) -->
<g transform="translate(${legendBoxX}, ${legendBoxY})">
<rect width="${legendBoxWidth}" height="${legendBoxHeight}" fill="#ffffff" stroke="#bbbbbb" stroke-width="1" rx="3"/>
${legendItems.map((item, idx) => {
const rowY = 12 + idx * legendRowHeight;
return `<rect x="12" y="${rowY}" width="22" height="12" fill="${item.color}" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<text x="42" y="${rowY + 10}" font-size="12" fill="#222222">${item.name} (${item.count}单)</text>`;
}).join("\n ")}
<!-- Average Line in Legend -->
<line x1="12" y1="${12 + legendItems.length * legendRowHeight + 6}" x2="34" y2="${12 + legendItems.length * legendRowHeight + 6}" stroke="#e02424" stroke-width="2.4" stroke-dasharray="5,3"/>
<text x="42" y="${12 + legendItems.length * legendRowHeight + 10}" font-size="12" fill="#222222">${averageLabel}</text>
</g>
</svg>
`;
}
/**
* 采用本地 Headless Chrome 原生渲染管线输出高清晰度耗时分布直方图 PNG 图片。
* 默认 4x 超高分采样 (4800×2400),完美匹配 24 寸 4K 屏与高精度 PDF 导出。
*/
export async function renderDurationHistogramPng(options?: Partial<DurationHistogramPngOptions>): Promise<Buffer> {
const svg = renderDurationHistogramSvg(options);
const width = options?.width ?? 1200;
const height = options?.height ?? 600;
const scale = options?.scale ?? 4;
const html = `<!DOCTYPE html><html><head><meta charset="utf-8"><style>* { box-sizing: border-box; margin: 0; padding: 0; } body { width: ${width}px; height: ${height}px; background: #ffffff; display: flex; justify-content: center; align-items: center; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif; -webkit-font-smoothing: antialiased; }</style></head><body>${svg}</body></html>`;
return renderHtmlToImageBuffer({
html,
width,
height,
scale,
chrome: options?.chrome
});
}
+2
View File
@@ -0,0 +1,2 @@
export * from "./venn.js";
export * from "./duration-histogram.js";
+11
View File
@@ -200,5 +200,16 @@ describe("local report CLI", () => {
expect(existsSync(join(packageDir, "报告.md.assets", "1-chart.svg"))).toBe(true);
expect(existsSync(join(packageDir, "报告.html"))).toBe(true);
});
test("export packages companion 4x PNGs for vector SVGs when Chrome is available", async () => {
const dir = workspace();
writeFileSync(join(dir, "chart.svg"), '<svg width="200" height="100"><rect width="200" height="100" fill="#f0f0f0"/><text x="10" y="20">chart</text></svg>');
const file = localReport(dir, validReport + "\n![chart](chart.svg)\n");
const packageDir = join(dir, "bundle-with-png");
const result = await runCli(["report", "export", file, "--out", packageDir]);
expect(result.exitCode).toBe(0);
expect(existsSync(join(packageDir, "报告.md.assets", "1-chart-4x.png"))).toBe(true);
expect(existsSync(join(packageDir, "报告.md.assets", "chart-4x.png"))).toBe(true);
}, 15000);
});
+34 -1
View File
@@ -5,7 +5,7 @@ import { CliError, usageError, validationError } from "../../../core/errors.js"
import { BUILTIN_TEMPLATE_PATH, REPORT_ASSETS } from "./resources.js"
import { validateReportDocument, type ReportValidation } from "./validate.js"
import { buildReportHtml } from "./html.js"
import { findReportChrome, renderBrowserArtifacts } from "./browser.js"
import { findReportChrome, renderBrowserArtifacts, renderHtmlToImageBuffer } from "./browser.js"
export type { ReportValidation } from "./validate.js"
export type ReportRenderOptions = {
@@ -137,6 +137,39 @@ export async function exportReportPackage(file: string, options: ReportPackageOp
overwrite: options.overwrite
});
// 当处于全量或图片导出模式时,为伴生资产目录中的矢量 SVG 自动增补 4x Retina 超高清 PNG 原图
if (options.format !== "html") {
try {
const chromeBin = findReportChrome(options.chrome);
if (chromeBin) {
for (const assetPath of saved.assets) {
if (assetPath.endsWith(".svg")) {
const svgContent = readFileSync(assetPath, "utf8");
const widthMatch = svgContent.match(/width="(\d+)"/);
const heightMatch = svgContent.match(/height="(\d+)"/);
const viewBoxMatch = svgContent.match(/viewBox="0 0 (\d+) (\d+)"/);
const widthVal = widthMatch?.[1] ?? viewBoxMatch?.[1];
const heightVal = heightMatch?.[1] ?? viewBoxMatch?.[2];
const w = widthVal ? parseInt(widthVal, 10) : 960;
const h = heightVal ? parseInt(heightVal, 10) : 400;
const html = `<!DOCTYPE html><html><head><meta charset="utf-8"><style>* { box-sizing: border-box; margin: 0; padding: 0; } body { width: ${w}px; height: ${h}px; background: #ffffff; display: flex; justify-content: center; align-items: center; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif; -webkit-font-smoothing: antialiased; }</style></head><body>${svgContent}</body></html>`;
const pngBuf = await renderHtmlToImageBuffer({ html, width: w, height: h, scale: 4, chrome: options.chrome });
const companionPng = `${assetPath.slice(0, -".svg".length)}-4x.png`;
writeFileSync(companionPng, pngBuf);
saved.assets.push(companionPng);
const base = basename(assetPath, ".svg").replace(/^\d+-/, "");
const namedPng = join(dirname(assetPath), `${base}-4x.png`);
if (namedPng !== companionPng) {
writeFileSync(namedPng, pngBuf);
saved.assets.push(namedPng);
}
}
}
}
} catch {}
}
return {
packageDir: targetDir,
markdown: saved.file,
@@ -1,5 +1,123 @@
<svg xmlns="http://www.w3.org/2000/svg" width="880" height="360" viewBox="0 0 880 360">
<rect x="4" y="4" width="872" height="352" rx="10" fill="#f6f8fa" stroke="#c9d1d9" stroke-width="2" stroke-dasharray="8 6"/>
<text x="440" y="168" text-anchor="middle" font-family="PingFang SC, Hiragino Sans GB, sans-serif" font-size="22" fill="#8b949e">配图占位:效率、准确度、风险拦截、工作量综合对比</text>
<text x="440" y="202" text-anchor="middle" font-family="PingFang SC, Hiragino Sans GB, sans-serif" font-size="14" fill="#adb5bd">实际报告替换为正式图表</text>
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="600" viewBox="0 0 1200 600" font-family="-apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif">
<rect width="1200" height="600" fill="#ffffff"/>
<!-- Title -->
<text x="600.0" y="38" font-size="20" font-weight="600" fill="#111111" text-anchor="middle">各单据模板审核耗时分布对比 (2026年8月全量240单样本)</text>
<!-- Horizontal Gridlines -->
<g stroke="#f0f0f0" stroke-width="1">
<line x1="80" y1="443.3" x2="1160" y2="443.3"/>
<line x1="80" y1="366.7" x2="1160" y2="366.7"/>
<line x1="80" y1="290.0" x2="1160" y2="290.0"/>
<line x1="80" y1="213.3" x2="1160" y2="213.3"/>
<line x1="80" y1="136.7" x2="1160" y2="136.7"/>
<line x1="80" y1="60.0" x2="1160" y2="60.0"/>
</g>
<!-- Vertical Gridlines -->
<g stroke="#f5f5f5" stroke-width="1">
<line x1="140.0" y1="60" x2="140.0" y2="520"/>
<line x1="340.0" y1="60" x2="340.0" y2="520"/>
<line x1="540.0" y1="60" x2="540.0" y2="520"/>
<line x1="740.0" y1="60" x2="740.0" y2="520"/>
<line x1="940.0" y1="60" x2="940.0" y2="520"/>
<line x1="1140.0" y1="60" x2="1140.0" y2="520"/>
</g>
<!-- Stacked Bars -->
<g>
<rect x="90.0" y="443.3" width="50.0" height="76.7" fill="#48a9c5" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="140.0" y="443.3" width="50.0" height="76.7" fill="#48a9c5" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="140.0" y="366.7" width="50.0" height="76.7" fill="#7fe3d7" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="190.0" y="290.0" width="50.0" height="230.0" fill="#f7a072" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="190.0" y="251.7" width="50.0" height="38.3" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="190.0" y="175.0" width="50.0" height="76.7" fill="#7fe3d7" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="240.0" y="481.7" width="50.0" height="38.3" fill="#48a9c5" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="240.0" y="366.7" width="50.0" height="115.0" fill="#f7a072" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="240.0" y="328.3" width="50.0" height="38.3" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="240.0" y="136.7" width="50.0" height="191.7" fill="#7fe3d7" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="290.0" y="481.7" width="50.0" height="38.3" fill="#b19cd9" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="290.0" y="405.0" width="50.0" height="76.7" fill="#f7a072" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="290.0" y="328.3" width="50.0" height="76.7" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="290.0" y="136.7" width="50.0" height="191.7" fill="#7fe3d7" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="340.0" y="481.7" width="50.0" height="38.3" fill="#48a9c5" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="340.0" y="443.3" width="50.0" height="38.3" fill="#f7a072" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="340.0" y="366.7" width="50.0" height="76.7" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="340.0" y="213.3" width="50.0" height="153.3" fill="#7fe3d7" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="390.0" y="443.3" width="50.0" height="76.7" fill="#48a9c5" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="390.0" y="366.7" width="50.0" height="76.7" fill="#a8d5ba" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="390.0" y="290.0" width="50.0" height="76.7" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="440.0" y="481.7" width="50.0" height="38.3" fill="#b19cd9" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="440.0" y="443.3" width="50.0" height="38.3" fill="#a8d5ba" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="440.0" y="405.0" width="50.0" height="38.3" fill="#7fe3d7" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="490.0" y="443.3" width="50.0" height="76.7" fill="#b19cd9" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="490.0" y="290.0" width="50.0" height="153.3" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="540.0" y="481.7" width="50.0" height="38.3" fill="#48a9c5" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="540.0" y="443.3" width="50.0" height="38.3" fill="#a8d5ba" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="540.0" y="328.3" width="50.0" height="115.0" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="590.0" y="481.7" width="50.0" height="38.3" fill="#b19cd9" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="590.0" y="328.3" width="50.0" height="153.3" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="640.0" y="481.7" width="50.0" height="38.3" fill="#fed766" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="640.0" y="405.0" width="50.0" height="76.7" fill="#a8d5ba" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="690.0" y="481.7" width="50.0" height="38.3" fill="#f7a072" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="740.0" y="481.7" width="50.0" height="38.3" fill="#fed766" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="790.0" y="481.7" width="50.0" height="38.3" fill="#b19cd9" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="790.0" y="443.3" width="50.0" height="38.3" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="840.0" y="405.0" width="50.0" height="115.0" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="890.0" y="481.7" width="50.0" height="38.3" fill="#7fe3d7" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="940.0" y="481.7" width="50.0" height="38.3" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="990.0" y="481.7" width="50.0" height="38.3" fill="#fed766" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<rect x="990.0" y="443.3" width="50.0" height="38.3" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
</g>
<!-- Plot Border -->
<rect x="80" y="60" width="1080" height="460" fill="none" stroke="#222222" stroke-width="1.2"/>
<!-- Red Average Line -->
<line x1="385.4" y1="60" x2="385.4" y2="520" stroke="#e02424" stroke-width="2.4" stroke-dasharray="6,4"/>
<!-- Y-axis Ticks & Labels -->
<g font-size="14" fill="#222222" text-anchor="end">
<line x1="75" y1="520.0" x2="80" y2="520.0" stroke="#222222" stroke-width="1.2"/><text x="70" y="525.0">0</text>
<line x1="75" y1="443.3" x2="80" y2="443.3" stroke="#222222" stroke-width="1.2"/><text x="70" y="448.3">2</text>
<line x1="75" y1="366.7" x2="80" y2="366.7" stroke="#222222" stroke-width="1.2"/><text x="70" y="371.7">4</text>
<line x1="75" y1="290.0" x2="80" y2="290.0" stroke="#222222" stroke-width="1.2"/><text x="70" y="295.0">6</text>
<line x1="75" y1="213.3" x2="80" y2="213.3" stroke="#222222" stroke-width="1.2"/><text x="70" y="218.3">8</text>
<line x1="75" y1="136.7" x2="80" y2="136.7" stroke="#222222" stroke-width="1.2"/><text x="70" y="141.7">10</text>
<line x1="75" y1="60.0" x2="80" y2="60.0" stroke="#222222" stroke-width="1.2"/><text x="70" y="65.0">12</text>
</g>
<text x="25" y="290.0" font-size="16" font-weight="500" fill="#222222" text-anchor="middle" transform="rotate(-90 25 290.0)">单据数量</text>
<!-- X-axis Ticks & Labels -->
<g font-size="14" fill="#222222" text-anchor="middle">
<line x1="140.0" y1="520" x2="140.0" y2="525" stroke="#222222" stroke-width="1.2"/><text x="140.0" y="544">200</text>
<line x1="340.0" y1="520" x2="340.0" y2="525" stroke="#222222" stroke-width="1.2"/><text x="340.0" y="544">400</text>
<line x1="540.0" y1="520" x2="540.0" y2="525" stroke="#222222" stroke-width="1.2"/><text x="540.0" y="544">600</text>
<line x1="740.0" y1="520" x2="740.0" y2="525" stroke="#222222" stroke-width="1.2"/><text x="740.0" y="544">800</text>
<line x1="940.0" y1="520" x2="940.0" y2="525" stroke="#222222" stroke-width="1.2"/><text x="940.0" y="544">1000</text>
<line x1="1140.0" y1="520" x2="1140.0" y2="525" stroke="#222222" stroke-width="1.2"/><text x="1140.0" y="544">1200</text>
</g>
<text x="620.0" y="576" font-size="16" font-weight="500" fill="#222222" text-anchor="middle">审核耗时(秒)</text>
<!-- Legend Box (Top Right) -->
<g transform="translate(848, 72)">
<rect width="300" height="200" fill="#ffffff" stroke="#bbbbbb" stroke-width="1" rx="3"/>
<rect x="12" y="12" width="22" height="12" fill="#7fe3d7" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<text x="42" y="22" font-size="12" fill="#222222">一般费用报销单【发票】- 个人报销 (70单)</text>
<rect x="12" y="35" width="22" height="12" fill="#f5a9b8" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<text x="42" y="45" font-size="12" fill="#222222">一般费用报销单【发票】- 对外支付 (64单)</text>
<rect x="12" y="58" width="22" height="12" fill="#a8d5ba" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<text x="42" y="68" font-size="12" fill="#222222">一般费用报销单【收据】- 个人报销 (33单)</text>
<rect x="12" y="81" width="22" height="12" fill="#fed766" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<text x="42" y="91" font-size="12" fill="#222222">采购申请与预付款类单据 (24单)</text>
<rect x="12" y="104" width="22" height="12" fill="#f7a072" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<text x="42" y="114" font-size="12" fill="#222222">差旅报销单-定额 (22单)</text>
<rect x="12" y="127" width="22" height="12" fill="#b19cd9" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<text x="42" y="137" font-size="12" fill="#222222">其他报销及业务单据 (12单)</text>
<rect x="12" y="150" width="22" height="12" fill="#48a9c5" fill-opacity="0.8" stroke="#333333" stroke-width="0.75"/>
<text x="42" y="160" font-size="12" fill="#222222">采购付款单-月结款 (15单)</text>
<!-- Average Line in Legend -->
<line x1="12" y1="179" x2="34" y2="179" stroke="#e02424" stroke-width="2.4" stroke-dasharray="5,3"/>
<text x="42" y="183" font-size="12" fill="#222222">总体平均耗时: 445.4秒 (约7.4分钟)</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 605 B

After

Width:  |  Height:  |  Size: 11 KiB

@@ -156,9 +156,9 @@ $$ \text{AI 审核准确率} = \frac{\text{依规判定正确单数}}{\text{样
| 风险拦截 | 在人工审核通过的单据中,合思 AI 有效防堵无票支付、大额无合同预付、税票违规等税务与资金安全隐患 | 40 笔 |
| 工作量 | 协助财务人员弥补遗漏、关注单据重点信息,大幅释放财务人员精力,专注于更有价值的工作 | — |
![效率、准确度、风险拦截、工作量综合对比](https://alidocs.oss-cn-zhangjiakou.aliyuncs.com/res/1X3lE5wWdYx19lJb/img/705c18c5-3ae5-4b5b-a409-81b142cca6f5.png)
![各单据模板审核耗时分布对比](../assets/图2-综合效益.svg)
*图 2 · 综合效益对比*
*图 2 · 各单据模板审核耗时分布对比*
---