From 21c8f1906a01ec7873334c358e1663c2e691ef98 Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 4 Jan 2026 07:04:39 -0800 Subject: [PATCH] feat(admin-web): integrate planting-service stats API for dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use planting-service's reliable database aggregation for total planting count instead of reporting-service's Kafka event-driven statistics. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../src/app/(dashboard)/dashboard/page.tsx | 39 ++++++++++++++++--- frontend/admin-web/src/hooks/useDashboard.ts | 17 ++++++++ .../src/infrastructure/api/endpoints.ts | 5 +++ .../src/services/dashboardService.ts | 9 +++++ .../admin-web/src/types/dashboard.types.ts | 7 ++++ 5 files changed, 71 insertions(+), 6 deletions(-) diff --git a/frontend/admin-web/src/app/(dashboard)/dashboard/page.tsx b/frontend/admin-web/src/app/(dashboard)/dashboard/page.tsx index ffef9a2d..ca4dd416 100644 --- a/frontend/admin-web/src/app/(dashboard)/dashboard/page.tsx +++ b/frontend/admin-web/src/app/(dashboard)/dashboard/page.tsx @@ -12,6 +12,7 @@ import { useDashboardTrend, useDashboardRegion, useDashboardActivities, + usePlantingStats, } from '@/hooks'; import type { DashboardPeriod } from '@/types'; import styles from './dashboard.module.scss'; @@ -76,6 +77,29 @@ export default function DashboardPage() { refetch: refetchActivities, } = useDashboardActivities(5); + // 从 planting-service 获取可靠的认种统计数据 + const { + data: plantingStatsData, + isLoading: plantingStatsLoading, + error: plantingStatsError, + refetch: refetchPlantingStats, + } = usePlantingStats(); + + // 合并统计数据:总认种量使用 planting-service 的数据 + const mergedStatsData = statsData?.map((stat) => { + if (stat.title === '总认种量' && plantingStatsData) { + return { + ...stat, + value: plantingStatsData.totalTreeCount, + }; + } + return stat; + }); + + // 判断是否正在加载统计数据 + const isStatsLoading = statsLoading || plantingStatsLoading; + const hasStatsError = statsError || plantingStatsError; + const headerActions = ( <>