修改任务下载刷新不及时
This commit is contained in:
parent
5806fbf5ac
commit
33cc1dc243
@ -5,23 +5,19 @@ import android.database.Cursor.*
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.database.getBlobOrNull
|
||||
import androidx.core.database.getFloatOrNull
|
||||
import androidx.core.database.getIntOrNull
|
||||
import androidx.core.database.getStringOrNull
|
||||
import com.blankj.utilcode.util.FileIOUtils
|
||||
import com.blankj.utilcode.util.ZipUtils
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.data.entity.ReferenceEntity
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.bean.Transform
|
||||
import com.navinfo.omqs.hilt.ImportOMDBHiltFactory
|
||||
import com.navinfo.omqs.hilt.OMDBDataBaseHiltFactory
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedInject
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmQuery
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
@ -137,8 +133,9 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
// 开始解压zip文件
|
||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||
// 将listResult数据插入到Realm数据库中
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.beginTransaction()
|
||||
try {
|
||||
Realm.getDefaultInstance().beginTransaction()
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
val currentConfig = currentEntry.value
|
||||
@ -153,12 +150,16 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for ((index, line) in list.withIndex()) {
|
||||
Log.d("ImportOMDBHelper", "解析第:${index+1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(line, object:TypeToken<Map<String, Any>>(){}.getType())
|
||||
Log.d("ImportOMDBHelper", "解析第:${index + 1}行")
|
||||
val map = gson.fromJson<Map<String, Any>>(
|
||||
line,
|
||||
object : TypeToken<Map<String, Any>>() {}.getType()
|
||||
)
|
||||
.toMutableMap()
|
||||
map["qi_table"] = currentConfig.table
|
||||
map["qi_name"] = currentConfig.name
|
||||
map["qi_code"] = if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
map["qi_code"] =
|
||||
if (currentConfig.code == 0) currentConfig.code else currentEntry.key
|
||||
|
||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||
// val meshEntity = Realm.getDefaultInstance().where(RenderEntity::class.java).equalTo("properties['mesh']", map["mesh"].toString()).findFirst()
|
||||
@ -171,16 +172,22 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
is String -> renderEntity.properties.put(key, value)
|
||||
is Int -> renderEntity.properties.put(key, value.toInt().toString())
|
||||
is Double -> renderEntity.properties.put(key, value.toDouble().toString())
|
||||
is Int -> renderEntity.properties.put(
|
||||
key,
|
||||
value.toInt().toString()
|
||||
)
|
||||
is Double -> renderEntity.properties.put(
|
||||
key,
|
||||
value.toDouble().toString()
|
||||
)
|
||||
else -> renderEntity.properties.put(key, value.toString())
|
||||
}
|
||||
}
|
||||
listResult.add(renderEntity)
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||
if (resultEntity!=null) {
|
||||
Realm.getDefaultInstance().insert(renderEntity)
|
||||
if (resultEntity != null) {
|
||||
realm.insert(renderEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -189,12 +196,14 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
emit("${index + 1}/${importConfig.tableMap.size}")
|
||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||
importConfig.preProcess.cacheRdLink = listResult.associateBy { it.properties["linkPid"] }
|
||||
importConfig.preProcess.cacheRdLink =
|
||||
listResult.associateBy { it.properties["linkPid"] }
|
||||
}
|
||||
}
|
||||
Realm.getDefaultInstance().commitTransaction()
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
} catch (e: Exception) {
|
||||
Realm.getDefaultInstance().cancelTransaction()
|
||||
realm.cancelTransaction()
|
||||
throw e
|
||||
}
|
||||
emit("finish")
|
||||
|
@ -133,10 +133,13 @@ class TaskDownloadScope(
|
||||
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile).collect {
|
||||
Log.e("jingo", "数据安装 $it")
|
||||
if (it == "finish") {
|
||||
change(FileDownloadStatus.DONE)
|
||||
withContext(Dispatchers.Main) {
|
||||
downloadManager.mapController.layerManagerHandler.omdbLayersUpdate()
|
||||
downloadManager.mapController.mMapView.updateMap(true)
|
||||
Log.e("jingo", "数据安装结束,刷新地图")
|
||||
}
|
||||
change(FileDownloadStatus.DONE)
|
||||
|
||||
} else {
|
||||
change(FileDownloadStatus.IMPORTING, it)
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ class MainViewModel @Inject constructor(
|
||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
|
||||
//遍历存储tile对应的x与y的值
|
||||
tileX.forEach { x ->
|
||||
tileX.forEach { x ->
|
||||
tileY.forEach { y ->
|
||||
location.tilex = x
|
||||
location.tiley = y
|
||||
|
@ -217,6 +217,13 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
|
||||
vectorNiLocationTileLayer.isEnabled = false
|
||||
labelNiLocationLayer.isEnabled = false
|
||||
}
|
||||
|
||||
fun omdbLayersUpdate(){
|
||||
// omdbVectorTileLayer
|
||||
// omdbReferenceTileLayer.
|
||||
omdbLabelLayer.update()
|
||||
omdbReferenceLabelLayer.update()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
2
vtm
2
vtm
@ -1 +1 @@
|
||||
Subproject commit 1ee201a41f78f169873848209a3f3bdac36f185a
|
||||
Subproject commit c74bcd29c24cddf395fa9654ef0b69d0c88ac3ad
|
Loading…
x
Reference in New Issue
Block a user