feat(platform): link quality issues to history evidence
This commit is contained in:
@@ -364,7 +364,7 @@ export default function App() {
|
|||||||
detail: <VehicleDetail vin={activeVin} protocol={activeProtocol} onOpenRealtime={openRealtimeForVehicle} onOpenHistory={openHistoryForVehicle} onOpenRaw={openRawForVehicle} onOpenMileage={openMileageForVehicle} onOpenVehicles={openVehicles} onOpenQuality={openQuality} onQueryChange={updateVehicleDetailQuery} />,
|
detail: <VehicleDetail vin={activeVin} protocol={activeProtocol} onOpenRealtime={openRealtimeForVehicle} onOpenHistory={openHistoryForVehicle} onOpenRaw={openRawForVehicle} onOpenMileage={openMileageForVehicle} onOpenVehicles={openVehicles} onOpenQuality={openQuality} onQueryChange={updateVehicleDetailQuery} />,
|
||||||
history: <History initialVin={analysisVin} initialProtocol={activeProtocol} initialTab={historyTab} initialFilters={historyFilters} onFiltersChange={updateHistoryFilters} onOpenVehicle={openVehicle} />,
|
history: <History initialVin={analysisVin} initialProtocol={activeProtocol} initialTab={historyTab} initialFilters={historyFilters} onFiltersChange={updateHistoryFilters} onOpenVehicle={openVehicle} />,
|
||||||
mileage: <Mileage initialVin={analysisVin} initialProtocol={activeProtocol} initialFilters={mileageFilters} onFiltersChange={updateMileageFilters} onOpenVehicle={openVehicle} onOpenHistory={openHistoryWithFilters} />,
|
mileage: <Mileage initialVin={analysisVin} initialProtocol={activeProtocol} initialFilters={mileageFilters} onFiltersChange={updateMileageFilters} onOpenVehicle={openVehicle} onOpenHistory={openHistoryWithFilters} />,
|
||||||
quality: <Quality onOpenVehicle={openVehicle} onHealthLoaded={(health) => setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length)} onFiltersChange={updateQualityFilters} initialFilters={qualityFilters} />
|
quality: <Quality onOpenVehicle={openVehicle} onOpenHistory={openHistoryWithFilters} onHealthLoaded={(health) => setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length)} onFiltersChange={updateQualityFilters} initialFilters={qualityFilters} />
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -121,6 +121,18 @@ function qualityShareURL() {
|
|||||||
return `${window.location.origin}${window.location.pathname}${window.location.hash}`;
|
return `${window.location.origin}${window.location.pathname}${window.location.hash}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function issueEvidenceDate(value?: string) {
|
||||||
|
const match = String(value ?? '').match(/^(\d{4})-(\d{2})-(\d{2})/);
|
||||||
|
return match ? `${match[1]}-${match[2]}-${match[3]}` : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextDate(value: string) {
|
||||||
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
||||||
|
if (!match) return '';
|
||||||
|
const date = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3]) + 1));
|
||||||
|
return date.toISOString().slice(0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
function qualityActionRecommendation(row: QualityIssueRow) {
|
function qualityActionRecommendation(row: QualityIssueRow) {
|
||||||
if (row.issueType === 'NO_SOURCE') {
|
if (row.issueType === 'NO_SOURCE') {
|
||||||
return {
|
return {
|
||||||
@@ -251,11 +263,13 @@ async function copyQualityShareURL() {
|
|||||||
|
|
||||||
export function Quality({
|
export function Quality({
|
||||||
onOpenVehicle,
|
onOpenVehicle,
|
||||||
|
onOpenHistory,
|
||||||
onHealthLoaded,
|
onHealthLoaded,
|
||||||
onFiltersChange,
|
onFiltersChange,
|
||||||
initialFilters = {}
|
initialFilters = {}
|
||||||
}: {
|
}: {
|
||||||
onOpenVehicle: (vin: string, protocol?: string) => void;
|
onOpenVehicle: (vin: string, protocol?: string) => void;
|
||||||
|
onOpenHistory?: (filters: Record<string, string>) => void;
|
||||||
onHealthLoaded?: (health: OpsHealth) => void;
|
onHealthLoaded?: (health: OpsHealth) => void;
|
||||||
onFiltersChange?: (filters: Record<string, string>) => void;
|
onFiltersChange?: (filters: Record<string, string>) => void;
|
||||||
initialFilters?: Record<string, string>;
|
initialFilters?: Record<string, string>;
|
||||||
@@ -338,6 +352,17 @@ export function Quality({
|
|||||||
filters.protocol ? `数据来源:${qualityProtocolLabel(filters.protocol)}` : '',
|
filters.protocol ? `数据来源:${qualityProtocolLabel(filters.protocol)}` : '',
|
||||||
filters.issueType ? `问题类型:${qualityIssueLabel(filters.issueType)}` : ''
|
filters.issueType ? `问题类型:${qualityIssueLabel(filters.issueType)}` : ''
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
const openIssueHistory = (row: QualityIssueRow) => {
|
||||||
|
const lookup = qualityIssueVehicleLookup(row);
|
||||||
|
const dateFrom = issueEvidenceDate(row.lastSeen);
|
||||||
|
const dateTo = nextDate(dateFrom);
|
||||||
|
onOpenHistory?.({
|
||||||
|
keyword: lookup.key,
|
||||||
|
protocol: row.protocol,
|
||||||
|
...(dateFrom ? { dateFrom } : {}),
|
||||||
|
...(dateTo ? { dateTo } : {})
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="vp-page">
|
<div className="vp-page">
|
||||||
@@ -573,13 +598,14 @@ export function Quality({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 250,
|
width: 330,
|
||||||
render: (_: unknown, row: QualityIssueRow) => {
|
render: (_: unknown, row: QualityIssueRow) => {
|
||||||
const lookup = qualityIssueVehicleLookup(row);
|
const lookup = qualityIssueVehicleLookup(row);
|
||||||
return (
|
return (
|
||||||
<Space spacing={4}>
|
<Space spacing={4}>
|
||||||
<Button size="small" icon={<IconCopy />} onClick={() => copyText(row.phone, '手机号')}>手机号</Button>
|
<Button size="small" icon={<IconCopy />} onClick={() => copyText(row.phone, '手机号')}>手机号</Button>
|
||||||
<Button size="small" icon={<IconCopy />} onClick={() => copyText(row.sourceEndpoint, '来源')}>来源</Button>
|
<Button size="small" icon={<IconCopy />} onClick={() => copyText(row.sourceEndpoint, '来源')}>来源</Button>
|
||||||
|
<Button size="small" disabled={!lookup.key || !onOpenHistory} onClick={() => openIssueHistory(row)}>核对历史</Button>
|
||||||
<Button size="small" disabled={!lookup.key} onClick={() => onOpenVehicle(lookup.key, row.protocol)}>
|
<Button size="small" disabled={!lookup.key} onClick={() => onOpenVehicle(lookup.key, row.protocol)}>
|
||||||
{lookup.label}
|
{lookup.label}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -2513,6 +2513,82 @@ test('opens vehicle service from quality issue with issue source evidence', asyn
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('opens same-day history evidence from quality issue row', async () => {
|
||||||
|
window.history.replaceState(null, '', '/#/quality');
|
||||||
|
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||||
|
const path = String(input);
|
||||||
|
if (path.includes('/api/ops/health')) {
|
||||||
|
return {
|
||||||
|
ok: true,
|
||||||
|
json: async () => ({
|
||||||
|
data: { linkHealth: [], kafkaLag: 0, redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } },
|
||||||
|
traceId: 'trace-test',
|
||||||
|
timestamp: 1783094400000
|
||||||
|
})
|
||||||
|
} as Response;
|
||||||
|
}
|
||||||
|
if (path.includes('/api/quality/summary')) {
|
||||||
|
return {
|
||||||
|
ok: true,
|
||||||
|
json: async () => ({
|
||||||
|
data: {
|
||||||
|
issueVehicleCount: 1,
|
||||||
|
issueRecordCount: 1,
|
||||||
|
errorCount: 0,
|
||||||
|
warningCount: 1,
|
||||||
|
protocols: [{ name: 'JT808', count: 1 }],
|
||||||
|
issueTypes: [{ name: 'LINK_GAP', count: 1 }]
|
||||||
|
},
|
||||||
|
traceId: 'trace-test',
|
||||||
|
timestamp: 1783094400000
|
||||||
|
})
|
||||||
|
} as Response;
|
||||||
|
}
|
||||||
|
if (path.includes('/api/quality/issues')) {
|
||||||
|
return {
|
||||||
|
ok: true,
|
||||||
|
json: async () => ({
|
||||||
|
data: {
|
||||||
|
items: [{
|
||||||
|
vin: 'VIN-QUALITY-HISTORY',
|
||||||
|
plate: '粤A告警证',
|
||||||
|
phone: '13307795425',
|
||||||
|
sourceEndpoint: '115.231.168.135:43625',
|
||||||
|
protocol: 'JT808',
|
||||||
|
issueType: 'LINK_GAP',
|
||||||
|
severity: 'warning',
|
||||||
|
lastSeen: '2026-07-03 20:12:10',
|
||||||
|
detail: 'JT808 来源存在上报间断'
|
||||||
|
}],
|
||||||
|
total: 1,
|
||||||
|
limit: 20,
|
||||||
|
offset: 0
|
||||||
|
},
|
||||||
|
traceId: 'trace-test',
|
||||||
|
timestamp: 1783094400000
|
||||||
|
})
|
||||||
|
} as Response;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
ok: true,
|
||||||
|
json: async () => ({
|
||||||
|
data: { items: [], total: 0, limit: 20, offset: 0 },
|
||||||
|
traceId: 'trace-test',
|
||||||
|
timestamp: 1783094400000
|
||||||
|
})
|
||||||
|
} as Response;
|
||||||
|
});
|
||||||
|
|
||||||
|
render(<App />);
|
||||||
|
|
||||||
|
expect(await screen.findByText('VIN-QUALITY-HISTORY')).toBeInTheDocument();
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: '核对历史' }));
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(window.location.hash).toBe('#/history?keyword=VIN-QUALITY-HISTORY&protocol=JT808&dateFrom=2026-07-03&dateTo=2026-07-04');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('drills into quality issues by issue type', async () => {
|
test('drills into quality issues by issue type', async () => {
|
||||||
window.history.replaceState(null, '', '/#/quality');
|
window.history.replaceState(null, '', '/#/quality');
|
||||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user