Riku
2025-06-04 7d33080998a2c5b38e8a74dbed2b0f40d39bbe47
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
@@ -30,6 +34,9 @@
    inner class AnalysisResult{
        // 按照被扫描次数降序排列的污染源列表
        var sortedSceneList: List<Pair<SceneInfo?, Int>>? = null
        var time: Date? = null
        var advice:String?= null
        var direction: AMapService.AMapDirection? = null
    }
    /**
@@ -154,8 +161,27 @@
        result.sortedSceneList = res.map { it.value }
        // 当前的走航数据的定位和污染源距离是否是逐渐接近,若走航远离了主要污染源,提示用户调整走航路线
        if (!result.sortedSceneList.isNullOrEmpty()) {
            val sT = clueList.first().pollutedData?.startTime
            val closetScene = result.sortedSceneList?.first()
            result.advice = "根据${sT}起的${clueList.size}条最新污染线索,污染源[${closetScene?.first?.name}]被多次溯源,具有较高污染风险,现提供新的走航推荐路线,可经过该污染源。"
            val lastP = realTimeDataList.last()
            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) {
                val origin = MapUtil.wgs84ToGcj02(lastP.longitude!!.toDouble() to lastP.latitude!!.toDouble())
                val destination = closetScene.first!!.longitude.toDouble() to closetScene.first!!.latitude.toDouble()
                result.direction = AMapService.directionDriving(origin, destination)
            }
        }
        result.time = realTimeDataList.last().dataTime
        // 线索分析完成后,移动至历史线索列表
        historyClueList.addAll(clueList)
        clueList.clear()