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