From a3cc1d220f8a1de11874bebceba0130d32157ff1 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 30 九月 2025 09:26:32 +0800 Subject: [PATCH] 2025.9.30 1. 联合前端调试数据产品接口(待完成) --- src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataAnalysis.kt | 89 ++++++++++++++++++++++++++++---------------- 1 files changed, 56 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataAnalysis.kt b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataAnalysis.kt index 417ca2d..8838bee 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataAnalysis.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/business/autooutput/dataanalysis/AopDataAnalysis.kt @@ -70,46 +70,58 @@ //鑾峰彇鍘熷鐩戞祴鏁版嵁 val dataList = fetchDataResources(evaluationScene) //璁$畻缁熻缁撴灉 - var tempExceedTimes = TempResult() - var tempAvg = TempResult() - var tempMax = TempResult() - var tempMin = TempResult() +// var tempExceedTimes = TempResult() +// var tempAvg = TempResult() +// var tempMax = TempResult() +// var tempMin = TempResult() dataList.forEach { - // 鐩戞祴鐐规湁澶氬彴璁惧鏃讹紝姣忓彴璁惧鍗曠嫭缁熻锛屽彇鍧囧�兼渶楂樼殑涓虹粺璁$粨鏋� - val _tempExceedTimes = TempResult() - val _tempAvg = TempResult() - val _tempMax = TempResult() - val _tempMin = TempResult() + // 鐩戞祴鐐规湁澶氬彴璁惧鏃讹紝姣忓彴璁惧鍗曠嫭璁板綍 + val deviceCode = if (it.isNotEmpty()) { + getDeviceCode(it[0]) + } else { + null + } + val tempExceedTimes = TempResult() + val tempAvg = TempResult() + val tempMax = TempResult() + val tempMin = TempResult() +// 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 +// if (_tempAvg.avg > tempAvg.avg) { +// tempExceedTimes = _tempExceedTimes +// tempAvg = _tempAvg +// tempMax = _tempMax +// tempMin = _tempMin +// } + val dustDataResult = DustDataResult().apply { + drSceneId = evaluationScene.scene.value?.guid + drSceneName = evaluationScene.scene.value?.name + drDeviceCode = deviceCode + drTime = source?.config?.startTime + drExceedTimes = tempExceedTimes.count + drAvg = tempAvg.avg + drMax = tempMax.total + drMin = tempMin.total + drOverAvgPer = overAvgRate(drAvg, dAvg) + drDataNum = count(dataList) + // 褰撴暟鎹噺涓�0鏃讹紝瓒呮湀搴﹀尯鍧囧�肩櫨鍒嗘瘮鍙樹负0 + if (drDataNum == 0) drOverAvgPer = .0 + drEffectiveRate = effectiveRate(dataList, evaluationScene) } + //鏇存柊鍏ュ簱 + aopOutput.toDbDataResult(dustDataResult) } - val dustDataResult = DustDataResult().apply { - drSceneId = evaluationScene.scene.value?.guid - drSceneName = evaluationScene.scene.value?.name - drTime = source?.config?.startTime - drExceedTimes = tempExceedTimes.count - drAvg = tempAvg.avg - drMax = tempMax.total - drMin = tempMin.total - drOverAvgPer = overAvgRate(drAvg, dAvg) - drDataNum = count(dataList) - drEffectiveRate = effectiveRate(dataList, evaluationScene) - } - //鏇存柊鍏ュ簱 - aopOutput.toDbDataResult(dustDataResult) } } @@ -118,6 +130,11 @@ * 褰撳墠涓鸿寖鍥村唴鍏ㄩ儴鐩戞祴鐐圭殑鍧囧�� */ abstract fun districtAvg(source: AopDataSource?): Double? + + /** + * 鑾峰彇璁惧缂栧彿 + */ + abstract fun getDeviceCode(data: T?): String? /** * 鑾峰彇鍘熷鐩戞祴鏁版嵁 @@ -147,7 +164,13 @@ /** * 瓒呮湀鍧囧�肩櫨鍒嗘瘮 */ - abstract fun overAvgRate(avg: Double, dAvg: Double?): Double? + open fun overAvgRate(avg: Double, dAvg: Double?): Double? { + return if (dAvg != null && dAvg != .0) { + round(((avg - dAvg) / dAvg) * 1000) / 1000 + } else { + .0 + } + } /** * 鏁版嵁涓暟 -- Gitblit v1.9.3