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

---
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt
index 489e66a..4a599d7 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt
@@ -28,8 +28,9 @@
         end: BaseRealTimeData?,
         factor: FactorFilter.SelectedFactor,
         exceptionData: List<BaseRealTimeData>,
+        historyData: List<BaseRealTimeData>,
         eType: ExceptionType,
-        windLevelCondition: RTExcWindLevelConfig.WindLevelCondition,
+        windLevelCondition: RTExcWindLevelConfig.WindLevelCondition?,
     ) : this() {
         exception = eType.des
         exceptionType = eType.value
@@ -41,17 +42,21 @@
 
         startTime = DateUtil.instance.dateToString(start.dataTime, DateUtil.DateStyle.HH_MM_SS)
         endTime = DateUtil.instance.dateToString(end?.dataTime, DateUtil.DateStyle.HH_MM_SS) ?: startTime
-        startData = start.getByFactorType(factor.main)
-        endData = end?.getByFactorType(factor.main) ?: startData
+//        startData = start.getByFactorType(factor.main)
+//        endData = end?.getByFactorType(factor.main) ?: startData
+        startData = start
+        endData = end
 
         windSpeed = exceptionData.first().windSpeed?.toDouble()
-        percentage = windLevelCondition.mutationRate.first
-        times = windLevelCondition.countLimit
+        percentage = windLevelCondition?.mutationRate?.first
+        times = windLevelCondition?.countLimit
 
+        dataList.add(start)
         exceptionData.forEach {
             dataList.add(it)
-            dataVoList.add(it.toDataVo())
         }
+        dataVoList.addAll(dataList.map { it.toDataVo() })
+        historyDataList.addAll(historyData.map { it.toDataVo() })
 
         calPer()
     }
@@ -70,8 +75,8 @@
     var startTime: String? = null
     var endTime: String? = null
 
-    var startData: Float? = null
-    var endData: Float? = null
+    var startData: BaseRealTimeData? = null
+    var endData: BaseRealTimeData? = null
 
     // 椋庨��
     var windSpeed: Double? = null
@@ -84,17 +89,23 @@
     // 鍙戠敓娆℃暟
     var times: Int? = null
 
+    var historyDataList = mutableListOf<DataVo>()
     // 寮傚父鐩戞祴鏁版嵁
     var dataList: MutableList<BaseRealTimeData> = mutableListOf()
     var dataVoList: MutableList<DataVo> = mutableListOf()
 
     private fun calPer() {
-        if (dataList.size < 2) return
+        val list = dataList
+//        list.add(startData)
+//        list.addAll(dataList)
+        if (list.size < 2) return
 
         var total = .0
-        for (i in 0 until dataList.size - 1) {
-            total += dataList[i].getByFactorType(selectedFactor!!.main)!!
+        for (i in 0 until list.size - 1) {
+            val p = list[i]?.getByFactorType(selectedFactor!!.main)!!
+            val n = list[i + 1]?.getByFactorType(selectedFactor!!.main)!!
+            total += (n - p) / p
         }
-        avgPer = total / (dataList.size - 1)
+        avgPer = total / (list.size - 1)
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3