From c1becf4cbd2e99601ce011c14b8742427249cfb4 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 09 一月 2024 17:25:05 +0800 Subject: [PATCH] 1. 多项调整 --- src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataAnalysis.kt | 54 ++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopDataAnalysis.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataAnalysis.kt similarity index 72% rename from src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopDataAnalysis.kt rename to src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataAnalysis.kt index e0f5e50..417ca2d 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/score/AopDataAnalysis.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataAnalysis.kt @@ -1,4 +1,4 @@ -package cn.flightfeather.supervision.business.autooutput.score +package cn.flightfeather.supervision.business.autooutput.dataanalysis import cn.flightfeather.supervision.business.autooutput.AopOutput import cn.flightfeather.supervision.business.autooutput.datasource.AopDataConfig @@ -22,13 +22,21 @@ ) { /** - * 缁熻涓棿瀛樺偍缁撴瀯 + * 缁熻鏁版嵁 涓存椂瀛樺偍缁撴瀯 */ inner class TempResult( var total: Double = .0, var count: Int = 0, ){ - fun avg(): Double { + var avg: Double = -1.0 + get() { + if (field == -1.0) { + field = avg() + } + return field + } + + private fun avg(): Double { return if (count == 0) { .0 } else { @@ -53,25 +61,39 @@ /** * 鎵ц缁熻閫昏緫 */ - fun execute() { - val dAvg = districtAvg(source) + fun execute(avg: Double? = null) { + //璁$畻鍖哄潎鍊� + val dAvg = avg ?: districtAvg(source) + println("鍧囧�硷細${dAvg}") //寰幆澶勭悊姣忎釜鍦烘櫙 source?.loop { _, evaluationScene -> //鑾峰彇鍘熷鐩戞祴鏁版嵁 val dataList = fetchDataResources(evaluationScene) //璁$畻缁熻缁撴灉 - val tempExceedTimes = TempResult() - val tempAvg = TempResult() - val tempMax = TempResult() - val tempMin = TempResult() + var tempExceedTimes = TempResult() + var tempAvg = TempResult() + var tempMax = TempResult() + var tempMin = TempResult() dataList.forEach { - it.forEach {t -> + // 鐩戞祴鐐规湁澶氬彴璁惧鏃讹紝姣忓彴璁惧鍗曠嫭缁熻锛屽彇鍧囧�兼渶楂樼殑涓虹粺璁$粨鏋� + val _tempExceedTimes = TempResult() + val _tempAvg = TempResult() + val _tempMax = TempResult() + val _tempMin = TempResult() + it.forEach { t -> t?.let { - exceedTimes(t, tempExceedTimes) - avg(t, tempAvg) - max(t, tempMax) - min(t, tempMin) + exceedTimes(t, _tempExceedTimes) + avg(t, _tempAvg) + max(t, _tempMax) + min(t, _tempMin) } + } + // 淇濈暀鍧囧�兼渶楂樼殑涓�鍙拌澶� + if (_tempAvg.avg > tempAvg.avg) { + tempExceedTimes = _tempExceedTimes + tempAvg = _tempAvg + tempMax = _tempMax + tempMin = _tempMin } } val dustDataResult = DustDataResult().apply { @@ -79,7 +101,7 @@ drSceneName = evaluationScene.scene.value?.name drTime = source?.config?.startTime drExceedTimes = tempExceedTimes.count - drAvg = tempAvg.avg() + drAvg = tempAvg.avg drMax = tempMax.total drMin = tempMin.total drOverAvgPer = overAvgRate(drAvg, dAvg) @@ -125,7 +147,7 @@ /** * 瓒呮湀鍧囧�肩櫨鍒嗘瘮 */ - abstract fun overAvgRate(avg: Double, dAvg: Double?): Double + abstract fun overAvgRate(avg: Double, dAvg: Double?): Double? /** * 鏁版嵁涓暟 -- Gitblit v1.9.3