From 176d7d8283e66ccf63878c9ab823e900df94b748 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 05 八月 2025 17:20:58 +0800
Subject: [PATCH] 2025.8.5 1. 动态溯源模块添加延迟数据周期异常合并功能

---
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt |   50 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 40 insertions(+), 10 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 b8c3e98..7a910ee 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt
@@ -28,7 +28,12 @@
      * 姣忎竴鍒婚挓瀵瑰巻鍙茬嚎绱㈣繘琛岀粺璁★紝鎻愬嚭浼氬晢寤鸿锛堢姹℃煋婧愯緝杩溿�佹薄鏌撴簮鏁伴噺銆佸嚭鐜版鏁帮級銆佽蛋鑸矾绾胯皟鏁村缓璁紙绂绘薄鏌撴簮杈冭繎銆佽蛋鑸建杩规湭鎺ヨ繎婧簮鍦烘櫙锛�
      */
 
-    constructor(sceneInfoRep: SceneInfoRep, sourceTraceRep: SourceTraceRep, factorFilter: FactorFilter?) {
+    constructor(
+        sceneInfoRep: SceneInfoRep,
+        sourceTraceRep: SourceTraceRep,
+        factorFilter: FactorFilter?,
+        isSearchAddress: Boolean,
+    ) {
         this.sceneInfoRep = sceneInfoRep
         this.sourceTraceRep = sourceTraceRep
         this.config = if (factorFilter != null) {
@@ -36,27 +41,38 @@
         } else {
             RTExcWindLevelConfig(
                 FactorFilter.builder()
-//                    .withMain(FactorType.NO2)
-//                    .withMain(FactorType.CO)
+                    .withMain(FactorType.NO2)
+                    .withMain(FactorType.CO)
 //                    .withMain(FactorType.H2S)
 //                    .withMain(FactorType.SO2)
-//                    .withMain(FactorType.O3)
+                    .withMain(FactorType.O3)
                     .withMain(FactorType.PM25)
                     .withMain(FactorType.PM10)
                     .withMain(FactorType.VOC)
+                    .withCombination(
+                        listOf(
+                            listOf(FactorType.PM25, FactorType.PM10),
+                            listOf(FactorType.VOC, FactorType.CO),
+                        )
+                    )
                     .create()
             )
         }
+        this.config.isSearchAddress = isSearchAddress
+
         pollutedSummary = PollutedSummary(config) { summaryCallback(it) }
         newTask()
     }
 
-    constructor(sceneInfoRep: SceneInfoRep, sourceTraceRep: SourceTraceRep) : this(sceneInfoRep, sourceTraceRep, null)
+    constructor(sceneInfoRep: SceneInfoRep, sourceTraceRep: SourceTraceRep, isSearchAddress: Boolean = true)
+            : this(sceneInfoRep, sourceTraceRep, null, isSearchAddress)
 
     private val pollutedSummary: PollutedSummary
     private val sceneInfoRep: SceneInfoRep
     private val sourceTraceRep: SourceTraceRep
     private val config: RTExcWindLevelConfig
+    private val timer = Timer()
+    private var timerTask: TimerTask? = null
 
     private val taskList = mutableListOf<BaseExceptionAnalysis<RTExcWindLevelConfig, PollutedClue>>()
 
@@ -86,23 +102,37 @@
      * 璁$畻鏂扮殑涓�鏉″疄鏃惰蛋鑸暟鎹�
      */
     fun addOneData(data: BaseRealTimeData) {
+//        println("====================>")
         // 璁$畻寮傚父
         taskList.forEach { it.onNextData(data) }
         pollutedSummary.refreshLatestMonitorData(data)
         // 闄愬畾鏃堕棿鍐呮病鏈夋柊鏁版嵁浼犲叆锛屽垯缁撴潫褰撳墠鐨勮绠�
+        dealOnTimeout()
+    }
+
+    fun addDataList(dataList: List<BaseRealTimeData>) {
+        // 璁$畻寮傚父
+        dataList.forEach { data ->
+            taskList.forEach { it.onNextData(data) }
+            pollutedSummary.refreshLatestMonitorData(data)
+        }
+        // 闄愬畾鏃堕棿鍐呮病鏈夋柊鏁版嵁浼犲叆锛屽垯缁撴潫褰撳墠鐨勮绠�
+        dealOnTimeout()
     }
 
     /**
      * 瓒呮椂澶勭悊锛岃緝闀挎椂闂存病鏈夋柊鏁版嵁杩涘叆锛岃繘琛屽垵濮嬪寲鎿嶄綔
      */
     private fun dealOnTimeout() {
-        val timer = Timer(true)
-        timer.schedule(object : TimerTask() {
+//        val timer = Timer()
+        timerTask?.cancel()
+        timer.purge()
+        timerTask = object : TimerTask() {
             override fun run() {
-                TODO("Not yet implemented")
+                initTask()
             }
-        }, 60 * 1000)
-        timer.cancel()
+        }
+        timer.schedule(timerTask, 2 * 60 * 60 * 1000)
     }
 
     // 鏁版嵁绐佸彉寮傚父鍥炶皟

--
Gitblit v1.9.3