feat(platform): add custom time window monitor

This commit is contained in:
lingniu
2026-07-05 17:23:12 +08:00
parent afbe29b8de
commit 2e20ec5c81
3 changed files with 168 additions and 0 deletions

View File

@@ -1006,6 +1006,54 @@ export function History({
onClick: () => copyDeliveryPackage()
}
];
const timeWindowMonitorItems = [
{
title: '轨迹复盘',
value: validLocations.length > 0 ? `${validLocations.length.toLocaleString()}` : '待查询',
detail: `${filters.dateFrom || '-'}${filters.dateTo || '-'},先确认位置覆盖和断点。`,
action: '位置历史',
color: validLocations.length > 0 ? 'green' as const : 'orange' as const,
disabled: false,
onClick: () => openQueryTab('location')
},
{
title: '统计核对',
value: formatNumber(mileageDelta, ' km'),
detail: '把同一时间窗带到统计查询,核对区间里程和日报闭合。',
action: '统计查询',
color: isFiniteNumber(mileageDelta) ? 'green' as const : 'grey' as const,
disabled: !onOpenMileage,
onClick: () => onOpenMileage?.({ keyword: currentVehicleKeyword, protocol: currentProtocol, ...(filters.dateFrom ? { dateFrom: filters.dateFrom } : {}), ...(filters.dateTo ? { dateTo: filters.dateTo } : {}) })
},
{
title: '历史证据',
value: `${(rawFrames.total ?? 0).toLocaleString()}`,
detail: selectedFieldCount > 0 ? `包含 ${selectedFieldCount.toLocaleString()} 个字段裁剪。` : '保留原始明细和解析字段,解释位置、里程和字段来源。',
action: '明细证据',
color: (rawFrames.total ?? 0) > 0 ? 'blue' as const : 'grey' as const,
disabled: false,
onClick: () => openQueryTab('raw')
},
{
title: '告警复盘',
value: anomalyTotal > 0 ? `${anomalyTotal.toLocaleString()} 项提示` : '同步说明',
detail: '用同一车辆和时间窗打开告警事件,解释断链、字段缺失和质量影响。',
action: '告警说明',
color: anomalyTotal > 0 ? 'orange' as const : 'blue' as const,
disabled: false,
onClick: () => {
window.location.hash = buildAppHash({
page: 'alert-events',
keyword: currentVehicleKeyword,
protocol: currentProtocol,
filters: {
...(filters.dateFrom ? { dateFrom: filters.dateFrom } : {}),
...(filters.dateTo ? { dateTo: filters.dateTo } : {})
}
});
}
}
];
const historyReportTemplates = [
{
title: '轨迹报告',
@@ -1442,6 +1490,40 @@ export function History({
<Tag color={currentProtocol ? 'blue' : 'green'}>{currentProtocol || '全部数据通道'}</Tag>
<Typography.Text type="tertiary">{scopeDescription}</Typography.Text>
</div>
{mode === 'query' ? (
<Card bordered title="自定义时间窗监控台" style={{ marginTop: 16 }}>
<div className="vp-history-time-window-board">
<div className="vp-history-time-window-summary">
<Space wrap>
<Tag color="blue"></Tag>
<Tag color={deliveryStateColor}>{deliveryState}</Tag>
<Tag color={currentVehicleKeyword ? 'green' : 'orange'}>{currentVehicleKeyword || '全部车辆'}</Tag>
</Space>
<Typography.Title heading={5} style={{ margin: 0 }}></Typography.Title>
<Typography.Text type="secondary">
线穿
</Typography.Text>
</div>
<div className="vp-history-time-window-grid">
{timeWindowMonitorItems.map((item) => (
<button
key={item.title}
type="button"
className="vp-history-time-window-item"
disabled={item.disabled}
onClick={item.onClick}
aria-label={`自定义时间窗监控 ${item.title} ${item.action}`}
>
<Tag color={item.color}>{item.title}</Tag>
<strong>{item.value}</strong>
<span>{item.detail}</span>
<em>{item.action}</em>
</button>
))}
</div>
</div>
</Card>
) : null}
{mode === 'query' ? (
<Card bordered className="vp-history-customer-export-board" bodyStyle={{ padding: 0 }}>
<div className="vp-history-customer-export-summary">

View File

@@ -5665,6 +5665,84 @@ button.vp-realtime-command-item:focus-visible {
word-break: break-word;
}
.vp-history-time-window-board {
display: grid;
grid-template-columns: minmax(280px, 0.68fr) minmax(0, 1.32fr);
gap: 16px;
}
.vp-history-time-window-summary {
min-height: 176px;
padding: 14px;
border: 1px solid rgba(22, 100, 255, 0.2);
border-radius: var(--vp-radius);
background: #f5f9ff;
display: grid;
gap: 12px;
align-content: start;
}
.vp-history-time-window-summary .semi-typography {
font-size: 13px;
line-height: 20px;
}
.vp-history-time-window-grid {
min-width: 0;
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 12px;
}
.vp-history-time-window-item {
min-height: 176px;
padding: 12px;
border: 1px solid var(--vp-border);
border-radius: var(--vp-radius);
background: #fff;
color: inherit;
cursor: pointer;
font: inherit;
text-align: left;
display: grid;
gap: 8px;
align-content: start;
}
.vp-history-time-window-item:disabled {
cursor: not-allowed;
opacity: 0.58;
}
.vp-history-time-window-item:not(:disabled):hover,
.vp-history-time-window-item:not(:disabled):focus-visible {
border-color: rgba(22, 100, 255, 0.42);
background: #f5f9ff;
outline: none;
}
.vp-history-time-window-item strong {
color: var(--vp-text);
font-size: 18px;
line-height: 24px;
font-weight: 700;
word-break: break-word;
}
.vp-history-time-window-item span {
color: var(--vp-text-muted);
font-size: 12px;
line-height: 18px;
}
.vp-history-time-window-item em {
color: var(--vp-primary);
font-size: 12px;
font-style: normal;
font-weight: 700;
line-height: 18px;
}
.vp-history-customer-export-board {
margin-top: 16px;
overflow: hidden;
@@ -7729,6 +7807,8 @@ button.vp-realtime-command-item:focus-visible {
.vp-trajectory-anomaly-grid,
.vp-trajectory-impact-board,
.vp-trajectory-impact-grid,
.vp-history-time-window-board,
.vp-history-time-window-grid,
.vp-history-customer-export-board .semi-card-body,
.vp-history-customer-export-steps,
.vp-history-report-templates,

View File

@@ -6588,6 +6588,12 @@ test('shows parsed field history as a flattened evidence table', async () => {
render(<App />);
expect(await screen.findByRole('heading', { name: '历史查询导出' })).toBeInTheDocument();
expect(screen.getByText('自定义时间窗监控台')).toBeInTheDocument();
expect(screen.getByText('客户选定车辆和时间范围后,直接判断这个窗口能否用于轨迹复盘、统计核对、历史证据导出和告警说明。')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '自定义时间窗监控 轨迹复盘 位置历史' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '自定义时间窗监控 统计核对 统计查询' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '自定义时间窗监控 历史证据 明细证据' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '自定义时间窗监控 告警复盘 告警说明' })).toBeInTheDocument();
expect(screen.getByText('客户数据交付台')).toBeInTheDocument();
expect(screen.getByText('轨迹回放工作台')).toBeInTheDocument();
expect(screen.getByText('按车辆和时间窗复盘每一段行程')).toBeInTheDocument();