From 3bb4fb15c664d29d179083698fdad35a661b1d7f Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 28 八月 2025 14:57:40 +0800
Subject: [PATCH] 2025.8.28 1. 添加走航季度报告相关统计功能(待完成)

---
 src/main/kotlin/com/flightfeather/uav/common/utils/FileUtil.kt |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/common/utils/FileUtil.kt b/src/main/kotlin/com/flightfeather/uav/common/utils/FileUtil.kt
index f290f76..a474c2e 100644
--- a/src/main/kotlin/com/flightfeather/uav/common/utils/FileUtil.kt
+++ b/src/main/kotlin/com/flightfeather/uav/common/utils/FileUtil.kt
@@ -13,7 +13,7 @@
 class FileUtil {
 
     private var file: File
-    private var basePath:String = "${File.separator}ObdData${File.separator}"
+    private var basePath:String = "${File.separator}UAVData${File.separator}"
     private var closeThread: Thread? = null
     private var fw: FileWriter? = null
     private var bw: BufferedWriter? = null
@@ -36,7 +36,7 @@
         }
     }
 
-    fun saveObdData(str: String) {
+    fun saveObdData(str: String, newFile: Boolean = false) {
         //妫�鏌ユ枃妗f槸鍚﹀瓨鍦�
         if (!file.exists()) {
             file.parentFile.mkdirs()
@@ -45,7 +45,7 @@
             println("----鍒涘缓鏂囦欢锛�${file.absolutePath}")
         }
         //鏂囦欢鏈�澶�512Kb,瓒呰繃鍚庢柊寤烘枃妗�
-        if (file.length() + str.toByteArray().size > 512 * 1024 || TimeUtil.isNextDay(oldTime, Date())) {
+        if (newFile || file.length() + str.toByteArray().size > 512 * 1024 || TimeUtil.isNextDay(oldTime, Date())) {
             //瓒呰繃涓�澶╁悗锛屾洿鏂板綋鍓嶆椂闂�
             oldTime = Date()
 
@@ -59,18 +59,18 @@
                 flush()
                 close()
             }
-            fw?.run {
-                flush()
-                close()
-            }
+//            fw?.run {
+//                flush()
+//                close()
+//            }
             //鏂板缓杈撳嚭娴�
             fw = FileWriter(file, true)
-            bw = BufferedWriter(fw)
+            bw = fw?.let { BufferedWriter(it) }
         }
         //绗竴娆″啓鏂囨。鏃跺垵濮嬪寲杈撳嚭娴�
         if (bw == null || fw == null) {
             fw = FileWriter(file, true)
-            bw = BufferedWriter(fw)
+            bw = fw?.let { BufferedWriter(it) }
         }
 
         bw?.run {
@@ -79,7 +79,7 @@
             flush()
         }
 
-        readyToShutDownStream(bw, fw)
+//        readyToShutDownStream(bw, fw)
         println("----鍐欏叆瀹屾垚")
 
     }

--
Gitblit v1.9.3