From fe04012057d024770e0180543483d393281a542f Mon Sep 17 00:00:00 2001
From: zhujie <leon.zhu@cloudroam.com.cn>
Date: 星期四, 03 四月 2025 09:18:16 +0800
Subject: [PATCH] Merge branch 'master' of http://47.96.225.205:8888/r/FirstApp2

---
 app/src/main/java/com/example/firstapp/database/dao/CodeDao.kt |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/app/src/main/java/com/example/firstapp/database/dao/CodeDao.kt b/app/src/main/java/com/example/firstapp/database/dao/CodeDao.kt
index f79e67a..58bcc20 100644
--- a/app/src/main/java/com/example/firstapp/database/dao/CodeDao.kt
+++ b/app/src/main/java/com/example/firstapp/database/dao/CodeDao.kt
@@ -10,6 +10,7 @@
 import com.example.firstapp.model.CourierStat
 import com.example.firstapp.model.DailyStat
 import com.example.firstapp.model.HeatmapStat
+import com.example.firstapp.model.StationGroup
 import io.reactivex.Completable
 import kotlinx.coroutines.flow.Flow
 
@@ -54,8 +55,14 @@
     """)
     fun getByKeyword(keyword: String): List<Code>
 
-    @Query("SELECT * FROM Code WHERE oneLevel = :content and code= :code and createTime = :dateString LIMIT 1")
-    fun queryByTypeAndCodeAndDate(content: String, code: String, dateString: String): Code
+    @Query("""
+        SELECT * FROM Code 
+        WHERE category = :category 
+        AND code = :code 
+        AND substr(createTime, 1, 10) = substr(:dateString, 1, 10)
+        LIMIT 1
+    """)
+    fun queryByTypeAndCodeAndDate(category: String, code: String, dateString: String): Code?
 
 
     @Query("update  Code set pickup = '1' ,  pickuptime = CURRENT_TIMESTAMP  where id=:id")
@@ -261,4 +268,21 @@
     WHERE strftime('%Y', createTime) = strftime('%Y', datetime(:date/1000, 'unixepoch', 'localtime'))
 """)
     fun getCurrentYearStats(date: Long): Flow<List<DailyStat>>
+
+    @Query("""
+        SELECT oneLevel as stationName, COUNT(*) as count
+        FROM Code 
+        WHERE category = :type AND pickup = '0'
+        GROUP BY oneLevel
+        ORDER BY createTime DESC
+    """)
+    fun getStationsByType(type: String): List<StationGroup>
+
+    @Query("""
+        SELECT * FROM Code 
+        WHERE category = :type AND pickup = '0'
+        AND oneLevel = :stationName
+        ORDER BY createTime DESC
+    """)
+    fun getPackagesByTypeAndStation(type: String, stationName: String): List<Code>
 }

--
Gitblit v1.9.3