From 7269d4a4755fa48c45e827bdc5b5ac56c6eca99c Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 11 十二月 2020 17:27:01 +0800
Subject: [PATCH] 修改监测因子类型

---
 src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataUnitDecoderImpl.kt |   12 ++++++------
 src/main/kotlin/com/flightfeather/uav/repository/impl/AirDataRepositoryImpl.kt   |    5 +++--
 src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt                     |    4 ++--
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/repository/impl/AirDataRepositoryImpl.kt b/src/main/kotlin/com/flightfeather/uav/repository/impl/AirDataRepositoryImpl.kt
index 5c548e2..34532fc 100644
--- a/src/main/kotlin/com/flightfeather/uav/repository/impl/AirDataRepositoryImpl.kt
+++ b/src/main/kotlin/com/flightfeather/uav/repository/impl/AirDataRepositoryImpl.kt
@@ -8,6 +8,7 @@
 import com.flightfeather.uav.socket.eunm.FactorType
 import com.google.gson.Gson
 import org.springframework.stereotype.Repository
+import java.text.SimpleDateFormat
 import java.util.*
 
 /**
@@ -37,8 +38,8 @@
                         data.longitude = it.factorData?.toBigDecimal()
                     }
                     FactorType.TIME.value -> {
-                        it.factorData?.let { f-> Date(f)}?.let {d ->
-                            data.dataTime = d
+                        it.statusList?.takeIf {l-> l.isNotEmpty() }?.get(0)?.let {d ->
+                            data.dataTime = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(d)
                         }
                     }
                 }
diff --git a/src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt b/src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt
index f1528bc..ed21640 100644
--- a/src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt
+++ b/src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt
@@ -10,10 +10,10 @@
     var sensorId: String? = null
 
     //鐩戞祴鍥犲瓙瀹為檯鍊�
-    var factorData: Long? = null
+    var factorData: Double? = null
 
     //鐩戞祴鍥犲瓙鐗╃悊閲忥紙鐢靛帇锛�
-    var physicalQuantity: Long? = null
+    var physicalQuantity: Double? = null
 
     //鐘舵�佷綅
     var statusList: List<String>? = null
diff --git a/src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataUnitDecoderImpl.kt b/src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataUnitDecoderImpl.kt
index b6eba76..1af1944 100644
--- a/src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataUnitDecoderImpl.kt
+++ b/src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataUnitDecoderImpl.kt
@@ -45,7 +45,7 @@
                     val valid = b[i].toInt(16).toChar()//缁忕含搴︽槸鍚︽湁鏁堬紙鏈夋晥: A; 鏃犳晥: V锛�
                     val a1 = b[i + 1].toInt(16)
                     val b1 = b[i + 2].toInt(16)
-                    var b2 = "${b[i + 3]}${b[i + 4]}".toInt(16).toLong()
+                    var b2 = "${b[i + 3]}${b[i + 4]}".toInt(16).toDouble()
                     while (b2 >= 1) {
                         b2 /= 10
                     }
@@ -62,7 +62,7 @@
                 FactorType.LAT -> {
                     val a1 = b[i].toInt(16)
                     val b1 = b[i + 1].toInt(16)
-                    var b2 = "${b[i + 2]}${b[i + 3]}".toInt(16).toLong()
+                    var b2 = "${b[i + 2]}${b[i + 3]}".toInt(16).toDouble()
                     while (b2 >= 1) {
                         b2 /= 10
                     }
@@ -87,7 +87,7 @@
                     resultList.add(AirData().apply {
                         factorId = it.factorType.value.toString()
                         factorName = it.factorType.des
-                        factorData = time
+                        factorData = time.toDouble()
                         statusList = listOf(date)
                     })
                 }
@@ -95,7 +95,7 @@
                     when (it.factorType.byteLength) {
                         AirDataPackage.FACTOR_BIT_LENGTH_2 -> {
                             val a1 = "${b[i]}${b[i + 1]}".toInt(16)
-                            var b1 = b[i + 2].toInt(16).toLong()
+                            var b1 = b[i + 2].toInt(16).toDouble()
                             while (b1 >= 1) {
                                 b1 /= 10
                             }
@@ -110,7 +110,7 @@
                         AirDataPackage.FACTOR_BIT_LENGTH_1 -> {
                             //鏁版嵁瀹為檯鍊硷紙3浣嶅瓧鑺傝〃绀猴級
                             val a1 = "${b[i]}${b[i + 1]}".toInt(16)
-                            var b1 = b[i + 2].toInt(16).toLong()
+                            var b1 = b[i + 2].toInt(16).toDouble()
                             while (b1 >= 1) {
                                 b1 /= 10
                             }
@@ -118,7 +118,7 @@
 
                             //鏁版嵁鐗╃悊閲忥紙3浣嶅瓧鑺傝〃绀猴級
                             val a2 = "${b[i+3]}${b[i + 4]}".toInt(16)
-                            var b2 = b[i + 5].toInt(16).toLong()
+                            var b2 = b[i + 5].toInt(16).toDouble()
                             while (b2 >= 1) {
                                 b2 /= 10
                             }

--
Gitblit v1.9.3