Files
next-tjwater-frontend/src/features/workbench/peripheral-sample/scada-anomaly-agent-trigger.ts
T
jiang 2d8506fea0
Generic Container CI/CD / test-build-publish (push) Successful in 2m9s
Frontend CI/CD / build-test-publish-and-deploy (push) Successful in 2m39s
feat: add project-aware agent workspace
2026-10-22 18:52:18 +08:00

28 lines
1.0 KiB
TypeScript

import type { CreateInvestigationInput } from "../hooks/use-operational-tasks";
import type { PeripheralTestDataRecord } from "./client";
export function buildScadaAnomalyInvestigation(
record: PeripheralTestDataRecord
): CreateInvestigationInput {
const valueLabel = record.value === null
? "无有效读数"
: `${record.value}${record.unit ? ` ${record.unit}` : ""}`;
const anomalyDetail = record.notes.replace("[SCADA_ANOMALY]", "").trim();
return {
kind: "scada_anomaly",
title: `SCADA 异常调查 · ${record.point_id}`,
summary: `${record.point_id} 在 ${record.observed_at} 记录模拟异常值 ${valueLabel}。${anomalyDetail}`,
detail: `由外围 SCADA 合成读数触发,点位 ${record.point_id},读数 ${valueLabel},发生时间 ${record.observed_at}。`,
occurredAt: record.observed_at,
priority: "normal",
source: {
kind: "external_system",
external_id: record.record_id,
external_revision: record.revision,
event_kind: "scada_anomaly"
},
triggerKind: "event"
};
}