From 61871594dfa0a5ac2c4d895d9ec4034feba57094 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期五, 12 九月 2025 17:20:53 +0800
Subject: [PATCH] 2025.9.5 1. 新增走航任务统计功能

---
 src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt |   53 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt
index f82bf96..ff1ab18 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt
@@ -2,11 +2,9 @@
 
 import com.flightfeather.uav.biz.sourcetrace.model.PollutedClue
 import com.flightfeather.uav.domain.entity.Mission
-import com.flightfeather.uav.domain.repository.MissionRep
 import com.flightfeather.uav.lightshare.bean.AreaVo
 import com.flightfeather.uav.socket.eunm.FactorType
 import com.flightfeather.uav.socket.sender.MsgType
-import org.springframework.stereotype.Component
 import java.util.*
 import kotlin.math.round
 
@@ -16,6 +14,10 @@
  * @author feiyu02
  */
 class MissionSummary() {
+
+    companion object {
+        private const val FOCUS_AREA_COUNT = 2
+    }
 
     data class Summary(
         // 姹囨�诲懆鏈熷紑濮嬫椂闂�
@@ -33,11 +35,13 @@
         // 鍚勭瓑绾х┖姘旇川閲忚儗鏅蛋鑸鏁�,<绌烘皵璐ㄩ噺绛夌骇锛屾鏁帮紝鍗犳瘮>
         val countByDegree: List<Triple<String, Int, Double>>,
         // 闂鎬绘暟
-        val probCount:Int,
+        val probCount: Int,
         // 楂橀闄╁満鏅�绘暟
-        val highRiskSceneCount:Int,
+        val highRiskSceneCount: Int,
         // 闂鎸夌洃娴嬪洜瀛愮被鍨嬪垎甯冩儏鍐�, <鍥犲瓙绫诲瀷锛屾鏁帮紝鍗犳瘮>
-        val probByFactor:List<Triple<String, Int, Double>>
+        val probByFactor: List<Triple<String, Int, Double>>,
+        // 鑱氱劍鍖哄煙鎴栧満鏅�
+        val focusRegion: List<String>,
     )
 
     /**
@@ -61,7 +65,8 @@
                 countByDegree = emptyList(),
                 probCount = 0,
                 highRiskSceneCount = 0,
-                probByFactor = emptyList()
+                probByFactor = emptyList(),
+                focusRegion = emptyList()
             )
         }
 
@@ -100,7 +105,10 @@
         val highRiskSceneCount = clueRes.second // 闇�鍏宠仈鍦烘櫙琛ㄧ粺璁�
         val probByFactor = clueRes.third
 
-        // 7. 鏋勫缓骞惰繑鍥炵粺璁$粨鏋�
+        // 7. 浠庡紓甯告墍鍦ㄥ湴鍖哄拰婧簮鐨勫満鏅腑缁熻鑱氱劍鍖哄煙
+        val focusRegion = calFocusRegion(clues)
+
+        // 8. 鏋勫缓骞惰繑鍥炵粺璁$粨鏋�
         return Summary(
             startTime = startTime,
             endTime = endTime,
@@ -111,7 +119,8 @@
             countByDegree = countByDegree,
             probCount = probCount,
             highRiskSceneCount = highRiskSceneCount,
-            probByFactor = probByFactor
+            probByFactor = probByFactor,
+            focusRegion = focusRegion
         )
     }
 
@@ -137,4 +146,32 @@
         }
         return Triple(probCount, highRiskSceneCount, probByFactor)
     }
+
+    private fun calFocusRegion(clues: List<PollutedClue?>): List<String> {
+        // 缁熻姣忎釜鍖哄煙鎴栧満鏅嚭鐜扮殑娆℃暟
+        val focusArea = mutableMapOf<String, Int>()
+        val focusScene = mutableMapOf<String, Int>()
+        clues.forEach { c->
+            if (c?.msgType == MsgType.PolClue.value) {
+                if (!c.pollutedArea?.address.isNullOrBlank()) {
+                    if (focusArea.containsKey(c.pollutedArea?.address)) {
+                        focusArea[c.pollutedArea?.address!!] = focusArea[c.pollutedArea?.address]!! + 1
+                    } else {
+                        focusArea[c.pollutedArea?.address!!] = 1
+                    }
+                }
+                c.pollutedSource?.sceneList?.forEach { s->
+                    if (s.name != null) {
+                        if (focusScene.containsKey(s.name!!)) {
+                            focusScene[s.name!!] = focusScene[s.name!!]!! + 1
+                        } else {
+                            focusScene[s.name!!] = 1
+                        }
+                    }
+                }
+            }
+        }
+        return focusArea.entries.sortedByDescending { it.value }.map { it.key }.take(FOCUS_AREA_COUNT) +
+                focusScene.entries.sortedByDescending { it.value }.map { it.key }.take(FOCUS_AREA_COUNT)
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3