From 2e024c986c14943a41f7bfe913cfef0cede64198 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 29 七月 2025 17:37:54 +0800
Subject: [PATCH] 2025.7.29 1. 动态溯源模块添加记录删除等debug功能

---
 src/main/kotlin/com/flightfeather/uav/domain/repository/impl/AirDataRepImpl.kt |   53 +++++++++--------------------------------------------
 1 files changed, 9 insertions(+), 44 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/impl/AirDataRepImpl.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/impl/AirDataRepImpl.kt
index 6f2bdc1..2931e5b 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/repository/impl/AirDataRepImpl.kt
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/impl/AirDataRepImpl.kt
@@ -127,23 +127,21 @@
         return count
     }
 
-    override fun savePrepData2(dataList: List<DataVo>): Int {
-        var count = 0
+    override fun savePrepData2(dataList: List<DataVo>): List<BaseRealTimeData> {
+        val res = mutableListOf<BaseRealTimeData>()
         dataList.forEach {vo ->
             when (UWDeviceType.getType(vo.deviceCode)) {
                 UWDeviceType.VEHICLE -> {
-                    val d = RealTimeDataVehicle()
-                    dataTransform(vo, d)
+                    val d = vo.toBaseRealTimeData(RealTimeDataVehicle::class.java)
                     /***************************************************************************************************/
                     // FIXME: 2021/10/27 杞﹁浇鐩戞祴閮ㄥ垎鍥犲瓙閲忕骇璋冩暣
                     calibration(d, UWDeviceType.VEHICLE)
                     /***************************************************************************************************/
                     realTimeDataVehicleMapper.insert(d)
-                    count++
+                    res.add(d)
                 }
                 UWDeviceType.UAV -> {
-                    val d = RealTimeDataUav()
-                    dataTransform(vo, d)
+                    val d = vo.toBaseRealTimeData(RealTimeDataUav::class.java)
                     /***************************************************************************************************/
                     // FIXME: 2021/10/25 鏃犱汉鏈洪儴鍒嗗洜瀛愰噰鐢ㄨ溅杞芥暟鎹~鍏咃紝鍙栨渶鏂扮殑15鍒嗛挓鐨勬暟鎹�
                     if (tmpVehicleDataList.isEmpty()) {
@@ -164,11 +162,10 @@
                     }
                     /***************************************************************************************************/
                     realTimeDataUavMapper.insert(d)
-                    count++
+                    res.add(d)
                 }
                 UWDeviceType.GRID -> {
-                    val d = RealTimeDataGrid()
-                    dataTransform(vo, d)
+                    val d = vo.toBaseRealTimeData(RealTimeDataGrid::class.java)
                     /**************************************************************************/
                     // FIXME: 2021/11/8 閽堝鍘嗗彶缃戞牸鍖栧師濮嬫暟鎹紝杩涜涓存椂鏍″噯澶勭悊
 //                    val dTime = LocalDateTime.ofInstant(d.dataTime?.toInstant(), ZoneId.systemDefault())
@@ -196,7 +193,7 @@
 //                    d.h2s = d.h2s?.let { sqrt(it) * 2 }
                     /**************************************************************************/
                     realTimeDataGridMapper.insert(d)
-                    count++
+                    res.add(d)
                 }
                 UWDeviceType.BOAT -> {
 
@@ -204,7 +201,7 @@
                 else -> Unit
             }
         }
-        return count
+        return res
     }
 
     private fun dataTransform(vo: RealTimeData, bean: BaseRealTimeData) {
@@ -267,38 +264,6 @@
                     }
                 }
             }
-        }
-    }
-
-    fun dataTransform(vo: DataVo, bean: BaseRealTimeData) {
-        bean.apply {
-            deviceCode = vo.deviceCode
-            latitude = vo.lat?.toBigDecimal()
-            longitude = vo.lng?.toBigDecimal()
-            dataTime = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(vo.time)
-            createTime = Date()
-            vo.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()
-                }
-            }
-
         }
     }
 

--
Gitblit v1.9.3