From d3b43d50df28c4fe27c104dcd146d35b2bad4d20 Mon Sep 17 00:00:00 2001 From: Riku <risaku@163.com> Date: 星期三, 11 六月 2025 22:48:01 +0800 Subject: [PATCH] 1. 新增动态污染溯源新的判定逻辑(待完成) --- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt index c2c651f..58b3e29 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt @@ -1,9 +1,13 @@ package com.flightfeather.uav.biz.sourcetrace.model import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig +import com.flightfeather.uav.common.net.AMapService +import com.flightfeather.uav.common.utils.MapUtil import com.flightfeather.uav.domain.entity.BaseRealTimeData import com.flightfeather.uav.domain.entity.SceneInfo +import java.math.BigDecimal import java.time.LocalDateTime +import java.util.Date import java.util.Timer import java.util.TimerTask @@ -27,9 +31,12 @@ /** * 鍒嗘瀽缁撴灉 */ - inner class AnalysisResult{ + inner class AnalysisResult { // 鎸夌収琚壂鎻忔鏁伴檷搴忔帓鍒楃殑姹℃煋婧愬垪琛� var sortedSceneList: List<Pair<SceneInfo?, Int>>? = null + var time: Date? = null + var advice: String? = null + var direction: AMapService.AMapDirection? = null } /** @@ -53,7 +60,7 @@ private var analysisTimer: Timer? = null // 瀹氭椂姹℃煋鍒嗘瀽浠诲姟 - private var lastAnalysisOnTimeTask:TimerTask? = null + private var lastAnalysisOnTimeTask: TimerTask? = null // 瀹氭椂姹℃煋鍒嗘瀽浠诲姟杩愯鐘舵�� private var analysisTaskIsRunning = false @@ -121,8 +128,8 @@ val statistic = AnalysisStatistic() // 鍏辨湁澶氬皯鐩稿叧姹℃煋婧愶紝鍝簺姹℃煋婧愯鎵弿娆℃暟杈冨 val sceneMap = mutableMapOf<String?, Pair<SceneInfo?, Int>>() - clueList.forEach {c-> - c.pollutedSource?.sceneList?.forEach { s-> + clueList.forEach { c -> + c.pollutedSource?.sceneList?.forEach { s -> if (!sceneMap.containsKey(s?.guid)) { sceneMap[s?.guid] = s to 1 } else { @@ -138,11 +145,12 @@ * 绾跨储鍒嗘瀽 */ private fun analysis() { + if (clueList.isEmpty()) return val result = AnalysisResult() // 鍏辨湁澶氬皯鐩稿叧姹℃煋婧愶紝鍝簺姹℃煋婧愯鎵弿娆℃暟杈冨 val sceneMap = mutableMapOf<String?, Pair<SceneInfo?, Int>>() - clueList.forEach {c-> - c.pollutedSource?.sceneList?.forEach { s-> + clueList.forEach { c -> + c.pollutedSource?.sceneList?.forEach { s -> if (!sceneMap.containsKey(s?.guid)) { sceneMap[s?.guid] = s to 1 } else { @@ -150,18 +158,40 @@ } } } - val res = sceneMap.entries.sortedBy { it.value.second } + val res = sceneMap.entries.sortedByDescending { it.value.second } result.sortedSceneList = res.map { it.value } // 褰撳墠鐨勮蛋鑸暟鎹殑瀹氫綅鍜屾薄鏌撴簮璺濈鏄惁鏄�愭笎鎺ヨ繎锛岃嫢璧拌埅杩滅浜嗕富瑕佹薄鏌撴簮锛屾彁绀虹敤鎴疯皟鏁磋蛋鑸矾绾� + if (!result.sortedSceneList.isNullOrEmpty()) { + val sT = clueList.first().pollutedData?.startTime + val eT = clueList.last().pollutedData?.endTime + val closetScene = result.sortedSceneList?.first() + // 璧拌埅璺嚎璋冩暣寤鸿 + result.advice = + "鏍规嵁${sT}鑷�${eT}鐨�${clueList.size}鏉℃渶鏂版薄鏌撶嚎绱紝姹℃煋婧愩��${closetScene?.first?.name}銆戣澶氭婧簮锛屽叿鏈夎緝楂樻薄鏌撻闄╋紝鐜版彁渚涙柊鐨勮蛋鑸帹鑽愯矾绾匡紝鍙粡杩囪姹℃煋婧愩��" + val lastP = realTimeDataList.last() + // 寤鸿瀵瑰簲鐨勬暟鎹噰鏍锋椂闂� + result.time = lastP.dataTime + if (lastP.longitude != null && lastP.latitude != null && + lastP.longitude!! > BigDecimal.ZERO && lastP.latitude!! > BigDecimal.ZERO + && closetScene?.first?.longitude != null && closetScene.first?.latitude != null && + closetScene.first?.longitude!! > BigDecimal.ZERO && closetScene.first?.latitude!! > BigDecimal.ZERO + ) { - // 绾跨储鍒嗘瀽瀹屾垚鍚庯紝绉诲姩鑷冲巻鍙茬嚎绱㈠垪琛� - historyClueList.addAll(clueList) - clueList.clear() - realTimeDataList.clear() + val origin = MapUtil.wgs84ToGcj02(lastP.longitude!!.toDouble() to lastP.latitude!!.toDouble()) + val destination = closetScene.first!!.longitude.toDouble() to closetScene.first!!.latitude.toDouble() - callback(result) + // 寤鸿鐨勮蛋鑸矾绾� + result.direction = AMapService.directionDriving(origin, destination) + } + // 绾跨储鍒嗘瀽瀹屾垚鍚庯紝绉诲姩鑷冲巻鍙茬嚎绱㈠垪琛� + historyClueList.addAll(clueList) + clueList.clear() + realTimeDataList.clear() + + callback(result) + } // TODO() } -- Gitblit v1.9.3