From c5f380b69707a9a09fe988a2f4bd98e142bf64ae Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 10 七月 2025 17:29:48 +0800
Subject: [PATCH] 2025.7.10 1. 修改动态溯源异常判断逻辑

---
 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt |   40 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt
index 1543d33..3e52986 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt
@@ -1,5 +1,6 @@
 package com.flightfeather.uav.biz.sourcetrace.model
 
+import com.flightfeather.uav.common.utils.DateUtil
 import com.flightfeather.uav.common.utils.MapUtil
 import com.flightfeather.uav.domain.entity.SceneInfo
 import com.flightfeather.uav.domain.repository.SceneInfoRep
@@ -25,7 +26,7 @@
      */
 
     // 婧簮浼佷笟
-    var sceneList: List<SceneInfoVo?>? = null
+    var sceneList: List<SceneInfoVo>? = null
 
     // 婧簮鎺ㄧ悊缁撹
     var conclusion: String? = null
@@ -69,7 +70,7 @@
         // 鏍规嵁姹℃煋鍥犲瓙鐨勯噺绾э紝璁$畻涓昏鐨勬薄鏌撳満鏅被鍨嬶紝绛涢�夌粨鏋�
         val mainSceneType = calSceneType(pollutedData)
         if (mainSceneType != null) {
-            this.conclusion = mainSceneType.first
+//            this.conclusion = mainSceneType.first
             result = result.filter {
                 val r = mainSceneType.second.find { s->
                     s.value == it.typeId.toInt()
@@ -80,6 +81,8 @@
 
         this.sceneList = findClosestStation(sceneInfoRep, result)
 
+        val txt = summaryTxt(pollutedData, this.sceneList!!)
+        this.conclusion = txt
     }
 
     /**
@@ -114,7 +117,7 @@
                     it.pm25!! / it.pm10!!
                 }.average()
                 val str =
-                    "PM2.5閲忕骇涓�${pm25Avg}渭g/m鲁锛孭M10閲忕骇涓�${pm25Avg}渭g/m鲁锛孭M2.5鍗燩M10鐨勬瘮閲嶄负${round(percentageAvg * 100)}%"
+                    "PM2.5閲忕骇涓�${pm25Avg}渭g/m鲁锛孭M10閲忕骇涓�${pm10Avg}渭g/m鲁锛孭M2.5鍗燩M10鐨勬瘮閲嶄负${round(percentageAvg * 100)}%"
                 return if (percentageAvg > 0.666) {
                     "${str}锛屾瘮閲嶈緝澶э紝姹℃煋婧愪互椁愰ギ涓轰富锛屽伐鍦版涔�" to
                             listOf(SceneType.TYPE1, SceneType.TYPE2, SceneType.TYPE3, SceneType.TYPE14, SceneType.TYPE5)
@@ -176,4 +179,35 @@
             return@map vo
         }
     }
+
+    private fun summaryTxt(pollutedData: PollutedData, sceneList: List<SceneInfoVo>): String {
+//        pollutedData.exception
+//        pollutedData.selectedFactor?.main
+        val st = DateUtil.instance.getTime(pollutedData.startTime)
+        val et = DateUtil.instance.getTime(pollutedData.endTime)
+        var txt =
+            "${pollutedData.selectedFactor?.main?.des}鍦�${st}鑷�${et}涔嬮棿锛屽嚭鐜�${pollutedData.exception}锛屾渶浣庡�间负${
+                pollutedData
+                    .min
+            }锛屾渶楂樺�间负${pollutedData.max}"
+        if (sceneList.isEmpty()) {
+            txt += ("锛屽彲鑳藉瓨鍦ㄩ殣钘忛闄╂簮銆�")
+        } else {
+            txt += ("锛屽彂鐜�${sceneList.size}涓闄╂簮锛屽寘鍚�")
+
+            val sizeMap = mutableMapOf<String, Int>()
+            sceneList.forEach {
+                if (!sizeMap.containsKey(it.type)) {
+                    sizeMap[it.type] = 0
+                }
+                sizeMap[it.type] = sizeMap[it.type]!! + 1
+            }
+            sizeMap.forEach { (t, u) ->
+                txt += ("${u}涓�${t}锛�")
+            }
+            txt = txt.replaceRange(txt.length - 1, txt.length, "銆�")
+        }
+
+        return txt
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3