F-10-async-task-worker-operation.html 22.7 KB
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>F-10 异步任务处理服务 测试操作 — llm-call-platform</title>
<style>
/* === Magic-Vision 设计系统 === */
:root {
  --color-primary: #2563eb; --color-primary-light: #dbeafe; --color-primary-dark: #1e40af;
  --color-success: #16a34a; --color-success-light: #dcfce7;
  --color-warning: #d97706; --color-warning-light: #fef3c7;
  --color-danger: #dc2626; --color-danger-light: #fee2e2;
  --color-pending: #6b7280; --color-pending-light: #f3f4f6;
  --color-bg: #ffffff; --color-bg-secondary: #f8fafc;
  --color-border: #e2e8f0; --color-text: #1e293b;
  --color-text-secondary: #64748b; --color-text-muted: #94a3b8;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  --radius: 8px; --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1); --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-family); background: var(--color-bg-secondary); color: var(--color-text); line-height: 1.6; min-height: 100vh; }
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* 通用组件 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-confirmed { background: var(--color-success-light); color: var(--color-success); }
.badge-pending { background: var(--color-pending-light); color: var(--color-pending); }
.badge-doubt { background: var(--color-warning-light); color: var(--color-warning); }
.priority { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; }
.priority-p0 { background: var(--color-danger-light); color: var(--color-danger); }
.priority-p1 { background: var(--color-warning-light); color: var(--color-warning); }
.priority-p2 { background: var(--color-primary-light); color: var(--color-primary); }
.card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: var(--color-bg-secondary); border-bottom: 1px solid var(--color-border); }
.card-title { margin: 0; font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }
.accordion { border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 12px; }
.accordion-summary { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; cursor: pointer; font-weight: 600; background: var(--color-bg-secondary); list-style: none; }
.accordion-summary::-webkit-details-marker { display: none; }
.accordion[open] .accordion-summary { border-bottom: 1px solid var(--color-border); }
.accordion-content { padding: 20px; }
.tabs { margin-bottom: 24px; }
.tab-nav { display: flex; gap: 0; border-bottom: 2px solid var(--color-border); margin-bottom: 20px; }
.tab-btn { padding: 10px 20px; border: none; background: none; cursor: pointer; font-size: 0.9rem; font-weight: 500; color: var(--color-text-secondary); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th { padding: 12px 14px; text-align: left; font-weight: 600; background: var(--color-bg-secondary); border-bottom: 2px solid var(--color-border); font-size: 0.78rem; text-transform: uppercase; color: var(--color-text-secondary); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--color-bg-secondary); }
.stack-tag { display: inline-block; padding: 2px 8px; margin: 2px; background: var(--color-primary-light); color: var(--color-primary-dark); border-radius: 4px; font-size: 0.75rem; font-weight: 500; }
.tree { font-family: var(--font-mono); font-size: 0.875rem; line-height: 2; }
.tree-node { padding: 2px 0; }
.tree-children { padding-left: 24px; border-left: 1px dashed var(--color-border); margin-left: 8px; }
.tree-icon { margin-right: 6px; }
.tree-comment { color: var(--color-text-muted); font-size: 0.8rem; font-family: var(--font-family); margin-left: 8px; }

/* 顶部导航栏 */
.top-nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; background: var(--color-bg); border-bottom: 1px solid var(--color-border); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100; }
.nav-left { display: flex; align-items: center; gap: 8px; }
.nav-title { margin: 0; font-size: 1.25rem; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-version { font-size: 0.85rem; color: var(--color-text-secondary); }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-label { font-size: 0.8rem; color: var(--color-text-muted); }
.nav-link { padding: 4px 12px; border-radius: var(--radius-sm); text-decoration: none; font-size: 0.85rem; font-weight: 500; color: var(--color-primary); border: 1px solid var(--color-primary-light); transition: all 0.2s; }
.nav-link:hover { background: var(--color-primary-light); }
.back-link { color: var(--color-text-secondary); text-decoration: none; font-size: 0.85rem; padding: 4px 10px; border-radius: var(--radius-sm); transition: all 0.2s; }
.back-link:hover { color: var(--color-primary); background: var(--color-primary-light); }

/* Hero 标题卡片 */
.hero-card { display: flex; align-items: center; justify-content: space-between; padding: 24px; background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-bg) 100%); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-md); margin-bottom: 24px; }
.hero-title { margin: 0 0 8px; font-size: 1.5rem; }
.hero-goal { margin: 0; color: var(--color-text-secondary); font-size: 1rem; }

