From 594de76ed51fd49fb79b912212bb0052a63e7671 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 09 四月 2026 16:10:45 +0800
Subject: [PATCH] 2026.4.9

---
 src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt |   52 ++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
index 23f46e0..d5c2e0a 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
@@ -99,30 +99,53 @@
         return if (res.isEmpty()) null else res[0]
     }
 
+    val stMsgCache = mutableMapOf<String, List<BaseExceptionResult?>>()
     fun fetchList(
         deviceCode: String,
         startTime: Date,
         endTime: Date,
         msgType: MsgType? = null,
+        minPer: Double? = 0.5,
     ): List<BaseExceptionResult?> {
-        var res = sourceTraceMsgBlobMapper.selectWithBlob(deviceCode, startTime, endTime)
-        if (msgType !== null) {
-            res = res.filter { it?.msgType == msgType.value }
+        var stMsgList = listOf<BaseExceptionResult?>()
+        val key = "${deviceCode}_${startTime.time}_${endTime.time}_${msgType?.value}"
+        if (stMsgCache.containsKey(key)) {
+            stMsgList = stMsgCache[key]!!
         }
+        if (stMsgList.isEmpty()) {
+            var res = sourceTraceMsgBlobMapper.selectWithBlob(deviceCode, startTime, endTime)
+            if (msgType !== null) {
+                res = res.filter { it?.msgType == msgType.value }
+            }
 
-        return res.map { stm ->
-            when (stm?.msgType) {
-                MsgType.PolClue.value,
-                MsgType.DataChange.value,
-                    -> {
-                    GsonUtils.gson.fromJson(stm.blobContent, PollutedClue::class.java)
+            stMsgList = res.map { stm ->
+                when (stm?.msgType) {
+                    MsgType.PolClue.value,
+                    MsgType.DataChange.value,
+                        -> {
+                        GsonUtils.gson.fromJson(stm.blobContent, PollutedClue::class.java)
+                    }
+
+                    MsgType.AnaResult.value -> {
+                        GsonUtils.gson.fromJson(stm.blobContent, AnalysisResult::class.java)
+                    }
+
+                    else -> null
                 }
-
-                MsgType.AnaResult.value -> {
-                    GsonUtils.gson.fromJson(stm.blobContent, AnalysisResult::class.java)
+            }
+            // Fixme 2026.1.21 婧簮璁板綍鐨勭紦瀛橀�昏緫鏆傜己澶憋紝姝ゅ澶勭悊涓嶆伆褰�
+//            stMsgCache[key] = stMsgList
+        }
+        // 绛涢�夊嚭寮傚父鏁版嵁PollutedClue涓紓甯哥櫨鍒嗘瘮澶т簬minPer鐨�
+        return stMsgList.filter {
+            if (it is PollutedClue) {
+                var valid = false
+                (it as PollutedClue?)?.pollutedData?.statisticMap?.entries?.forEach {sta->
+                    if (!valid) valid = (sta.value.avgPer?:.0) > minPer!!
                 }
-
-                else -> null
+                valid
+            } else {
+                true
             }
         }
     }
@@ -134,6 +157,7 @@
                 .andGreaterThanOrEqualTo("startTime", mission.startTime)
                 .andLessThanOrEqualTo("endTime", mission.endTime)
         }).map { it?.id }
+        if (idList.isEmpty()) return 0
         sourceTraceMsgMapper.deleteByExample(Example(SourceTraceMsg::class.java).apply {
             createCriteria().andIn("id", idList)
         })

--
Gitblit v1.9.3