fix(burst-location): explain normal data source
This commit is contained in:
@@ -75,6 +75,33 @@ const toneStyles: Record<
|
||||
const formatDateTime = (value?: string) =>
|
||||
value ? dayjs(value).format("MM-DD HH:mm") : "-";
|
||||
|
||||
const formatDateTimeRange = (start?: string, end?: string) => {
|
||||
if (!start || !end) return "-";
|
||||
return `${formatDateTime(start)} 至 ${formatDateTime(end)}`;
|
||||
};
|
||||
|
||||
const getDataSourceLabel = (result: BurstLocationResult) =>
|
||||
result.data_source === "simulation" ? "模拟方案" : "监测数据";
|
||||
|
||||
const getNormalDataDescription = (result: BurstLocationResult) => {
|
||||
switch (result.observed_source) {
|
||||
case "simulation_scheme_burst_realtime_normal_timerange":
|
||||
return "正常数据读取实时模拟结果,与爆管数据使用同一时间窗。";
|
||||
case "scada_burst_scada_normal_timerange":
|
||||
return "正常数据读取监测数据;未单独指定正常时间窗时,默认使用爆管时段前一天同一时段。";
|
||||
case "scada_burst_payload_normal_timerange":
|
||||
return "爆管数据读取监测数据,正常数据来自请求载荷。";
|
||||
case "simulation_scheme_timerange":
|
||||
return "历史方案记录:爆管数据和正常数据均读取方案模拟结果。";
|
||||
case "scada_timerange":
|
||||
return "历史方案记录:爆管数据和正常数据使用同一监测时间窗。";
|
||||
case "request_payload":
|
||||
return "爆管数据和正常数据均来自请求载荷。";
|
||||
default:
|
||||
return "正常数据按后端返回的数据源规则选择。";
|
||||
}
|
||||
};
|
||||
|
||||
const MetricCard = ({ label, value, hint, tone }: MetricCardProps) => {
|
||||
const style = toneStyles[tone];
|
||||
return (
|
||||
@@ -214,6 +241,16 @@ const LocationResults: React.FC<Props> = ({ result }) => {
|
||||
const burstTime = result.scada_window?.burst_start
|
||||
? formatDateTime(result.scada_window.burst_start)
|
||||
: "-";
|
||||
const burstWindow = formatDateTimeRange(
|
||||
result.scada_window?.burst_start,
|
||||
result.scada_window?.burst_end,
|
||||
);
|
||||
const normalWindow = formatDateTimeRange(
|
||||
result.scada_window?.normal_start,
|
||||
result.scada_window?.normal_end,
|
||||
);
|
||||
const sourceLabel = getDataSourceLabel(result);
|
||||
const normalDataDescription = getNormalDataDescription(result);
|
||||
|
||||
return (
|
||||
<Box className="h-full overflow-auto p-1">
|
||||
@@ -287,6 +324,31 @@ const LocationResults: React.FC<Props> = ({ result }) => {
|
||||
tone="green"
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Box className="rounded-lg border border-gray-200 bg-gray-50 px-3 py-2">
|
||||
<Box className="mb-1 flex flex-wrap items-center gap-1.5">
|
||||
<Chip
|
||||
size="small"
|
||||
label={sourceLabel}
|
||||
color={result.data_source === "simulation" ? "secondary" : "primary"}
|
||||
sx={{ height: 22, fontSize: "0.72rem", fontWeight: 600 }}
|
||||
/>
|
||||
<Typography variant="caption" className="text-gray-600">
|
||||
正常数据选择说明
|
||||
</Typography>
|
||||
</Box>
|
||||
<Typography variant="caption" className="block leading-5 text-gray-700">
|
||||
{normalDataDescription}
|
||||
</Typography>
|
||||
<Typography variant="caption" className="mt-1 block leading-5 text-gray-500">
|
||||
爆管窗口: {burstWindow};正常窗口: {normalWindow}
|
||||
</Typography>
|
||||
{result.data_source === "simulation" && result.simulation_scheme?.name ? (
|
||||
<Typography variant="caption" className="mt-1 block truncate text-purple-600">
|
||||
爆管方案: {result.simulation_scheme.name}
|
||||
</Typography>
|
||||
) : null}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Candidate List */}
|
||||
|
||||
Reference in New Issue
Block a user