fix: 修改普通交限入库规则,首尾相接数据不入库
This commit is contained in:
parent
a5e964efbb
commit
e9af1785f8
@ -171,6 +171,12 @@
|
|||||||
"code": 4006,
|
"code": 4006,
|
||||||
"name": "普通交限",
|
"name": "普通交限",
|
||||||
"transformer": [
|
"transformer": [
|
||||||
|
{
|
||||||
|
"k": "geometry",
|
||||||
|
"v": "~",
|
||||||
|
"klib": "geometry",
|
||||||
|
"vlib": "checkCircleRoad()"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"k": "geometry",
|
"k": "geometry",
|
||||||
"v": "~",
|
"v": "~",
|
||||||
|
@ -13,7 +13,7 @@ class ImportConfig {
|
|||||||
var checked : Boolean = true
|
var checked : Boolean = true
|
||||||
val preProcess: ImportPreProcess = ImportPreProcess()
|
val preProcess: ImportPreProcess = ImportPreProcess()
|
||||||
|
|
||||||
fun transformProperties(renderEntity: RenderEntity): RenderEntity {
|
fun transformProperties(renderEntity: RenderEntity): RenderEntity? {
|
||||||
val transformList = tableMap[renderEntity.code.toString()]?.transformer
|
val transformList = tableMap[renderEntity.code.toString()]?.transformer
|
||||||
if (transformList.isNullOrEmpty()) {
|
if (transformList.isNullOrEmpty()) {
|
||||||
return renderEntity
|
return renderEntity
|
||||||
@ -31,6 +31,7 @@ class ImportConfig {
|
|||||||
// 如果key和value都为空,说明当前数据需要增加一个新字段
|
// 如果key和value都为空,说明当前数据需要增加一个新字段
|
||||||
if (key.isNullOrEmpty()&&value.isNullOrEmpty()&&!renderEntity.properties.containsKey(keylib)) {
|
if (key.isNullOrEmpty()&&value.isNullOrEmpty()&&!renderEntity.properties.containsKey(keylib)) {
|
||||||
renderEntity.properties[keylib] = valuelib
|
renderEntity.properties[keylib] = valuelib
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
// 开始解析key和value,并对数据进行匹配
|
// 开始解析key和value,并对数据进行匹配
|
||||||
m@ for (k in processKeyOrValue(key)) {
|
m@ for (k in processKeyOrValue(key)) {
|
||||||
@ -54,7 +55,12 @@ class ImportConfig {
|
|||||||
callByParams[methodParams[index+1]] = value
|
callByParams[methodParams[index+1]] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
method.callBy(callByParams)
|
when(val result = method.callBy(callByParams)) { // 如果方法返回的数据类型是boolean,且返回为false,则该数据不处理
|
||||||
|
is Boolean ->
|
||||||
|
if (!result) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
renderEntity.properties[keylib] = valuelib
|
renderEntity.properties[keylib] = valuelib
|
||||||
}
|
}
|
||||||
@ -77,7 +83,12 @@ class ImportConfig {
|
|||||||
callByParams[methodParams[index+1]] = value
|
callByParams[methodParams[index+1]] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
method.callBy(callByParams)
|
when(val result = method.callBy(callByParams)) {
|
||||||
|
is Boolean ->
|
||||||
|
if (!result) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
renderEntity.properties[keylib] = valuelib
|
renderEntity.properties[keylib] = valuelib
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
it.name == currentConfig.table
|
it.name == currentConfig.table
|
||||||
}
|
}
|
||||||
|
|
||||||
val listResult = mutableListOf<Map<String, Any>>()
|
val listResult = mutableListOf<RenderEntity>()
|
||||||
currentConfig?.let {
|
currentConfig?.let {
|
||||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||||
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
|
||||||
@ -159,33 +159,38 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
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
|
||||||
listResult.add(map)
|
|
||||||
|
// 先查询这个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()
|
||||||
|
// 其他数据插入到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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
listResult.add(renderEntity)
|
||||||
|
// 对renderEntity做预处理后再保存
|
||||||
|
val resultEntity = importConfig.transformProperties(renderEntity)
|
||||||
|
if (resultEntity!=null) {
|
||||||
|
Realm.getDefaultInstance().insert(renderEntity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (map in listResult) { // 每一个map就是Realm的一条数据
|
|
||||||
// 先查询这个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()
|
|
||||||
// 其他数据插入到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())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 对renderEntity做预处理后再保存
|
|
||||||
importConfig.transformProperties(renderEntity)
|
|
||||||
Realm.getDefaultInstance().copyToRealm(renderEntity)
|
|
||||||
}
|
|
||||||
// 1个文件发送一次flow流
|
// 1个文件发送一次flow流
|
||||||
emit("${index + 1}/${importConfig.tableMap.size}")
|
emit("${index + 1}/${importConfig.tableMap.size}")
|
||||||
|
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||||
|
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||||
|
importConfig.preProcess.cacheRdLink = listResult.associateBy { it.properties["linkPid"] }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Realm.getDefaultInstance().commitTransaction()
|
Realm.getDefaultInstance().commitTransaction()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.navinfo.omqs.db
|
||||||
|
|
||||||
|
class ImportPreCacheData {
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.navinfo.omqs.db
|
package com.navinfo.omqs.db
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import com.navinfo.collect.library.data.entity.ReferenceEntity
|
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.collect.library.utils.GeometryTools
|
import com.navinfo.collect.library.utils.GeometryTools
|
||||||
@ -14,6 +15,23 @@ import org.oscim.core.GeoPoint
|
|||||||
|
|
||||||
class ImportPreProcess {
|
class ImportPreProcess {
|
||||||
val code2NameMap = Code2NameMap()
|
val code2NameMap = Code2NameMap()
|
||||||
|
lateinit var cacheRdLink: Map<String?, RenderEntity>
|
||||||
|
|
||||||
|
fun checkCircleRoad(renderEntity: RenderEntity): Boolean {
|
||||||
|
val linkInId = renderEntity.properties["linkIn"]
|
||||||
|
val linkOutId = renderEntity.properties["linkOut"]
|
||||||
|
// 根据linkIn和linkOut获取对应的link数据
|
||||||
|
val linkInEntity = cacheRdLink[linkInId]
|
||||||
|
val linkOutEntity = cacheRdLink[linkOutId]
|
||||||
|
Log.d("checkCircleRoad", "LinkInEntity: ${linkInId}- ${linkInEntity?.properties?.get("snodePid")},LinkOutEntity: ${linkOutId}- ${linkOutEntity?.properties?.get("enodePid")}")
|
||||||
|
// 查询linkIn的sNode和linkOut的eNode是否相同,如果相同,认为数据是环形路口,返回false
|
||||||
|
if (linkInEntity!=null&&linkOutEntity!=null) {
|
||||||
|
if ((linkInEntity.properties["snodePid"] == linkOutEntity.properties["enodePid"]) || linkInEntity.properties["enodePid"] == linkOutEntity.properties["snodePid"]
|
||||||
|
|| linkInEntity.properties["snodePid"] == linkOutEntity.properties["snodePid"]|| linkInEntity.properties["enodePid"] == linkOutEntity.properties["enodePid"])
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 计算指定数据指定方向的坐标
|
* 计算指定数据指定方向的坐标
|
||||||
* @param direction 判断当前数据是否为逆向,给定的应该是一个a=b的表达式,a为对应的properties的key,b为对应的值
|
* @param direction 判断当前数据是否为逆向,给定的应该是一个a=b的表达式,a为对应的properties的key,b为对应的值
|
||||||
|
@ -112,7 +112,7 @@ class PersonalCenterFragment(private var backListener: (() -> Unit?)? = null) :
|
|||||||
viewModel.readRealmData()
|
viewModel.readRealmData()
|
||||||
// 定位到指定位置
|
// 定位到指定位置
|
||||||
niMapController.mMapView.vtmMap.animator()
|
niMapController.mMapView.vtmMap.animator()
|
||||||
.animateTo(GeoPoint( 39.80392140200183, 116.51446703352337 ))
|
.animateTo(GeoPoint( 39.80130797136839, 116.51808677349096 ))
|
||||||
}
|
}
|
||||||
// R.id.personal_center_menu_task_list -> {
|
// R.id.personal_center_menu_task_list -> {
|
||||||
// findNavController().navigate(R.id.TaskManagerFragment)
|
// findNavController().navigate(R.id.TaskManagerFragment)
|
||||||
|
@ -1804,7 +1804,7 @@
|
|||||||
</m>
|
</m>
|
||||||
</m>
|
</m>
|
||||||
<!--电子眼-->
|
<!--电子眼-->
|
||||||
<m v="OMDB_RESTRICTION">
|
<m v="OMDB_ELECTRONICEYE">
|
||||||
<m k="angle">
|
<m k="angle">
|
||||||
<symbol repeat="false" repeat-start="0" rotate="false"
|
<symbol repeat="false" repeat-start="0" rotate="false"
|
||||||
src="assets:symbols/volcano.svg" symbol-height="69" symbol-width="69"></symbol>
|
src="assets:symbols/volcano.svg" symbol-height="69" symbol-width="69"></symbol>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user