From e731486b50c4ea6e2d28f302df449b4bd0b2be57 Mon Sep 17 00:00:00 2001 From: Riku <risaku@163.com> Date: 星期一, 02 六月 2025 23:02:59 +0800 Subject: [PATCH] 1. 新增走航动态溯源功能 --- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt | 71 ++++++++++++++++++++++++++++++++--- 1 files changed, 65 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt index 2dc6b58..c948fe3 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt @@ -4,7 +4,13 @@ import com.flightfeather.uav.common.utils.MapUtil import com.flightfeather.uav.domain.entity.SceneInfo import com.flightfeather.uav.domain.repository.SceneInfoRep +import com.flightfeather.uav.lightshare.bean.AreaVo +import com.flightfeather.uav.lightshare.bean.SceneInfoVo +import com.flightfeather.uav.lightshare.eunm.SceneType +import com.flightfeather.uav.socket.eunm.FactorType +import org.springframework.beans.BeanUtils import org.springframework.web.context.ContextLoader +import kotlin.math.min /** * 姹℃煋鏉ユ簮 @@ -20,7 +26,11 @@ */ // 婧簮浼佷笟 - var sceneList:List<SceneInfo?>? = null + var sceneList:List<SceneInfoVo?>? = null + + init { + + } fun searchScenes(pollutedArea: PollutedArea, factor: FactorFilter.SelectedFactor) { ContextLoader.getCurrentWebApplicationContext()?.getBean(SceneInfoRep::class.java)?.run { @@ -35,9 +45,10 @@ // Fixme 2025.5.14: 姹℃煋婧愮殑鍧愭爣鏄珮寰峰湴鍥惧潗鏍囩郴锛堢伀鏄熷潗鏍囩郴锛夛紝鑰岃蛋鑸暟鎹槸WGS84鍧愭爣绯� // 鎸夌収鍖哄煙妫�绱㈠唴閮ㄦ薄鏌撴簮淇℃伅 // 1. 棣栧厛鎸夌収鍥涜嚦鑼冨洿浠庢暟鎹簱鍒濇绛涢�夋薄鏌撴簮锛岄渶瑕佸厛灏嗗潗鏍囪浆鎹负gcj02锛堢伀鏄熷潗鏍囩郴锛夛紝鍥犱负姹℃煋婧愬満鏅俊鎭兘涓烘鍧愭爣绯� - val polygonTmp = pollutedArea.polygon!!.map { - MapUtil.gcj02ToWgs84(it) - } +// val polygonTmp = pollutedArea.polygon!!.map { +// MapUtil.gcj02ToWgs84(it) +// } + val polygonTmp = pollutedArea.polygon!! val fb = MapUtil.calFourBoundaries(polygonTmp) val sceneList = sceneInfoRep.findByCoordinateRange(fb) // 2. 鍐嶇簿纭垽鏂槸鍚﹀湪鍙嶅悜婧簮鍖哄煙澶氳竟褰㈠唴閮� @@ -49,9 +60,57 @@ } } - this.sceneList = result + findClosestStation(sceneInfoRep, result) - TODO("鎸夌収鎵�閫夌洃娴嬪洜瀛愮被鍨嬶紝鍖哄垎姹℃煋婧愮被鍨�") +// TODO("鎸夌収鎵�閫夌洃娴嬪洜瀛愮被鍨嬶紝鍖哄垎姹℃煋婧愮被鍨�") + + } + + /** + * 璁$畻鍙兘鐨勭浉鍏虫薄鏌撳満鏅被鍨� + */ + private fun calFactorType(factor: FactorFilter.SelectedFactor) { +// when (factor.main) { +// FactorType.PM25 -> {} +// +// } + } + + /** + * 璁$畻鏈�杩戠殑鐩戞祴绔欑偣 + */ + private fun findClosestStation(sceneInfoRep: SceneInfoRep, sceneList: List<SceneInfo>) { + val res1 = sceneInfoRep.findByArea(AreaVo().apply { + sceneTypeId = SceneType.TYPE19.value.toString() + }) + + val res2 = sceneInfoRep.findByArea(AreaVo().apply { + sceneTypeId = SceneType.TYPE20.value.toString() + }) + val res = res1.toMutableList().apply { addAll(res2) } + + this.sceneList = sceneList.map { + var minLen = -1.0 + var selectedRes: SceneInfo? = null + res.forEach { r-> + val dis = MapUtil.getDistance( + it.longitude.toDouble(), + it.latitude.toDouble(), + r!!.longitude.toDouble(), + r.latitude.toDouble() + ) + if (minLen < 0 || dis < minLen) { + minLen = dis + selectedRes = r + } + } + val vo = SceneInfoVo() + BeanUtils.copyProperties(it, vo) + vo.closestStation = selectedRes + vo.length = minLen + + return@map vo + } } } \ No newline at end of file -- Gitblit v1.9.3