feat(platform): add customer mileage decision panel
This commit is contained in:
@@ -240,6 +240,73 @@ function mileageDeliveryPackageText({
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function mileageCustomerDecisionText({
|
||||
filters,
|
||||
summary,
|
||||
pageMileageTotal,
|
||||
pageCoverageRate,
|
||||
anomalyCount,
|
||||
closureStatus,
|
||||
closureDeltaKm,
|
||||
confidenceStatus,
|
||||
publishAuditConclusion,
|
||||
onlineSummary,
|
||||
peakMileage,
|
||||
statisticsURL,
|
||||
vehicleURL
|
||||
}: {
|
||||
filters: Record<string, string>;
|
||||
summary: MileageSummary;
|
||||
pageMileageTotal: number;
|
||||
pageCoverageRate: number;
|
||||
anomalyCount: number;
|
||||
closureStatus: string;
|
||||
closureDeltaKm?: number;
|
||||
confidenceStatus: string;
|
||||
publishAuditConclusion: string;
|
||||
onlineSummary: OnlineStatisticsSummary;
|
||||
peakMileage?: DailyMileageRow;
|
||||
statisticsURL: string;
|
||||
vehicleURL?: string;
|
||||
}) {
|
||||
const keyword = filters.keyword?.trim() || '全部车辆';
|
||||
const protocol = filters.protocol?.trim() || '全部来源';
|
||||
const dateFrom = filters.dateFrom?.trim();
|
||||
const dateTo = filters.dateTo?.trim();
|
||||
const dateRange = dateFrom || dateTo ? `${dateFrom || '-'} 至 ${dateTo || '-'}` : '全部日期';
|
||||
const deliveryState = publishAuditConclusion === '可发布' && confidenceStatus === '可用于 BI'
|
||||
? '可交付'
|
||||
: publishAuditConclusion === '阻断发布' ? '暂缓交付' : '复核后交付';
|
||||
const peak = peakMileage
|
||||
? `${peakMileage.plate || peakMileage.vin} / ${peakMileage.date} / ${formatKm(peakMileage.dailyMileageKm)} km`
|
||||
: '-';
|
||||
return [
|
||||
'【客户里程决策说明】',
|
||||
`决策结论:${deliveryState}`,
|
||||
`车辆范围:${keyword}`,
|
||||
`数据来源:${protocol}`,
|
||||
`时间范围:${dateRange}`,
|
||||
`区间总里程:${formatKm(summary.totalMileageKm)} km`,
|
||||
`当前明细合计:${formatKm(pageMileageTotal)} km`,
|
||||
`区间闭合:${closureStatus}${closureDeltaKm == null ? ',当前为分页抽样' : `,差值 ${formatKm(Math.abs(closureDeltaKm))} km`}`,
|
||||
`记录覆盖:${formatPercent(pageCoverageRate)}`,
|
||||
`异常记录:${anomalyCount.toLocaleString()} 条`,
|
||||
`最高单日:${peak}`,
|
||||
`在线影响:${onlineSummary.onlineVehicleCount.toLocaleString()} 在线 / ${onlineSummary.offlineVehicleCount.toLocaleString()} 离线 / 在线率 ${formatPercent(onlineSummary.onlineRatePercent)}`,
|
||||
`BI发布判断:${publishAuditConclusion}`,
|
||||
'',
|
||||
'客户判断路径:',
|
||||
'1. 先看区间闭合:区间总值必须等于每日里程之和。',
|
||||
'2. 再看记录覆盖:发布前需要覆盖全量明细或导出全量。',
|
||||
'3. 再看异常记录:异常日必须回看轨迹和 RAW。',
|
||||
'4. 最后看在线影响:离线车辆会影响当天里程解释。',
|
||||
`里程统计:${statisticsURL}`,
|
||||
`轨迹复核:${appURL(buildAppHash({ page: 'history', keyword: filters.keyword?.trim() || '', protocol: filters.protocol?.trim() || '', filters: { ...(dateFrom ? { dateFrom } : {}), ...(dateTo ? { dateTo } : {}) } }))}`,
|
||||
`RAW证据:${appURL(buildAppHash({ page: 'history-query', keyword: filters.keyword?.trim() || '', protocol: filters.protocol?.trim() || '', filters: { ...(dateFrom ? { dateFrom } : {}), ...(dateTo ? { dateTo } : {}), tab: 'raw', includeFields: 'true' } }))}`,
|
||||
...(vehicleURL ? [`车辆服务:${vehicleURL}`] : [])
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function mileageBIPublishText({
|
||||
filters,
|
||||
summary,
|
||||
@@ -675,6 +742,48 @@ export function Mileage({
|
||||
color: publishAuditColor
|
||||
}
|
||||
];
|
||||
const mileageDecisionItems = [
|
||||
{
|
||||
label: '交付结论',
|
||||
value: mileageDeliveryState,
|
||||
detail: mileageDeliveryState === '可交付' ? '可进入客户查询、BI发布和运营日报。' : mileageDeliveryState === '暂缓交付' ? '存在阻断项,先完成证据复核。' : '需补齐闭合、覆盖、异常或在线证据后交付。',
|
||||
color: mileageDeliveryColor,
|
||||
action: '复制决策',
|
||||
onClick: () => copyMileageDecision()
|
||||
},
|
||||
{
|
||||
label: '区间闭合',
|
||||
value: closureStatus,
|
||||
detail: closureDeltaKm == null ? '当前页是分页抽样,发布前请拉齐全量明细。' : `闭合差值 ${formatKm(Math.abs(closureDeltaKm))} km。`,
|
||||
color: closureStatusColor,
|
||||
action: '统计摘要',
|
||||
onClick: () => copyStatisticsSummary()
|
||||
},
|
||||
{
|
||||
label: '覆盖率',
|
||||
value: formatPercent(pageCoverageRate),
|
||||
detail: `${rows.length.toLocaleString()} / ${summary.recordCount.toLocaleString()} 条记录,交付前建议覆盖全量。`,
|
||||
color: pageCoverageRate >= 100 ? 'green' as const : pageCoverageRate >= 60 ? 'orange' as const : 'red' as const,
|
||||
action: '导出明细',
|
||||
onClick: () => exportMileage()
|
||||
},
|
||||
{
|
||||
label: '异常复核',
|
||||
value: `${anomalyRows.length.toLocaleString()} 条`,
|
||||
detail: anomalyRows[0] ? `${anomalyRows[0].plate || anomalyRows[0].vin} / ${anomalyRows[0].date} 需要回看轨迹。` : '当前明细未命中异常标记。',
|
||||
color: anomalyRows.length > 0 ? 'orange' as const : 'green' as const,
|
||||
action: '异常证据',
|
||||
onClick: () => anomalyRows[0] ? copyMileageEvidence(anomalyRows[0]) : copyMileageDecision()
|
||||
},
|
||||
{
|
||||
label: '在线影响',
|
||||
value: formatPercent(onlineRatePercent),
|
||||
detail: `${onlineVehicleCount.toLocaleString()} 在线 / ${offlineVehicleCount.toLocaleString()} 离线。`,
|
||||
color: onlineRatePercent >= 90 ? 'green' as const : onlineRatePercent >= 60 ? 'orange' as const : 'red' as const,
|
||||
action: '在线态势',
|
||||
onClick: () => copyOnlineOperationsReport()
|
||||
}
|
||||
];
|
||||
const maxDateMileage = Math.max(...dateSeries.map((item) => item.value), 0);
|
||||
const maxSourceMileage = Math.max(...sourceSeries.map((item) => item.value), 0);
|
||||
const filterSummary = [
|
||||
@@ -855,6 +964,29 @@ export function Mileage({
|
||||
'客户里程复核交付包'
|
||||
);
|
||||
};
|
||||
const copyMileageDecision = () => {
|
||||
const vehicleURL = currentVehicleKeyword
|
||||
? appURL(buildAppHash({ page: 'detail', keyword: currentVehicleKeyword, protocol: currentProtocol }))
|
||||
: undefined;
|
||||
copyText(
|
||||
mileageCustomerDecisionText({
|
||||
filters,
|
||||
summary,
|
||||
pageMileageTotal,
|
||||
pageCoverageRate,
|
||||
anomalyCount: anomalyRows.length,
|
||||
closureStatus,
|
||||
closureDeltaKm,
|
||||
confidenceStatus,
|
||||
publishAuditConclusion,
|
||||
onlineSummary,
|
||||
peakMileage,
|
||||
statisticsURL: appURL(window.location.hash || buildAppHash({ page: 'mileage', keyword: currentVehicleKeyword, protocol: currentProtocol })),
|
||||
vehicleURL
|
||||
}),
|
||||
'客户里程决策说明'
|
||||
);
|
||||
};
|
||||
const copyBIPublishText = () => {
|
||||
const vehicleURL = currentVehicleKeyword
|
||||
? appURL(buildAppHash({ page: 'detail', keyword: currentVehicleKeyword, protocol: currentProtocol }))
|
||||
@@ -1056,6 +1188,47 @@ export function Mileage({
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
<Card
|
||||
bordered
|
||||
title={<Space><span>客户里程决策台</span><Button size="small" onClick={copyMileageDecision}>复制决策说明</Button></Space>}
|
||||
style={{ marginTop: 16 }}
|
||||
>
|
||||
<div className="vp-mileage-decision-board">
|
||||
<div className="vp-mileage-decision-summary">
|
||||
<Space wrap>
|
||||
<Tag color={mileageDeliveryColor}>{mileageDeliveryState}</Tag>
|
||||
<Tag color={publishAuditColor}>{publishAuditConclusion}</Tag>
|
||||
<Tag color={confidenceColor}>{confidenceStatus}</Tag>
|
||||
</Space>
|
||||
<Typography.Title heading={5} style={{ margin: 0 }}>先判断能不能交付,再进入轨迹、RAW 和导出复核</Typography.Title>
|
||||
<Typography.Text type="secondary">
|
||||
客户关心的是区间里程是否可信、异常是否解释清楚、离线是否影响统计。协议来源只作为可追溯证据,不作为页面主入口。
|
||||
</Typography.Text>
|
||||
<Space wrap>
|
||||
<Button size="small" theme="solid" type="primary" onClick={copyMileageDecision}>复制决策说明</Button>
|
||||
<Button size="small" disabled={!currentVehicleKeyword || !onOpenHistory} onClick={() => onOpenHistory?.({ keyword: currentVehicleKeyword, protocol: currentProtocol, dateFrom: filters.dateFrom ?? '', dateTo: filters.dateTo ?? '' })}>轨迹复核</Button>
|
||||
<Button size="small" disabled={!currentVehicleKeyword || !onOpenRaw} onClick={() => onOpenRaw?.({ keyword: currentVehicleKeyword, protocol: currentProtocol, dateFrom: filters.dateFrom ?? '', dateTo: filters.dateTo ?? '', includeFields: 'true' })}>RAW证据</Button>
|
||||
<Button size="small" disabled={rows.length === 0} onClick={exportMileage}>导出明细</Button>
|
||||
</Space>
|
||||
</div>
|
||||
<div className="vp-mileage-decision-grid">
|
||||
{mileageDecisionItems.map((item) => (
|
||||
<button
|
||||
key={item.label}
|
||||
type="button"
|
||||
className="vp-mileage-decision-item"
|
||||
aria-label={`客户里程决策 ${item.label} ${item.action}`}
|
||||
onClick={item.onClick}
|
||||
>
|
||||
<Tag color={item.color}>{item.label}</Tag>
|
||||
<strong>{item.value}</strong>
|
||||
<span>{item.detail}</span>
|
||||
<em>{item.action}</em>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card bordered title="客户里程复核交付包" style={{ marginTop: 16 }}>
|
||||
<div className="vp-mileage-delivery-board">
|
||||
<div className="vp-mileage-delivery-summary">
|
||||
|
||||
Reference in New Issue
Block a user