Files
ssw-mvp/docs/e2e/gen_manual.py
T
admin 8288d4e866 chore(db): 0810 增量 — 沿用 schema-only / app-config-only 双策略
- docs/db/0810/{sswflow,tdc,tds}/: schema-only 导出(应用库策略不变)
- docs/db/0810/j7/: 按 SSW 3 应用 systemId 过滤的 schema + 应用配置数据
  (base_system 3 + base_module 131 + base_visual_dev/release 各 11)
- docs/db/0810/summary.json: 总览
- 顺手带上当天 DAG 多用户隔离 + headless 默认 + SandboxView 4 行微调 + e2e 调试产物
2026-08-10 21:06:21 +08:00

269 lines
14 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
import os, base64
ROOT = os.path.dirname(os.path.abspath(__file__))
SHOTS = os.path.join(ROOT, "results", "shots")
OUT = os.path.join(ROOT, "seq1-operation-manual.html")
ROLE = {
"user": ("数据使用方", "#58a6ff"),
"ops": ("运营方", "#a371f7"),
"provider": ("数据提供方", "#3fb950"),
"server": ("服务方(算法)", "#d29922"),
"regulator": ("监管方", "#f78166"),
}
PAGE = {
"/tds/market": "资源目录(需求广场)",
"/tds/products": "算法产品目录",
"/tds/contracts": "数字合约",
"/tdc/sandbox": "安全沙盒",
"/tdc/resources": "资源目录(样本数据)",
"/tds/billing": "结算台账",
"/tds/chain": "区块链存证",
"/tds/audit": "审计核验",
}
MODE = {
"create": "新建/挂出", "status": "状态切换", "view": "查看/查询详情",
"execute": "触发执行", "query": "查询提取",
}
STAGE = {
"s1-1": ("阶段1:需求与撮合", "#58a6ff"),
"s1-2": ("阶段2:合约签订", "#a371f7"),
"s1-3": ("阶段3:算法开发与调试", "#d29922"),
"s1-4": ("阶段4:交付与执行", "#3fb950"),
"s1-5": ("阶段5:结算与审计", "#f78166"),
}
# 21 节点:id, label, lane, stage, route, mode, steps, shots
NODES = [
("n1-1","提交数据需求","user","s1-1","/tds/market","create",[
"进入「资源目录 / 需求广场」,点击「新建需求」。",
"填写需求名称(如「客群画像」)、用途、精度(城市级)、周期(30 天)等字段。",
"保存后列表出现该需求单,状态=待撮合,系统自动生成 demandId / demandCode。",
],["EXTRA-图1-需求广场.jpg","TC-TRADE-001__01-新建需求后列表.png"]),
("n1-2","交易撮合","ops","s1-1","/tds/market","view",[
"运营方在监控台看到新需求单。",
"借助 AI 助手匹配数据提供方与可用算法服务。",
"撮合生成匹配订单并推送供需双方(人工 + AI 协作步骤)。",
],["EXTRA-图3-治理监控.jpg","DAG-SIM-001.jpg"]),
("n1-3","推送匹配订单","ops","s1-1","/tds/market","view",[
"运营方将撮合出的匹配订单推送给数据提供方。",
"提供方账户收到待确认接单通知。",
],["SIM-BIZ-order-856450643781494725.png","SIM-BIZ-order-856463366246377413.png"]),
("n1-4","确认接单","provider","s1-1","/tds/market","status",[
"提供方切换「供需订单」Tab,按订单号搜索订单。",
"打开订单详情,点击「确认接单」。",
"系统生成响应订单 orderId,状态流转至已接单。",
],["SIM-BIZ-order-856199145537414981.png","SIM-BIZ-order-856450643781494725.png"]),
("n1-5","挂出算法服务","server","s1-1","/tds/products","create",[
"进入「算法产品目录」,点击「新建 / 挂出算法」。",
"填写算法名称、版本、计费方式等字段。",
"保存后算法出现在平台目录,生成 algorithmProductId / algorithmCode。",
],["TC-PLATFORM-001__01-新建产品后列表.png","TC-TRADE-007__01-产品必填校验.png"]),
("n1-6","使用方订单签约","user","s1-2","/tds/market","view",[
"使用方在「供需订单」打开订单详情。",
"发起线下付款(确认支付),订单进入签约状态。",
"可在「业务全景」中查看上游订单与双签进度。",
],["SIM-BIZ-contract-856433205689984901.png","SIM-BIZ-order-856199145537414981.png"]),
("n1-7","提供方订单签约","provider","s1-2","/tds/market","view",[
"提供方在「供需订单」打开同一订单详情。",
"发起线下付款(确认收款),双方完成签约。",
],["SIM-BIZ-contract-856199357370738501.png","SIM-BIZ-order-856463366246377413.png"]),
("n1-8","生成合作协议 & 数字合约","ops","s1-2","/tds/contracts","create",[
"运营方基于已签约订单「生成合作协议与数字合约」。",
"填写合约条款,保存后生成 contractId / contractCode,合约待双签。",
"在合约详情可查看上游订单、链上存证、双签与用量配额(业务全景)。",
],["EXTRA-图1-数字合约.jpg","SIM-BIZ-contract-856433205689984901.png"]),
("n1-9","上链 / 存证","regulator","s1-2","/tds/contracts","status",[
"监管方 / 系统在合约详情触发「双签 + 上链存证」。",
"FISCO-BCOS group0 写入合约哈希(sha256)。",
"合约状态变为「已生效 02」,详情抽屉显示双签与链上凭证。",
],["TC-EVIDENCE-007__01-区块链存证列表.png","SIM-BIZ-contract-856199357370738501.png"]),
("n1-10","交付算法代码","server","s1-3","/tdc/sandbox","status",[
"服务方将算法代码上传并挂载到沙盒。",
"打开沙盒「日志 / 结果」弹窗,确认代码已就位。",
],["TC-TRADE-005__01-查询结果.png","TC-DEVELOPMENT-004__01-数据开发 tab.png"]),
("n1-11","提供样例数据","provider","s1-3","/tdc/resources","view",[
"提供方在「资源目录」准备信贷样例数据(12 万条)。",
"数据由 n1-15 真实密态灌入沙盒(此处为准备步骤)。",
],["EXTRA-图3-资源目录.jpg","TC-PLATFORM-002__02-资源 ID 必填校验.png"]),
("n1-12","沙盒开发调试","user","s1-3","/tdc/sandbox","create",[
"使用方在沙盒「创建开发调试环境」。",
"关联合约、算法服务与样例数据,运行调试。",
"查看 AUC / KS 等指标,打开「日志 / 结果」确认环境就绪(业务全景含 TEE 远程证明)。",
],["TC-DEVELOPMENT-004__01-数据开发 tab.png","TC-DELIVERY-001__01-交付处理完成.png"]),
("n1-13","算法审核","ops","s1-3","/tdc/sandbox","status",[
"运营方对沙盒算法「提交审核」。",
"审核通过(状态机切换),表格刷新至审核通过。",
"打开「日志 / 结果」查看审核结论。",
],["TC-DEVELOPMENT-001__01-数据治理 tab.png","TC-TRADE-005__01-查询结果.png"]),
("n1-14","审核通过","user","s1-3","/tdc/sandbox","view",[
"使用方收到「审核通过」通知。",
"沙盒进入可投产状态,可继续灌数与执行。",
],["TC-DELIVERY-001__01-交付处理完成.png","TC-TRADE-011__01-查询结果.png"]),
("n1-15","灌入数据到沙盒","provider","s1-4","/tdc/sandbox","view",[
"提供方将 12 万条样例数据密态灌入沙盒。",
"打开「日志 / 结果」确认数据已就位。",
],["TC-DEVELOPMENT-001__01-数据治理 tab.png","TC-DEVELOPMENT-004__01-数据开发 tab.png"]),
("n1-16","安全沙盒交付执行","user","s1-4","/tdc/sandbox","execute",[
"使用方触发沙盒计算(密态执行)。",
"结果以 AES-256-GCM 封装(约 1.2MB),写入 sha256 指纹。",
"打开「日志 / 结果」查看执行日志。",
],["TC-DELIVERY-001__01-交付处理完成.png"]),
("n1-17","提取计算结果","user","s1-4","/tdc/sandbox","query",[
"从沙盒提取真实业务指标(AUC / KS / 求交数 / 模型)。",
"在「日志 / 结果」弹窗查看计算结果明细。",
],["TC-TRADE-005__01-查询结果.png","TC-TRADE-011__01-查询结果.png"]),
("n1-18","订单支付(线下)","user","s1-5","/tds/billing","view",[
"使用方记录线下支付凭证(ConfirmPayment)。",
"订单支付状态更新,流转至待结算。",
],["SIM-BIZ-billing-856451640473954245.png","SIM-BIZ-billing-856470768345688005.png"]),
("n1-19","生成结算凭证","ops","s1-5","/tds/billing","create",[
"运营方基于执行结果「生成结算凭证」。",
"填写金额(如 XGBoost ¥21600 + OPRF ¥22500),保存为 settlementId。",
"结算台账状态=SETTLED,可在业务全景查看利益分配与上下游调用留痕。",
],["SIM-BIZ-billing-856470768345688005.png","SIM-BIZ-billing-856501482080446597.png"]),
("n1-20","提交交易凭证","regulator","s1-5","/tds/chain","view",[
"监管方将结算凭证上链存证。",
"写入 contentHash(sha256:...),区块链存证列表新增记录。",
],["TC-EVIDENCE-007__01-区块链存证列表.png","TC-DELIVERY-013__01-存证列表命中.png"]),
("n1-21","审计核验","regulator","s1-5","/tds/audit","query",[
"监管方在审计台核验哈希链。",
"确认链上存证匹配、调用频次合规,审计结果通过。",
],["TC-EVIDENCE-004__01-哈希链完整.png","TC-EVIDENCE-007__01-区块链存证列表.png"]),
]
def b64(path):
p = os.path.join(SHOTS, path)
if not os.path.exists(p):
return None
with open(p, "rb") as f:
data = f.read()
ext = os.path.splitext(path)[1].lower()
mime = "image/png" if ext in (".png",) else "image/jpeg"
return "data:%s;base64,%s" % (mime, base64.b64encode(data).decode())
# ---- 阶段概览 + 节点导航 ----
stage_html = ""
nav_html = ""
for sid, (sname, scolor) in STAGE.items():
cnt = sum(1 for n in NODES if n[3] == sid)
stage_html += '<div class="stage-card" style="border-color:%s"><b style="color:%s">%s</b><span>%d 个节点</span></div>' % (scolor, scolor, sname, cnt)
for nid, label, lane, st, route, mode, steps, shots in NODES:
if st == sid:
nav_html += '<a class="nav-item" href="#%s">%s %s</a>' % (nid, nid, label)
# ---- 节点卡片 ----
ICON = {
"n1-1":"📝","n1-2":"🤝","n1-3":"📤","n1-4":"✅","n1-5":"⚙️","n1-6":"🖋️","n1-7":"🖋️",
"n1-8":"📜","n1-9":"⛓️","n1-10":"💻","n1-11":"🧪","n1-12":"🛠️","n1-13":"🔍","n1-14":"👍",
"n1-15":"🔐","n1-16":"🚀","n1-17":"📊","n1-18":"💰","n1-19":"🧾","n1-20":"📤","n1-21":"🛡️",
}
# 重新生成 nodes_html(含 icon)
miss = []
nodes_html = ""
for nid, label, lane, st, route, mode, steps, shots in NODES:
rname, rcolor = ROLE[lane]
sname, scolor = STAGE[st]
pname = PAGE.get(route, route)
steps_html = "".join("<li>%s</li>" % s for s in steps)
shots_html = ""
for s in shots:
src = b64(s)
if not src:
miss.append(s); continue
shots_html += '<figure><img loading="lazy" src="%s" alt="%s"/><figcaption>%s</figcaption></figure>' % (src, s, s)
if not shots_html:
shots_html = '<p class="noshot">(暂无对应截图)</p>'
nodes_html += (
'<section class="node" id="%s" style="border-left:5px solid %s">'
'<div class="node-head"><span class="nid">%s</span><span class="icon">%s</span>'
'<h3>%s</h3><span class="badge" style="background:%s">%s</span>'
'<span class="badge stage">%s</span><span class="badge page">%s</span>'
'<span class="badge mode">%s</span></div>'
'<ol class="steps">%s</ol><div class="gallery">%s</div></section>'
) % (nid, scolor, nid, ICON.get(nid,"•"), label, rcolor, rname, sname, pname, MODE.get(mode,mode), steps_html, shots_html)
CSS = """
:root{--bg:#0d1117;--panel:#161b22;--line:#30363d;--fg:#e6edf3;--muted:#8b949e;}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--fg);font-family:-apple-system,"PingFang SC","Microsoft YaHei",Segoe UI,Roboto,sans-serif;line-height:1.6}
header{padding:32px 24px 20px;background:linear-gradient(135deg,#1f6feb22,#a371f722);border-bottom:1px solid var(--line)}
header h1{margin:0 0 6px;font-size:26px}
header .sub{color:var(--muted);font-size:14px}
.wrap{max-width:1100px;margin:0 auto;padding:24px}
.stages{display:flex;gap:12px;flex-wrap:wrap;margin:18px 0}
.stage-card{flex:1;min-width:160px;background:var(--panel);border:1px solid var(--line);border-left-width:4px;border-radius:10px;padding:12px 14px;display:flex;flex-direction:column;gap:4px}
.stage-card b{font-size:14px}
.stage-card span{color:var(--muted);font-size:12px}
.nav{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0 24px}
.nav-item{font-size:12px;color:var(--fg);text-decoration:none;background:var(--panel);border:1px solid var(--line);border-radius:20px;padding:4px 10px}
.nav-item:hover{border-color:#58a6ff}
.node{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:18px 20px;margin:18px 0}
.node-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.node-head .nid{font-family:ui-monospace,monospace;color:var(--muted);font-size:13px}
.node-head .icon{font-size:20px}
.node-head h3{margin:0;font-size:18px}
.badge{font-size:12px;color:#fff;padding:2px 9px;border-radius:20px;background:#30363d}
.badge.stage{background:#21262d;color:var(--muted)}
.badge.page{background:#1f6feb}
.badge.mode{background:#238636}
.steps{margin:6px 0 14px;padding-left:22px}
.steps li{margin:4px 0}
.gallery{display:flex;gap:12px;overflow-x:auto;padding-bottom:8px}
.gallery figure{margin:0;flex:0 0 auto;max-width:340px}
.gallery img{width:100%;border:1px solid var(--line);border-radius:8px;display:block;background:#000}
.gallery figcaption{font-size:11px;color:var(--muted);margin-top:4px;word-break:break-all}
.noshot{color:var(--muted);font-style:italic}
footer{color:var(--muted);font-size:12px;text-align:center;padding:30px}
"""
TEMPLATE = """<!DOCTYPE html>
<html lang="zh-CN"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>流程1 操作手册 · 沙盒交付(两方/标准)</title>
<style>__CSS__</style></head>
<body>
<header>
<h1>流程1 操作手册 · 沙盒交付(两方/标准)</h1>
<div class="sub">数据使用方 ↔ 数据提供方 端到端 5 阶段 / 21 个节点 · 每节点配真实系统截图</div>
</header>
<div class="wrap">
<div class="stages">__STAGES__</div>
<div class="nav">__NAV__</div>
__NODES__
</div>
<footer>本手册由 seq-1 DAG 流程定义自动生成,截图取自 e2e 真实运行(results/shots)。操作以「角色视角」描述人工步骤。</footer>
</body></html>"""
html = TEMPLATE.replace("__CSS__", CSS).replace("__STAGES__", stage_html).replace("__NAV__", nav_html).replace("__NODES__", nodes_html)
with open(OUT, "w", encoding="utf-8") as f:
f.write(html)
print("OK ->", OUT, "size=", os.path.getsize(OUT))
if miss:
print("缺失截图(已跳过):", sorted(set(miss)))
else:
print("全部截图命中")