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/dataanalysis/ExceptionAnalysisController.kt | 85 +++++++++++++++++++++++++++++++++++++----- 1 files changed, 75 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/ExceptionAnalysisController.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/ExceptionAnalysisController.kt index 45008af..556353a 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/ExceptionAnalysisController.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/ExceptionAnalysisController.kt @@ -1,53 +1,118 @@ package com.flightfeather.uav.biz.dataanalysis import com.flightfeather.uav.biz.FactorFilter -import com.flightfeather.uav.biz.dataanalysis.exceptiontype.ExceptionDataExceed +import com.flightfeather.uav.biz.dataanalysis.exceptiontype.ExceptionSlideAverage import com.flightfeather.uav.biz.dataanalysis.exceptiontype.ExceptionValueMutation import com.flightfeather.uav.biz.dataanalysis.model.DataAnalysisConfig import com.flightfeather.uav.biz.dataanalysis.model.ExceptionResult import com.flightfeather.uav.biz.dataanalysis.model.ExceptionSetting +import com.flightfeather.uav.common.location.LocationRoadNearby import com.flightfeather.uav.domain.entity.Mission import com.flightfeather.uav.domain.repository.RealTimeDataRep -import org.springframework.stereotype.Component +import com.flightfeather.uav.domain.repository.SegmentInfoRep +import com.flightfeather.uav.socket.eunm.UWDeviceType +import java.time.LocalDateTime +import java.time.ZoneId /** * 鏁版嵁寮傚父鍒嗘瀽鎺у埗鍣� */ -@Component -class ExceptionAnalysisController( +class ExceptionAnalysisController( private val realTimeDataRep: RealTimeDataRep, + private val locationRoadNearby: LocationRoadNearby, + private val segmentInfoRep: SegmentInfoRep, ) { var running = false - private val taskList = mutableListOf<BaseExceptionAnalysis>() + private val taskList = mutableListOf<BaseExceptionAnalysis<DataAnalysisConfig, ExceptionResult>>() private fun initTask(config: DataAnalysisConfig) { taskList.clear() taskList.apply { - add(ExceptionDataExceed(config)) +// add(ExceptionDataExceed(config)) add(ExceptionValueMutation(config)) + add(ExceptionSlideAverage(config)) } } - fun run(mission: Mission, factorFilter: FactorFilter): List<ExceptionResult> { + fun execute(mission: Mission, factorFilter: FactorFilter): List<ExceptionResult> { running = true - val config = DataAnalysisConfig(mission, ExceptionSetting(), 8, factorFilter) + val config = DataAnalysisConfig(mission, ExceptionSetting(), factorFilter) initTask(config) val result = mutableListOf<ExceptionResult>() taskList.forEach { it.init() } // 杞鏁版嵁锛岃绠楀悇涓紓甯� - realTimeDataRep.fetchData(mission.deviceCode, mission.startTime, mission.endTime).forEach { d -> + realTimeDataRep.fetchData(UWDeviceType.fromValue(mission.deviceType), + mission.deviceCode, + mission.startTime, + mission.endTime + ).forEach { d -> taskList.forEach { it.onNextData(d) } } // 鍚勪釜寮傚父鍒嗘瀽鍒嗗埆缁撴潫 taskList.forEach { it.onDone() } - // 瀛樺偍鍒嗘瀽缁撴灉 + taskList.forEach { + it.resultList.forEach { r-> + // 鏌ヨ寮傚父鍛ㄨ竟鍙兘姹℃煋婧� + nearBy(r, config) + // 鏌ヨ鏃舵鎵�鍦ㄨ矾娈� +// road(r) + // 灏嗘暟鎹浆鎹负閫氱敤鏍煎紡 + r.dataVoList = r.dataList.map { e-> e.toDataVo() } + } + // 瀛樺偍鍒嗘瀽缁撴灉 result.addAll(it.resultList) } running = false return result } + +// private fun + + private fun nearBy(r: ExceptionResult, config: DataAnalysisConfig) { + if (r.longitude != null && r.latitude != null) { + val sceneList = locationRoadNearby.searchByRadius( + r.longitude!!.toDouble() to r.latitude!!.toDouble(), config.radius) + if (sceneList.isNotEmpty()) { + val idList = mutableListOf<String>() + val nameList = mutableListOf<String>() + sceneList.forEach { s-> + idList.add(s?.guid?:"") + nameList.add(s?.name ?: "") + } + r.relatedSceneId = idList + r.relatedSceneName = nameList + r.relatedSceneList = sceneList + } + } + } + + private fun road(r: ExceptionResult) { + val sT = LocalDateTime.ofInstant(r.startDate?.toInstant(), ZoneId.systemDefault()) + val eT = LocalDateTime.ofInstant(r.endDate?.toInstant(), ZoneId.systemDefault()) + val segments = segmentInfoRep.findPeriod(r.missionCode, sT, eT) + var txt = "" + val size = segments.size + segments.forEachIndexed { i, s -> + txt += if (i == 0) { + if (size == 1) { + "鍦�${s?.street}" + } else { + "浠�${s?.street}" + } + } else if (i == size - 1 && i >= 2) { + "锛岃嚦${s?.street}" + } else { + if (i == 1) { + "锛岀粡${s?.street}" + } else { + "銆�${s?.street}" + } + } + } + r.road = txt + } } \ No newline at end of file -- Gitblit v1.9.3