|
|
|
@ -9,7 +9,9 @@ import com.common.commonlib.db.entity.Warning
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.LztekUtil
|
|
|
|
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
|
import kotlinx.coroutines.async
|
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
import java.io.File
|
|
|
|
|
|
|
|
|
|
@OptIn(DelicateCoroutinesApi::class)
|
|
|
|
|
class App : CommonApplication() {
|
|
|
|
@ -28,6 +30,8 @@ class App : CommonApplication() {
|
|
|
|
|
|
|
|
|
|
private fun tryFixDbData() {
|
|
|
|
|
GlobalScope.launch {
|
|
|
|
|
// 修复告警数据
|
|
|
|
|
async {
|
|
|
|
|
val warningDao = DBUtils.warningDao()
|
|
|
|
|
val warningList = warningDao.queryWarningsNoEndTime()
|
|
|
|
|
warningList?.apply {
|
|
|
|
@ -36,11 +40,25 @@ class App : CommonApplication() {
|
|
|
|
|
}
|
|
|
|
|
warningDao.updateAll(warningList)
|
|
|
|
|
}
|
|
|
|
|
}.await()
|
|
|
|
|
|
|
|
|
|
// 修复视频数据
|
|
|
|
|
async {
|
|
|
|
|
val videoDao = DBUtils.videoDao()
|
|
|
|
|
val videoList = videoDao.getAll()
|
|
|
|
|
videoList.apply {
|
|
|
|
|
forEach { video ->
|
|
|
|
|
if (!File(video.path).exists()) {
|
|
|
|
|
videoDao.delete(video)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}.await()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private suspend fun tryAssignment(warningDao: WarningDao, warning: Warning): Long {
|
|
|
|
|
val latest = warningDao.findLatestByName(warning.gasName)
|
|
|
|
|
return latest?.endTime ?: System.currentTimeMillis()
|
|
|
|
|
return if (latest?.endTime!! > 0L) latest?.endTime else System.currentTimeMillis()
|
|
|
|
|
}
|
|
|
|
|
}
|