/* 页脚 */
.footer { text-align: center; padding: 32px; color: var(--color-text-muted); font-size: 0.8rem; }

/* 信息网格 */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; }
.info-item { display: flex; flex-direction: column; padding: 12px 16px; border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border); }
.info-item:nth-child(3n) { border-right: none; }
.info-full { grid-column: 1 / -1; border-right: none; }
.info-label { font-size: 0.72rem; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: 4px; font-weight: 600; letter-spacing: 0.05em; }
.info-value { font-size: 0.9rem; }
.info-value code { font-family: var(--font-mono); background: var(--color-bg-secondary); padding: 1px 6px; border-radius: 3px; font-size: 0.85rem; }

/* 导航中心 */
.nav-card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; transition: box-shadow 0.2s; }
.nav-card:hover { box-shadow: var(--shadow-md); }
.nav-card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--color-bg-secondary); border-bottom: 1px solid var(--color-border); }
.nav-card-title { display: flex; align-items: center; gap: 10px; font-size: 1rem; font-weight: 600; }
.nav-card-icon { font-size: 1.2rem; }
.nav-card-date { font-size: 0.75rem; color: var(--color-text-muted); }
.nav-card-body { padding: 8px 0; }
.nav-card-body.empty { padding: 20px 24px; color: var(--color-text-muted); font-style: italic; text-align: center; }
.nav-file-link { display: flex; align-items: center; padding: 8px 24px; text-decoration: none; color: var(--color-text); font-size: 0.9rem; transition: background 0.15s; }
.nav-file-link:hover { background: var(--color-primary-light); color: var(--color-primary); }
.nav-file-link .file-icon { margin-right: 10px; font-size: 0.85rem; flex-shrink: 0; }
.nav-file-link .file-desc { margin-left: auto; font-size: 0.78rem; color: var(--color-text-muted); }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 13px; opacity: 0; transition: opacity .2s; z-index: 200; }
.toast.show { opacity: 1; }

/* 交互图 */
.diagram-container { background: var(--color-bg-secondary); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; overflow-x: auto; }
.interaction-svg, .flow-svg, .dep-svg { width: 100%; height: auto; }
.node-box { fill: var(--color-bg); stroke-width: 2; }
.node-t01 { stroke: var(--color-primary); }
.node-t02 { stroke: var(--color-success); }
.node-db { stroke: var(--color-warning); }
.node-title { font-size: 0.85rem; font-weight: 700; fill: var(--color-text); }
.node-subtitle { font-size: 0.7rem; fill: var(--color-text-secondary); }
.edge { stroke: var(--color-text-muted); stroke-width: 2; }
.edge-label { font-size: 0.7rem; fill: var(--color-text-secondary); }

