From dc64a28efb75df0b1d9c290c4209ddba8594b944 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 20 Dec 2025 02:26:34 -0800 Subject: [PATCH] =?UTF-8?q?refactor(reporting-service):=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E4=BB=AA=E8=A1=A8=E6=9D=BF=E5=8C=BA=E5=9F=9F=E5=88=86?= =?UTF-8?q?=E5=B8=83=E5=92=8C=E8=B6=8B=E5=8A=BF=E7=9A=84=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 区域分布无真实数据源时返回空数组 - 趋势数据无数据时返回空数组 - 删除 generateTrendData 模拟方法 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../services/dashboard-application.service.ts | 40 ++++--------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/backend/services/reporting-service/src/application/services/dashboard-application.service.ts b/backend/services/reporting-service/src/application/services/dashboard-application.service.ts index 8e082d68..230eda41 100644 --- a/backend/services/reporting-service/src/application/services/dashboard-application.service.ts +++ b/backend/services/reporting-service/src/application/services/dashboard-application.service.ts @@ -159,7 +159,7 @@ export class DashboardApplicationService { /** * 获取趋势图表数据 - * 从 RealtimeStats 表读取每日统计数据 + * 从 RealtimeStats 表读取每日统计数据,无数据时返回空数组 */ async getTrendData(period: DashboardPeriod): Promise { this.logger.debug(`Fetching dashboard trend data for period: ${period}`); @@ -186,9 +186,8 @@ export class DashboardApplicationService { value: item.plantingCount, })); } else { - // 如果没有数据,生成模拟数据 - this.logger.debug('No trend data found, generating mock data'); - data = this.generateTrendData(days); + // 无数据时返回空数组 + data = []; } } @@ -254,43 +253,18 @@ export class DashboardApplicationService { /** * 获取区域分布数据 + * 无数据时返回空数组 */ async getRegionDistribution(): Promise { this.logger.debug('Fetching region distribution'); - // TODO: 从 planting-service 获取真实区域分布 - // 目前返回模拟数据 - 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' }, - ]; + // TODO: 从 planting-service 获取真实区域分布数据 + // 目前无真实数据源,返回空数组 + const regions: RegionDistributionItemDto[] = []; 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 格式 */