From aa94ef4e1f060b184e6ea9fb37254b376a1eb60e Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 14 十一月 2023 10:49:06 +0800 Subject: [PATCH] 1. 新增风险值的自动运行逻辑; --- src/main/java/com/flightfeather/monitor/analysis/dust/risk/DustRiskAnalysis.kt | 30 ++++++++++++++++-------------- 1 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/flightfeather/monitor/analysis/dust/risk/DustRiskAnalysis.kt b/src/main/java/com/flightfeather/monitor/analysis/dust/risk/DustRiskAnalysis.kt index df364e2..3e05493 100644 --- a/src/main/java/com/flightfeather/monitor/analysis/dust/risk/DustRiskAnalysis.kt +++ b/src/main/java/com/flightfeather/monitor/analysis/dust/risk/DustRiskAnalysis.kt @@ -2,6 +2,9 @@ import com.flightfeather.monitor.domain.ds1.entity.* import com.flightfeather.monitor.enumration.dust.ExceptionType +import java.time.LocalDate +import java.time.ZoneId +import java.util.* /** * 鎵皹鐩戞祴鏁版嵁椋庨櫓鍒嗘瀽鍩虹被 @@ -21,8 +24,12 @@ /** * 姣忚疆娆$殑鍒濆鍖� */ - fun roundInit() { - resultList.add(RiskValue()) + fun roundInit(mnCode: String, date: LocalDate) { + resultList.add(RiskValue().apply { + this.mnCode = mnCode + lst = Date.from(date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()) + type = "day" + }) } /** @@ -37,7 +44,6 @@ riskExceedRate(res, list) riskExceptionRepetitionRate(res, dList) riskExceptionType(res, dList) - onDone(res) } /** @@ -66,7 +72,7 @@ var v2 = 0 // 鏃ヤ复杩戣秴鏍囨鏁�/7 var v3 = 0 - list.forEach {d -> + list.forEach { d -> if (d == null) return@forEach when { d.dustValue >= 2.0 -> v2++ @@ -92,7 +98,7 @@ var v1 = 0 var v2 = 0 var v3 = 0 - list.forEach { d-> + list.forEach { d -> if (d == null) return@forEach when (d.exceptionType) { ExceptionType.TYPE4.value -> v1++ @@ -100,10 +106,10 @@ ExceptionType.TYPE6.value -> v3++ } } - val e1 = upperLimit((v1 - 1) / 4.0) - val e2 = upperLimit((v2 - 1) / 3.0) - val e3 = upperLimit((v3 - 1) / 2.0) - riskValue.typicalExceptionRepetitionRate = upperLimit(e1 + e2 + e3) + val e1 = settingRange((v1 - 1) / 4.0) + val e2 = settingRange((v2 - 1) / 3.0) + val e3 = settingRange((v3 - 1) / 2.0) + riskValue.typicalExceptionRepetitionRate = settingRange(e1 + e2 + e3) } /** @@ -125,9 +131,5 @@ riskValue.exceptionTypeAggregation = exceptionTypes.size / 6.0 } - fun onDone(riskValue: RiskValue) { - riskValue.type = "day" - } - - private fun upperLimit(d:Double):Double = if (d > 1) 1.0 else d + private fun settingRange(d: Double): Double = if (d > 1) 1.0 else if (d < 0) .0 else d } \ No newline at end of file -- Gitblit v1.9.3