From 88ae069fcf657c1790bb04b444e150c06f04e5f6 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 30 十二月 2021 11:50:46 +0800
Subject: [PATCH] 1. 网格化风向权重分析完善

---
 src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt |   40 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt b/src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt
index c6dd971..380b3dd 100644
--- a/src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt
+++ b/src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt
@@ -33,6 +33,8 @@
 
         val dataList = mutableListOf<RealTimeData>()
 
+        val lastData = mutableListOf<Double>()
+
         for (i in 1 until sheet.lastRowNum) {
             val row = sheet.getRow(i)
             val time = row.getCell(2).numericCellValue.toLong() * 1000
@@ -44,11 +46,27 @@
             val datetime = Date(time)
             //鐩戞祴鍥犲瓙
             val jO = JSONObject.parseObject(value)
-            val tmp = jO.getDoubleValue(TMP)
-            val spC = jO.getDoubleValue(SPCOND)
-            val tur = jO.getDoubleValue(TUR)
-            val dO = jO.getDoubleValue(DO)
-            val ph = jO.getDoubleValue(PH)
+            var tmp = jO.getDoubleValue(TMP)
+            var spC = jO.getDoubleValue(SPCOND)
+            var tur = jO.getDoubleValue(TUR)
+            var dO = jO.getDoubleValue(DO)
+            var ph = jO.getDoubleValue(PH)
+
+            if (lastData.isEmpty()) {
+                lastData.addAll(listOf(tmp, spC, tur, dO, ph))
+            } else {
+                if (tmp == .0) tmp = lastData[0]
+                if (spC == .0) spC = lastData[1]
+                if (tur == .0) tur = lastData[2]
+                if (dO == .0) dO = lastData[3]
+                if (ph == .0) ph = lastData[4]
+            }
+
+            lastData[0] = tmp
+            lastData[1] = spC
+            lastData[2] = tur
+            lastData[3] = dO
+            lastData[4] = ph
 
             val factorsList = mutableListOf<AirData>()
 
@@ -83,6 +101,18 @@
                     factorData = ph
                     physicalQuantity = 0.0
                 })
+                add(AirData().apply {
+                    factorId = "12"
+                    factorName = "LNG"
+                    factorData = lng
+                    physicalQuantity = 0.0
+                })
+                add(AirData().apply {
+                    factorId = "13"
+                    factorName = "LAT"
+                    factorData = lat
+                    physicalQuantity = 0.0
+                })
             }
 
             val factors = JSONObject.toJSON(factorsList).toString()

--
Gitblit v1.9.3