From 94fee0b511279679b43e210878d3d36e5a14384b Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 30 九月 2025 09:14:10 +0800 Subject: [PATCH] 2025.9.30 1. 新增走航任务统计功能 --- src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt | 61 ++++++++++++++++++++++++------ 1 files changed, 49 insertions(+), 12 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 3cc0cbb..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() ) } @@ -94,13 +99,16 @@ Triple(degree, count, count.toDouble() / totalCount) } - // 6. 闂鐩稿叧缁熻锛堢ず渚嬶細姝ゅ鍋囪闇�鍏宠仈鍏朵粬琛紝鏆傝繑鍥�0锛屽疄闄呴渶鏍规嵁涓氬姟琛ュ厖锛� + // 6. 闂鐩稿叧缁熻 val clueRes = calClue(clues) val probCount = clueRes.first // 闇�鍏宠仈闂琛ㄧ粺璁� val highRiskSceneCount = clueRes.second // 闇�鍏宠仈鍦烘櫙琛ㄧ粺璁� val probByFactor = clueRes.third - // 7. 鏋勫缓骞惰繑鍥炵粺璁$粨鏋� + // 7. 浠庡紓甯告墍鍦ㄥ湴鍖哄拰婧簮鐨勫満鏅腑缁熻鑱氱劍鍖哄煙 + val focusRegion = calFocusRegion(clues) + + // 8. 鏋勫缓骞惰繑鍥炵粺璁$粨鏋� return Summary( startTime = startTime, endTime = endTime, @@ -111,14 +119,15 @@ countByDegree = countByDegree, probCount = probCount, highRiskSceneCount = highRiskSceneCount, - probByFactor = probByFactor + probByFactor = probByFactor, + focusRegion = focusRegion ) } private fun calClue(clues: List<PollutedClue?>): Triple<Int, Int, List<Triple<String, Int, Double>>> { - var probCount = 0 // 闇�鍏宠仈闂琛ㄧ粺璁� - var highRiskSceneCount = 0 // 闇�鍏宠仈鍦烘櫙琛ㄧ粺璁� - val probByFactorMap = mutableMapOf<FactorType, Int>() // 闇�鍏宠仈鍥犲瓙琛ㄧ粺璁� + var probCount = 0 + var highRiskSceneCount = 0 + val probByFactorMap = mutableMapOf<FactorType, Int>() clues.forEach { c -> if (c?.msgType == MsgType.PolClue.value) { c.pollutedSource?.sceneList?.size?.let { s -> highRiskSceneCount += s } @@ -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