From 94fee0b511279679b43e210878d3d36e5a14384b Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 30 九月 2025 09:14:10 +0800
Subject: [PATCH] 2025.9.30 1. 新增走航任务统计功能

---
 src/main/kotlin/com/flightfeather/uav/domain/repository/MissionRep.kt |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/MissionRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/MissionRep.kt
index 2540179..164f303 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/repository/MissionRep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/MissionRep.kt
@@ -2,18 +2,68 @@
 
 import com.flightfeather.uav.domain.entity.Mission
 import com.flightfeather.uav.domain.mapper.MissionMapper
+import com.flightfeather.uav.lightshare.bean.AreaVo
 import org.springframework.stereotype.Repository
+import tk.mybatis.mapper.entity.Example
+import java.util.*
 
 @Repository
 class MissionRep(
     private val missionMapper: MissionMapper,
 ) {
 
+    /**
+     * 鏍规嵁浠诲姟缂栫爜鏌ヨ鍗曚釜璧拌埅浠诲姟
+     * @param missionCode 浠诲姟缂栫爜锛堜富閿級
+     * @return 鏌ヨ鍒扮殑浠诲姟瀵硅薄锛岃嫢涓嶅瓨鍦ㄥ垯杩斿洖null
+     */
     fun findOne(missionCode:String?): Mission? {
         return missionMapper.selectByPrimaryKey(missionCode)
     }
 
+    /**
+     * 鏍规嵁浠诲姟瀵硅薄灞炴�ф潯浠舵煡璇换鍔″垪琛�
+     * @param mission 鍖呭惈鏌ヨ鏉′欢鐨勪换鍔″璞★紙濡傝澶囩被鍨嬨�佸尯鍩熺瓑锛�
+     * @return 绗﹀悎鏉′欢鐨勪换鍔″垪琛�
+     */
     fun findList(mission: Mission): List<Mission?> {
         return missionMapper.select(mission)
     }
+
+    /**
+     * 鏍规嵁鏃堕棿鑼冨洿鏌ヨ璧拌埅浠诲姟鍒楄〃
+     * @param startTime 鏌ヨ璧峰鏃堕棿锛堝寘鍚級
+     * @param endTime 鏌ヨ缁撴潫鏃堕棿锛堝寘鍚級
+     * @return 绗﹀悎鏃堕棿鏉′欢鐨勮蛋鑸换鍔″垪琛�
+     */
+    fun findByTimeRange(startTime: Date, endTime: Date): List<Mission?> {
+        // 浣跨敤tk.mybatis鐨凟xample鏋勫缓鏌ヨ鏉′欢
+        return missionMapper.selectByExample(Example(Mission::class.java).apply {
+            // 鍒涘缓鏌ヨ鏉′欢锛歴tartTime瀛楁鍦ㄦ寚瀹氭椂闂磋寖鍥村唴
+            createCriteria().andBetween("startTime", startTime, endTime)
+                // 杩囨护鎺夋病鏈夌粨鏉熸椂闂寸殑浠诲姟锛堢‘淇濅换鍔″凡瀹屾垚锛�
+                .andIsNotNull("endTime")
+        })
+    }
+    
+    /**
+     * 鏍规嵁鍖哄煙鍜屾椂闂磋寖鍥存煡璇㈡湁鏁堣蛋鑸换鍔″垪琛�
+     * 绛涢�夋寚瀹氳鏀垮尯鍒掑唴銆佺壒瀹氭椂闂存涓斿凡瀹屾垚鏈夋晥閲岀▼璁板綍鐨勮蛋鑸换鍔�
+     * @param areaVo 鍖哄煙鍙傛暟瀵硅薄锛屽寘鍚渷銆佸競銆佸尯涓夌骇琛屾斂鍖哄垝缂栫爜
+     * @param startTime 鏌ヨ璧峰鏃堕棿锛堝寘鍚級
+     * @param endTime 鏌ヨ缁撴潫鏃堕棿锛堝寘鍚級
+     * @return 绗﹀悎鏉′欢鐨勮蛋鑸换鍔″垪琛紝鑻ユ棤鍙繑鍥炵┖鍒楄〃
+     * @see AreaVo 鍖哄煙鍙傛暟鏁版嵁缁撴瀯
+     * @see Mission 璧拌埅浠诲姟瀹炰綋绫�
+     */
+    fun findByAreaAndTime(areaVo: AreaVo, startTime: Date, endTime: Date): List<Mission?> {
+        return missionMapper.selectByExample(Example(Mission::class.java).apply {
+            createCriteria().andBetween("startTime", startTime, endTime)
+                .andEqualTo("provinceCode", areaVo.provinceCode)
+                .andEqualTo("cityCode", areaVo.cityCode)
+                .andEqualTo("districtCode", areaVo.districtCode)
+                .andIsNotNull("kilometres")
+                .andNotEqualTo("kilometres", 0)
+        })
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3