From dac47617b37ccfb834cd73ce0ee725e1101de214 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 14 八月 2025 17:25:51 +0800 Subject: [PATCH] 2025.8.14 1. 动态溯源模块添加滑动平均异常计算(调试中) --- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt | 79 +++++++++++++++++++++++++-------------- 1 files changed, 51 insertions(+), 28 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 d721f59..d2b696f 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt @@ -28,11 +28,16 @@ * 姣忎竴鍒婚挓瀵瑰巻鍙茬嚎绱㈣繘琛岀粺璁★紝鎻愬嚭浼氬晢寤鸿锛堢姹℃煋婧愯緝杩溿�佹薄鏌撴簮鏁伴噺銆佸嚭鐜版鏁帮級銆佽蛋鑸矾绾胯皟鏁村缓璁紙绂绘薄鏌撴簮杈冭繎銆佽蛋鑸建杩规湭鎺ヨ繎婧簮鍦烘櫙锛� */ - 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) { - RTExcWindLevelConfig(factorFilter, emptyList()) + RTExcWindLevelConfig(factorFilter) } else { RTExcWindLevelConfig( FactorFilter.builder() @@ -44,23 +49,30 @@ .withMain(FactorType.PM25) .withMain(FactorType.PM10) .withMain(FactorType.VOC) - .create(), - listOf( - listOf(FactorType.PM25, FactorType.PM10), - listOf(FactorType.VOC, FactorType.CO), - ) + .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>>() @@ -72,6 +84,7 @@ private fun newTask() { taskList.apply { +// add(RTExcSlideAverage(config) { dataChangeCallback(it) }.also { it.init() }) 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() }) @@ -90,52 +103,62 @@ * 璁$畻鏂扮殑涓�鏉″疄鏃惰蛋鑸暟鎹� */ 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) } // 鏁版嵁绐佸彉寮傚父鍥炶皟 - private fun exceptionCallback(ex: List<PollutedClue>) { - ex.forEach { - // 婧簮姹℃煋婧愪俊鎭� - it.searchScenes(sceneInfoRep) - it.msgType = MsgType.PolClue.value - } + private fun exceptionCallback(ex: PollutedClue) { + // 婧簮姹℃煋婧愪俊鎭� + ex.searchScenes(sceneInfoRep) + ex.msgType = MsgType.PolClue.value // 骞挎挱姹℃煋婧簮寮傚父缁撴灉 UnderwayWebSocketSender.broadcast(MsgType.PolClue.value, ex) - sourceTraceRep.insertList(MsgType.PolClue, ex) + sourceTraceRep.insert(MsgType.PolClue, ex) // 璁板綍姹℃煋绾跨储 - pollutedSummary.addClueList(ex) + pollutedSummary.addClue(ex) } // 鏁版嵁鍙樺寲鎻愰啋鍥炶皟 - private fun dataChangeCallback(ex: List<PollutedClue>) { - ex.forEach { - // 婧簮姹℃煋婧愪俊鎭� - it.searchScenes(sceneInfoRep) - it.msgType = MsgType.DataChange.value - } + private fun dataChangeCallback(ex: PollutedClue) { + // 婧簮姹℃煋婧愪俊鎭� + ex.searchScenes(sceneInfoRep) + ex.msgType = MsgType.DataChange.value // 骞挎挱鏁版嵁鍙樺寲鎻愰啋 UnderwayWebSocketSender.broadcast(MsgType.DataChange.value, ex) - sourceTraceRep.insertList(MsgType.DataChange, ex) + sourceTraceRep.insert(MsgType.DataChange, ex) } private fun summaryCallback(ex: AnalysisResult) { -- Gitblit v1.9.3