1.增加搜索相关功能业务2.解决下载omdb后不及时渲染问题3.增加按任务及link关联渲染业务4.接口中增加按任务查询条件
This commit is contained in:
@@ -14,6 +14,7 @@ import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.db.deep.ListList
|
||||
import com.navinfo.omqs.hilt.OMDBDataBaseHiltFactory
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedInject
|
||||
@@ -102,13 +103,10 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
FIELD_TYPE_NULL -> rowMap[columnName] = ""
|
||||
FIELD_TYPE_INTEGER -> rowMap[columnName] =
|
||||
getInt(columnIndex)
|
||||
|
||||
FIELD_TYPE_FLOAT -> rowMap[columnName] =
|
||||
getFloat(columnIndex)
|
||||
|
||||
FIELD_TYPE_BLOB -> rowMap[columnName] =
|
||||
String(getBlob(columnIndex), Charsets.UTF_8)
|
||||
|
||||
else -> rowMap[columnName] = getString(columnIndex)
|
||||
}
|
||||
}
|
||||
@@ -127,132 +125,155 @@ class ImportOMDBHelper @AssistedInject constructor(
|
||||
* @param omdbZipFile omdb数据抽取生成的Zip文件
|
||||
* @param configFile 对应的配置文件
|
||||
* */
|
||||
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
||||
flow {
|
||||
if (unZipFolder.exists()) {
|
||||
unZipFolder.deleteRecursively()
|
||||
}
|
||||
unZipFolder.mkdirs()
|
||||
// 开始解压zip文件
|
||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||
// 将listResult数据插入到Realm数据库中
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.beginTransaction()
|
||||
try {
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
val currentConfig = currentEntry.value
|
||||
val txtFile = unZipFiles.find {
|
||||
it.name == currentConfig.table
|
||||
}
|
||||
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> = withContext(Dispatchers.IO) {
|
||||
val unZipFolder = File(omdbZipFile.parentFile, "result")
|
||||
flow {
|
||||
if (unZipFolder.exists()) {
|
||||
unZipFolder.deleteRecursively()
|
||||
}
|
||||
unZipFolder.mkdirs()
|
||||
// 开始解压zip文件
|
||||
val unZipFiles = ZipUtils.unzipFile(omdbZipFile, unZipFolder)
|
||||
// 将listResult数据插入到Realm数据库中
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.beginTransaction()
|
||||
try {
|
||||
// 遍历解压后的文件,读取该数据返回
|
||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||
val currentConfig = currentEntry.value
|
||||
val txtFile = unZipFiles.find {
|
||||
it.name == currentConfig.table
|
||||
}
|
||||
|
||||
val listResult = mutableListOf<RenderEntity>()
|
||||
currentConfig?.let {
|
||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for ((index, line) in list.withIndex()) {
|
||||
if (line == null || line.trim() == "") {
|
||||
continue
|
||||
val listResult = mutableListOf<RenderEntity>()
|
||||
currentConfig?.let {
|
||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
||||
if (list != null) {
|
||||
// 将list数据转换为map
|
||||
for ((index, line) in list.withIndex()) {
|
||||
if (line == null || line.trim() == "") {
|
||||
continue
|
||||
}
|
||||
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
|
||||
map["qi_zoomMin"] = currentConfig.zoomMin
|
||||
map["qi_zoomMax"] = currentConfig.zoomMax
|
||||
|
||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||
// val meshEntity = Realm.getDefaultInstance().where(RenderEntity::class.java).equalTo("properties['mesh']", map["mesh"].toString()).findFirst()
|
||||
val renderEntity = RenderEntity()
|
||||
renderEntity.code = map["qi_code"].toString().toInt()
|
||||
renderEntity.name = map["qi_name"].toString()
|
||||
renderEntity.table = map["qi_table"].toString()
|
||||
renderEntity.taskId = task.id
|
||||
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
||||
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
|
||||
|
||||
// 其他数据插入到Properties中
|
||||
renderEntity.geometry = map["geometry"].toString()
|
||||
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()
|
||||
)
|
||||
else -> renderEntity.properties.put(key, value.toString())
|
||||
}
|
||||
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
|
||||
map["qi_zoomMin"] = currentConfig.zoomMin
|
||||
map["qi_zoomMax"] = currentConfig.zoomMax
|
||||
|
||||
// 先查询这个mesh下有没有数据,如果有则跳过即可
|
||||
// val meshEntity = Realm.getDefaultInstance().where(RenderEntity::class.java).equalTo("properties['mesh']", map["mesh"].toString()).findFirst()
|
||||
val renderEntity = RenderEntity()
|
||||
renderEntity.code = map["qi_code"].toString().toInt()
|
||||
renderEntity.name = map["qi_name"].toString()
|
||||
renderEntity.table = map["qi_table"].toString()
|
||||
renderEntity.taskId = task.id
|
||||
renderEntity.zoomMin = map["qi_zoomMin"].toString().toInt()
|
||||
renderEntity.zoomMax = map["qi_zoomMax"].toString().toInt()
|
||||
|
||||
// 其他数据插入到Properties中
|
||||
renderEntity.geometry = map["geometry"].toString()
|
||||
|
||||
for ((key, value) in map) {
|
||||
when (value) {
|
||||
|
||||
is String -> renderEntity.properties[key] = value
|
||||
|
||||
is Int -> renderEntity.properties[key] = value.toInt().toString()
|
||||
|
||||
is Double -> renderEntity.properties[key] = value.toDouble().toString()
|
||||
|
||||
else -> renderEntity.properties[key] = value.toString()
|
||||
}
|
||||
}
|
||||
|
||||
//如果要素不包括linkPid,需要从其他字段获得
|
||||
if(!renderEntity.properties.containsKey("linkPid")){
|
||||
//交限从进入线获取
|
||||
if(renderEntity.properties.containsKey("linkIn")){
|
||||
renderEntity.properties["linkPid"]= renderEntity.properties["linkIn"]
|
||||
}
|
||||
}
|
||||
|
||||
//遍历判断只显示与任务Link相关的任务数据
|
||||
if (currentConfig.checkLinkId && renderEntity.properties.containsKey("linkPid")) {
|
||||
|
||||
var currentLinkPid = renderEntity.properties["linkPid"]
|
||||
|
||||
task.hadLinkDvoList.forEach {
|
||||
if (it.linkPid == currentLinkPid) {
|
||||
}
|
||||
//遍历判断只显示与任务Link相关的任务数据
|
||||
if(currentConfig.checkLinkId){
|
||||
if(renderEntity.properties.containsKey("linkPid")&&renderEntity.properties["linkPid"]!=null){
|
||||
task.hadLinkDvoList.forEach{
|
||||
if(it.linkPid==renderEntity.properties["linkPid"]){
|
||||
renderEntity.enable = 1
|
||||
Log.e("qj", "${renderEntity.name}==包括任务link")
|
||||
Log.e("qj","${renderEntity.name}==包括任务link")
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}else if(renderEntity.table == "OMDB_RESTRICTION" && renderEntity.properties.containsKey("linkIn")){
|
||||
if (renderEntity.properties["linkIn"] != null) {
|
||||
|
||||
var currentLinkPid = renderEntity.properties["linkIn"]
|
||||
|
||||
task.hadLinkDvoList.forEach{
|
||||
if(it.linkPid==renderEntity.properties["linkPid"]){
|
||||
renderEntity.enable = 1
|
||||
Log.e("qj","${renderEntity.name}==包括任务link")
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(renderEntity.table == "OMDB_INTERSECTION" &&renderEntity.properties.containsKey("type")&& renderEntity.properties.containsKey("linkList")){
|
||||
if (renderEntity.properties["type"]!=null&&renderEntity.properties["linkList"] != null) {
|
||||
|
||||
val type = renderEntity.properties["type"]
|
||||
|
||||
if(type=="1"){
|
||||
|
||||
if (renderEntity.properties["linkList"] != null) {
|
||||
|
||||
val list: List<ListList> = gson.fromJson(renderEntity.properties["linkList"], object : TypeToken<List<ListList>>() {}.type)
|
||||
|
||||
if (list != null) {
|
||||
m@for (link in list){
|
||||
for(hadLink in task.hadLinkDvoList){
|
||||
if (link.featureType == 1 && hadLink.linkPid == link.linkPid) {
|
||||
renderEntity.enable = 1
|
||||
Log.e("qj", "${renderEntity.name}==包括任务link")
|
||||
break@m
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
renderEntity.enable = 2
|
||||
Log.e("qj", "${renderEntity.name}==不包括任务linkPid")
|
||||
Log.e("qj","${renderEntity.name}==不包括任务linkPid")
|
||||
}
|
||||
|
||||
listResult.add(renderEntity)
|
||||
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||
|
||||
if (resultEntity != null) {
|
||||
realm.insert(renderEntity)
|
||||
}
|
||||
|
||||
}else{
|
||||
renderEntity.enable = 2
|
||||
Log.e("qj","${renderEntity.name}==不包括任务linkPid")
|
||||
}
|
||||
listResult.add(renderEntity)
|
||||
// 对renderEntity做预处理后再保存
|
||||
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||
if (resultEntity != null) {
|
||||
realm.insert(renderEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 1个文件发送一次flow流
|
||||
emit("${index + 1}/${importConfig.tableMap.size}")
|
||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||
importConfig.preProcess.cacheRdLink =
|
||||
listResult.associateBy { it.properties["linkPid"] }
|
||||
}
|
||||
}
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
} catch (e: Exception) {
|
||||
realm.cancelTransaction()
|
||||
throw e
|
||||
// 1个文件发送一次flow流
|
||||
emit("${index + 1}/${importConfig.tableMap.size}")
|
||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||
importConfig.preProcess.cacheRdLink =
|
||||
listResult.associateBy { it.properties["linkPid"] }
|
||||
}
|
||||
}
|
||||
emit("finish")
|
||||
realm.commitTransaction()
|
||||
realm.close()
|
||||
} catch (e: Exception) {
|
||||
realm.cancelTransaction()
|
||||
throw e
|
||||
}
|
||||
emit("finish")
|
||||
}
|
||||
}
|
||||
|
||||
// 获取指定数据表的列名
|
||||
fun getColumns(db: SQLiteDatabase, tableName: String): List<String> {
|
||||
|
||||
@@ -433,6 +433,8 @@ class ImportPreProcess {
|
||||
referenceEntity.renderEntityId = renderEntity.id
|
||||
referenceEntity.name = "${renderEntity.name}参考方向"
|
||||
referenceEntity.table = renderEntity.table
|
||||
referenceEntity.enable = renderEntity.enable
|
||||
referenceEntity.taskId = renderEntity.taskId
|
||||
// 与原数据使用相同的geometry
|
||||
referenceEntity.geometry = renderEntity.geometry.toString()
|
||||
referenceEntity.properties["qi_table"] = renderEntity.table
|
||||
|
||||
@@ -4,11 +4,14 @@ import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.collect.library.utils.RealmDBParamUtils
|
||||
import com.navinfo.omqs.bean.QRCodeBean
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -60,7 +63,7 @@ class RealmOperateHelper() {
|
||||
val realmList = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd")
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd").and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||
val dataList = realm.copyFromRealm(realmList)
|
||||
@@ -85,9 +88,7 @@ class RealmOperateHelper() {
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
suspend fun captureTaskLink(
|
||||
taskId: Int,
|
||||
point: GeoPoint,
|
||||
buffer: Double = DEFAULT_BUFFER,
|
||||
bufferType: BUFFER_TYPE = DEFAULT_BUFFER_TYPE,
|
||||
@@ -101,7 +102,7 @@ class RealmOperateHelper() {
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val realmList = realm.where(HadLinkDvoBean::class.java)
|
||||
.equalTo("taskId", taskId)
|
||||
.equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
var linkBean: HadLinkDvoBean? = null
|
||||
var nearLast: Double = 99999.99
|
||||
@@ -125,7 +126,7 @@ class RealmOperateHelper() {
|
||||
val realmR = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findFirst()
|
||||
if (realmR != null) {
|
||||
link = realm.copyFromRealm(realmR)
|
||||
@@ -133,13 +134,31 @@ class RealmOperateHelper() {
|
||||
return link
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据markid查询获取对应数据
|
||||
* @param markId
|
||||
* */
|
||||
suspend fun queryQcRecordBean(markId: String): QsRecordBean? {
|
||||
var qsRecordBean: QsRecordBean? = null
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val realmR = realm.where(QsRecordBean::class.java)
|
||||
.equalTo("table", "QsRecordBean")
|
||||
.and()
|
||||
.equalTo("id", markId).and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findFirst()
|
||||
if (realmR != null) {
|
||||
qsRecordBean = realm.copyFromRealm(realmR)
|
||||
}
|
||||
return qsRecordBean
|
||||
}
|
||||
|
||||
suspend fun queryLinkToMutableRenderEntityList(linkPid: String): MutableList<RenderEntity>? {
|
||||
val resultList = mutableListOf<RenderEntity>()
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
|
||||
val realmR = realm.where(RenderEntity::class.java)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
|
||||
val dataList = realm.copyFromRealm(realmR)
|
||||
@@ -184,7 +203,7 @@ class RealmOperateHelper() {
|
||||
val realmList = realm.where(RenderEntity::class.java)
|
||||
.notEqualTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd")
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd").and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
// 将获取到的数据和查询的polygon做相交,只返回相交的数据
|
||||
val queryResult = realmList?.stream()?.filter {
|
||||
@@ -214,7 +233,7 @@ class RealmOperateHelper() {
|
||||
val realmList = realm.where(RenderEntity::class.java)
|
||||
.notEqualTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid).and().equalTo("taskId",RealmDBParamUtils.getTaskId())
|
||||
.findAll()
|
||||
result.addAll(realm.copyFromRealm(realmList))
|
||||
return result
|
||||
|
||||
6
app/src/main/java/com/navinfo/omqs/db/deep/LinkList.kt
Normal file
6
app/src/main/java/com/navinfo/omqs/db/deep/LinkList.kt
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.navinfo.omqs.db.deep
|
||||
|
||||
data class ListList(
|
||||
var featureType: Int = -1,
|
||||
var linkPid: String = ""
|
||||
)
|
||||
Reference in New Issue
Block a user