From eb3dd00b0b7fcda477229d518d250f9c842b790b Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 21 十月 2025 17:45:44 +0800
Subject: [PATCH] 2025.10.21 1. 走航季度报告相关数据计算逻辑调整

---
 src/main/kotlin/com/flightfeather/uav/biz/report/MissionRiskArea.kt |  109 ++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 76 insertions(+), 33 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionRiskArea.kt b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionRiskArea.kt
index 4ac954c..3974903 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionRiskArea.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionRiskArea.kt
@@ -5,6 +5,7 @@
 import com.flightfeather.uav.domain.entity.SceneInfo
 import com.flightfeather.uav.domain.entity.avg
 import com.flightfeather.uav.socket.eunm.AggregatedFactorType
+import com.flightfeather.uav.socket.eunm.FactorType
 
 /**
  * 璧拌埅鍏稿瀷闅愭偅鍖哄煙
@@ -13,6 +14,7 @@
  */
 class MissionRiskArea {
 
+    // 鎸夊尯鍩熷垎绫荤殑姹℃煋绾跨储
     class ClueByArea {
         var sceneInfo: SceneInfo? = null
         // 鎵�灞炶闀�
@@ -23,10 +25,24 @@
         var roadinter:String? = null
         var clueByFactorList: MutableList<ClueByFactor>? = null
     }
-
+    // 鎸夊洜瀛愬垎绫荤殑姹℃煋绾跨储
     class ClueByFactor {
         var factor: String? = null
         var clues: MutableList<PollutedClue>? = null
+    }
+
+    // 鍒嗙被绾跨储
+    class ClassifyClue {
+        // 鎸夋墍鍦ㄨ闀囧垎绫�
+        var township:String? = null
+        // 鎸夊洜瀛愮被鍨嬪垎绫�
+        var factorTag: String? = null
+        // 瀹為檯鍖呭惈鐨勫洜瀛愮被鍨�
+        var factors: List<FactorType>? = null
+        // 鎸夋墍鍦ㄩ亾璺垎绫�
+        var street: String? = null
+        // 绾跨储
+        var clue: PollutedClue? = null
     }
 
     /**
@@ -101,43 +117,70 @@
      * @param pollutedClues 姹℃煋绾跨储鍒楄〃
      * @return 鎸夊尯鍩熷拰鍥犲瓙鍒嗙粍鐨勬薄鏌撶嚎绱�
      */
-    fun generateClueByRiskArea(pollutedClues: List<PollutedClue?>): List<ClueByArea> {
-        val result = mutableListOf<ClueByArea>()
+    fun generateClueByRiskArea(pollutedClues: List<PollutedClue?>): List<ClassifyClue> {
+        val clues =  pollutedClues.map { pollutedClue ->
+            ClassifyClue().apply {
+                this.township = pollutedClue?.pollutedArea?.township
 
-        pollutedClues.forEach { pollutedClue ->
-            if (pollutedClue == null) return@forEach
-            val dataList = pollutedClue.pollutedData?.dataList ?: emptyList()
-            if (dataList.isEmpty()) return@forEach
-
-            // 鎸夋薄鏌撴函婧愬湴鍧�琛楅晣鍜屽洜瀛愬垎缁勭嚎绱�
-            pollutedClue.pollutedArea?.township?.let { township ->
-                var clueByArea = result.find { it.township == township }
-                if (clueByArea == null) {
-                    clueByArea = ClueByArea().apply {
-                        this.township = township
-                        this.address = pollutedClue.pollutedArea?.address
-                        this.roadinter = pollutedClue.pollutedArea?.roadinter
-                        this.clueByFactorList = mutableListOf()
-                    }
-                    result.add(clueByArea)
-                }
-
-                val firstFactorType = pollutedClue.pollutedData?.statisticMap?.keys?.first()
+                val factorTypes = pollutedClue?.pollutedData?.statisticMap?.keys ?: emptyList()
+                val firstFactorType = factorTypes.firstOrNull()
+                // 鑱氬悎鍥犲瓙绫诲瀷
                 val afType =  AggregatedFactorType.getAFType(firstFactorType)
-                val factorName = afType?.des ?: firstFactorType?.des
-                var clueByFactor = clueByArea.clueByFactorList?.find { it.factor == factorName }
-                if (clueByFactor == null) {
-                    clueByFactor = ClueByFactor().apply {
-                        this.factor = factorName
-                        this.clues = mutableListOf()
-                    }
-                    clueByArea.clueByFactorList?.add(clueByFactor)
-                }
+                this.factorTag = afType?.des ?: firstFactorType?.des
+                this.factors = factorTypes.toList()
+                // 鎸夋墍鍦ㄩ亾璺垎绫�
+                this.street = pollutedClue?.pollutedArea?.street
 
-                clueByFactor.clues?.add(pollutedClue)
+                this.clue = pollutedClue
             }
         }
+        // 缁熻姣忔潯閬撹矾涓嬬殑绾跨储鏁伴噺
+        val streetClueCount = clues.groupingBy { it.street }.eachCount()
+        // 绛涢�夊嚭閬撹矾涓嬬嚎绱㈡暟閲忚秴杩�1鏉$殑
+        val validStreets = streetClueCount.filter { it.value > 1 }.keys
+        // 绛涢�夊嚭鏈夋晥閬撹矾涓嬬殑绾跨储
+        val validClues = clues.filter { it.street in validStreets }
+        return validClues
 
-        return result
+
+
+//        pollutedClues.forEach { pollutedClue ->
+//            if (pollutedClue == null) return@forEach
+//            val dataList = pollutedClue.pollutedData?.dataList ?: emptyList()
+//            if (dataList.isEmpty()) return@forEach
+//
+//            // 鎸夋薄鏌撴函婧愬湴鍧�琛楅晣鍜屽洜瀛愬垎缁勭嚎绱�
+//            pollutedClue.pollutedArea?.township?.let { township ->
+//                var clueByArea = result.find { it.township == township }
+//                if (clueByArea == null) {
+//                    clueByArea = ClueByArea().apply {
+//                        this.township = township
+//                        this.address = pollutedClue.pollutedArea?.address
+//                        this.roadinter = pollutedClue.pollutedArea?.roadinter
+//                        this.clueByFactorList = mutableListOf()
+//                    }
+//                    result.add(clueByArea)
+//                }
+//
+//                val firstFactorType = pollutedClue.pollutedData?.statisticMap?.keys?.first()
+//                // 鑱氬悎鍥犲瓙绫诲瀷
+////                val afType =  AggregatedFactorType.getAFType(firstFactorType)
+////                val factorName = afType?.des ?: firstFactorType?.des
+//                // 浣跨敤鐩存帴鐨勫洜瀛愮被鍨�
+//                val factorName = firstFactorType?.des ?: ""
+//                var clueByFactor = clueByArea.clueByFactorList?.find { it.factor == factorName }
+//                if (clueByFactor == null) {
+//                    clueByFactor = ClueByFactor().apply {
+//                        this.factor = factorName
+//                        this.clues = mutableListOf()
+//                    }
+//                    clueByArea.clueByFactorList?.add(clueByFactor)
+//                }
+//
+//                clueByFactor.clues?.add(pollutedClue)
+//            }
+//        }
+
+//        return result
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3