From e3783b167f132005c7afcc4c10f9ab167806331d Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期二, 04 三月 2025 13:22:04 +0800
Subject: [PATCH] fix: 按天统计相关逻辑

---
 app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt b/app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt
index 565676c..f0e308a 100644
--- a/app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt
+++ b/app/src/main/java/com/example/firstapp/ui/dashboard/DashboardFragment.kt
@@ -85,7 +85,8 @@
                     else -> 0
                 }
                 updateDateDisplay()
-//                loadPackages()
+                //加载按天统计包裹数量和列表
+                loadPackages()
                 observePackages()
             }
             override fun onTabUnselected(tab: TabLayout.Tab?) {}
@@ -185,7 +186,7 @@
     private fun updatePieChartData() {
         viewModel.getCourierStats(currentDate.timeInMillis).observe(viewLifecycleOwner) { stats ->
             val entries = stats.map { stat ->
-                PieEntry(stat.count.toFloat(), stat.category)
+                PieEntry(stat.count.toFloat(), stat.courierName)
             }
 
             val dataSet = PieDataSet(entries, "快递公司分布")
@@ -205,15 +206,13 @@
     private fun loadPackages() {
         // 这里应该从数据库或网络加载数据
         // 根据当前选择的日期类型传入对应参数
-        val packages = when (currentDateType) {
-            DateType.DAY -> Core.code.getPackagesByDay(currentDate.timeInMillis)
+//        val packages = when (currentDateType) {
+//            DateType.DAY -> Core.code.getPackagesByDay(currentDate.timeInMillis)
 //            DateType.WEEK -> Core.code.getPackagesByWeek(currentDate.timeInMillis)
 //            DateType.MONTH -> Core.code.getPackagesByMonth(currentDate.timeInMillis)
 //            DateType.YEAR -> Core.code.getPackagesByYear(currentDate.timeInMillis)
-            DateType.WEEK -> TODO()
-            DateType.MONTH -> TODO()
-            DateType.YEAR -> TODO()
-        }
+//        }
+        val packages =Core.code.getPackagesByDay(currentDate.timeInMillis)
         packageAdapter.updatePackages(packages)
         binding.textPackageCount.text = "${packageAdapter.itemCount}个"
     }

--
Gitblit v1.9.3