refactor(reporting-service): 移除仪表板区域分布和趋势的模拟数据
- 区域分布无真实数据源时返回空数组 - 趋势数据无数据时返回空数组 - 删除 generateTrendData 模拟方法 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
59b83acfa4
commit
dc64a28efb
|
|
@ -159,7 +159,7 @@ export class DashboardApplicationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取趋势图表数据
|
* 获取趋势图表数据
|
||||||
* 从 RealtimeStats 表读取每日统计数据
|
* 从 RealtimeStats 表读取每日统计数据,无数据时返回空数组
|
||||||
*/
|
*/
|
||||||
async getTrendData(period: DashboardPeriod): Promise<DashboardTrendResponseDto> {
|
async getTrendData(period: DashboardPeriod): Promise<DashboardTrendResponseDto> {
|
||||||
this.logger.debug(`Fetching dashboard trend data for period: ${period}`);
|
this.logger.debug(`Fetching dashboard trend data for period: ${period}`);
|
||||||
|
|
@ -186,9 +186,8 @@ export class DashboardApplicationService {
|
||||||
value: item.plantingCount,
|
value: item.plantingCount,
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
// 如果没有数据,生成模拟数据
|
// 无数据时返回空数组
|
||||||
this.logger.debug('No trend data found, generating mock data');
|
data = [];
|
||||||
data = this.generateTrendData(days);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,43 +253,18 @@ export class DashboardApplicationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取区域分布数据
|
* 获取区域分布数据
|
||||||
|
* 无数据时返回空数组
|
||||||
*/
|
*/
|
||||||
async getRegionDistribution(): Promise<DashboardRegionResponseDto> {
|
async getRegionDistribution(): Promise<DashboardRegionResponseDto> {
|
||||||
this.logger.debug('Fetching region distribution');
|
this.logger.debug('Fetching region distribution');
|
||||||
|
|
||||||
// TODO: 从 planting-service 获取真实区域分布
|
// TODO: 从 planting-service 获取真实区域分布数据
|
||||||
// 目前返回模拟数据
|
// 目前无真实数据源,返回空数组
|
||||||
const regions: RegionDistributionItemDto[] = [
|
const regions: RegionDistributionItemDto[] = [];
|
||||||
{ region: '华东地区', percentage: 35, color: '#1565C0' },
|
|
||||||
{ region: '华南地区', percentage: 25, color: '#4CAF50' },
|
|
||||||
{ region: '华北地区', percentage: 20, color: '#F5A623' },
|
|
||||||
{ region: '华中地区', percentage: 12, color: '#9C27B0' },
|
|
||||||
{ region: '其他地区', percentage: 8, color: '#607D8B' },
|
|
||||||
];
|
|
||||||
|
|
||||||
return { regions };
|
return { regions };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成趋势数据(模拟)
|
|
||||||
*/
|
|
||||||
private generateTrendData(days: number): TrendDataPointDto[] {
|
|
||||||
const data: TrendDataPointDto[] = [];
|
|
||||||
const now = new Date();
|
|
||||||
|
|
||||||
for (let i = days - 1; i >= 0; i--) {
|
|
||||||
const date = new Date(now);
|
|
||||||
date.setDate(date.getDate() - i);
|
|
||||||
|
|
||||||
data.push({
|
|
||||||
date: this.formatDate(date),
|
|
||||||
value: Math.floor(Math.random() * 300) + 100, // 100-400随机值
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化日期为 MM-DD 格式
|
* 格式化日期为 MM-DD 格式
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue