From 9c797fa0d704ef8ffb65cd1716b8eb694b4c46c3 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期五, 04 七月 2025 17:28:00 +0800
Subject: [PATCH] 2025.7.4 1. 新增动态污染溯源新的判定逻辑

---
 src/main/kotlin/com/flightfeather/uav/socket/UnderwaySocketServer.kt                     |    6 
 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt |   12 ++
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt           |   23 +++-
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt              |    9 +
 src/main/kotlin/com/flightfeather/uav/socket/processor/UnderwayProcessor.kt              |    4 
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/BasePollutedMsg.kt           |   11 ++
 src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt                |   98 +++++++++++++++++++
 src/main/kotlin/com/flightfeather/uav/socket/sender/MsgType.kt                           |    2 
 src/main/resources/generator/generatorConfig.xml                                         |    3 
 src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt          |    4 
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/DistanceType.kt              |    2 
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedClue.kt              |   13 ++
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/AnalysisResult.kt            |   27 +++++
 src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt           |    6 +
 src/main/kotlin/com/flightfeather/uav/socket/handler/UnderwayWebSocketServerHandler.kt   |    5 
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt           |   20 +---
 16 files changed, 209 insertions(+), 36 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt
index 9c522a0..504efa2 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt
@@ -5,11 +5,13 @@
 import com.flightfeather.uav.biz.sourcetrace.RealTimeAnalysisConfig
 import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig
 import com.flightfeather.uav.biz.sourcetrace.exceptiontype.*
+import com.flightfeather.uav.biz.sourcetrace.model.AnalysisResult
 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.BaseRealTimeData
 import com.flightfeather.uav.domain.repository.SceneInfoRep
+import com.flightfeather.uav.domain.repository.SourceTraceRep
 import com.flightfeather.uav.socket.eunm.FactorType
 import com.flightfeather.uav.socket.sender.MsgType
 import com.flightfeather.uav.socket.sender.UnderwayWebSocketSender
@@ -28,11 +30,12 @@
      * 姣忎竴鍒婚挓瀵瑰巻鍙茬嚎绱㈣繘琛岀粺璁★紝鎻愬嚭浼氬晢寤鸿锛堢姹℃煋婧愯緝杩溿�佹薄鏌撴簮鏁伴噺銆佸嚭鐜版鏁帮級銆佽蛋鑸矾绾胯皟鏁村缓璁紙绂绘薄鏌撴簮杈冭繎銆佽蛋鑸建杩规湭鎺ヨ繎婧簮鍦烘櫙锛�
      */
 
