From 718aabb1db80e7efbb2e866ca3ae74bcd264e20a Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期一, 02 六月 2025 08:30:19 +0800
Subject: [PATCH] 1. 新增动态污染溯源新的判定逻辑(待完成)

---
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt |   92 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 91 insertions(+), 1 deletions(-)

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 e4eed40..3070bcf 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
@@ -1,10 +1,100 @@
 package com.flightfeather.uav.biz.sourcetrace.model
 
+import com.flightfeather.uav.biz.FactorFilter
+import com.flightfeather.uav.biz.dataanalysis.BaseExceptionAnalysis
+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.common.utils.GsonUtils
+import com.flightfeather.uav.domain.entity.BaseRealTimeData
+import com.flightfeather.uav.domain.repository.SceneInfoRep
+import com.flightfeather.uav.socket.eunm.FactorType
+import com.flightfeather.uav.socket.sender.UnderwayWebSocketSender
+import java.util.*
+
 /**
  * 姹℃煋鎯呭喌姹囨��
- * 閽堝鍗曟璧拌埅锛屽畾鏃剁粺璁″凡鏈夋薄鏌撶嚎绱紝鎸夌収绛栫暐缁欏嚭璧拌埅寤鸿
+ * 閽堝鍗曟璧拌埅锛屽畾鏃剁粺璁″凡鏈夋薄鏌撶嚎绱PollutedClue]锛屾寜鐓х瓥鐣ョ粰鍑鸿蛋鑸缓璁�
  * @date 2025/5/27
  * @author feiyu02
  */
 class PollutedSummary {
+
+
+    /**
+     * 5. 姹℃煋婧愮殑琚壂鎻忔鏁�
+     * 姣忎竴鍒婚挓瀵瑰巻鍙茬嚎绱㈣繘琛岀粺璁★紝鎻愬嚭浼氬晢寤鸿锛堢姹℃煋婧愯緝杩溿�佹薄鏌撴簮鏁伴噺銆佸嚭鐜版鏁帮級銆佽蛋鑸矾绾胯皟鏁村缓璁紙绂绘薄鏌撴簮杈冭繎銆佽蛋鑸建杩规湭鎺ヨ繎婧簮鍦烘櫙锛�
+     */
+
+    constructor(sceneInfoRep: SceneInfoRep, factorFilter: FactorFilter?) {
+        this.sceneInfoRep = sceneInfoRep
+        this.config = if (factorFilter != null)
+            RTExcWindLevelConfig(factorFilter)
+        else
+            RTExcWindLevelConfig(
+                FactorFilter.builder()
+//                .withMain(FactorType.NO2)
+                    .withMain(FactorType.CO)
+//                .withMain(FactorType.H2S)
+//                .withMain(FactorType.SO2)
+//                .withMain(FactorType.O3)
+                    .withMain(FactorType.PM25)
+                    .withMain(FactorType.PM10)
+                    .withMain(FactorType.VOC)
+                    .create()
+            )
+        initTask()
+    }
+
+    constructor(sceneInfoRep: SceneInfoRep) : this(sceneInfoRep, null)
+
+    // 姹℃煋绾跨储
+    var clueList = mutableListOf<PollutedClue>()
+
+    private val sceneInfoRep: SceneInfoRep
+
+    private val config: RTExcWindLevelConfig
+
+    private val taskList = mutableListOf<BaseExceptionAnalysis<RTExcWindLevelConfig, PollutedClue>>()
+
+    fun initTask() {
+        taskList.clear()
+        taskList.apply {
+            add(RTExcWindLevel1(config) { exceptionCallback(it) }.also { it.init() })
+            add(RTExcWindLevel1_1(config) { exceptionCallback(it) }.also { it.init() })
+            add(RTExcWindLevel4(config) { exceptionCallback(it) }.also { it.init() })
+            add(RTExcWindLevel6(config) { exceptionCallback(it) }.also { it.init() })
+        }
+    }
+
+    /**
+     * 璁$畻鏂扮殑涓�鏉″疄鏃惰蛋鑸暟鎹�
+     */
+    fun addOneData(data: BaseRealTimeData) {
+        // 璁$畻寮傚父
+        taskList.forEach { it.onNextData(data) }
+        // 闄愬畾鏃堕棿鍐呮病鏈夋柊鏁版嵁浼犲叆锛屽垯缁撴潫褰撳墠鐨勮绠�
+    }
+
+    /**
+     * 瓒呮椂澶勭悊锛岃緝闀挎椂闂存病鏈夋柊鏁版嵁杩涘叆锛岃繘琛屽垵濮嬪寲鎿嶄綔
+     */
+    private fun dealOnTimeout() {
+        val timer = Timer(true)
+        timer.schedule(object : TimerTask() {
+            override fun run() {
+                TODO("Not yet implemented")
+            }
+        }, 60 * 1000)
+        timer.cancel()
+    }
+
+    // 鏁版嵁绐佸彉寮傚父鍥炶皟
+    private fun exceptionCallback(ex: PollutedClue) {
+        // 婧簮姹℃煋婧愪俊鎭�
+        ex.searchScenes(sceneInfoRep)
+        clueList
+        // 骞挎挱姹℃煋婧簮寮傚父缁撴灉
+        UnderwayWebSocketSender.broadcast(GsonUtils.gson.toJson(ex))
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3