From c56e1e74426238939f229f0005828d05089715ff Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 03 七月 2025 17:30:58 +0800
Subject: [PATCH] 2025.7.3 1. 新增动态污染溯源新的判定逻辑

---
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt |   69 +++++++++++++++++++++++++---------
 1 files changed, 51 insertions(+), 18 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 aa722b8..5661859 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
@@ -15,16 +15,6 @@
 class PollutedData() {
 
     /**
-     *
-     * 1. 杞1.5m/s鍙婁互涓嬶紝
-     * 	鍓嶅悗鍊间笂鍗囧箙搴﹀湪50%浠ヤ笂1娆★紝璁や负鏄复杩戝彂鐢�(50绫�)
-     * 	鍓嶅悗鍊间笂鍗囧箙搴﹀湪20%浠ヤ笂1娆★紝璁や负鏄繙璺濈鍙戠敓锛�50绫� - 500绫筹級
-     * 	1.5 m/s鍙婁互涓嬶紝闈欑ǔ澶╂皵锛屼复杩戝彂鐢�(50绫�)
-     * 2. 1.6 - 7.9 m/s锛屽墠鍚庡�间笂鍗囧箙搴﹀湪20%浠ヤ笂3娆★紝璁や负鏄繙璺濈鍙戠敓锛�50绫� - 1鍏噷锛�
-     * 3. 8 - 13.8 m/s 浠ヤ笂锛屽墠鍚庡�间笂鍗囧箙搴﹀湪10%浠ヤ笂3娆★紝璁や负鏄繙璺濈鍙戠敓(50绫� - 2鍏噷)
-     */
-
-    /**
      * 9. 鍏宠仈鍥犲瓙
      * 	a) pm2.5銆乸m10鐗瑰埆楂橈紝涓よ�呭湪鍚勬儏鍐典笅鍚屾灞曠ず锛宲m2.5鍗爌m10鐨勬瘮閲嶅彉鍖栵紝姣旈噸瓒婇珮锛岃秺鏈夊彲鑳芥槸椁愰ギ
      * 	b) pm10鐗瑰埆楂樸�乸m2.5杈冮珮锛屽ぇ棰楃矑鎵皹姹℃煋锛屽彧灞曠ずpm10锛宲m2.5鍗爌m10鐨勬瘮閲嶅彉鍖栵紝宸ュ湴涓轰富
@@ -38,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
@@ -51,17 +42,24 @@
 
         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()
+        calRate()
     }
 
     var deviceCode: String? = null
@@ -78,19 +76,54 @@
     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
 
     // 鍥犲瓙閲忕骇鍙樺寲骞呭害
     var percentage: Double? = null
+    // 鍥犲瓙閲忕骇骞冲潎鍙樺寲骞呭害
+    var avgPer: Double? = null
+    // 鍥犲瓙閲忕骇骞冲潎鍙樺寲閫熺巼
+    var avgRate: Double? = null
 
     // 鍙戠敓娆℃暟
     var times: Int? = null
 
+    var historyDataList = mutableListOf<DataVo>()
     // 寮傚父鐩戞祴鏁版嵁
     var dataList: MutableList<BaseRealTimeData> = mutableListOf()
     var dataVoList: MutableList<DataVo> = mutableListOf()
+
+    private fun calPer() {
+        val list = dataList
+//        list.add(startData)
+//        list.addAll(dataList)
+        if (list.size < 2) return
+
+        var total = .0
+        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 / (list.size - 1)
+    }
+
+    private fun calRate() {
+        val list = dataList
+//        list.add(startData)
+//        list.addAll(dataList)
+        if (list.size < 2) return
+
+        var total = .0
+        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) / 4
+        }
+        avgRate = total / (list.size - 1)
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3