From eb3dd00b0b7fcda477229d518d250f9c842b790b Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 21 十月 2025 17:45:44 +0800
Subject: [PATCH] 2025.10.21 1. 走航季度报告相关数据计算逻辑调整
---
src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt | 121 +++++++++++++++++++++++++--------------
1 files changed, 77 insertions(+), 44 deletions(-)
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt
index 7ac9d4b..65c0fab 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt
+++ b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataVo.kt
@@ -1,10 +1,12 @@
package com.flightfeather.uav.lightshare.bean
-import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonInclude
+import com.flightfeather.uav.domain.entity.BaseRealTimeData
import com.flightfeather.uav.model.BaseMData
import com.flightfeather.uav.socket.bean.AirData
import com.flightfeather.uav.socket.eunm.FactorType
+import java.text.SimpleDateFormat
+import java.util.Date
/**
* @author riku
@@ -12,55 +14,86 @@
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
data class DataVo(
- //鏃堕棿, yyyy-MM-dd HH:mm:ss
- var time: String? = null,
- //绔欑偣缂栧彿
- var deviceCode: String? = null,
- //鏁版嵁鍊�
- var values: List<AirData>? = null,
- //缁忓害
- var lng: Double? = null,
- //绾害
- var lat: Double? = null
+ //鏃堕棿, yyyy-MM-dd HH:mm:ss
+ var time: String? = null,
+ //绔欑偣缂栧彿
+ var deviceCode: String? = null,
+ //鏁版嵁鍊�
+ var values: List<AirData>? = null,
+ //缁忓害
+ var lng: Double? = null,
+ //绾害
+ var lat: Double? = null,
) : BaseMData() {
- override fun getFactorData(type: FactorType): Double? {
- if (values == null) throw IllegalStateException(this.javaClass.name + ": 鐩戞祴鏁版嵁鏁扮粍涓簄ull")
- for (d in values!!) {
- if (d.factorName == type.name) {
- return d.factorData
- }
- }
- return null
+ override fun getFactorData(type: FactorType): Double? {
+ if (values == null) throw IllegalStateException(this.javaClass.name + ": 鐩戞祴鏁版嵁鏁扮粍涓簄ull")
+ for (d in values!!) {
+ if (d.factorName == type.name) {
+ return d.factorData
+ }
}
+ return null
+ }
- fun toRowContent(): Array<Any> {
- val row = mutableListOf<Any>()
- row.add(deviceCode ?: "")
- row.add(time ?: "")
- row.add(lng ?: -1.0)
- row.add(lat ?: -1.0)
- values?.forEach {
- if (FactorType.outputFactor(it.factorName)) {
- row.add(it.factorData ?: -1.0)
+ fun toRowContent(): Array<Any> {
+ val row = mutableListOf<Any>()
+ row.add(deviceCode ?: "")
+ row.add(time ?: "")
+ row.add(lng ?: -1.0)
+ row.add(lat ?: -1.0)
+ values?.forEach {
+ if (FactorType.isOutputFactor(it.factorName)) {
+ row.add(it.factorData ?: -1.0)
// row.add(it.physicalQuantity ?: -1.0)
- }
- }
- return row.toTypedArray()
+ }
}
+ return row.toTypedArray()
+ }
- fun toRowTitle(): Array<String> {
- val list = mutableListOf<String>()
- list.add("缂栧彿")
- list.add("閲囨牱鏃堕棿")
- list.add("缁忓害")
- list.add("绾害")
- values?.forEach {
- if (FactorType.outputFactor(it.factorName)) {
- val name = it.factorName ?: ""
- list.add(name)
+ fun toRowTitle(): Array<String> {
+ val list = mutableListOf<String>()
+ list.add("缂栧彿")
+ list.add("閲囨牱鏃堕棿")
+ list.add("缁忓害")
+ list.add("绾害")
+ values?.forEach {
+ if (FactorType.isOutputFactor(it.factorName)) {
+ val name = it.factorName ?: ""
+ list.add(name)
// list.add("$name(鐗╃悊閲�)")
- }
- }
- return list.toTypedArray()
+ }
}
+ return list.toTypedArray()
+ }
+
+ fun <T : BaseRealTimeData> toBaseRealTimeData(clz:Class<T>): T {
+ return clz.newInstance().apply {
+ deviceCode = this@DataVo.deviceCode
+ latitude = this@DataVo.lat?.toBigDecimal()
+ longitude = this@DataVo.lng?.toBigDecimal()
+ dataTime = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(this@DataVo.time)
+ createTime = Date()
+ this@DataVo.values?.forEach {
+ when (it.factorId?.toInt()) {
+ FactorType.NO2.value -> no2 = it.factorData?.toFloat()
+ FactorType.CO.value -> co = it.factorData?.toFloat()
+ FactorType.H2S.value -> h2s = it.factorData?.toFloat()
+ FactorType.SO2.value -> so2 = it.factorData?.toFloat()
+ FactorType.O3.value -> o3 = it.factorData?.toFloat()
+
+ FactorType.PM25.value -> pm25 = it.factorData?.toFloat()
+ FactorType.PM10.value -> pm10 = it.factorData?.toFloat()
+ FactorType.TEMPERATURE.value -> temperature = it.factorData?.toFloat()
+ FactorType.HUMIDITY.value -> humidity = it.factorData?.toFloat()
+ FactorType.VOC.value -> voc = it.factorData?.toFloat()
+
+ FactorType.NOI.value -> noi = it.factorData?.toFloat()
+ FactorType.VELOCITY.value -> velocity = it.factorData?.toFloat()
+ FactorType.WIND_SPEED.value -> windSpeed = it.factorData?.toFloat()
+ FactorType.WIND_DIRECTION.value -> windDirection = it.factorData?.toFloat()
+ FactorType.HEIGHT.value -> height = it.factorData?.toFloat()
+ }
+ }
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3