From 344d9006faa27ea65e3eaf5e8f9173aad2266038 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期三, 23 七月 2025 17:23:53 +0800
Subject: [PATCH] 2025.7.23 1. 动态溯源模块完成,发布
---
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt | 159 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 147 insertions(+), 12 deletions(-)
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 8ae7734..3dc2e05 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
@@ -1,35 +1,170 @@
package com.flightfeather.uav.biz.sourcetrace.model
+import com.flightfeather.uav.biz.FactorFilter
+import com.flightfeather.uav.biz.dataanalysis.model.ExceptionType
+import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig
+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
/**
* 姹℃煋鏁版嵁
* @date 2025/5/27
* @author feiyu02
*/
-class PollutedData {
+class PollutedData() {
+
+ inner class Statistic(){
+ var factorId: Int? = null
+ var factorName: String? = null
+ var subFactorId: List<Int>? = null
+ var subFactorName: List<String>? = null
+ var selectedFactor: FactorFilter.SelectedFactor? = null
+
+ // 鍥犲瓙閲忕骇骞冲潎鍙樺寲骞呭害
+ var avgPer: Double? = null
+ // 鍥犲瓙閲忕骇骞冲潎鍙樺寲閫熺巼
+ var avgRate: Double? = null
+
+ var avg: Double? = null
+ var min: Double? = null
+ var max: Double? = null
+ }
/**
- *
- * 1. 杞1.5m/s鍙婁互涓嬶紝
- * 鍓嶅悗鍊间笂鍗囧箙搴﹀湪50%浠ヤ笂1娆★紝璁や负鏄复杩戝彂鐢�(50绫�)
- * 鍓嶅悗鍊间笂鍗囧箙搴﹀湪20%浠ヤ笂1娆★紝璁や负鏄繙璺濈鍙戠敓锛�50绫� - 500绫筹級
- * 1.5 m/s鍙婁互涓嬶紝闈欑ǔ澶╂皵锛屼复杩戝彂鐢�(50绫�)
- * 2. 1.6 - 7.9 m/s锛屽墠鍚庡�间笂鍗囧箙搴﹀湪20%浠ヤ笂3娆★紝璁や负鏄繙璺濈鍙戠敓锛�50绫� - 1鍏噷锛�
- * 3. 8 - 13.8 m/s 浠ヤ笂锛屽墠鍚庡�间笂鍗囧箙搴﹀湪10%浠ヤ笂3娆★紝璁や负鏄繙璺濈鍙戠敓(50绫� - 2鍏噷)
+ * 9. 鍏宠仈鍥犲瓙
+ * a) pm2.5銆乸m10鐗瑰埆楂橈紝涓よ�呭湪鍚勬儏鍐典笅鍚屾灞曠ず锛宲m2.5鍗爌m10鐨勬瘮閲嶅彉鍖栵紝姣旈噸瓒婇珮锛岃秺鏈夊彲鑳芥槸椁愰ギ
+ * b) pm10鐗瑰埆楂樸�乸m2.5杈冮珮锛屽ぇ棰楃矑鎵皹姹℃煋锛屽彧灞曠ずpm10锛宲m2.5鍗爌m10鐨勬瘮閲嶅彉鍖栵紝宸ュ湴涓轰富
+ * c) VOC杈冮珮锛屽悓姣旇绠梡m2.5鐨勯噺绾э紝鍙兘瀛樺湪鍚屾鍋忛珮锛堟苯淇�佸姞娌圭珯锛�, 鍚屾璁$畻O3鏄惁鏈夐珮鍊�
+ * d) VOC杈冮珮锛屽浜庡姞娌圭珯锛堣溅杈嗘嫢鍫垫儏鍐碉級锛孋O涓�鑸緝楂�, 鍚屾璁$畻O3鏄惁鏈夐珮鍊�
+ * e) 姘哀鍖栧悎鐗╋紝涓�鑸敱浜庢満鍔ㄨ溅灏炬皵锛屽悓姝ヨ绠桟O
*/
- // 椋庨��
- var windSpeed: Float? = null
+ constructor(
+ start: BaseRealTimeData,
+ end: BaseRealTimeData?,
+ factorList: List<FactorFilter.SelectedFactor>,
+ exceptionData: List<BaseRealTimeData>,
+ historyData: List<BaseRealTimeData>,
+ eType: ExceptionType,
+ windLevelCondition: RTExcWindLevelConfig.WindLevelCondition?,
+ ) : this() {
+ exception = eType.des
+ exceptionType = eType.value
- // 鍥犲瓙閲忕骇鍙樺寲骞呭害
- var percentage: Float? = null
+ startTime = start.dataTime
+ endTime = end?.dataTime
+// startData = start.getByFactorType(factor.main)
+// endData = end?.getByFactorType(factor.main) ?: startData
+ startData = start
+ endData = end
+
+ windSpeed = exceptionData.first().windSpeed?.toDouble()
+ times = windLevelCondition?.countLimit
+
+ dataList.add(start)
+ exceptionData.forEach {
+ dataList.add(it)
+ }
+ dataVoList.addAll(dataList.map { it.toDataVo() })
+ historyDataList.addAll(historyData.map { it.toDataVo() })
+
+
+ factorList.forEach { f->
+ statisticMap[f.main] = Statistic().apply {
+ factorId = f.main.value
+ factorName = f.main.des
+ subFactorId = f.subs.map { it.value }
+ subFactorName = f.subs.map { it.des }
+ selectedFactor = f
+
+ avgPer = calPer(f.main)
+ avgRate = calRate(f.main)
+
+ val s = dataSummary(exceptionData, f.main)
+ avg = s.first
+ min = s.second
+ max = s.third
+ }
+ }
+ }
+
+ var deviceCode: String? = null
+
+ var exception: String? = null
+ var exceptionType: Int? = null
+
+ var startTime: Date? = null
+ var endTime: Date? = null
+
+ var startData: BaseRealTimeData? = null
+ var endData: BaseRealTimeData? = null
+
+ // 椋庨��
+ var windSpeed: Double? = null
// 鍙戠敓娆℃暟
var times: Int? = null
+ var historyDataList = mutableListOf<DataVo>()
// 寮傚父鐩戞祴鏁版嵁
var dataList: MutableList<BaseRealTimeData> = mutableListOf()
var dataVoList: MutableList<DataVo> = mutableListOf()
+
+ var statisticMap = mutableMapOf<FactorType, Statistic>()
+
+ fun toFactorNames(): String {
+ val factors = statisticMap.entries.map { it.key }.sortedBy { it.value }.joinToString(";") { it.des }
+ return factors
+ }
+
+ private fun calPer(factorType: FactorType): Double? {
+ val list = dataList
+ if (list.size < 2) return null
+
+ var total = .0
+ for (i in 0 until list.size - 1) {
+ val p = list[i].getByFactorType(factorType)!!
+ val n = list[i + 1].getByFactorType(factorType)!!
+ total += (n - p) / p
+ }
+ return total / (list.size - 1)
+ }
+
+ private fun calRate(factorType: FactorType): Double? {
+ val list = dataList
+ if (list.size < 2) return null
+
+ var total = .0
+ for (i in 0 until list.size - 1) {
+ val p = list[i].getByFactorType(factorType)!!
+ val n = list[i + 1].getByFactorType(factorType)!!
+ total += (n - p) / 4
+ }
+ return 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
--
Gitblit v1.9.3