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/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