From 0bfd1f3b422677ddfed45f13fc034f17f049b9d5 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 03 六月 2025 17:30:35 +0800 Subject: [PATCH] 1. 新增动态污染溯源新的判定逻辑(待完成) --- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcWindLevel1_1.kt | 1 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionSlideAverage.kt | 2 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt | 26 ++++++++---- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt | 2 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt | 2 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt | 11 +++-- src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt | 7 +++ src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionSlideAverage.kt | 4 +- src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt | 6 ++ src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt | 49 +++++++++++++++++++++--- 10 files changed, 84 insertions(+), 26 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt index 658c621..ce55583 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt @@ -109,6 +109,11 @@ recordException(s, it, data) } } + // 3. 鏁版嵁姝e父锛屾棤浠讳綍寮傚父鏃禿 + // TODO("2025.6.3锛氬叾浠栧瓙绫荤殑姝ゅ鍒锋柊閫昏緫寰呭畬鎴愨��) + else { + it.refreshWithNoException(data) + } } } lastData = data @@ -154,7 +159,7 @@ */ open fun onNewException(tag: T, factor: FactorFilter.SelectedFactor, exceptionStatus: ExceptionStatusType) { if (tag.startData == null) return - val ex = newResult(tag.startData!!, lastData, factor, tag.exceptionData) + val ex = newResult(tag.startData!!, tag.endData, factor, tag.exceptionData) .apply { status = exceptionStatus.value } // 寮傚父宸插垱寤烘椂锛屾洿鏂板紓甯镐俊鎭� if (tag.exceptionCreated) { diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionSlideAverage.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionSlideAverage.kt index f5f6b8b..7cfcd1f 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionSlideAverage.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionSlideAverage.kt @@ -183,7 +183,7 @@ if (factor != null && tag != null) { if (tag.exceptionExisted) { tag.startData?.let { - resultList.add(newResult(it, lastData, factor, tag.exceptionData)) + resultList.add(newResult(it, tag.endData, factor, tag.exceptionData)) } tag.exceptionExisted = false } @@ -192,7 +192,7 @@ val tag1 = tagMap[f.main] ?: return@forEach if (tag1.exceptionExisted) { tag1.startData?.let { - resultList.add(newResult(it, lastData, f, tag1.exceptionData)) + resultList.add(newResult(it, tag1.endData, f, tag1.exceptionData)) } tag1.exceptionExisted = false } diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt index 0bb8a4a..7886a5d 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt @@ -37,9 +37,13 @@ exceptionData.add(data) } - fun refreshWithNextException(data: BaseRealTimeData) { + fun refreshWithNoException(data: BaseRealTimeData) { sIndex = eIndex startData = data + } + + fun refreshWithNextException(data: BaseRealTimeData) { + refreshWithNoException(data) exceptionData.clear() exceptionExisted = false exceptionCreated = false diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt index 1e08443..d5fbbe0 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt @@ -13,7 +13,8 @@ inner class WindLevelCondition( val windSpeed: Pair<Double, Double>, - val mutationRate: Pair<Double, DistanceType>, + val mutationRate: Pair<Double, Double>, + val distanceType: DistanceType, val countLimit: Int, ) @@ -25,28 +26,33 @@ // 0 - 1绾ч var windLevelCondition1 = WindLevelCondition( .0 to 1.5, - 0.5 to DistanceType.TYPE1, + 0.5 to Double.MAX_VALUE, + DistanceType.TYPE1, 1 ) // 0 - 1绾ч var windLevelCondition1_1 = WindLevelCondition( .0 to 1.5, - 0.2 to DistanceType.TYPE2, + 0.2 to 0.5, + DistanceType.TYPE2, 1 ) // 2 - 4绾ч var windLevelCondition2 = WindLevelCondition( 1.6 to 7.9, - 0.2 to DistanceType.TYPE3, - 3 + 0.2 to Double.MAX_VALUE, + DistanceType.TYPE3, +// 3 + 1 ) // 5 - 6绾ч var windLevelCondition3 = WindLevelCondition( 8.0 to 13.8, - 0.1 to DistanceType.TYPE4, + 0.1 to Double.MAX_VALUE, + DistanceType.TYPE4, 3 ) @@ -57,4 +63,35 @@ var analysisPeriod = 15 // 瀹氭椂鍒嗘瀽闂撮殧涓紝绔嬪嵆杩涜绾跨储鍒嗘瀽鐨勬渶灏忕嚎绱㈤噺(鍗曚綅锛氫釜) var analysisCount = 3 + + + +// // 0 - 1绾ч +// var windLevelCondition1 = WindLevelCondition( +// .0 to 1.5, +// listOf(0.5 to DistanceType.TYPE1, 0.2 to DistanceType.TYPE2,), +// listOf(1, 1) +// ) +// +// // 0 - 1绾ч +// var windLevelCondition1_1 = WindLevelCondition( +// .0 to 1.5, +// 0.2 to DistanceType.TYPE2, +// 1 +// ) +// +// // 2 - 4绾ч +// var windLevelCondition2 = WindLevelCondition( +// 1.6 to 7.9, +// listOf(0.2 to DistanceType.TYPE3), +//// listOf(3) +// listOf(1) +// ) +// +// // 5 - 6绾ч +// var windLevelCondition3 = WindLevelCondition( +// 8.0 to 13.8, +// listOf(0.1 to DistanceType.TYPE4), +// listOf(3) +// ) } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt index e1fe81d..779d121 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt @@ -54,7 +54,7 @@ val nValue = n.getByFactorType(f)!! // 璁$畻鍚庝竴涓暟鎹浉姣斾簬鍓嶄竴涓暟鎹殑鍙樺寲鐜� val r = (nValue - pValue) / pValue - val b1 = r >= con.mutationRate.first + val b1 = r >= con.mutationRate.first && r < con.mutationRate.second println("鍥犲瓙锛�${f.des}锛屽箙搴︼細${r}锛岄檺瀹氾細${con.mutationRate.first}锛�${b1}") res[f] = b1 } else { diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcWindLevel1_1.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcWindLevel1_1.kt index adc39e8..0668d1d 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcWindLevel1_1.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcWindLevel1_1.kt @@ -7,6 +7,7 @@ * @date 2025/5/29 * @author feiyu02 */ + class RTExcWindLevel1_1 : BaseRTExcWindLevel { constructor(config: RTExcWindLevelConfig) : super(config) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionSlideAverage.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionSlideAverage.kt index f471a79..5aa8052 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionSlideAverage.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionSlideAverage.kt @@ -121,7 +121,7 @@ */ open fun onNewException(tag: ExceptionSlideAverageTag, factor: FactorFilter.SelectedFactor, exceptionStatus: ExceptionStatusType) { if (tag.startData == null) return - val ex = newResult(tag.startData!!, lastData, factor, tag.exceptionData) + val ex = newResult(tag.startData!!, tag.endData, factor, tag.exceptionData) .apply { status = exceptionStatus.value } // 寮傚父宸插垱寤烘椂锛屾洿鏂板紓甯镐俊鎭� if (tag.exceptionCreated) { diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt index 6f7fd3c..2d0a968 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt @@ -24,7 +24,7 @@ config: RTExcWindLevelConfig, windLevelCondition: RTExcWindLevelConfig.WindLevelCondition, ) : this() { - distanceType = windLevelCondition.mutationRate.second + distanceType = windLevelCondition.distanceType sourceTrace(exceptionData, config, windLevelCondition) } @@ -55,13 +55,16 @@ polygon = calSector( avgData.windSpeed!!.toDouble(), pair, - windLevelCondition.mutationRate.second.disRange, + windLevelCondition.distanceType.disRange, config.sourceTraceDegOffset - ) + ).map { + // 灏嗗潗鏍囪浆鎹负gcj02锛堢伀鏄熷潗鏍囩郴锛夛紝鍥犱负姹℃煋婧愬満鏅俊鎭兘涓烘鍧愭爣绯� + MapUtil.wgs84ToGcj02(it) + } try { val address = AMapService.reGeo(pair) - this.address = address.township + address.street + this.address = address.district + address.township + address.street } catch (e: Exception) { e.printStackTrace() } diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt index 489e66a..56190ed 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt @@ -41,17 +41,20 @@ startTime = DateUtil.instance.dateToString(start.dataTime, DateUtil.DateStyle.HH_MM_SS) endTime = DateUtil.instance.dateToString(end?.dataTime, DateUtil.DateStyle.HH_MM_SS) ?: startTime - startData = start.getByFactorType(factor.main) - endData = end?.getByFactorType(factor.main) ?: startData +// startData = start.getByFactorType(factor.main) +// endData = end?.getByFactorType(factor.main) ?: startData + startData = start + endData = end windSpeed = exceptionData.first().windSpeed?.toDouble() percentage = windLevelCondition.mutationRate.first times = windLevelCondition.countLimit + dataList.add(start) exceptionData.forEach { dataList.add(it) - dataVoList.add(it.toDataVo()) } + dataVoList.addAll(dataList.map { it.toDataVo() }) calPer() } @@ -70,8 +73,8 @@ var startTime: String? = null var endTime: String? = null - var startData: Float? = null - var endData: Float? = null + var startData: BaseRealTimeData? = null + var endData: BaseRealTimeData? = null // 椋庨�� var windSpeed: Double? = null @@ -89,12 +92,17 @@ var dataVoList: MutableList<DataVo> = mutableListOf() private fun calPer() { - if (dataList.size < 2) return + val list = dataList +// list.add(startData) +// list.addAll(dataList) + if (list.size < 2) return var total = .0 - for (i in 0 until dataList.size - 1) { - total += dataList[i].getByFactorType(selectedFactor!!.main)!! + for (i in 0 until list.size - 1) { + val p = list[i]?.getByFactorType(selectedFactor!!.main)!! + val n = list[i + 1]?.getByFactorType(selectedFactor!!.main)!! + total += (n - p) / p } - avgPer = total / (dataList.size - 1) + avgPer = total / (list.size - 1) } } \ No newline at end of file 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 c948fe3..7817607 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 @@ -44,7 +44,7 @@ fun searchScenes(pollutedArea: PollutedArea, sceneInfoRep: SceneInfoRep, factor: FactorFilter.SelectedFactor) { // Fixme 2025.5.14: 姹℃煋婧愮殑鍧愭爣鏄珮寰峰湴鍥惧潗鏍囩郴锛堢伀鏄熷潗鏍囩郴锛夛紝鑰岃蛋鑸暟鎹槸WGS84鍧愭爣绯� // 鎸夌収鍖哄煙妫�绱㈠唴閮ㄦ薄鏌撴簮淇℃伅 - // 1. 棣栧厛鎸夌収鍥涜嚦鑼冨洿浠庢暟鎹簱鍒濇绛涢�夋薄鏌撴簮锛岄渶瑕佸厛灏嗗潗鏍囪浆鎹负gcj02锛堢伀鏄熷潗鏍囩郴锛夛紝鍥犱负姹℃煋婧愬満鏅俊鎭兘涓烘鍧愭爣绯� + // 1. 棣栧厛鎸夌収鍥涜嚦鑼冨洿浠庢暟鎹簱鍒濇绛涢�夋薄鏌撴簮 // val polygonTmp = pollutedArea.polygon!!.map { // MapUtil.gcj02ToWgs84(it) // } -- Gitblit v1.9.3