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

---
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 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..56190ed 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
@@ -41,17 +41,20 @@
 
         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
 
+        dataList.add(start)
         exceptionData.forEach {
             dataList.add(it)
-            dataVoList.add(it.toDataVo())
         }
+        dataVoList.addAll(dataList.map { it.toDataVo() })
 
         calPer()
     }
@@ -70,8 +73,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
@@ -89,12 +92,17 @@
     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