-    constructor(sceneInfoRep: SceneInfoRep, factorFilter: FactorFilter?) {
+    constructor(sceneInfoRep: SceneInfoRep, sourceTraceRep: SourceTraceRep, factorFilter: FactorFilter?) {
         this.sceneInfoRep = sceneInfoRep
-        this.config = if (factorFilter != null)
+        this.sourceTraceRep = sourceTraceRep
+        this.config = if (factorFilter != null) {
             RTExcWindLevelConfig(factorFilter)
-        else
+        } else {
             RTExcWindLevelConfig(
                 FactorFilter.builder()
 //                    .withMain(FactorType.NO2)
@@ -45,16 +48,16 @@
                     .withMain(FactorType.VOC)
                     .create()
             )
+        }
         pollutedSummary = PollutedSummary(config) { summaryCallback(it) }
         newTask()
     }
 
-    constructor(sceneInfoRep: SceneInfoRep) : this(sceneInfoRep, null)
+    constructor(sceneInfoRep: SceneInfoRep, sourceTraceRep: SourceTraceRep) : this(sceneInfoRep, sourceTraceRep, null)
 
     private val pollutedSummary: PollutedSummary
-
     private val sceneInfoRep: SceneInfoRep
-
+    private val sourceTraceRep: SourceTraceRep
     private val config: RTExcWindLevelConfig
 
     private val taskList = mutableListOf<BaseExceptionAnalysis<RTExcWindLevelConfig, PollutedClue>>()
@@ -103,9 +106,11 @@
     private fun exceptionCallback(ex: PollutedClue) {
         // 婧簮姹℃煋婧愪俊鎭�
         ex.searchScenes(sceneInfoRep)
+        ex.msgType = MsgType.PolClue.value
 
         // 骞挎挱姹℃煋婧簮寮傚父缁撴灉
         UnderwayWebSocketSender.broadcast(MsgType.PolClue.value, ex)
+        sourceTraceRep.insert(MsgType.PolClue, ex)
 
         // 璁板綍姹℃煋绾跨储
         pollutedSummary.addClue(ex)
@@ -115,13 +120,17 @@
     private fun dataChangeCallback(ex: PollutedClue) {
         // 婧簮姹℃煋婧愪俊鎭�
         ex.searchScenes(sceneInfoRep)
+        ex.msgType = MsgType.DataChange.value
 
         // 骞挎挱鏁版嵁鍙樺寲鎻愰啋
         UnderwayWebSocketSender.broadcast(MsgType.DataChange.value, ex)
+        sourceTraceRep.insert(MsgType.DataChange, ex)
     }
 
-    private fun summaryCallback(ex: PollutedSummary.AnalysisResult) {
+    private fun summaryCallback(ex: AnalysisResult) {
+        ex.msgType = MsgType.AnaResult.value
         // 骞挎挱姹℃煋婧簮寮傚父缁撴灉
         UnderwayWebSocketSender.broadcast(MsgType.AnaResult.value, ex)
+        sourceTraceRep.insert(ex)
     }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/AnalysisResult.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/AnalysisResult.kt
new file mode 100644
index 0000000..c142345
--- /dev/null
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/AnalysisResult.kt
@@ -0,0 +1,27 @@
+package com.flightfeather.uav.biz.sourcetrace.model
+
+import com.flightfeather.uav.biz.dataanalysis.BaseExceptionResult
+import com.flightfeather.uav.common.net.AMapService
+import com.flightfeather.uav.domain.entity.SceneInfo
+import com.flightfeather.uav.socket.sender.MsgType
+import java.util.*
+
+/**
+ * 鍒嗘瀽缁撴灉
+ * @date 2025/7/4
+ * @author feiyu02
+ */
+class AnalysisResult : BaseExceptionResult() {
+    /**
+     * @see [MsgType]
+     */
+    var msgType: Int? = null
+
+    var deviceCode: String? = null
+
+    // 鎸夌収琚壂鎻忔鏁伴檷搴忔帓鍒楃殑姹℃煋婧愬垪琛�
+    var sortedSceneList: List<Pair<SceneInfo?, Int>>? = null
+    var time: Date? = null
+    var advice: String? = null
+    var direction: AMapService.AMapDirection? = null
+}
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/BasePollutedMsg.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/BasePollutedMsg.kt
new file mode 100644
index 0000000..ec30830
--- /dev/null
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/BasePollutedMsg.kt
@@ -0,0 +1,11 @@
+package com.flightfeather.uav.biz.sourcetrace.model
+import com.flightfeather.uav.socket.sender.MsgType
+
+/**
+ * 鍔ㄦ�佹函婧愪俊鎭�
+ * @date 2025/7/4
+ * @author feiyu02
+ * 鍖呭惈娑堟伅鐨勭被鍨嬩负[MsgType]
+ * 瀵瑰簲鐨勬暟鎹粨鏋勫寘鎷琜PollutedClue],[AnalysisResult]
+ */
+interface BasePollutedMsg
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/DistanceType.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/DistanceType.kt
index 37c753a..ffa489b 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/DistanceType.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/DistanceType.kt
@@ -6,7 +6,7 @@
  * @author feiyu02
  */
 enum class DistanceType(val des: String, val disRange: Pair<Double, Double>) {
-    TYPE1("50绫�", .0 to 50.0),
+    TYPE1("100绫�", .0 to 100.0),
     TYPE2("50绫� - 500绫�", 50.0 to 500.0),
     TYPE3("50绫� - 1鍏噷", 50.0 to 1000.0),
     TYPE4("50绫� - 2鍏噷", 50.0 to 2000.0);
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedClue.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedClue.kt
index 53fbd07..c87812e 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedClue.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedClue.kt
@@ -10,6 +10,7 @@
 import com.flightfeather.uav.domain.entity.BaseRealTimeData
 import com.flightfeather.uav.domain.entity.SceneInfo
 import com.flightfeather.uav.domain.repository.SceneInfoRep
+import com.flightfeather.uav.socket.sender.MsgType
 
 /**
  * 姹℃煋绾跨储
@@ -17,7 +18,7 @@
  * @date 2025/5/27
  * @author feiyu02
  */
-class PollutedClue() : BaseExceptionResult() {
+class PollutedClue() : BaseExceptionResult(){
 
 //    constructor(
 //        start: BaseRealTimeData,
@@ -36,13 +37,14 @@
     constructor(
         tag: ExceptionTag, factor: FactorFilter.SelectedFactor, eType: ExceptionType, config: RTExcWindLevelConfig,
         windLevelCondition: RTExcWindLevelConfig.WindLevelCondition?,
-    ) :this()
+    ) : this()
 //            this(
 //        tag.startData!!, tag.endData, factor, tag.exceptionData, eType, config,
 //        windLevelCondition
 //    )
     {
         if (tag.exceptionData.isEmpty()) return
+        deviceCode = tag.startData?.deviceCode
         pollutedData = PollutedData(
             tag.startData!!, tag.endData, factor, tag.exceptionData, tag.historyData, eType, windLevelCondition
         )
@@ -53,6 +55,13 @@
      * 6. 灞曠ず鏁版嵁鍙樺寲鎯呭喌锛屼笂鍗囬�熺巼绛夌瓑
      */
 
+    /**
+     * @see [MsgType]
+     */
+    var msgType: Int? = null
+
+    var deviceCode: String? = null
+
     var pollutedData: PollutedData? = null
 
     var pollutedArea: PollutedArea? = null
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt
index 5661859..d9adf45 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt
@@ -6,6 +6,7 @@
 import com.flightfeather.uav.common.utils.DateUtil
 import com.flightfeather.uav.domain.entity.BaseRealTimeData
 import com.flightfeather.uav.lightshare.bean.DataVo
+import java.util.Date
 
 /**
  * 姹℃煋鏁版嵁
@@ -40,8 +41,8 @@
         subFactorName = factor.subs.map { it.des }
         selectedFactor = factor
 
-        startTime = DateUtil.instance.dateToString(start.dataTime, DateUtil.DateStyle.HH_MM_SS)
-        endTime = DateUtil.instance.dateToString(end?.dataTime, DateUtil.DateStyle.HH_MM_SS) ?: startTime
+        startTime = start.dataTime
+        endTime = end?.dataTime
 //        startData = start.getByFactorType(factor.main)
 //        endData = end?.getByFactorType(factor.main) ?: startData
         startData = start
@@ -73,8 +74,8 @@
     var subFactorName: List<String>? = null
     var selectedFactor: FactorFilter.SelectedFactor? = null
 
-    var startTime: String? = null
-    var endTime: String? = null
+    var startTime: Date? = null
+    var endTime: Date? = null
 
     var startData: BaseRealTimeData? = null
     var endData: BaseRealTimeData? = null
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt
index 53532f6..cbd6721 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt
@@ -2,6 +2,7 @@
 
 import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig
 import com.flightfeather.uav.common.net.AMapService
+import com.flightfeather.uav.common.utils.DateUtil
 import com.flightfeather.uav.common.utils.MapUtil
 import com.flightfeather.uav.domain.entity.BaseRealTimeData
 import com.flightfeather.uav.domain.entity.SceneInfo
@@ -12,7 +13,7 @@
 import java.util.TimerTask
 
 // 寮傚父鏁版嵁鐢熸垚鍥炶皟绫�
-typealias NewPolluteSummaryCallback = (ex: PollutedSummary.AnalysisResult) -> Unit
+typealias NewPolluteSummaryCallback = (ex: AnalysisResult) -> Unit
 
 /**
  * 姹℃煋鎯呭喌姹囨��
@@ -27,17 +28,6 @@
      * 5. 姹℃煋婧愮殑琚壂鎻忔鏁�
      * 姣忎竴鍒婚挓瀵瑰巻鍙茬嚎绱㈣繘琛岀粺璁★紝鎻愬嚭浼氬晢寤鸿锛堢姹℃煋婧愯緝杩溿�佹薄鏌撴簮鏁伴噺銆佸嚭鐜版鏁帮級銆佽蛋鑸矾绾胯皟鏁村缓璁紙绂绘薄鏌撴簮杈冭繎銆佽蛋鑸建杩规湭鎺ヨ繎婧簮鍦烘櫙锛�
      */
-
-    /**
-     * 鍒嗘瀽缁撴灉
-     */
-    inner class AnalysisResult {
-        // 鎸夌収琚壂鎻忔鏁伴檷搴忔帓鍒楃殑姹℃煋婧愬垪琛�
-        var sortedSceneList: List<Pair<SceneInfo?, Int>>? = null
-        var time: Date? = null
-        var advice: String? = null
-        var direction: AMapService.AMapDirection? = null
-    }
 
     /**
      * 瀹炴椂缁熻
@@ -146,7 +136,7 @@
      */
     private fun analysis() {
         if (clueList.isEmpty()) return
-        val result = AnalysisResult()
+        val result = AnalysisResult().apply { deviceCode = clueList.first().deviceCode }
         // 鍏辨湁澶氬皯鐩稿叧姹℃煋婧愶紝鍝簺姹℃煋婧愯鎵弿娆℃暟杈冨
         val sceneMap = mutableMapOf<String?, Pair<SceneInfo?, Int>>()
         clueList.forEach { c ->
@@ -163,8 +153,8 @@
 
         // 褰撳墠鐨勮蛋鑸暟鎹殑瀹氫綅鍜屾薄鏌撴簮璺濈鏄惁鏄�愭笎鎺ヨ繎锛岃嫢璧拌埅杩滅浜嗕富瑕佹薄鏌撴簮锛屾彁绀虹敤鎴疯皟鏁磋蛋鑸矾绾�
         if (!result.sortedSceneList.isNullOrEmpty()) {
-            val sT = clueList.first().pollutedData?.startTime
-            val eT = clueList.last().pollutedData?.endTime
+            val sT = DateUtil.instance.dateToString(clueList.first().pollutedData?.startTime, DateUtil.DateStyle.HH_MM_SS)
+            val eT = DateUtil.instance.dateToString(clueList.last().pollutedData?.endTime, DateUtil.DateStyle.HH_MM_SS)
             val closetScene = result.sortedSceneList?.first()
             // 璧拌埅璺嚎璋冩暣寤鸿
             result.advice =
diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
new file mode 100644
index 0000000..fcf91d1
--- /dev/null
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
@@ -0,0 +1,98 @@
+package com.flightfeather.uav.domain.repository
+
+import com.flightfeather.uav.biz.dataanalysis.BaseExceptionResult
+import com.flightfeather.uav.biz.sourcetrace.model.AnalysisResult
+import com.flightfeather.uav.biz.sourcetrace.model.BasePollutedMsg
+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.SourceTraceMsg
+import com.flightfeather.uav.domain.mapper.SourceTraceMsgMapper
+import com.flightfeather.uav.socket.sender.MsgType
+import org.springframework.stereotype.Repository
+import tk.mybatis.mapper.entity.Example
+import java.util.*
+
+/**
+ * 鍔ㄦ�佹薄鏌撴函婧愭暟鎹簱鎿嶄綔
+ * @date 2025/7/4
+ * @author feiyu02
+ */
+@Repository
+class SourceTraceRep(private val sourceTraceMsgMapper: SourceTraceMsgMapper) {
+
+    /**
+     * 鎻掑叆婧簮淇℃伅鍜屾彁閱掍俊鎭�
+     */
+    fun insert(msgType: MsgType, obj: PollutedClue): Int {
+        val stm = SourceTraceMsg().apply {
+            deviceCode = obj.deviceCode
+            factorName = obj.pollutedData?.factorName
+            exceptionType = obj.pollutedData?.exceptionType
+            startTime = obj.pollutedData?.startTime
+            endTime = obj.pollutedData?.endTime
+            this.msgType = msgType.value
+            content = GsonUtils.gson.toJson(obj)
+            createTime = Date()
+        }
+        return if (fetchOneExist(stm) == null) {
+            sourceTraceMsgMapper.insert(stm)
+        } else {
+            0
+        }
+    }
+
+    /**
+     * 鎻掑叆绾跨储淇℃伅
+     */
+    fun insert(res: AnalysisResult): Int {
+        val stm = SourceTraceMsg().apply {
+            deviceCode = res.deviceCode
+            startTime = res.time
+            endTime = res.time
+            this.msgType = MsgType.AnaResult.value
+            content = GsonUtils.gson.toJson(res)
+            createTime = Date()
+        }
+        return if (fetchOneExist(stm) == null) {
+            sourceTraceMsgMapper.insert(stm)
+        } else {
+            0
+        }
+    }
+
+    fun fetchOneExist(stm: SourceTraceMsg): SourceTraceMsg? {
+        val res = sourceTraceMsgMapper.selectByExample(Example(SourceTraceMsg::class.java).apply {
+            createCriteria().andEqualTo("deviceCode", stm.deviceCode)
+                .andEqualTo("msgType", stm.msgType)
+                .andEqualTo("exceptionType", stm.exceptionType)
+                .andEqualTo("factorName", stm.factorName)
+                .andEqualTo("startTime", stm.startTime)
+                .andEqualTo("endTime", stm.endTime)
+        })
+        return if (res.isEmpty()) null else res[0]
+    }
+
+    fun fetchList(deviceCode: String, startTime: Date, endTime: Date): List<BaseExceptionResult?> {
+        return sourceTraceMsgMapper.selectByExample(Example(SourceTraceMsg::class.java).apply {
+            createCriteria().andEqualTo("deviceCode", deviceCode)
+                .andGreaterThanOrEqualTo("startTime", startTime)
+                .andLessThanOrEqualTo("endTime", endTime)
+            orderBy("id").desc()
+        }).map { stm ->
+            when (stm?.msgType) {
+                MsgType.PolClue.value,
+                MsgType.DataChange.value,
+                    -> {
+                    GsonUtils.gson.fromJson(stm.content, PollutedClue::class.java)
+                }
+
+                MsgType.AnaResult.value -> {
+                    GsonUtils.gson.fromJson(stm.content, AnalysisResult::class.java)
+                }
+
+                else -> null
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt
index 31d6937..b84e115 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt
+++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt
@@ -1,6 +1,8 @@
 package com.flightfeather.uav.lightshare.service
 
+import com.flightfeather.uav.biz.dataanalysis.BaseExceptionResult
 import com.flightfeather.uav.biz.dataanalysis.model.ExceptionResult
+import com.flightfeather.uav.biz.sourcetrace.model.BasePollutedMsg
 
 /**
  *
@@ -14,4 +16,6 @@
      * @param missionCode 璧拌埅浠诲姟缂栧彿
      */
     fun pollutionTrace(missionCode: String): List<ExceptionResult>
+
+    fun fetchHistory(missionCode: String): String
 }
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt
index d64872d..f8ad2c7 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt
+++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt
@@ -1,13 +1,17 @@
 package com.flightfeather.uav.lightshare.service.impl
 
 import com.flightfeather.uav.biz.FactorFilter
+import com.flightfeather.uav.biz.dataanalysis.BaseExceptionResult
 import com.flightfeather.uav.biz.dataanalysis.ExceptionAnalysisController
 import com.flightfeather.uav.biz.dataanalysis.model.ExceptionResult
+import com.flightfeather.uav.biz.sourcetrace.model.BasePollutedMsg
 import com.flightfeather.uav.common.exception.BizException
 import com.flightfeather.uav.common.location.LocationRoadNearby
+import com.flightfeather.uav.common.utils.GsonUtils
 import com.flightfeather.uav.domain.repository.MissionRep
 import com.flightfeather.uav.domain.repository.RealTimeDataRep
 import com.flightfeather.uav.domain.repository.SegmentInfoRep
+import com.flightfeather.uav.domain.repository.SourceTraceRep
 import com.flightfeather.uav.lightshare.service.DataAnalysisService
 import com.flightfeather.uav.socket.eunm.FactorType
 import org.springframework.stereotype.Service
@@ -23,6 +27,7 @@
     private val realTimeDataRep: RealTimeDataRep,
     private val locationRoadNearby: LocationRoadNearby,
     private val segmentInfoRep: SegmentInfoRep,
+    private val sourceTraceRep: SourceTraceRep
 ) : DataAnalysisService {
 
     override fun pollutionTrace(missionCode: String): List<ExceptionResult> {
@@ -44,4 +49,11 @@
                 .create()
         )
     }
+
+    override fun fetchHistory(missionCode: String): String {
+        val mission = missionRep.findOne(missionCode) ?: throw BizException("璧拌埅浠诲姟涓嶅瓨鍦�")
+
+        val res = sourceTraceRep.fetchList(mission.deviceCode, mission.startTime, mission.endTime)
+        return GsonUtils.gson.toJson(res)
+    }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt
index 26b0fbe..67634b9 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt
+++ b/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt
@@ -25,4 +25,10 @@
 //        @RequestParam("per_page", required = false) perPage: Int?,
     ) = resPack { dataAnalysisService.pollutionTrace(missionCode) }
 
+    @ApiOperation(value = "鑾峰彇鍘嗗彶姹℃煋婧簮缁撴灉")
+    @GetMapping("/pollution/trace/history")
+    fun fetchHistory(
+        @ApiParam("璧拌埅浠诲姟缂栧彿") @RequestParam missionCode: String,
+    ) = resPack { dataAnalysisService.fetchHistory(missionCode) }
+
 }
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/socket/UnderwaySocketServer.kt b/src/main/kotlin/com/flightfeather/uav/socket/UnderwaySocketServer.kt
index 09adc8b..f3248ef 100644
--- a/src/main/kotlin/com/flightfeather/uav/socket/UnderwaySocketServer.kt
+++ b/src/main/kotlin/com/flightfeather/uav/socket/UnderwaySocketServer.kt
@@ -1,6 +1,7 @@
 package com.flightfeather.uav.socket
 
 import com.flightfeather.uav.domain.repository.SceneInfoRep
+import com.flightfeather.uav.domain.repository.SourceTraceRep
 import com.flightfeather.uav.socket.handler.ServerHandler
 import com.flightfeather.uav.socket.handler.UnderwayWebSocketServerHandler
 import com.flightfeather.uav.socket.processor.BaseProcessor
@@ -26,7 +27,8 @@
  * *******************************************************************************/
 @Component
 class UnderwaySocketServer(
-    private val sceneInfoRep: SceneInfoRep
+    private val sceneInfoRep: SceneInfoRep,
+    private val sourceTraceRep: SourceTraceRep
 ) {
 
     private val bossGroup = NioEventLoopGroup()
@@ -99,7 +101,7 @@
                 ?.addLast(HttpServerCodec())
                 ?.addLast(HttpObjectAggregator(65535))
                 ?.addLast(WebSocketServerProtocolHandler("/ws"))
-                ?.addLast(UnderwayWebSocketServerHandler(sceneInfoRep))
+                ?.addLast(UnderwayWebSocketServerHandler(sceneInfoRep, sourceTraceRep))
         }
     })
 }
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/socket/handler/UnderwayWebSocketServerHandler.kt b/src/main/kotlin/com/flightfeather/uav/socket/handler/UnderwayWebSocketServerHandler.kt
index 12cbe75..11f5696 100644
--- a/src/main/kotlin/com/flightfeather/uav/socket/handler/UnderwayWebSocketServerHandler.kt
+++ b/src/main/kotlin/com/flightfeather/uav/socket/handler/UnderwayWebSocketServerHandler.kt
@@ -4,6 +4,7 @@
 import com.flightfeather.uav.common.utils.GsonUtils
 import com.flightfeather.uav.domain.entity.BaseRealTimeData
 import com.flightfeather.uav.domain.repository.SceneInfoRep
+import com.flightfeather.uav.domain.repository.SourceTraceRep
 import com.flightfeather.uav.lightshare.bean.DataVo
 import com.flightfeather.uav.socket.sender.UnderwayWebSocketSender
 import io.netty.channel.ChannelHandlerContext
@@ -14,9 +15,9 @@
  * @date 2025/5/13
  * @author feiyu02
  */
-class UnderwayWebSocketServerHandler(sceneInfoRep: SceneInfoRep) : BaseHandler() {
+class UnderwayWebSocketServerHandler(sceneInfoRep: SceneInfoRep, sourceTraceRep: SourceTraceRep) : BaseHandler() {
 
-    private val sourceTraceController = SourceTraceController(sceneInfoRep)
+    private val sourceTraceController = SourceTraceController(sceneInfoRep, sourceTraceRep)
 
     override var tag: String = "UAV-WS"
 
diff --git a/src/main/kotlin/com/flightfeather/uav/socket/processor/UnderwayProcessor.kt b/src/main/kotlin/com/flightfeather/uav/socket/processor/UnderwayProcessor.kt
index 7d8fd21..8d7f42f 100644
--- a/src/main/kotlin/com/flightfeather/uav/socket/processor/UnderwayProcessor.kt
+++ b/src/main/kotlin/com/flightfeather/uav/socket/processor/UnderwayProcessor.kt
@@ -5,6 +5,7 @@
 import com.flightfeather.uav.model.epw.EPWDataPrep
 import com.flightfeather.uav.domain.repository.AirDataRep
 import com.flightfeather.uav.domain.repository.SceneInfoRep
+import com.flightfeather.uav.domain.repository.SourceTraceRep
 import com.flightfeather.uav.socket.bean.AirDataPackage
 import com.flightfeather.uav.socket.decoder.AirDataDecoder
 import com.flightfeather.uav.socket.decoder.DataPackageDecoder
@@ -25,6 +26,7 @@
 class UnderwayProcessor(
     private val airDataRep: AirDataRep,
     private val sceneInfoRep: SceneInfoRep,
+    private val sourceTraceRep: SourceTraceRep
 ) : BaseProcessor() {
 
     companion object {
@@ -53,7 +55,7 @@
             saveToDataBase(packageData)?.takeIf { it.isNotEmpty() }?.get(0)?.let {
                 // 姣忓彴璁惧鏈夊悇鑷崟鐙殑寮傚父鏁版嵁澶勭悊鍣�
                 if (!sourceTraceMap.containsKey(it.deviceCode)) {
-                    sourceTraceMap[it.deviceCode] = SourceTraceController(sceneInfoRep)
+                    sourceTraceMap[it.deviceCode] = SourceTraceController(sceneInfoRep, sourceTraceRep)
                 }
                 // 灏嗚蛋鑸暟鎹紶鍏ュ紓甯稿鐞嗗櫒
                 sourceTraceMap[it.deviceCode]?.addOneData(it)
diff --git a/src/main/kotlin/com/flightfeather/uav/socket/sender/MsgType.kt b/src/main/kotlin/com/flightfeather/uav/socket/sender/MsgType.kt
index 6aba55f..c432001 100644
--- a/src/main/kotlin/com/flightfeather/uav/socket/sender/MsgType.kt
+++ b/src/main/kotlin/com/flightfeather/uav/socket/sender/MsgType.kt
@@ -12,7 +12,7 @@
 
     /**
      * 姹℃煋鍒嗘瀽缁撴灉
-     * @see [PollutedSummary.AnalysisResult]
+     * @see [AnalysisResult]
      */
     AnaResult(2),
 
diff --git a/src/main/resources/generator/generatorConfig.xml b/src/main/resources/generator/generatorConfig.xml
index 02686f9..f6279e6 100644
--- a/src/main/resources/generator/generatorConfig.xml
+++ b/src/main/resources/generator/generatorConfig.xml
@@ -52,7 +52,7 @@
         </javaClientGenerator>
         <!-- 瑕佺敓鎴愮殑琛� tableName鏄暟鎹簱涓殑琛ㄥ悕鎴栬鍥惧悕 domainObjectName鏄疄浣撶被鍚�-->
 <!--        <table tableName="air_real_time_data" domainObjectName="RealTimeData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
-        <table tableName="mission" domainObjectName="Mission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
+<!--        <table tableName="mission" domainObjectName="Mission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
 <!--        <table tableName="el_minutevalue" domainObjectName="ElectricMinuteValue" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
 <!--        <table tableName="el_company_device" domainObjectName="CompanyDevice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
 <!--        <table tableName="co_complaint" domainObjectName="Complaint" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
@@ -70,5 +70,6 @@
 <!--        <table tableName="grid_cell" domainObjectName="GridCell" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
 <!--        <table tableName="grid_data" domainObjectName="GridData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
 <!--        <table tableName="grid_data_detail" domainObjectName="GridDataDetail" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
+        <table tableName="source_trace_msg" domainObjectName="SourceTraceMsg" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
     </context>
 </generatorConfiguration>
\ No newline at end of file

--
Gitblit v1.9.3