feat: refactor artifact analysis workspace

This commit is contained in:
2026-08-19 16:09:51 +08:00
parent bfadc95f93
commit d2f2895c36
26 changed files with 998 additions and 2278 deletions
@@ -1,12 +1,20 @@
import type { AnalysisDocument } from "./workspace-model";
import type { AnalysisArtifact } from "./workspace-model";
type FixtureFactory = (id: string, generatedAt: string) => AnalysisDocument;
type FixtureFactory = (id: string, generatedAt: string) => AnalysisArtifact;
const PRESSURE_DIAGNOSIS: FixtureFactory = (id, generatedAt) => ({
id,
type: "diagnosis",
lifecycle: "reviewed",
revision: 3,
title: "北辰分区压力异常诊断",
subtitle: "Agent 汇总最近 6 小时 SCADA 压力、流量与泵组工况",
summary: "北辰低压由上游泵组扰动与局部供水缺口共同触发,7 个测点需要持续观察。",
scope: "北辰供水分区 · 最近 6 小时",
confidence: "92.6%",
generatedAt,
preferredView: "map_split",
mapRelation: "required",
blocks: [
{
id: "pressure-metrics",
@@ -65,14 +73,28 @@ const PRESSURE_DIAGNOSIS: FixtureFactory = (id, generatedAt) => ({
{ time: "10:21", source: "二泵站 2#", finding: "出口压力波动 0.041 MPa", impact: "上游扰动", confidence: "88.9%" }
]
}
],
sources: ["SCADA 压力遥测", "泵站运行记录", "供水分区拓扑"],
limitations: ["BC-P-026 在 09:12 至 09:24 存在数据缺口", "尚未纳入现场阀门开度复核结果"],
actions: [
{ id: "locate", label: "定位异常测点", description: "在地图中定位 7 个异常测点", tone: "primary" },
{ id: "review", label: "标记为已复核", description: "将当前版本进入复核完成状态", tone: "neutral" }
]
});
const SUPPLY_ZONE_ANALYSIS: FixtureFactory = (id, generatedAt) => ({
id,
type: "metric_analysis",
lifecycle: "draft",
revision: 2,
title: "供水服务分区平衡分析",
subtitle: "Agent 对比分区供水量、需求预测和关键连通通道",
summary: "北辰与东丽接近能力上限,津南仍有可调配余量,建议优先验证三条联络线。",
scope: "六个服务分区 · 今日峰值预测",
confidence: "88.4%",
generatedAt,
preferredView: "focus",
mapRelation: "none",
blocks: [
{
id: "zone-metrics",
@@ -129,14 +151,28 @@ const SUPPLY_ZONE_ANALYSIS: FixtureFactory = (id, generatedAt) => ({
"执行前需复核三泵站 2# 泵组可用状态,并确认阀门 V-BC-103、V-DL-047 的远控权限。"
]
}
],
sources: ["分区日供水量", "短期需求预测", "连通能力台账"],
limitations: ["需求预测未包含临时大型活动增量", "联络线能力采用最近一次校核值"],
actions: [
{ id: "compare", label: "生成方案对比", description: "基于当前结论创建调配模拟", tone: "primary" },
{ id: "export", label: "导出摘要", description: "导出当前分析摘要", tone: "neutral" }
]
});
const DISPATCH_FLOW: FixtureFactory = (id, generatedAt) => ({
id,
type: "simulation",
lifecycle: "published",
revision: 5,
title: "低压事件调度处置流程",
subtitle: "Agent 将诊断、复核、调度和验证步骤编排为受控流程",
summary: "建议方案预计在 20 分钟内恢复目标压力,执行前仍有 3 项权限与现场状态待确认。",
scope: "北辰低压事件 · 30 分钟模拟",
confidence: "90.8%",
generatedAt,
preferredView: "map_split",
mapRelation: "required",
blocks: [
{
id: "flow-metrics",
@@ -196,12 +232,18 @@ const DISPATCH_FLOW: FixtureFactory = (id, generatedAt) => ({
{ name: "执行建议方案", values: [0.186, 0.204, 0.226, 0.251, 0.267, 0.281], color: "#2563eb" }
]
}
],
sources: ["低压事件诊断 R3", "调度规则库", "水力模拟结果"],
limitations: ["模拟未计入突发大用户需求变化", "远控动作必须由值班调度二次确认"],
actions: [
{ id: "prepare", label: "准备受控执行", description: "生成执行前确认清单", tone: "primary" },
{ id: "archive", label: "归档方案", description: "保留当前模拟版本", tone: "neutral" }
]
});
const FIXTURE_FACTORIES = [PRESSURE_DIAGNOSIS, SUPPLY_ZONE_ANALYSIS, DISPATCH_FLOW] as const;
export function createAnalysisDocumentFixture(index: number, instance: number): AnalysisDocument {
export function createAnalysisArtifactFixture(index: number, instance: number): AnalysisArtifact {
const factory = FIXTURE_FACTORIES[index % FIXTURE_FACTORIES.length] ?? PRESSURE_DIAGNOSIS;
const now = new Date();
return factory(