|
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
import android.net.Uri
|
|
|
|
|
import android.os.Build
|
|
|
|
|
import android.os.FileUtils
|
|
|
|
|
import android.provider.Settings
|
|
|
|
|
import com.common.commonlib.db.DBUtils
|
|
|
|
|
import com.common.commonlib.db.entity.Gas
|
|
|
|
@ -21,6 +22,7 @@ import kotlinx.coroutines.GlobalScope
|
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
import java.io.BufferedReader
|
|
|
|
|
import java.io.DataOutputStream
|
|
|
|
|
import java.io.File
|
|
|
|
|
import java.io.IOException
|
|
|
|
|
import java.io.InputStreamReader
|
|
|
|
|
|
|
|
|
@ -105,7 +107,12 @@ object TestUtils {
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun testExportExcel(context: Context, datas: MutableList<Gas>, commonDialog: CommonDialog?) {
|
|
|
|
|
suspend fun testExportExcel(
|
|
|
|
|
context: Context,
|
|
|
|
|
usbPath: String,
|
|
|
|
|
datas: MutableList<Gas>,
|
|
|
|
|
commonDialog: CommonDialog?
|
|
|
|
|
) {
|
|
|
|
|
val allData = mutableListOf<List<SimpleCellValue>>()
|
|
|
|
|
datas.forEach {
|
|
|
|
|
val row = mutableListOf<SimpleCellValue>()
|
|
|
|
@ -115,17 +122,17 @@ object TestUtils {
|
|
|
|
|
row.add(SimpleCellValue(it.unit))
|
|
|
|
|
allData.add(row)
|
|
|
|
|
}
|
|
|
|
|
val excelPath = ExcelUtils.writeStringListToExcel(allData, context)
|
|
|
|
|
// val dataPath = LztekUtil.getLztek()?.usbStoragePath + "/"
|
|
|
|
|
// // 直接copy到机身
|
|
|
|
|
// val command = arrayOf("remount","cp -r $excelPath $dataPath")
|
|
|
|
|
// execCommand(command, true, true)
|
|
|
|
|
val excelPath = ExcelUtils.writeStringListToExcel(allData, usbPath, context)
|
|
|
|
|
commonDialog?.dismiss()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun testExportWarnExcel(context: Context, datas: MutableList<Warning>, loadingDialog: CommonDialog?) {
|
|
|
|
|
suspend fun testExportWarnExcel(
|
|
|
|
|
context: Context,
|
|
|
|
|
usbPath: String,
|
|
|
|
|
datas: MutableList<Warning>,
|
|
|
|
|
loadingDialog: CommonDialog?
|
|
|
|
|
) {
|
|
|
|
|
val allData = mutableListOf<List<SimpleCellValue>>()
|
|
|
|
|
datas.forEach {
|
|
|
|
|
val row = mutableListOf<SimpleCellValue>()
|
|
|
|
@ -135,11 +142,7 @@ object TestUtils {
|
|
|
|
|
row.add(SimpleCellValue(it.unit))
|
|
|
|
|
allData.add(row)
|
|
|
|
|
}
|
|
|
|
|
val excelPath = ExcelUtils.writeStringListToExcel(allData, context, true)
|
|
|
|
|
// val dataPath = LztekUtil.getLztek()?.usbStoragePath + "/"
|
|
|
|
|
// // 直接copy到机身
|
|
|
|
|
// val command = arrayOf("remount","cp -r $excelPath $dataPath")
|
|
|
|
|
// execCommand(command, true, true)
|
|
|
|
|
val excelPath = ExcelUtils.writeStringListToExcel(allData, usbPath, context, true)
|
|
|
|
|
loadingDialog?.dismiss()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -202,4 +205,24 @@ object TestUtils {
|
|
|
|
|
process?.destroy()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suspend fun testCopyVideo(
|
|
|
|
|
context: Context,
|
|
|
|
|
usbPath: String,
|
|
|
|
|
datas: MutableList<Video>,
|
|
|
|
|
loadingDialog: CommonDialog?
|
|
|
|
|
) {
|
|
|
|
|
val usbVideoPath = usbPath + File.separator + "Video"
|
|
|
|
|
val dFile = File(usbVideoPath);
|
|
|
|
|
if (!dFile.exists() || !dFile.isDirectory) {
|
|
|
|
|
dFile.mkdir()
|
|
|
|
|
}
|
|
|
|
|
datas.forEach {
|
|
|
|
|
FileUtils.copy(
|
|
|
|
|
File(it.path).inputStream(),
|
|
|
|
|
File(usbVideoPath + "/${it.name}").outputStream()
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
loadingDialog?.dismiss()
|
|
|
|
|
}
|
|
|
|
|
}
|