From 8fc27dba6719041402e3e3c099e2f3e01d9d52c7 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期三, 16 七月 2025 17:30:56 +0800 Subject: [PATCH] 2025.7.16 1. 修改动态溯源异常判断逻辑 --- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt | 65 +++++++++++++++++++++++--------- 1 files changed, 47 insertions(+), 18 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 cefe129..0e4c5ef 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt @@ -2,14 +2,14 @@ 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.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,33 +28,40 @@ * 姣忎竴鍒婚挓瀵瑰巻鍙茬嚎绱㈣繘琛岀粺璁★紝鎻愬嚭浼氬晢寤鸿锛堢姹℃煋婧愯緝杩溿�佹薄鏌撴簮鏁伴噺銆佸嚭鐜版鏁帮級銆佽蛋鑸矾绾胯皟鏁村缓璁紙绂绘薄鏌撴簮杈冭繎銆佽蛋鑸建杩规湭鎺ヨ繎婧簮鍦烘櫙锛� */ - 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) + .withMain(FactorType.NO2) .withMain(FactorType.CO) -// .withMain(FactorType.H2S) -// .withMain(FactorType.SO2) -// .withMain(FactorType.O3) +// .withMain(FactorType.H2S) +// .withMain(FactorType.SO2) + .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() ) - pollutedSummary = PollutedSummary(config){ summaryCallback(it)} + } + 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 pollutedSummary: PollutedSummary private val sceneInfoRep: SceneInfoRep - + private val sourceTraceRep: SourceTraceRep private val config: RTExcWindLevelConfig private val taskList = mutableListOf<BaseExceptionAnalysis<RTExcWindLevelConfig, PollutedClue>>() @@ -71,6 +78,13 @@ 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() }) + + add(RTExcChangeRate1(config) { exceptionCallback(it) }.also { it.init() }) + add(RTExcChangeRate4(config) { exceptionCallback(it) }.also { it.init() }) + add(RTExcChangeRate6(config) { exceptionCallback(it) }.also { it.init() }) + + add(RTWarnChangeRate(config) { dataChangeCallback(it) }.also { it.init() }) + add(RTWarnChangeRate2(config) { dataChangeCallback(it) }.also { it.init() }) } } @@ -101,16 +115,31 @@ private fun exceptionCallback(ex: PollutedClue) { // 婧簮姹℃煋婧愪俊鎭� ex.searchScenes(sceneInfoRep) - - // 璁板綍姹℃煋绾跨储 - pollutedSummary.addClue(ex) + ex.msgType = MsgType.PolClue.value // 骞挎挱姹℃煋婧簮寮傚父缁撴灉 UnderwayWebSocketSender.broadcast(MsgType.PolClue.value, ex) + sourceTraceRep.insert(MsgType.PolClue, ex) + + // 璁板綍姹℃煋绾跨储 + pollutedSummary.addClue(ex) } - private fun summaryCallback(ex: PollutedSummary.AnalysisResult) { + // 鏁版嵁鍙樺寲鎻愰啋鍥炶皟 + 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: AnalysisResult) { + ex.msgType = MsgType.AnaResult.value // 骞挎挱姹℃煋婧簮寮傚父缁撴灉 UnderwayWebSocketSender.broadcast(MsgType.AnaResult.value, ex) + sourceTraceRep.insert(ex) } } \ No newline at end of file -- Gitblit v1.9.3