From c5f380b69707a9a09fe988a2f4bd98e142bf64ae Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 10 七月 2025 17:29:48 +0800 Subject: [PATCH] 2025.7.10 1. 修改动态溯源异常判断逻辑 --- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 43 insertions(+), 5 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 d74ceaa..3e52986 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 @@ -1,5 +1,6 @@ package com.flightfeather.uav.biz.sourcetrace.model +import com.flightfeather.uav.common.utils.DateUtil import com.flightfeather.uav.common.utils.MapUtil import com.flightfeather.uav.domain.entity.SceneInfo import com.flightfeather.uav.domain.repository.SceneInfoRep @@ -25,7 +26,7 @@ */ // 婧簮浼佷笟 - var sceneList: List<SceneInfoVo?>? = null + var sceneList: List<SceneInfoVo>? = null // 婧簮鎺ㄧ悊缁撹 var conclusion: String? = null @@ -69,7 +70,7 @@ // 鏍规嵁姹℃煋鍥犲瓙鐨勯噺绾э紝璁$畻涓昏鐨勬薄鏌撳満鏅被鍨嬶紝绛涢�夌粨鏋� val mainSceneType = calSceneType(pollutedData) if (mainSceneType != null) { - this.conclusion = mainSceneType.first +// this.conclusion = mainSceneType.first result = result.filter { val r = mainSceneType.second.find { s-> s.value == it.typeId.toInt() @@ -80,6 +81,8 @@ this.sceneList = findClosestStation(sceneInfoRep, result) + val txt = summaryTxt(pollutedData, this.sceneList!!) + this.conclusion = txt } /** @@ -107,18 +110,22 @@ FactorType.PM25, FactorType.PM10, -> { + val pm25Avg = round(pollutedData.dataList.map { it.pm25!! }.average() * 10) / 10 + val pm10Avg = round(pollutedData.dataList.map { it.pm10!! }.average() * 10) / 10 // 璁$畻寮傚父鏁版嵁鐨刾m2.5鍗爌m10姣旈噸鐨勫潎鍊� val percentageAvg = pollutedData.dataList.map { it.pm25!! / it.pm10!! }.average() + val str = + "PM2.5閲忕骇涓�${pm25Avg}渭g/m鲁锛孭M10閲忕骇涓�${pm10Avg}渭g/m鲁锛孭M2.5鍗燩M10鐨勬瘮閲嶄负${round(percentageAvg * 100)}%" return if (percentageAvg > 0.666) { - "PM2.5鍗燩M10鐨勬瘮閲嶄负${round(percentageAvg * 100)}%锛屾瘮閲嶈緝澶э紝姹℃煋婧愪互椁愰ギ涓轰富锛屽伐鍦版涔�" to + "${str}锛屾瘮閲嶈緝澶э紝姹℃煋婧愪互椁愰ギ涓轰富锛屽伐鍦版涔�" to listOf(SceneType.TYPE1, SceneType.TYPE2, SceneType.TYPE3, SceneType.TYPE14, SceneType.TYPE5) } else if (percentageAvg < 0.333) { - "PM2.5鍗燩M10鐨勬瘮閲嶄负${round(percentageAvg * 100)}%锛屾瘮閲嶈緝灏忥紝灞炰簬澶ч绮掓壃灏樻薄鏌擄紝姹℃煋婧愪互宸ュ湴涓轰富" to + "${str}锛屾瘮閲嶈緝灏忥紝灞炰簬澶ч绮掓壃灏樻薄鏌擄紝姹℃煋婧愪互宸ュ湴涓轰富" to listOf(SceneType.TYPE1, SceneType.TYPE2, SceneType.TYPE3, SceneType.TYPE14, SceneType.TYPE5) } else { - "PM2.5鍗燩M10鐨勬瘮閲嶄负${round(percentageAvg * 100)}%锛屾薄鏌撴簮浠ラ楗�佸伐鍦颁负涓�" to + "${str}锛屾薄鏌撴簮浠ラ楗�佸伐鍦颁负涓�" to listOf(SceneType.TYPE1, SceneType.TYPE2, SceneType.TYPE3, SceneType.TYPE14, SceneType.TYPE5) } } @@ -172,4 +179,35 @@ return@map vo } } + + private fun summaryTxt(pollutedData: PollutedData, sceneList: List<SceneInfoVo>): String { +// pollutedData.exception +// pollutedData.selectedFactor?.main + val st = DateUtil.instance.getTime(pollutedData.startTime) + val et = DateUtil.instance.getTime(pollutedData.endTime) + var txt = + "${pollutedData.selectedFactor?.main?.des}鍦�${st}鑷�${et}涔嬮棿锛屽嚭鐜�${pollutedData.exception}锛屾渶浣庡�间负${ + pollutedData + .min + }锛屾渶楂樺�间负${pollutedData.max}" + if (sceneList.isEmpty()) { + txt += ("锛屽彲鑳藉瓨鍦ㄩ殣钘忛闄╂簮銆�") + } else { + txt += ("锛屽彂鐜�${sceneList.size}涓闄╂簮锛屽寘鍚�") + + val sizeMap = mutableMapOf<String, Int>() + sceneList.forEach { + if (!sizeMap.containsKey(it.type)) { + sizeMap[it.type] = 0 + } + sizeMap[it.type] = sizeMap[it.type]!! + 1 + } + sizeMap.forEach { (t, u) -> + txt += ("${u}涓�${t}锛�") + } + txt = txt.replaceRange(txt.length - 1, txt.length, "銆�") + } + + return txt + } } \ No newline at end of file -- Gitblit v1.9.3