feiyu02
2025-07-29 2e024c986c14943a41f7bfe913cfef0cede64198
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt
@@ -2,6 +2,7 @@
import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig
import com.flightfeather.uav.common.net.AMapService
import com.flightfeather.uav.common.utils.DateUtil
import com.flightfeather.uav.common.utils.MapUtil
import com.flightfeather.uav.domain.entity.BaseRealTimeData
import com.flightfeather.uav.domain.entity.SceneInfo
@@ -12,7 +13,7 @@
import java.util.TimerTask
// 异常数据生成回调类
typealias NewPolluteSummaryCallback = (ex: PollutedSummary.AnalysisResult) -> Unit
typealias NewPolluteSummaryCallback = (ex: AnalysisResult) -> Unit
/**
 * 污染情况汇总
@@ -27,17 +28,6 @@
     * 5. 污染源的被扫描次数
     * 每一刻钟对历史线索进行统计,提出会商建议(离污染源较远、污染源数量、出现次数)、走航路线调整建议(离污染源较近、走航轨迹未接近溯源场景)
     */
    /**
     * 分析结果
     */
    inner class AnalysisResult {
        // 按照被扫描次数降序排列的污染源列表
        var sortedSceneList: List<Pair<SceneInfo?, Int>>? = null
        var time: Date? = null
        var advice: String? = null
        var direction: AMapService.AMapDirection? = null
    }
    /**
     * 实时统计
@@ -74,9 +64,16 @@
    // 新增一条污染线索
    fun addClue(pollutedClue: PollutedClue) {
        clueList.add(pollutedClue)
        // 当溯源未找到风险源时,此次溯源信息不作为线索统计项
        if (pollutedClue.pollutedSource?.sceneList?.isNotEmpty() == true)
            clueList.add(pollutedClue)
//        realTimeSummary()
        analysisOnClueCount()
    }
    // 新增一条污染线索
    fun addClueList(pollutedClues: List<PollutedClue>) {
        pollutedClues.forEach { addClue(it) }
    }
    // 刷新当前最新的走航监测数据
@@ -146,7 +143,7 @@
     */
    private fun analysis() {
        if (clueList.isEmpty()) return
        val result = AnalysisResult()
        val result = AnalysisResult().apply { deviceCode = clueList.first().deviceCode }
        // 共有多少相关污染源,哪些污染源被扫描次数较多
        val sceneMap = mutableMapOf<String?, Pair<SceneInfo?, Int>>()
        clueList.forEach { c ->
@@ -163,12 +160,13 @@
        // 当前的走航数据的定位和污染源距离是否是逐渐接近,若走航远离了主要污染源,提示用户调整走航路线
        if (!result.sortedSceneList.isNullOrEmpty()) {
            val sT = clueList.first().pollutedData?.startTime
            val eT = clueList.last().pollutedData?.endTime
            val sT = DateUtil.instance.dateToString(clueList.first().pollutedData?.startTime, DateUtil.DateStyle.HH_MM_SS)
            val eT = DateUtil.instance.dateToString(clueList.last().pollutedData?.endTime, DateUtil.DateStyle.HH_MM_SS)
            val closetScene = result.sortedSceneList?.first()
            // 走航路线调整建议
            result.advice =
                "根据${sT}至${eT}的${clueList.size}条最新污染线索,污染源【${closetScene?.first?.name}】被多次溯源,具有较高污染风险,现提供新的走航推荐路线,可经过该污染源。"
                "根据${sT}至${eT}的${clueList.size}个溯源切片,风险源【" +
                        "${closetScene?.first?.name}】被多次溯源,具有较高污染风险,现提供最新直达走航路线。"
            val lastP = realTimeDataList.last()
            // 建议对应的数据采样时间
@@ -184,6 +182,7 @@
                // 建议的走航路线
                result.direction = AMapService.directionDriving(origin, destination)
//                Thread.sleep(200)
            }
            // 线索分析完成后,移动至历史线索列表
            historyClueList.addAll(clueList)