/* 技术栈卡片网格 */
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tech-card { position: relative; padding: 20px; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-bg); box-shadow: var(--shadow); border-top: 3px solid var(--color-pending); }
.tech-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tech-card.dimension-frontend { border-top-color: var(--color-primary); }
.tech-card.dimension-backend { border-top-color: var(--color-success); }
.tech-card.dimension-database { border-top-color: var(--color-warning); }
.tech-card.dimension-cache { border-top-color: #e11d48; }
.tech-card.dimension-deploy { border-top-color: #7c3aed; }
.tech-card.dimension-disabled { opacity: 0.55; border-top-color: var(--color-border); }
.tech-card-icon { font-size: 1.5rem; margin-bottom: 8px; }
.tech-dimension { margin: 0 0 12px; font-size: 0.95rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-secondary); }
.tech-choice, .tech-reason, .tech-alt { font-size: 0.85rem; margin-bottom: 8px; color: var(--color-text); }
.tech-na { font-size: 0.85rem; color: var(--color-text-muted); font-style: italic; }
.tech-card .badge { position: absolute; top: 16px; right: 16px; }

.op-type { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 16px; font-size: 0.8rem; font-weight: 600; }
.op-type-admin { background: #dbeafe; color: #1e40af; }
.op-type-external { background: #dcfce7; color: #166534; }
.op-type-system { background: #f3e8ff; color: #6b21a8; }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 8px 0; font-size: 0.85rem; }
.crumb { padding: 3px 10px; background: var(--color-bg-secondary); border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text-secondary); }
.crumb.active { background: var(--color-primary-light); border-color: var(--color-primary); color: var(--color-primary); font-weight: 600; }
.crumb-arrow { color: var(--color-text-muted); font-size: 0.75rem; }
.op-badge { display: inline-block; padding: 3px 12px; border-radius: 14px; font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700; cursor: pointer; transition: all 0.15s; }
.op-badge:hover { filter: brightness(0.95); transform: scale(1.05); }
.op-badge-admin { background: #dbeafe; color: #1e40af; }
.op-badge-external { background: #dcfce7; color: #166534; }
.op-badge-system { background: #f3e8ff; color: #6b21a8; }
.step-card { border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; box-shadow: var(--shadow); }
.step-card.impl-not { border-left: 4px solid var(--color-pending); }
.step-card.impl-done { border-left: 4px solid var(--color-success); }
.step-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; background: var(--color-bg-secondary); border-bottom: 1px solid var(--color-border); }
.step-header-left { display: flex; align-items: center; gap: 8px; }
.step-header-right { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.step-body { padding: 20px; }
.step-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; background: var(--color-bg-secondary); border-top: 1px solid var(--color-border); }
.step-label { display: block; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-secondary); margin-bottom: 8px; }
.action-list { margin: 0; padding-left: 20px; font-size: 0.9rem; line-height: 2; }
.backend-list { margin: 0; padding-left: 20px; font-size: 0.88rem; line-height: 2; }
.backend-tag { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 0.68rem; font-weight: 700; margin-right: 6px; }
.tag-receive { background: #dbeafe; color: #1e40af; }
.tag-validate { background: #fef3c7; color: #92400e; }
.tag-write { background: #dcfce7; color: #166534; }
.tag-query { background: #e0f2fe; color: #0369a1; }
.tag-return { background: #f3f4f6; color: #374151; }
.tag-external { background: #f3e8ff; color: #6b21a8; }
.impl-status { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 14px; font-size: 0.78rem; font-weight: 600; }
.impl-not { background: var(--color-pending-light); color: var(--color-pending); }
.impl-done { background: var(--color-success-light); color: var(--color-success); }
.scenario-card { border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 28px; overflow: hidden; }
.scenario-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%); border-bottom: 1px solid var(--color-border); }
.scenario-title { font-weight: 700; font-size: 1rem; }
.scenario-meta { padding: 14px 20px; background: #fffbeb; border-bottom: 1px solid #fde68a; font-size: 0.85rem; }
.scenario-expect { padding: 14px 20px; background: #f0fdf4; border-top: 1px solid #bbf7d0; font-size: 0.88rem; }
.scenario-expect-label { font-weight: 700; color: var(--color-success); margin-right: 8px; }
.trigger-info { display: flex; align-items: center; gap: 10px; }
.trigger-source { padding: 4px 12px; background: var(--color-warning-light); border-radius: 4px; font-size: 0.85rem; font-weight: 600; color: var(--color-warning); }
.trigger-time { font-size: 0.85rem; color: var(--color-text-secondary); font-family: var(--font-mono); }
.op-stat { font-size: 0.82rem; color: var(--color-text-secondary); }
.op-stat strong { color: var(--color-text); }
.module-id { font-family: var(--font-mono); font-weight: 700; color: var(--color-primary); }
.module-id.large { font-size: 1.1em; margin-right: 8px; }

/* OP 变更记录指示 — 单独一行 */
.step-changelog-row { display: flex; align-items: center; gap: 12px; padding: 8px 20px; background: #fffbeb; border-top: 1px solid #fde68a; border-bottom: 1px solid #fde68a; font-size: 0.78rem; }
.op-changelog-new { display: inline-block; padding: 2px 8px; background: var(--color-danger); color: #fff; border-radius: 4px; font-size: 0.65rem; font-weight: 700; }
.op-changelog-id { font-family: var(--font-mono); font-weight: 700; color: #78350f; }
.op-changelog-date { font-family: var(--font-mono); color: #b45309; }
.op-changelog-reason { color: #92400e; }
.op-changelog-label { font-weight: 600; color: var(--color-text-muted); font-size: 0.72rem; }
</style>
</head>
<body>
<nav class="top-nav">
  <div class="nav-left">
    <a href="../index.html" class="back-link" title="返回文档导航中心">🏠 导航</a>
    <a href="overview.html" class="back-link">← 测试总览</a>
    <h1 class="nav-title"><span class="module-id">F-10</span> 异步任务处理服务 测试操作</h1>
  </div>
  <div class="nav-right">
    <span class="op-stat">共 <strong>3</strong> 个 OP</span>
  </div>
</nav>

<main class="container">
  <div class="hero-card">
    <div class="hero-left">
      <h2 class="hero-title"><span class="module-id large">F-10</span> 异步任务处理服务 操作流程</h2>
      <p class="hero-goal">Celery Worker 实现的后台异步任务处理服务。消费 Celery 队列中的 LLM 调用任务,加载配置后调用 F-09 适配引擎执行模型请求。执行完成后更新 F-04 任务状态并写入调用记录。<br><br>替代 Java 项目的 Elastic-Job LlmJob/EngJob(每分钟 cron 扫描 + 线程池 ExecutorService 并行处理)。Celery 提供原生任务队列机制,避免数据库轮询。</p>
    </div>
  </div>

  <div class="tabs">
    <div class="tab-nav">
      <button class="tab-btn active" onclick="switchTab(event, 'tab-api')">🔌 API</button>
    </div>
    <div class="tab-content active" id="tab-api"><div class="scenario-card"><div class="scenario-header"><span class="scenario-title">📋 处理异步 LLM 调用:加载配置→调用适配器→写入结果→更新任务状态</span><span class="badge badge-confirmed">必须</span></div><div class="scenario-meta">前置条件:Celery 队列中存在待处理的异步任务</div><div class="step-card impl-done"><div class="step-header"><span class="step-header-left"><span class="impl-status impl-done">✅ 已实现</span></span><span class="step-header-right"><span class="op-badge op-badge-api" onclick="copyOP('OP-F-10.1.1')" title="点击复制">OP-F-10.1.1</span><span class="crumb">API 客户端 › 处理异步 LLM 调用:加载配置→调用适配器→写入结果→更新任务状态</span></span></div><div class="step-body"><span class="step-label">📝 操作步骤</span><ol class="action-list"><li>准备 API Token</li><li>构造请求</li><li>发送请求</li></ol><span class="step-label" style="margin-top:16px">⚙️ 后端逻辑</span><ol class="backend-list"><li><span class="backend-tag tag-receive">receive</span> 接收 GET Task 请求</li><li><span class="backend-tag tag-query">query</span> 从数据库表按条件查询记录</li><li><span class="backend-tag tag-validate">validate</span> 验证记录存在和修改后的字段</li><li><span class="backend-tag tag-write">write</span> 更新数据库表记录</li><li><span class="backend-tag tag-return">return</span> 返回操作结果</li></ol><span class="step-label" style="margin-top:16px">✅ 预期结果</span><ol class="action-list"><li>任务执行完成</li><li>async_tasks 状态更新为 success/failed</li></ol></div></div><div class="scenario-expect"><span class="scenario-expect-label">🔍 场景预期:</span>任务执行完成;async_tasks 状态更新为 success/failed</div></div></div><div class="tab-content active" id="tab-api"><div class="scenario-card"><div class="scenario-header"><span class="scenario-title">📋 任务失败自动重试(可配置最大重试次数)</span><span class="badge badge-confirmed">必须</span></div><div class="scenario-meta">前置条件:存在执行失败的异步任务</div><div class="step-card impl-done"><div class="step-header"><span class="step-header-left"><span class="impl-status impl-done">✅ 已实现</span></span><span class="step-header-right"><span class="op-badge op-badge-api" onclick="copyOP('OP-F-10.2.1')" title="点击复制">OP-F-10.2.1</span><span class="crumb">API 客户端 › 任务失败自动重试(可配置最大重试次数)</span></span></div><div class="step-body"><span class="step-label">📝 操作步骤</span><ol class="action-list"><li>准备 API Token</li><li>构造请求</li><li>发送请求</li></ol><span class="step-label" style="margin-top:16px">⚙️ 后端逻辑</span><ol class="backend-list"><li><span class="backend-tag tag-receive">receive</span> 接收 GET Task.retry() 请求</li><li><span class="backend-tag tag-validate">validate</span> 验证请求参数</li><li><span class="backend-tag tag-query">query</span> 从数据库表按条件查询记录</li><li><span class="backend-tag tag-return">return</span> 返回操作结果</li></ol><span class="step-label" style="margin-top:16px">✅ 预期结果</span><ol class="action-list"><li>任务自动重试执行</li><li>重试次数 +1</li></ol></div></div><div class="scenario-expect"><span class="scenario-expect-label">🔍 场景预期:</span>任务自动重试执行;重试次数 +1</div></div></div><div class="tab-content active" id="tab-api"><div class="scenario-card"><div class="scenario-header"><span class="scenario-title">📋 批量处理:扫描待处理任务列表,批量提交到线程池并行执行</span><span class="badge badge-confirmed">必须</span></div><div class="scenario-meta">前置条件:存在多个待处理的异步任务</div><div class="step-card impl-done"><div class="step-header"><span class="step-header-left"><span class="impl-status impl-done">✅ 已实现</span></span><span class="step-header-right"><span class="op-badge op-badge-api" onclick="copyOP('OP-F-10.3.1')" title="点击复制">OP-F-10.3.1</span><span class="crumb">API 客户端 › 批量处理:扫描待处理任务列表,批量提交到线程池并行执行</span></span></div><div class="step-body"><span class="step-label">📝 操作步骤</span><ol class="action-list"><li>准备 API Token</li><li>构造请求</li><li>发送请求</li></ol><span class="step-label" style="margin-top:16px">⚙️ 后端逻辑</span><ol class="backend-list"><li><span class="backend-tag tag-receive">receive</span> 接收 GET 定时触发 请求</li><li><span class="backend-tag tag-validate">validate</span> 验证分页和筛选参数</li><li><span class="backend-tag tag-query">query</span> 从数据库表按条件查询记录</li><li><span class="backend-tag tag-return">return</span> 返回分页结果</li></ol><span class="step-label" style="margin-top:16px">✅ 预期结果</span><ol class="action-list"><li>批量任务按序处理</li><li>各任务状态更新</li></ol></div></div><div class="scenario-expect"><span class="scenario-expect-label">🔍 场景预期:</span>批量任务按序处理;各任务状态更新</div></div></div>
  </div>
</main>
<footer class="footer">Magic-Vision-Spec · F-10 异步任务处理服务 测试操作 · v1.0</footer>

<script>
function switchTab(event, tabId) {
  document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
  document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
  event.target.classList.add('active');
  document.getElementById(tabId).classList.add('active');
}
function copyOP(text) {
  navigator.clipboard.writeText(text).then(() => {}).catch(() => {});
}
</script>
</body>
</html>