From 37d47c6a7ab0f454b948b68c987146b261117993 Mon Sep 17 00:00:00 2001
From: Riku <risaku@163.com>
Date: 星期日, 13 七月 2025 22:47:21 +0800
Subject: [PATCH] 2025.7.13 动态溯源逻辑调整
---
src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt | 8 ++++
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionValueMutation.kt | 2
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionResult.kt | 4 +-
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt | 26 +++++++-----
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuousSingle.kt | 2
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt | 20 ++++++++-
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/RealTimeExceptionResult.kt | 4 +-
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt | 4 +-
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt | 6 +++
9 files changed, 54 insertions(+), 22 deletions(-)
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuousSingle.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuousSingle.kt
index cd592ab..e9f33fd 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuousSingle.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuousSingle.kt
@@ -20,7 +20,7 @@
it.startData = data
}
// 鍒ゆ柇鐩搁偦鏁版嵁鏄惁杩炵画骞朵笖鏄惁婊¤冻寮傚父鍒ゆ柇
- if (!isContinue || needCut(it, hasException[f])) {
+ if (!isContinue || needCut(it, hasException[f], data)) {
recordException(s, it, data)
} else {
if (hasException[f] == true) {
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionResult.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionResult.kt
index 2929675..23e3d65 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionResult.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionResult.kt
@@ -20,8 +20,8 @@
var exception: String? = null
var exceptionType: Int? = null
var exceptionValue: Float? = null
- var factorId: Int? = null
- var factorName: String? = null
+// var factorId: Int? = null
+// var factorName: String? = null
var subFactorId: List<Int>? = null
var subFactorName: List<String>? = null
var selectedFactor: FactorFilter.SelectedFactor? = null
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 65fc3a8..d721f59 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt
@@ -110,28 +110,32 @@
}
// 鏁版嵁绐佸彉寮傚父鍥炶皟
- private fun exceptionCallback(ex: PollutedClue) {
- // 婧簮姹℃煋婧愪俊鎭�
- ex.searchScenes(sceneInfoRep)
- ex.msgType = MsgType.PolClue.value
+ private fun exceptionCallback(ex: List<PollutedClue>) {
+ ex.forEach {
+ // 婧簮姹℃煋婧愪俊鎭�
+ it.searchScenes(sceneInfoRep)
+ it.msgType = MsgType.PolClue.value
+ }
// 骞挎挱姹℃煋婧簮寮傚父缁撴灉
UnderwayWebSocketSender.broadcast(MsgType.PolClue.value, ex)
- sourceTraceRep.insert(MsgType.PolClue, ex)
+ sourceTraceRep.insertList(MsgType.PolClue, ex)
// 璁板綍姹℃煋绾跨储
- pollutedSummary.addClue(ex)
+ pollutedSummary.addClueList(ex)
}
// 鏁版嵁鍙樺寲鎻愰啋鍥炶皟
- private fun dataChangeCallback(ex: PollutedClue) {
- // 婧簮姹℃煋婧愪俊鎭�
- ex.searchScenes(sceneInfoRep)
- ex.msgType = MsgType.DataChange.value
+ private fun dataChangeCallback(ex: List<PollutedClue>) {
+ ex.forEach {
+ // 婧簮姹℃煋婧愪俊鎭�
+ it.searchScenes(sceneInfoRep)
+ it.msgType = MsgType.DataChange.value
+ }
// 骞挎挱鏁版嵁鍙樺寲鎻愰啋
UnderwayWebSocketSender.broadcast(MsgType.DataChange.value, ex)
- sourceTraceRep.insert(MsgType.DataChange, ex)
+ sourceTraceRep.insertList(MsgType.DataChange, ex)
}
private fun summaryCallback(ex: AnalysisResult) {
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt
index 91f783a..c3ad456 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt
@@ -131,10 +131,10 @@
latestCombinedResult
callback?.let { func ->
latestExceptionResult.forEach {
- func.invoke(it as PollutedClue)
+ func.invoke(listOf(it as PollutedClue))
}
latestCombinedResult.forEach {
- func.invoke(it as PollutedClue)
+ func.invoke(it as List<PollutedClue>)
}
}
}
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt
index 2fa4571..490c6ac 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt
@@ -16,7 +16,7 @@
// 寮傚父鏁版嵁鐢熸垚鍥炶皟绫�
-typealias NewPolluteClueCallback = (ex: PollutedClue) -> Unit
+typealias NewPolluteClueCallback = (ex: List<PollutedClue>) -> Unit
/**
* 涓嶅悓椋庨�熶笅锛屾暟鎹獊鍙樺紓甯稿熀绫�
* @date 2025/5/29
@@ -134,9 +134,23 @@
exceptionStatus: ExceptionStatusType,
) {
super.onNewException(tag, factor, exceptionStatus)
+// callback?.let { func ->
+// val exc = tag.exceptionResult.last()
+// func.invoke(exc as PollutedClue)
+// }
+ }
+
+ override fun mergeExceptionResult() {
+ super.mergeExceptionResult()
+ latestExceptionResult
+ latestCombinedResult
callback?.let { func ->
- val exc = tag.exceptionResult.last()
- func.invoke(exc as PollutedClue)
+ latestExceptionResult.forEach {
+ func.invoke(listOf(it as PollutedClue))
+ }
+ latestCombinedResult.forEach {
+ func.invoke(it as List<PollutedClue>)
+ }
}
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionValueMutation.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionValueMutation.kt
index 4c36a09..a7dece6 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionValueMutation.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionValueMutation.kt
@@ -62,7 +62,7 @@
return b1 || b2
}
- override fun needCut(tag: ExceptionTag, hasException: Boolean?): Boolean {
+ override fun needCut(tag: ExceptionTag, hasException: Boolean?, data: BaseRealTimeData): Boolean {
// 鎸夌収鏃堕暱鍜岃窛绂婚檺鍒跺皢寮傚父鎴彇
if (tag.exceptionData.isEmpty()) return false
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 6d74863..6741ee7 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
@@ -69,6 +69,12 @@
analysisOnClueCount()
}
+ // 鏂板涓�鏉℃薄鏌撶嚎绱�
+ fun addClueList(pollutedClues: List<PollutedClue>) {
+ clueList.addAll(pollutedClues)
+ analysisOnClueCount()
+ }
+
// 鍒锋柊褰撳墠鏈�鏂扮殑璧拌埅鐩戞祴鏁版嵁
fun refreshLatestMonitorData(data: BaseRealTimeData) {
// realTimeDataList.clear()
diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/RealTimeExceptionResult.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/RealTimeExceptionResult.kt
index 48e8f8b..15ae23b 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/RealTimeExceptionResult.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/RealTimeExceptionResult.kt
@@ -26,8 +26,8 @@
var exception: String? = null
var exceptionType: Int? = null
- var factorId: Int? = null
- var factorName: String? = null
+// var factorId: Int? = null
+// var factorName: String? = null
var subFactorId: List<Int>? = null
var subFactorName: List<String>? = null
var selectedFactor: FactorFilter.SelectedFactor? = null
diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
index fcf91d1..5b961ba 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt
@@ -42,6 +42,14 @@
}
}
+ fun insertList(msgType: MsgType, objList: List<PollutedClue>): Int {
+ var res = 0
+ objList.forEach {
+ res += insert(msgType, it)
+ }
+ return res
+ }
+
/**
* 鎻掑叆绾跨储淇℃伅
*/
--
Gitblit v1.9.3