From 2e024c986c14943a41f7bfe913cfef0cede64198 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 29 七月 2025 17:37:54 +0800
Subject: [PATCH] 2025.7.29 1. 动态溯源模块添加记录删除等debug功能

---
 src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 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 fcf91d1..17a9a7e 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
@@ -6,6 +6,7 @@
 import com.flightfeather.uav.biz.sourcetrace.model.PollutedClue
 import com.flightfeather.uav.biz.sourcetrace.model.PollutedSummary
 import com.flightfeather.uav.common.utils.GsonUtils
+import com.flightfeather.uav.domain.entity.Mission
 import com.flightfeather.uav.domain.entity.SourceTraceMsg
 import com.flightfeather.uav.domain.mapper.SourceTraceMsgMapper
 import com.flightfeather.uav.socket.sender.MsgType
@@ -27,7 +28,7 @@
     fun insert(msgType: MsgType, obj: PollutedClue): Int {
         val stm = SourceTraceMsg().apply {
             deviceCode = obj.deviceCode
-            factorName = obj.pollutedData?.factorName
+            factorName = obj.pollutedData?.toFactorNames()
             exceptionType = obj.pollutedData?.exceptionType
             startTime = obj.pollutedData?.startTime
             endTime = obj.pollutedData?.endTime
@@ -40,6 +41,14 @@
         } else {
             0
         }
+    }
+
+    fun insertList(msgType: MsgType, objList: List<PollutedClue>): Int {
+        var res = 0
+        objList.forEach {
+            res += insert(msgType, it)
+        }
+        return res
     }
 
     /**
@@ -95,4 +104,12 @@
             }
         }
     }
+
+    fun delete(mission: Mission): Int {
+        return sourceTraceMsgMapper.deleteByExample(Example(SourceTraceMsg::class.java).apply {
+            createCriteria().andEqualTo("deviceCode", mission.deviceCode)
+                .andGreaterThanOrEqualTo("startTime", mission.startTime)
+                .andLessThanOrEqualTo("endTime", mission.endTime)
+        })
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3