From 594de76ed51fd49fb79b912212bb0052a63e7671 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 09 四月 2026 16:10:45 +0800
Subject: [PATCH] 2026.4.9

---
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 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 0483664..4d85e8f 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
@@ -3,7 +3,6 @@
 import com.flightfeather.uav.biz.FactorFilter
 import com.flightfeather.uav.biz.dataanalysis.model.ExceptionTag
 import com.flightfeather.uav.biz.dataanalysis.model.ExceptionType
-import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig
 import com.flightfeather.uav.common.utils.DateUtil
 import com.flightfeather.uav.domain.entity.BaseRealTimeData
 import com.flightfeather.uav.domain.entity.avg
@@ -31,8 +30,8 @@
         constructor(dataIndexList: List<Int>, factorType: FactorType){
             this.dataIndexList = dataIndexList
             this.factorType = factorType
-            val first = getFirstDataValue()?.toDouble()
-            val last = getLastDataValue()?.toDouble()
+            val first = firstDataValue()?.toDouble()
+            val last = lastDataValue()?.toDouble()
             if (first != null && last != null) {
                 per = round((last - first) / first * 100) / 100
                 rate = round((last - first) / DEFAULT_PERIOD * 100) / 100
@@ -52,26 +51,26 @@
          * 鑾峰彇寮傚父鏁版嵁鐨勭涓�涓暟鎹�
          * !!!!绗竴涓暟鎹叾瀹炴槸棣栦釜寮傚父鏁版嵁鐨勫墠涓�涓暟鎹��!!!!
          */
-        fun getFirstData(): BaseRealTimeData? {
+        fun firstData(): BaseRealTimeData? {
             return dataIndexList?.firstOrNull()?.let {
                 val i = if (it > 0) it - 1 else it
                 historyDataList[i].toBaseRealTimeData(BaseRealTimeData::class.java)
             }
         }
-        fun getFirstDataValue(): Float? {
-            return getFirstData()?.getByFactorType(factorType)
+        fun firstDataValue(): Float? {
+            return firstData()?.getByFactorType(factorType)
         }
 
         /**
          * 鑾峰彇寮傚父鏁版嵁鐨勬渶鍚庝竴涓暟鎹�
          */
-        fun getLastData(): BaseRealTimeData? {
+        fun lastData(): BaseRealTimeData? {
             return dataIndexList?.lastOrNull()?.let {
                 historyDataList[it].toBaseRealTimeData(BaseRealTimeData::class.java)
             }
         }
-        fun getLastDataValue(): Float? {
-            return getLastData()?.getByFactorType(factorType)
+        fun lastDataValue(): Float? {
+            return lastData()?.getByFactorType(factorType)
         }
     }
 
@@ -105,7 +104,7 @@
         /**
          * 鑾峰彇寮傚父鏁版嵁
          */
-        fun getExceptionData(): List<BaseRealTimeData>? {
+        fun exceptionData(): List<BaseRealTimeData>? {
             return dataIndexList?.map { historyDataList[it].toBaseRealTimeData(BaseRealTimeData::class.java) }
         }
 
@@ -113,7 +112,7 @@
          * 鑾峰彇寮傚父鏁版嵁鍒嗘鎯呭喌
          * 灏嗚繛缁殑寮傚父鏁版嵁鍒嗕负涓�缁�
          */
-        fun getExceptionDataGroup(): List<List<Int>> {
+        fun exceptionDataGroup(): List<List<Int>> {
             val res = mutableListOf<MutableList<Int>>()
             var curGroup = mutableListOf<Int>()
             var lastIndex = -2
@@ -202,9 +201,11 @@
                 min = s.second
                 max = s.third
 
-                excGroup = getExceptionDataGroup().map { ExcGroup(it, e.first.main) }
+                excGroup = exceptionDataGroup().map { ExcGroup(it, e.first.main) }
                 avgPer = excGroup?.mapNotNull { it.per }?.average()
+                if (avgPer?.isNaN() == true) avgPer = .0
                 avgRate = excGroup?.mapNotNull { it.rate }?.average()
+                if (avgRate?.isNaN() == true) avgRate = .0
             }
         }
     }
@@ -232,16 +233,16 @@
         return factors
     }
 
-    fun getExceptionAvgData(): BaseRealTimeData {
-        val exceptionDataList = statisticMap.flatMap { it.value.getExceptionData() ?: emptyList() }
+    fun exceptionAvgData(): BaseRealTimeData {
+        val exceptionDataList = statisticMap.flatMap { it.value.exceptionData() ?: emptyList() }
         val avgData = exceptionDataList.avg()
         return avgData
     }
     /**
      * 鑾峰彇寮傚父鏁版嵁涓績鍧愭爣锛堝紓甯告暟鎹腑缁忓害绾害鐨勫钩鍧囧�硷級
      */
-    fun getExceptionCenter(): Pair<Double, Double>? {
-        val avgData = getExceptionAvgData()
+    fun exceptionCenter(): Pair<Double, Double>? {
+        val avgData = exceptionAvgData()
         val wgs84Lng = avgData.longitude?.toDouble()
         val wgs84Lat = avgData.latitude?.toDouble()
         return if (wgs84Lng == null || wgs84Lat == null) null else Pair(wgs84Lng, wgs84Lat)

--
Gitblit v1.9.3