fix: 修复数据监测页面打不开问题;页面内容显示及数据获取依然存在问题

master
Lxy 3 months ago
parent eab9f3ce9b
commit 19810e4519

@ -259,18 +259,12 @@ export default function DataCheck() {
};
// 计算统计数据(优先使用后端返回的 summary 数据)
const completionRate = summary?.completenessRate ?? (dataStatus.length > 0
? Math.round((dataStatus.filter(d => d.status === 'complete').length / dataStatus.length) * 100)
: 0);
// 新的 summary 格式: { stockCount, quoteCount, klineCount, localLatestDate, externalLatestDate, externalStatus, daysBehind, syncStatus }
const completionRate = summary?.syncStatus === 'complete' ? 100 : summary?.syncStatus === 'incomplete' ? 70 : 0;
const totalMissing = summary?.missingQuotesCount ?? dataStatus.reduce((acc, item) => {
if (item.status !== 'complete') {
return acc + (item.total - item.current);
}
return acc;
}, 0);
const totalMissing = summary?.daysBehind ?? 0;
const estimatedTime = Math.ceil(totalMissing / 1000); // 估算时间(分钟)
const estimatedTime = Math.ceil(totalMissing * 1000); // 估算时间(分钟)
return (
<div className="space-y-6">
@ -336,7 +330,7 @@ export default function DataCheck() {
<p className="text-sm text-[#666] mt-1">
{currentTask && (
<>
: {currentTask.processedRecords.toLocaleString()} / {currentTask.totalRecords.toLocaleString()}
: {(currentTask.processedRecords || 0).toLocaleString()} / {(currentTask.totalRecords || 0).toLocaleString()}
</>
)}
</p>
@ -473,15 +467,17 @@ export default function DataCheck() {
>
<div className="flex items-center justify-between">
<div>
<p className="text-[#b0b0b0] text-sm"></p>
<p className="text-2xl font-bold text-white mt-1">{summary.completenessRate}%</p>
<p className="text-[#b0b0b0] text-sm"></p>
<p className="text-2xl font-bold text-white mt-1">
{summary.syncStatus === 'complete' ? '已同步' : summary.syncStatus === 'incomplete' ? '部分同步' : '未同步'}
</p>
</div>
<div className="w-12 h-12 bg-green-500/20 rounded-xl flex items-center justify-center">
<CheckCircle className="w-6 h-6 text-green-400" />
</div>
</div>
<div className="mt-3 h-2 bg-[#2a2a2a] rounded-full overflow-hidden">
<div className="h-full bg-green-500 rounded-full transition-all" style={{ width: `${summary.completenessRate}%` }} />
<div className="h-full bg-green-500 rounded-full transition-all" style={{ width: `${completionRate}%` }} />
</div>
</motion.div>
@ -493,15 +489,15 @@ export default function DataCheck() {
>
<div className="flex items-center justify-between">
<div>
<p className="text-[#b0b0b0] text-sm"></p>
<p className="text-2xl font-bold text-white mt-1">{summary.missingQuotesCount.toLocaleString()}</p>
<p className="text-[#b0b0b0] text-sm"></p>
<p className="text-2xl font-bold text-white mt-1">{summary.daysBehind ?? '-'} </p>
</div>
<div className="w-12 h-12 bg-red-500/20 rounded-xl flex items-center justify-center">
<AlertCircle className="w-6 h-6 text-red-400" />
</div>
</div>
<p className="text-sm text-[#666] mt-3">
{summary.missingQuotesCount > 0 ? '建议执行一键缓冲' : '数据完整无需缓冲'}
{summary.daysBehind && summary.daysBehind > 0 ? '建议执行一键缓冲' : '数据已同步'}
</p>
</motion.div>
@ -513,15 +509,17 @@ export default function DataCheck() {
>
<div className="flex items-center justify-between">
<div>
<p className="text-[#b0b0b0] text-sm"></p>
<p className="text-2xl font-bold text-white mt-1">{summary.tradingDaysCount} </p>
<p className="text-[#b0b0b0] text-sm"></p>
<p className="text-2xl font-bold text-white mt-1">
{summary.externalStatus === 'connected' ? '已连接' : summary.externalStatus === 'disabled' ? '未配置' : '异常'}
</p>
</div>
<div className="w-12 h-12 bg-blue-500/20 rounded-xl flex items-center justify-center">
<Calendar className="w-6 h-6 text-blue-400" />
</div>
</div>
<p className="text-sm text-[#666] mt-3">
: {summary.referenceDate}, : {summary.dailyStockCount}
: {summary.localLatestDate || '无'}, : {summary.externalLatestDate || '无'}
</p>
</motion.div>
</div>
@ -537,28 +535,26 @@ export default function DataCheck() {
<h3 className="text-white font-semibold mb-4"></h3>
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="p-3 bg-[#0a0a0a] rounded-lg">
<p className="text-[#666] text-xs"></p>
<p className="text-white text-lg font-medium">{summary.expectedTotalQuotes.toLocaleString()}</p>
<p className="text-[#666] text-xs"></p>
<p className="text-white text-lg font-medium">{(summary.stockCount || 0).toLocaleString()}</p>
</div>
<div className="p-3 bg-[#0a0a0a] rounded-lg">
<p className="text-[#666] text-xs"></p>
<p className="text-white text-lg font-medium">{summary.actualTotalQuotes.toLocaleString()}</p>
<p className="text-[#666] text-xs"></p>
<p className="text-white text-lg font-medium">{(summary.quoteCount || 0).toLocaleString()}</p>
</div>
<div className="p-3 bg-[#0a0a0a] rounded-lg">
<p className="text-[#666] text-xs"></p>
<p className={`text-lg font-medium ${summary.missingQuotesCount > 0 ? 'text-red-400' : 'text-green-400'}`}>
{summary.missingQuotesCount.toLocaleString()}
<p className="text-[#666] text-xs"></p>
<p className={`text-lg font-medium ${(summary.daysBehind || 0) > 0 ? 'text-red-400' : 'text-green-400'}`}>
{summary.daysBehind ?? '-'}
</p>
</div>
<div className="p-3 bg-[#0a0a0a] rounded-lg">
<p className="text-[#666] text-xs"></p>
<p className={`text-lg font-medium ${summary.completenessRate >= 90 ? 'text-green-400' : summary.completenessRate >= 50 ? 'text-yellow-400' : 'text-red-400'}`}>
{summary.completenessRate}%
</p>
<p className="text-[#666] text-xs">K线</p>
<p className="text-white text-lg font-medium">{(summary.klineCount || 0).toLocaleString()}</p>
</div>
</div>
<p className="text-xs text-[#666] mt-3">
* : = ({summary.dailyStockCount}) × ({summary.tradingDaysCount}) = {summary.expectedTotalQuotes.toLocaleString()}
* : {summary.localLatestDate || '无'}, : {summary.externalLatestDate || '无'}
</p>
</motion.div>
)}
@ -635,11 +631,11 @@ export default function DataCheck() {
/>
</div>
<span className="text-sm text-[#b0b0b0]">
{((item.current / item.total) * 100).toFixed(1)}%
{item.total > 0 ? ((item.current / item.total) * 100).toFixed(1) : '0.0'}%
</span>
</div>
<p className="text-xs text-[#666] mt-1">
{item.current.toLocaleString()} / {item.total.toLocaleString()}
{(item.current || 0).toLocaleString()} / {(item.total || 0).toLocaleString()}
</p>
</div>
{item.details && (

@ -320,9 +320,9 @@ export default function DataImport() {
<div className="flex items-center gap-4 mt-2 text-xs text-[#666]">
<span>{task.createdAt}</span>
<span>: {task.type}</span>
{task.status !== 'pending' && task.totalRecords > 0 && (
{task.status !== 'pending' && (task.totalRecords || 0) > 0 && (
<span>
: {task.importedRecords.toLocaleString()} / {task.totalRecords.toLocaleString()}
: {(task.importedRecords || 0).toLocaleString()} / {(task.totalRecords || 0).toLocaleString()}
</span>
)}
</div>

@ -78,13 +78,23 @@ export interface DataCheckItem {
// 数据检查结果汇总
export interface DataCheckSummary {
tradingDaysCount: number;
referenceDate: string;
dailyStockCount: number;
expectedTotalQuotes: number;
actualTotalQuotes: number;
missingQuotesCount: number;
completenessRate: number;
// 新的数据源对比格式
stockCount?: number;
quoteCount?: number;
klineCount?: number;
localLatestDate?: string | null;
externalLatestDate?: string | null;
externalStatus?: 'connected' | 'disconnected' | 'error' | 'disabled';
daysBehind?: number | null;
syncStatus?: 'complete' | 'incomplete' | 'missing';
// 兼容旧格式
tradingDaysCount?: number;
referenceDate?: string;
dailyStockCount?: number;
expectedTotalQuotes?: number;
actualTotalQuotes?: number;
missingQuotesCount?: number;
completenessRate?: number;
}
// 数据检查响应
@ -98,13 +108,14 @@ export interface SyncTask {
id: string;
type: string;
status: 'pending' | 'running' | 'completed' | 'failed';
progress: number;
currentTask: string;
totalRecords: number;
processedRecords: number;
progress?: number;
currentTask?: string;
totalRecords?: number;
processedRecords?: number;
createdAt: string;
completedAt?: string;
error?: string;
result?: any;
}
// 管理员 API

Loading…
Cancel
Save