增加任务缓存处理,保留已上传最近3个月数据及未上传任务
This commit is contained in:
parent
f415ded353
commit
39a3835de4
@ -9,6 +9,7 @@ import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.db.ImportOMDBHelper
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileDownloadStatus
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.*
|
||||
import java.io.File
|
||||
@ -94,6 +95,8 @@ class TaskDownloadScope(
|
||||
if (taskBean.status != status || status == FileDownloadStatus.LOADING || status == FileDownloadStatus.IMPORTING) {
|
||||
taskBean.status = status
|
||||
taskBean.message = message
|
||||
//赋值时间,用于查询过滤
|
||||
taskBean.operationTime = DateTimeUtil.getNowDate().time
|
||||
downloadData.postValue(taskBean)
|
||||
if (status != FileDownloadStatus.LOADING && status != FileDownloadStatus.IMPORTING) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
|
@ -13,6 +13,7 @@ import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.bean.SysUserBean
|
||||
import com.navinfo.omqs.http.DefaultResponse
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileUploadStatus
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.*
|
||||
import java.util.*
|
||||
@ -72,6 +73,8 @@ class TaskUploadScope(
|
||||
if (taskBean.syncStatus != status) {
|
||||
taskBean.syncStatus = status
|
||||
taskBean.errMsg = message
|
||||
//赋值时间,用于查询过滤
|
||||
taskBean.operationTime = DateTimeUtil.getNowDate().time
|
||||
uploadData.postValue(taskBean)
|
||||
//同步中不进行状态记录,只做界面变更显示
|
||||
if(status!=FileUploadStatus.UPLOADING){
|
||||
|
@ -16,6 +16,7 @@ import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.http.NetResult
|
||||
import com.navinfo.omqs.http.NetworkService
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.*
|
||||
@ -74,21 +75,15 @@ class TaskViewModel @Inject constructor(
|
||||
task.fileSize = item.fileSize
|
||||
task.status = item.status
|
||||
task.currentSize = item.currentSize
|
||||
// task.color = item.color
|
||||
//已上传后不在更新操作时间
|
||||
if(task.syncStatus!= FileManager.Companion.FileUploadStatus.DONE){
|
||||
//赋值时间,用于查询过滤
|
||||
task.operationTime = DateTimeUtil.getNowDate().time
|
||||
}
|
||||
}else{
|
||||
//赋值时间,用于查询过滤
|
||||
task.operationTime = DateTimeUtil.getNowDate().time
|
||||
}
|
||||
// else {
|
||||
// if (index < 6)
|
||||
// task.color = colors[index]
|
||||
// else {
|
||||
// val random = Random()
|
||||
// task.color = Color.argb(
|
||||
// 255,
|
||||
// random.nextInt(256),
|
||||
// random.nextInt(256),
|
||||
// random.nextInt(256)
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
realm.copyToRealmOrUpdate(task)
|
||||
}
|
||||
}
|
||||
@ -114,29 +109,16 @@ class TaskViewModel @Inject constructor(
|
||||
is NetResult.Loading -> {}
|
||||
}
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects = realm.where(TaskBean::class.java).findAll()
|
||||
//过滤掉已上传的超过90天的数据
|
||||
var nowTime:Long = DateTimeUtil.getNowDate().time
|
||||
var beginNowTime:Long = nowTime - 90*3600*24*1000L
|
||||
var syncUpload:Int = FileManager.Companion.FileUploadStatus.DONE
|
||||
val objects = realm.where(TaskBean::class.java).notEqualTo("syncStatus",syncUpload).or().between("operationTime",beginNowTime,nowTime).equalTo("syncStatus",syncUpload).findAll()
|
||||
taskList = realm.copyFromRealm(objects)
|
||||
for (item in taskList) {
|
||||
FileManager.checkOMDBFileInfo(item)
|
||||
}
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.setLineColor(
|
||||
// Color.rgb(0, 255, 0).toColor()
|
||||
// )
|
||||
// taskList.forEach {
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.addLineList(it.hadLinkDvoList)
|
||||
// }
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.update()
|
||||
liveDataTaskList.postValue(taskList)
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// mapController.lineHandler.omdbTaskLinkLayer.removeAll()
|
||||
// if(taskList.isNotEmpty()){
|
||||
// mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
|
||||
// }
|
||||
// for (item in taskList) {
|
||||
// mapController.lineHandler.omdbTaskLinkLayer.setLineColor(Color.valueOf(item.color))
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,11 @@ open class TaskBean @JvmOverloads constructor(
|
||||
*/
|
||||
var status: Int = 0,
|
||||
|
||||
/**
|
||||
* 操作时间
|
||||
*/
|
||||
var operationTime: Long = 0L,
|
||||
|
||||
/**
|
||||
* 上传状态
|
||||
*/
|
||||
|
2
vtm
2
vtm
@ -1 +1 @@
|
||||
Subproject commit 1ee201a41f78f169873848209a3f3bdac36f185a
|
||||
Subproject commit dd13e533c38b5738ab404c2737d7ccadeff01323
|
Loading…
x
Reference in New Issue
Block a user