From b10c22af595bd995e56946bff63b8f2f984b13e8 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 14 八月 2025 17:25:05 +0800 Subject: [PATCH] 2025.8.14 1. 动态溯源模块添加滑动平均异常计算(调试中) --- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt | 39 ++++++++++++++++++++------------------- 1 files changed, 20 insertions(+), 19 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 58b3e29..0ea4343 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 @@ -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,14 @@ // 褰撳墠鐨勮蛋鑸暟鎹殑瀹氫綅鍜屾薄鏌撴簮璺濈鏄惁鏄�愭笎鎺ヨ繎锛岃嫢璧拌埅杩滅浜嗕富瑕佹薄鏌撴簮锛屾彁绀虹敤鎴疯皟鏁磋蛋鑸矾绾� 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() // 寤鸿瀵瑰簲鐨勬暟鎹噰鏍锋椂闂� @@ -182,8 +181,10 @@ 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) + if (config.isSearchAddress) { + // 寤鸿鐨勮蛋鑸矾绾� + result.direction = AMapService.directionDriving(origin, destination) + } } // 绾跨储鍒嗘瀽瀹屾垚鍚庯紝绉诲姩鑷冲巻鍙茬嚎绱㈠垪琛� historyClueList.addAll(clueList) -- Gitblit v1.9.3