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/common/utils/DateUtil.kt | 2 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt | 9 + src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTWarnChangeRate2.kt | 20 ++++ src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt | 32 ++++++ src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt | 40 +++++++ src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt | 18 ++- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt | 25 ++-- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt | 80 +++++++++++++-- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate1.kt | 17 +++ src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate4.kt | 17 +++ src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTWarnChangeRate.kt | 4 src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionType.kt | 3 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate6.kt | 17 +++ src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt | 4 14 files changed, 242 insertions(+), 46 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 7193e08..f0acf81 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt @@ -121,12 +121,14 @@ // 瀵逛簬寮傚父鐨勭敓鎴愬垎鍒墽琛屽悗缃垽鏂�佸拰绔嬪嵆鍒ゆ柇 // 1. 鍚庣疆鍒ゆ柇锛氬綋鐩搁偦鏁版嵁鏃堕棿涓嶈繛缁椂锛屾垨鑰呮弧瓒宠嚜瀹氫箟鏉′欢鏃讹紝瀵逛箣鍓嶅凡鏈夌殑寮傚父杩涜璁板綍锛屽舰鎴愬紓甯哥粨鏋� - if (afterExcCheck(isContinue, it, hasException[f])) { - // 鏁版嵁涓嶈繛缁椂鎴栬�呮弧瓒充富鍔ㄦ埅鏂潯浠舵椂锛岃褰曞紓甯告儏鍐� - recordException(s, it, data) - } +// if (afterExcCheck(isContinue, it, hasException[f])) { +// // 鏁版嵁涓嶈繛缁椂鎴栬�呮弧瓒充富鍔ㄦ埅鏂潯浠舵椂锛岃褰曞紓甯告儏鍐� +// recordException(s, it, data) +// } // 2. 绔嬪嵆鍒ゆ柇锛氬綋鍑虹幇寮傚父鏃讹紝缂撳瓨寮傚父鏁版嵁鐨勫悓鏃讹紝绔嬪嵆瀵瑰凡鏈夊紓甯歌繘琛屽垽鏂槸鍚︽弧瓒冲紓甯哥粨鏋滆姹� - else if (hasException[f] == true) { + if (hasException[f] == true) { +// afterExcCheck(isContinue, it, hasException[f]) + needCut(it, hasException[f]) // 鏈夊紓甯稿嚭鐜版椂锛岃褰曞紓甯告暟鎹� it.addExceptionData(data) // 褰撶珛鍗冲垽鏂�氳繃鏃讹紝褰㈡垚寮傚父缁撴灉 @@ -136,9 +138,9 @@ } // 3. 鏁版嵁姝e父锛屾棤浠讳綍寮傚父鏃禿 // TODO("2025.6.3锛氬叾浠栧瓙绫荤殑姝ゅ鍒锋柊閫昏緫寰呭畬鎴愨��) - else { - it.refreshWithNextException(data) - } +// else { +// it.refreshWithNextException(data) +// } } } lastData = data diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionType.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionType.kt index a80de91..9a5fbad 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionType.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionType.kt @@ -11,5 +11,6 @@ TYPE7(7, "婊戝姩骞冲潎鍊肩獊鍙�"), TYPE8(8, "鏈夋晥鐜囧紓甯�"), TYPE9(9, "蹇�熶笂鍗�"), - TYPE10(10, "蹇�熶笅闄�") + TYPE10(10, "蹇�熶笅闄�"), + TYPE11(11, "涓婂崌瓒嬪娍") } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt index 504efa2..b8c3e98 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt @@ -2,13 +2,11 @@ import com.flightfeather.uav.biz.FactorFilter import com.flightfeather.uav.biz.dataanalysis.BaseExceptionAnalysis -import com.flightfeather.uav.biz.sourcetrace.RealTimeAnalysisConfig import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig import com.flightfeather.uav.biz.sourcetrace.exceptiontype.* import com.flightfeather.uav.biz.sourcetrace.model.AnalysisResult import com.flightfeather.uav.biz.sourcetrace.model.PollutedClue import com.flightfeather.uav.biz.sourcetrace.model.PollutedSummary -import com.flightfeather.uav.common.utils.GsonUtils import com.flightfeather.uav.domain.entity.BaseRealTimeData import com.flightfeather.uav.domain.repository.SceneInfoRep import com.flightfeather.uav.domain.repository.SourceTraceRep @@ -74,8 +72,13 @@ add(RTExcWindLevel1_1(config) { exceptionCallback(it) }.also { it.init() }) add(RTExcWindLevel4(config) { exceptionCallback(it) }.also { it.init() }) add(RTExcWindLevel6(config) { exceptionCallback(it) }.also { it.init() }) - add(RTExcChangeRate(config) { exceptionCallback(it) }.also { it.init() }) + + add(RTExcChangeRate1(config) { exceptionCallback(it) }.also { it.init() }) + add(RTExcChangeRate4(config) { exceptionCallback(it) }.also { it.init() }) + add(RTExcChangeRate6(config) { exceptionCallback(it) }.also { it.init() }) + add(RTWarnChangeRate(config) { dataChangeCallback(it) }.also { it.init() }) + add(RTWarnChangeRate2(config) { dataChangeCallback(it) }.also { it.init() }) } } 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 d39d51d..5665000 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 @@ -65,37 +65,71 @@ ) /****鏁版嵁蹇�熶笂鍗�*****************************************************************************/ - var changeRateCondition = WindLevelCondition( - .0 to Double.MAX_VALUE, - 0.1 to Double.MAX_VALUE, - DistanceType.TYPE1, - 3 - ) // 鐩戞祴鍥犲瓙鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級鍐呮甯稿彉鍖栫殑閲忕骇鑼冨洿 - var changeRateUp = mutableMapOf( + var changeRateUp1 = mutableMapOf( FactorType.PM25 to WindLevelCondition( - .0 to Double.MAX_VALUE, + .0 to 1.5, 4.0 to Double.MAX_VALUE, DistanceType.TYPE1, 3 ), FactorType.PM10 to WindLevelCondition( - .0 to Double.MAX_VALUE, + .0 to 1.5, 4.0 to Double.MAX_VALUE, DistanceType.TYPE1, 3 ), FactorType.VOC to WindLevelCondition( - .0 to Double.MAX_VALUE, + .0 to 1.5, 6.0 to Double.MAX_VALUE, DistanceType.TYPE1, 1 ), ) + var changeRateUp2 = mutableMapOf( + FactorType.PM25 to WindLevelCondition( + 1.6 to 7.9, + 4.0 to Double.MAX_VALUE, + DistanceType.TYPE3, + 3 + ), + FactorType.PM10 to WindLevelCondition( + 1.6 to 7.9, + 4.0 to Double.MAX_VALUE, + DistanceType.TYPE3, + 3 + ), + FactorType.VOC to WindLevelCondition( + 1.6 to 7.9, + 6.0 to Double.MAX_VALUE, + DistanceType.TYPE3, + 1 + ), + ) + var changeRateUp3 = mutableMapOf( + FactorType.PM25 to WindLevelCondition( + 8.0 to 13.8, + 4.0 to Double.MAX_VALUE, + DistanceType.TYPE4, + 3 + ), + FactorType.PM10 to WindLevelCondition( + 8.0 to 13.8, + 4.0 to Double.MAX_VALUE, + DistanceType.TYPE4, + 3 + ), + FactorType.VOC to WindLevelCondition( + 8.0 to 13.8, + 6.0 to Double.MAX_VALUE, + DistanceType.TYPE4, + 1 + ), + ) - /****鏁版嵁蹇�熶笅闄�*****************************************************************************/ + /****鏁版嵁蹇�熶笅闄嶆彁閱�*****************************************************************************/ // 鐩戞祴鍥犲瓙鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級鍐呮甯稿彉鍖栫殑閲忕骇鑼冨洿 - var changeRateDown = mutableMapOf( + var changeRateWarnDown = mutableMapOf( FactorType.PM25 to WindLevelCondition( .0 to Double.MAX_VALUE, -Double.MAX_VALUE to -2.0, @@ -115,4 +149,26 @@ 3 ), ) + + /****鏁版嵁鏈変笂鍗囪秼鍔挎彁閱�*****************************************************************************/ + var changeRateWarnUp = mutableMapOf( + FactorType.PM25 to WindLevelCondition( + .0 to Double.MAX_VALUE, + 2.0 to 4.0, + DistanceType.TYPE1, + 3 + ), + FactorType.PM10 to WindLevelCondition( + .0 to Double.MAX_VALUE, + 2.0 to 4.0, + DistanceType.TYPE1, + 3 + ), + FactorType.VOC to WindLevelCondition( + .0 to Double.MAX_VALUE, + 3.0 to 6.0, + DistanceType.TYPE1, + 1 + ), + ) } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt similarity index 86% rename from src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate.kt rename to src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt index f07fd1c..e36031e 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt @@ -19,7 +19,7 @@ * @date 2025/6/10 * @author feiyu02 */ -open class RTExcChangeRate(config: RTExcWindLevelConfig) : +abstract class BaseRTExcChangeRate(config: RTExcWindLevelConfig) : BaseExceptionContinuous<ExceptionTag, RTExcWindLevelConfig, PollutedClue>(config, ExceptionTag::class.java) { constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : this(config){ @@ -28,7 +28,7 @@ private var callback: NewPolluteClueCallback? = null - open var changeRate = this.config.changeRateUp + abstract var changeRate: MutableMap<FactorType, RTExcWindLevelConfig.WindLevelCondition> override fun getExceptionType(): ExceptionType { return ExceptionType.TYPE9 @@ -58,20 +58,17 @@ val rate = changeRate[f] - val pValue = p.getByFactorType(f)!! - val nValue = n.getByFactorType(f)!! - // 璁$畻鍚庝竴涓暟鎹浉姣斾簬鍓嶄竴涓暟鎹殑鍙樺寲閫熺巼 - val v = (nValue - pValue) - - val b1 = if (rate != null) { - v in rate.mutationRate.first..rate.mutationRate.second + if (rate != null && n.windSpeed!! in rate.windSpeed.first..rate.windSpeed.second) { + val pValue = p.getByFactorType(f)!! + val nValue = n.getByFactorType(f)!! + // 璁$畻鍚庝竴涓暟鎹浉姣斾簬鍓嶄竴涓暟鎹殑鍙樺寲閫熺巼 + val v = (nValue - pValue) + val b1 = v in rate.mutationRate.first..rate.mutationRate.second + println("鍥犲瓙锛�${f.des}锛岄�熺巼锛�${v}锛�${b1}") + res[f] = b1 } else { - false + res[f] = false } -// val r = (nValue - pValue) / pValue -// val b1 = r >= con.mutationRate.first && r < con.mutationRate.second - println("鍥犲瓙锛�${f.des}锛岄�熺巼锛�${v}锛�${b1}") - res[f] = b1 } return res } diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate1.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate1.kt new file mode 100644 index 0000000..0694835 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate1.kt @@ -0,0 +1,17 @@ +package com.flightfeather.uav.biz.sourcetrace.exceptiontype + +import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig +import com.flightfeather.uav.socket.eunm.FactorType + +/** + * 鏁版嵁鍙樺寲閫熺巼寮傚父 + * @date 2025/6/10 + * @author feiyu02 + */ +open class RTExcChangeRate1 : BaseRTExcChangeRate { + + constructor(config: RTExcWindLevelConfig):super(config) + constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) + + override var changeRate: MutableMap<FactorType, RTExcWindLevelConfig.WindLevelCondition> = this.config.changeRateUp1 +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate4.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate4.kt new file mode 100644 index 0000000..4dbe607 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate4.kt @@ -0,0 +1,17 @@ +package com.flightfeather.uav.biz.sourcetrace.exceptiontype + +import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig +import com.flightfeather.uav.socket.eunm.FactorType + +/** + * 鏁版嵁鍙樺寲閫熺巼寮傚父 + * @date 2025/6/10 + * @author feiyu02 + */ +open class RTExcChangeRate4 : BaseRTExcChangeRate { + + constructor(config: RTExcWindLevelConfig):super(config) + constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) + + override var changeRate: MutableMap<FactorType, RTExcWindLevelConfig.WindLevelCondition> = this.config.changeRateUp2 +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate6.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate6.kt new file mode 100644 index 0000000..94d70c9 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate6.kt @@ -0,0 +1,17 @@ +package com.flightfeather.uav.biz.sourcetrace.exceptiontype + +import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig +import com.flightfeather.uav.socket.eunm.FactorType + +/** + * 鏁版嵁鍙樺寲閫熺巼寮傚父 + * @date 2025/6/10 + * @author feiyu02 + */ +open class RTExcChangeRate6 : BaseRTExcChangeRate { + + constructor(config: RTExcWindLevelConfig):super(config) + constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) + + override var changeRate: MutableMap<FactorType, RTExcWindLevelConfig.WindLevelCondition> = this.config.changeRateUp3 +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTWarnChangeRate.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTWarnChangeRate.kt index 7dce4e3..99ae3c6 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTWarnChangeRate.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTWarnChangeRate.kt @@ -8,7 +8,7 @@ * @date 2025/7/3 * @author feiyu02 */ -class RTWarnChangeRate : RTExcChangeRate { +class RTWarnChangeRate : BaseRTExcChangeRate { constructor(config: RTExcWindLevelConfig):super(config) constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) @@ -16,5 +16,5 @@ return ExceptionType.TYPE10 } - override var changeRate = config.changeRateDown + override var changeRate = config.changeRateWarnDown } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTWarnChangeRate2.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTWarnChangeRate2.kt new file mode 100644 index 0000000..e6ee193 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTWarnChangeRate2.kt @@ -0,0 +1,20 @@ +package com.flightfeather.uav.biz.sourcetrace.exceptiontype + +import com.flightfeather.uav.biz.dataanalysis.model.ExceptionType +import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig + +/** + * 鏁版嵁鏈変笂鍗囪秼鍔挎彁閱� + * @date 2025/7/3 + * @author feiyu02 + */ +class RTWarnChangeRate2 : RTExcChangeRate1 { + constructor(config: RTExcWindLevelConfig):super(config) + constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) + + override fun getExceptionType(): ExceptionType { + return ExceptionType.TYPE11 + } + + override var changeRate = config.changeRateWarnUp +} \ No newline at end of file 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 d9adf45..e38d254 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 @@ -6,7 +6,9 @@ import com.flightfeather.uav.common.utils.DateUtil import com.flightfeather.uav.domain.entity.BaseRealTimeData import com.flightfeather.uav.lightshare.bean.DataVo +import com.flightfeather.uav.socket.eunm.FactorType import java.util.Date +import kotlin.math.round /** * 姹℃煋鏁版嵁 @@ -61,6 +63,11 @@ calPer() calRate() + + val s = dataSummary(exceptionData, factor.main) + avg = s.first + min = s.second + max = s.third } var deviceCode: String? = null @@ -89,6 +96,10 @@ var avgPer: Double? = null // 鍥犲瓙閲忕骇骞冲潎鍙樺寲閫熺巼 var avgRate: Double? = null + + var avg: Double? = null + var min: Double? = null + var max: Double? = null // 鍙戠敓娆℃暟 var times: Int? = null @@ -127,4 +138,25 @@ } avgRate = total / (list.size - 1) } + + private fun dataSummary(exceptionData: List<BaseRealTimeData?>, factorType: FactorType): Triple<Double, Double, + Double> { + var min = -1.0 + var max = -1.0 + var total = .0 + var count = 0 + exceptionData.forEach { + val value = it?.getByFactorType(factorType)?.toDouble() ?: return@forEach + if (min == -1.0 || min > value) { + min = round(value * 1000) / 1000 + } + if (max == -1.0 || max < value) { + max = round(value * 1000) / 1000 + } + total += value + count++ + } + val avg = if (count == 0) .0 else round(total / count * 1000) / 1000 + return Triple(avg, min, max) + } } \ 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 1543d33..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 } /** @@ -114,7 +117,7 @@ it.pm25!! / it.pm10!! }.average() val str = - "PM2.5閲忕骇涓�${pm25Avg}渭g/m鲁锛孭M10閲忕骇涓�${pm25Avg}渭g/m鲁锛孭M2.5鍗燩M10鐨勬瘮閲嶄负${round(percentageAvg * 100)}%" + "PM2.5閲忕骇涓�${pm25Avg}渭g/m鲁锛孭M10閲忕骇涓�${pm10Avg}渭g/m鲁锛孭M2.5鍗燩M10鐨勬瘮閲嶄负${round(percentageAvg * 100)}%" return if (percentageAvg > 0.666) { "${str}锛屾瘮閲嶈緝澶э紝姹℃煋婧愪互椁愰ギ涓轰富锛屽伐鍦版涔�" to listOf(SceneType.TYPE1, SceneType.TYPE2, SceneType.TYPE3, SceneType.TYPE14, SceneType.TYPE5) @@ -176,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 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 cbd6721..6d74863 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 @@ -158,8 +158,8 @@ 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() // 寤鸿瀵瑰簲鐨勬暟鎹噰鏍锋椂闂� diff --git a/src/main/kotlin/com/flightfeather/uav/common/utils/DateUtil.kt b/src/main/kotlin/com/flightfeather/uav/common/utils/DateUtil.kt index 0e26e93..52149ff 100644 --- a/src/main/kotlin/com/flightfeather/uav/common/utils/DateUtil.kt +++ b/src/main/kotlin/com/flightfeather/uav/common/utils/DateUtil.kt @@ -650,7 +650,7 @@ * @param date 鏃ユ湡 * @return 鏃堕棿 */ - fun getTime(date: Date): String? { + fun getTime(date: Date?): String? { return dateToString(date, DateStyle.HH_MM_SS) } -- Gitblit v1.9.3