对数据插入进行优化重构

This commit is contained in:
qiji4215
2023-09-13 17:53:12 +08:00
parent de0a1e3223
commit c3d9ed5a2f
7 changed files with 379 additions and 250 deletions

View File

@@ -6,15 +6,17 @@
"table": "OMDB_NODE_FORM", "table": "OMDB_NODE_FORM",
"code": 1007, "code": 1007,
"name": "点形态", "name": "点形态",
"existSubCode": true,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 20, "zoomMax": 20
}, },
"1007_PA": { "1007_PA": {
"table": "OMDB_NODE_PA", "table": "OMDB_NODE_PA",
"code": 1007, "code": 1007,
"name": "点形态PA", "name": "点形态PA",
"existSubCode": true,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 20, "zoomMax": 20
}, },
"1012": { "1012": {
"table": "OMDB_CHECKPOINT", "table": "OMDB_CHECKPOINT",
@@ -30,7 +32,7 @@
"name": "道路线", "name": "道路线",
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 17, "zoomMax": 17,
"catch":true, "catch":true
}, },
"2002": { "2002": {
"table": "OMDB_RD_LINK_FUNCTION_CLASS", "table": "OMDB_RD_LINK_FUNCTION_CLASS",
@@ -78,6 +80,8 @@
"name": "车道边界类型", "name": "车道边界类型",
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20, "zoomMax": 20,
"checkLinkId": false,
"filterData": true,
"catch":true, "catch":true,
"transformer": [ "transformer": [
{ {
@@ -126,14 +130,18 @@
"table": "OMDB_RDBOUND_BOUNDARYTYPE", "table": "OMDB_RDBOUND_BOUNDARYTYPE",
"code": 2083, "code": 2083,
"name": "道路边界类型", "name": "道路边界类型",
"checkLinkId": false,
"filterData": true,
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20, "zoomMax": 20,
"catch":true, "catch":true
}, },
"2090":{ "2090":{
"table": "OMDB_LANE_CONSTRUCTION", "table": "OMDB_LANE_CONSTRUCTION",
"code": 2090, "code": 2090,
"name": "车道施工", "name": "车道施工",
"checkLinkId": false,
"existSubCode": true,
"catch":true, "catch":true,
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20 "zoomMax": 20
@@ -142,6 +150,7 @@
"table": "OMDB_BRIDGE", "table": "OMDB_BRIDGE",
"code": 2201, "code": 2201,
"name": "桥", "name": "桥",
"checkLinkId": false,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 20, "zoomMax": 20,
"transformer": [ "transformer": [
@@ -157,6 +166,7 @@
"table": "OMDB_TUNNEL", "table": "OMDB_TUNNEL",
"code": 2202, "code": 2202,
"name": "隧道", "name": "隧道",
"checkLinkId": false,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 20, "zoomMax": 20,
"transformer": [ "transformer": [
@@ -175,12 +185,14 @@
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20, "zoomMax": 20,
"catch":true, "catch":true,
"checkLinkId": false,
"transformer": [] "transformer": []
}, },
"3003":{ "3003":{
"table": "OMDB_OBJECT_SYMBOL", "table": "OMDB_OBJECT_SYMBOL",
"code": 3003, "code": 3003,
"name": "符号", "name": "符号",
"checkLinkId": false,
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20, "zoomMax": 20,
"catch":true, "catch":true,
@@ -190,6 +202,7 @@
"table": "OMDB_OBJECT_ARROW", "table": "OMDB_OBJECT_ARROW",
"code": 3004, "code": 3004,
"name": "箭头", "name": "箭头",
"checkLinkId": false,
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20, "zoomMax": 20,
"transformer": [ "transformer": [
@@ -228,6 +241,7 @@
"name": "杆状物", "name": "杆状物",
"is3D": true, "is3D": true,
"catch":true, "catch":true,
"filterData": true,
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20, "zoomMax": 20,
"transformer": [ "transformer": [
@@ -244,6 +258,7 @@
"code": 3012, "code": 3012,
"name": "导流区", "name": "导流区",
"catch":true, "catch":true,
"checkLinkId": false,
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20 "zoomMax": 20
}, },
@@ -259,6 +274,8 @@
"table": "OMDB_OBJECT_STOPLOCATION", "table": "OMDB_OBJECT_STOPLOCATION",
"code": 3016, "code": 3016,
"name": "停止位置", "name": "停止位置",
"checkLinkId": false,
"filterData": true,
"zoomMin": 18, "zoomMin": 18,
"catch":true, "catch":true,
"zoomMax": 20 "zoomMax": 20
@@ -342,12 +359,13 @@
} }
] ]
}, },
"4006":{ "4006": {
"table": "OMDB_RESTRICTION", "table": "OMDB_RESTRICTION",
"code": 4006, "code": 4006,
"name": "普通交限", "name": "普通交限",
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 17, "zoomMax": 17,
"filterData":true,
"catch":true, "catch":true,
"transformer": [ "transformer": [
{ {
@@ -497,6 +515,7 @@
"table": "OMDB_LANE_LINK_LG", "table": "OMDB_LANE_LINK_LG",
"code": 5001, "code": 5001,
"name": "车道中心线", "name": "车道中心线",
"checkLinkId": false,
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20, "zoomMax": 20,
"transformer": [ "transformer": [
@@ -517,6 +536,7 @@
"table": "OMDB_LINK_ATTRIBUTE", "table": "OMDB_LINK_ATTRIBUTE",
"code": 2004, "code": 2004,
"name": "道路属性", "name": "道路属性",
"existSubCode": true,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 20, "zoomMax": 20,
"transformer": [ "transformer": [
@@ -539,6 +559,7 @@
"table": "OMDB_RAMP", "table": "OMDB_RAMP",
"code": 2037, "code": 2037,
"name": "匝道", "name": "匝道",
"existSubCode": true,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 17 "zoomMax": 17
}, },
@@ -562,12 +583,14 @@
"table": "OMDB_LINK_FORM1", "table": "OMDB_LINK_FORM1",
"code": 2205, "code": 2205,
"name": "道路形态1", "name": "道路形态1",
"existSubCode": true,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 17 "zoomMax": 17
}, },
"2206":{ "2206":{
"table": "OMDB_LINK_FORM2", "table": "OMDB_LINK_FORM2",
"code": 2206, "code": 2206,
"existSubCode": true,
"name": "道路形态2", "name": "道路形态2",
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 17 "zoomMax": 17

View File

@@ -125,6 +125,9 @@ class TableInfo {
val zoomMin: Int = 16 val zoomMin: Int = 16
val zoomMax: Int = 21 val zoomMax: Int = 21
val checkLinkId: Boolean = true//是否需要校验linkid val checkLinkId: Boolean = true//是否需要校验linkid
val filterData : Boolean = false//是否需要过滤数据
val existSubCode : Boolean = false//是否存在子编码
val catch: Boolean = false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置参考文档W行设置条件https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM val catch: Boolean = false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置参考文档W行设置条件https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
val name: String = "" val name: String = ""
var checked : Boolean = true var checked : Boolean = true

View File

@@ -166,7 +166,16 @@ class ImportOMDBHelper @AssistedInject constructor(
// 先获取当前配置的所有图层的个数,方便后续计算数据解析进度 // 先获取当前配置的所有图层的个数,方便后续计算数据解析进度
var tableNum = 0 var tableNum = 0
var processIndex = 0 var processIndex = 0
//下载数据统计
var dataIndex = 0 var dataIndex = 0
//数据库插入的统计
var insertIndex = 0
//单个表要素统计
var elementIndex = 0
//单个表要素时间统计
var tableImportTime = System.currentTimeMillis()
//总表要素统计时间
var dataImportTime = System.currentTimeMillis()
Realm.getInstance(currentInstallTaskConfig).beginTransaction() Realm.getInstance(currentInstallTaskConfig).beginTransaction()
@@ -174,19 +183,30 @@ class ImportOMDBHelper @AssistedInject constructor(
tableNum += importConfig.tableMap.size tableNum += importConfig.tableMap.size
} }
//缓存任务link信息便于下面与数据进行任务link匹配 //缓存任务link信息便于下面与数据进行任务link匹配
val hashMap: HashMap<String, HadLinkDvoBean> = val hashMap: HashMap<Long, HadLinkDvoBean> =
HashMap<String, HadLinkDvoBean>() //define empty hashmap HashMap<Long, HadLinkDvoBean>() //define empty hashmap
task.hadLinkDvoList.forEach { task.hadLinkDvoList.forEach {
hashMap.put(it.linkPid, it); hashMap[it.linkPid.toLong()] = it;
} }
val resHashMap: HashMap<String, RenderEntity> = val resHashMap: HashMap<String, RenderEntity> =
HashMap<String, RenderEntity>() //define empty hashmap HashMap<String, RenderEntity>() //define empty hashmap
try { try {
// 遍历解压后的文件,读取该数据返回 // 遍历解压后的文件,读取该数据返回
Log.d("ImportOMDBHelper", "表解析===开始时间$dataImportTime===")
for (importConfig in importConfigList) { for (importConfig in importConfigList) {
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) { for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
processIndex += 1
Log.d(
"ImportOMDBHelper",
"表解析===开始时间$tableImportTime===${currentEntry.value.table}"
)
Log.d(
"ImportOMDBHelper",
"表解析===processIndex${processIndex}====${processIndex}/${tableNum}"
)
val listResult = mutableListOf<RenderEntity>() val listResult = mutableListOf<RenderEntity>()
val currentConfig = currentEntry.value val currentConfig = currentEntry.value
val txtFile = unZipFiles.find { val txtFile = unZipFiles.find {
@@ -202,6 +222,8 @@ class ImportOMDBHelper @AssistedInject constructor(
if (line == null || line.trim() == "") { if (line == null || line.trim() == "") {
continue continue
} }
elementIndex += 1
dataIndex +=1
Log.d("ImportOMDBHelper", "解析第:${index + 1}") Log.d("ImportOMDBHelper", "解析第:${index + 1}")
val map = gson.fromJson<Map<String, Any>>( val map = gson.fromJson<Map<String, Any>>(
line, line,
@@ -279,83 +301,94 @@ class ImportOMDBHelper @AssistedInject constructor(
} }
Log.d("ImportOMDBHelper", "解析===2处理name") Log.d("ImportOMDBHelper", "解析===2处理name")
Log.d("ImportOMDBHelper", "解析===1处理杆状物") Log.d("ImportOMDBHelper", "解析===1处理杆状物")
//优先过滤掉不需要的数据
if (renderEntity.code == DataCodeEnum.OMDB_POLE.code) { // 杆状物
//过滤树类型的杆状物,无需导入到数据库中
val poleType = renderEntity.properties["poleType"]
if (poleType != null && poleType.toInt() == 2) {
continue
}
} else if (renderEntity.code == DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code) {
var boundaryType =
renderEntity.properties["boundaryType"]
if (boundaryType != null) {
when (boundaryType) {
"0", "1", "6", "8", "9" -> {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
}
}
} else if (renderEntity.code == DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code) {
//过滤不需要渲染的要素 if(currentConfig.filterData){
var boundaryType = when (renderEntity.code.toInt()) {
renderEntity.properties["boundaryType"]
if (boundaryType != null) { DataCodeEnum.OMDB_POLE.code.toInt() -> {
when (boundaryType) { //过滤树类型的杆状物,无需导入到数据库中
"0", "3", "4", "5", "7", "9" -> { val poleType = renderEntity.properties["poleType"]
renderEntity.enable = 0 if (poleType != null && poleType.toInt() == 2) {
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue continue
} }
} }
}
} else if (renderEntity.code == DataCodeEnum.OMDB_OBJECT_STOPLOCATION.code) { DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code.toInt() -> {
//过滤不需要渲染的要素 var boundaryType =
var locationType = renderEntity.properties["boundaryType"]
renderEntity.properties["locationType"] if (boundaryType != null) {
if (locationType != null) { when (boundaryType.toInt()) {
when (locationType) { 0, 1, 6, 8, 9 -> {
"3", "4" -> { renderEntity.enable = 0
renderEntity.enable = 0 Log.e(
Log.e( "qj",
"qj", "过滤不显示数据${renderEntity.table}"
"过滤不显示数据${renderEntity.table}" )
continue
}
}
}
}
DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code.toInt() -> {
var boundaryType =
renderEntity.properties["boundaryType"]
if (boundaryType != null) {
when (boundaryType.toInt()) {
0, 3, 4, 5, 7, 9 -> {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
}
}
}
DataCodeEnum.OMDB_OBJECT_STOPLOCATION.code.toInt() -> {
var locationType =
renderEntity.properties["locationType"]
if (locationType != null) {
when (locationType.toInt()) {
3, 4 -> {
renderEntity.enable = 0
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
}
}
}
DataCodeEnum.OMDB_RESTRICTION.code.toInt() -> {
if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
"linkOut"
) )
continue ) {
} var linkIn = renderEntity.properties["linkIn"]
} var linkOut = renderEntity.properties["linkOut"]
} if (linkIn != null && linkOut != null) {
//交限增加相同LinkIn与LinkOut过滤原则 var checkMsg = "$linkIn$linkOut"
}else if (renderEntity.code == DataCodeEnum.OMDB_RESTRICTION.code) { if (resHashMap.containsKey(checkMsg)) {
if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey( Log.e(
"linkOut" "qj",
) "${renderEntity.name}==过滤交限linkin与linkout相同且存在多条数据"
) { )
var linkIn = renderEntity.properties["linkIn"] continue
var linkOut = renderEntity.properties["linkOut"] } else {
if (linkIn != null && linkOut != null) { resHashMap[checkMsg] = renderEntity
var checkMsg = "$linkIn$linkOut" }
if (resHashMap.containsKey(checkMsg)) { }
Log.e(
"qj",
"${renderEntity.name}==过滤交限linkin与linkout相同且存在多条数据"
)
continue
} else {
resHashMap.put(checkMsg, renderEntity)
} }
} }
} }
} }
Log.d("ImportOMDBHelper", "解析===2处理杆状物") Log.d("ImportOMDBHelper", "解析===2处理杆状物")
Log.d("ImportOMDBHelper", "解析===1任务路线匹配") Log.d("ImportOMDBHelper", "解析===1任务路线匹配")
//遍历判断只显示与任务Link相关的任务数据 //遍历判断只显示与任务Link相关的任务数据
@@ -366,13 +399,24 @@ class ImportOMDBHelper @AssistedInject constructor(
var currentLinkPid = var currentLinkPid =
renderEntity.properties["linkPid"] renderEntity.properties["linkPid"]
Log.d(
"ImportOMDBHelper",
"解析===1任务路线匹配${currentLinkPid}"
)
if (!currentLinkPid.isNullOrEmpty() && currentLinkPid != "null") { if (!currentLinkPid.isNullOrEmpty() && currentLinkPid != "null") {
var list = currentLinkPid.split(",") var list = currentLinkPid.split(",")
if (list != null && list.size > 0) { if (list != null && list.isNotEmpty()) {
Log.d(
"ImportOMDBHelper",
"解析===1任务路线匹配${list.size}"
)
m@ for (linkPid in list) { m@ for (linkPid in list) {
if (hashMap.containsKey(linkPid)) { if (hashMap.containsKey(linkPid.toLong())) {
renderEntity.enable = 1 renderEntity.enable = 1
Log.e( Log.e(
"qj", "qj",
@@ -384,32 +428,49 @@ class ImportOMDBHelper @AssistedInject constructor(
} }
} }
}else if(renderEntity.code == DataCodeEnum.OMDB_INTERSECTION.code && renderEntity.properties.containsKey("linkList")){ } else if (renderEntity.code.toInt() == DataCodeEnum.OMDB_INTERSECTION.code.toInt() && renderEntity.properties.containsKey(
"linkList"
)
) {
if (renderEntity.properties["linkList"] != null) { if (renderEntity.properties["linkList"] != null) {
Log.e("qj", "linkList==开始${renderEntity.name}==${renderEntity.properties["linkList"]}}") Log.e(
"qj",
"linkList==开始${renderEntity.name}==${renderEntity.properties["linkList"]}}"
)
val linkList = renderEntity.properties["linkList"] val linkList =
renderEntity.properties["linkList"]
if (!linkList.isNullOrEmpty()&&linkList!="null") { if (!linkList.isNullOrEmpty() && linkList != "null") {
Log.e("qj", "linkList==${renderEntity.name}==${renderEntity.properties["linkList"]}}") Log.e(
"qj",
"linkList==${renderEntity.name}==${renderEntity.properties["linkList"]}}"
)
val list: List<LinkList> = gson.fromJson(linkList, object : TypeToken<List<LinkList>>() {}.type) val list: List<LinkList> = gson.fromJson(
linkList,
object :
TypeToken<List<LinkList>>() {}.type
)
if (list != null) { if (list != null) {
m@for (link in list){ m@ for (link in list) {
if (hashMap.containsKey(link.linkPid)) { if (hashMap.containsKey(link.linkPid.toLong())) {
renderEntity.enable = 1 renderEntity.enable = 1
Log.e("qj", "${renderEntity.name}==包括任务link") Log.e(
"qj",
"${renderEntity.name}==包括任务link"
)
break@m break@m
} }
} }
} }
} }
} }
}else{ } else {
//不包括linkPid直接过滤 //不包括linkPid直接过滤
continue continue
} }
@@ -436,199 +497,223 @@ class ImportOMDBHelper @AssistedInject constructor(
} }
// 对renderEntity做预处理后再保存 // 对renderEntity做预处理后再保存
val resultEntity = importConfig.transformProperties(renderEntity) val resultEntity =
importConfig.transformProperties(renderEntity)
Log.d("ImportOMDBHelper", "解析===2预处理") Log.d("ImportOMDBHelper", "解析===2预处理")
if (resultEntity != null) { if (resultEntity != null) {
Log.d("ImportOMDBHelper", "解析===1子code处理") Log.d("ImportOMDBHelper", "解析===1子code处理")
//对code编码需要特殊处理 存在多个属性值时渲染优先级SA>PA,存在多个属性值时渲染优先级FRONTAGE>MAIN_SIDE_A CCESS //对code编码需要特殊处理 存在多个属性值时渲染优先级SA>PA,存在多个属性值时渲染优先级FRONTAGE>MAIN_SIDE_A CCESS
if (renderEntity.code == DataCodeEnum.OMDB_LINK_ATTRIBUTE.code) {
Log.e("qj", "道路属性===0") if(currentConfig.existSubCode){
when (renderEntity.code.toInt()) {
DataCodeEnum.OMDB_LINK_ATTRIBUTE.code.toInt() -> {
var type = renderEntity.properties["sa"] Log.e("qj", "道路属性===0")
var type = renderEntity.properties["sa"]
if (type != null && type == "1") {
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_SA.code
Log.e("qj", "道路属性===1")
} else {
type = renderEntity.properties["pa"]
if (type != null && type == "1") {
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_PA.code
Log.e("qj", "道路属性===2")
} else {
type = renderEntity.properties["frontage"]
if (type != null && type == "1") { if (type != null && type == "1") {
renderEntity.code = renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_FORNTAGE.code DataCodeEnum.OMDB_LINK_ATTRIBUTE_SA.code
renderEntity.zoomMin = 15 Log.e("qj", "道路属性===1")
renderEntity.zoomMax = 17
Log.e("qj", "道路属性===3")
} else { } else {
type = type = renderEntity.properties["pa"]
renderEntity.properties["mainSideAccess"]
if (type != null && type == "1") { if (type != null && type == "1") {
renderEntity.code = renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_MAIN_SIDE_ACCESS.code DataCodeEnum.OMDB_LINK_ATTRIBUTE_PA.code
renderEntity.zoomMin = 15 Log.e("qj", "道路属性===2")
renderEntity.zoomMax = 17
Log.e("qj", "道路属性===4")
} else { } else {
renderEntity.enable = 0 type =
renderEntity.zoomMin = 15 renderEntity.properties["frontage"]
renderEntity.zoomMax = 17 if (type != null && type == "1") {
Log.e( renderEntity.code =
"qj", DataCodeEnum.OMDB_LINK_ATTRIBUTE_FORNTAGE.code
"过滤不显示数据${renderEntity.table}" renderEntity.zoomMin = 15
) renderEntity.zoomMax = 17
Log.e("qj", "道路属性===5") Log.e("qj", "道路属性===3")
continue } else {
type =
renderEntity.properties["mainSideAccess"]
if (type != null && type == "1") {
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_MAIN_SIDE_ACCESS.code
renderEntity.zoomMin = 15
renderEntity.zoomMax = 17
Log.e("qj", "道路属性===4")
} else {
renderEntity.enable = 0
renderEntity.zoomMin = 15
renderEntity.zoomMax = 17
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
Log.e("qj", "道路属性===5")
continue
}
}
} }
} }
} }
}
} else if (renderEntity.code == DataCodeEnum.OMDB_RAMP.code) {
/*匝道*/
var formWay = renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay) {
"93" -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_1.code
"98" -> renderEntity.code = DataCodeEnum.OMDB_RAMP.code.toInt() -> {
DataCodeEnum.OMDB_RAMP_2.code /*匝道*/
var formWay =
renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay.toInt()) {
93 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_1.code
"99" -> renderEntity.code = 98 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_3.code DataCodeEnum.OMDB_RAMP_2.code
"100" -> renderEntity.code = 99 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_4.code DataCodeEnum.OMDB_RAMP_3.code
"102" -> renderEntity.code = 100 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_5.code DataCodeEnum.OMDB_RAMP_4.code
"103" -> renderEntity.code = 102 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_6.code DataCodeEnum.OMDB_RAMP_5.code
"104" -> renderEntity.code = 103 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_7.code DataCodeEnum.OMDB_RAMP_6.code
104 -> renderEntity.code =
DataCodeEnum.OMDB_RAMP_7.code
}
}
}
DataCodeEnum.OMDB_LINK_FORM1.code.toInt() -> {
/*道路形态1*/
var formWay =
renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay.toInt()) {
35 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_1.code
37 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_2.code
38 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_3.code
}
}
}
DataCodeEnum.OMDB_LINK_FORM2.code.toInt() -> {
Log.e(
"qj",
"道路形态2${renderEntity.properties["formOfWay"]}"
)
/*道路形态2*/
var formWay =
renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay.toInt()) {
10 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_1.code
11 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_2.code
17 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_3.code
18 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_4.code
20 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_5.code
22 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_6.code
36 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_7.code
52 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_8.code
53 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_9.code
54 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_10.code
60 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_11.code
84 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_12.code
85 -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_13.code
}
}
}
DataCodeEnum.OMDB_LANE_CONSTRUCTION.code.toInt() -> {
//特殊处理空数据,渲染原则使用
var startTime =
renderEntity.properties["startTime"]
if (startTime == null || startTime == "") {
renderEntity.properties["startTime"] =
"null"
}
} }
} }
} else if (renderEntity.code == DataCodeEnum.OMDB_LINK_FORM1.code) {
/*道路形态1*/
var formWay = renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay) {
"35" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM1_1.code
"37" -> renderEntity.code = if (renderEntity.table == DataCodeEnum.OMDB_NODE_FORM.name) {//特殊处理因为code相同使用表名判断
DataCodeEnum.OMDB_LINK_FORM1_2.code //过滤不需要渲染的要素
var formOfWay = renderEntity.properties["formOfWay"]
"38" -> renderEntity.code = if (formOfWay != null && formOfWay.toInt() == 30) {
DataCodeEnum.OMDB_LINK_FORM1_3.code renderEntity.enable = 2
renderEntity.code =
DataCodeEnum.OMDB_NODE_FORM.code
} else {
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
} }
} } else if (renderEntity.table == DataCodeEnum.OMDB_NODE_PA.name) {//特殊处理因为code相同使用表名判断
} else if (renderEntity.code == DataCodeEnum.OMDB_LINK_FORM2.code) { //过滤不需要渲染的要素
Log.e( var attributeType =
"qj", renderEntity.properties["attributeType"]
"道路形态2${renderEntity.properties["formOfWay"]}" if (attributeType != null && attributeType.toInt() == 30) {
) renderEntity.enable = 2
/*道路形态2*/ renderEntity.code =
var formWay = renderEntity.properties["formOfWay"] DataCodeEnum.OMDB_NODE_PA.code
if (formWay != null) { } else {
when (formWay) { Log.e(
"10" -> renderEntity.code = "qj",
DataCodeEnum.OMDB_LINK_FORM2_1.code "过滤不显示数据${renderEntity.table}"
)
"11" -> renderEntity.code = continue
DataCodeEnum.OMDB_LINK_FORM2_2.code
"17" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_3.code
"18" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_4.code
"20" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_5.code
"22" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_6.code
"36" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_7.code
"52" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_8.code
"53" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_9.code
"54" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_10.code
"60" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_11.code
"84" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_12.code
"85" -> renderEntity.code =
DataCodeEnum.OMDB_LINK_FORM2_13.code
} }
} }
} else if (renderEntity.table == DataCodeEnum.OMDB_NODE_FORM.name) {//特殊处理因为code相同使用表名判断
//过滤不需要渲染的要素
var formOfWay = renderEntity.properties["formOfWay"]
if (formOfWay != null && formOfWay == "30") {
renderEntity.enable = 2
renderEntity.code =
DataCodeEnum.OMDB_NODE_FORM.code
} else {
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
} else if (renderEntity.table == DataCodeEnum.OMDB_NODE_PA.name) {//特殊处理因为code相同使用表名判断
//过滤不需要渲染的要素
var attributeType =
renderEntity.properties["attributeType"]
if (attributeType != null && attributeType == "30") {
renderEntity.enable = 2
renderEntity.code =
DataCodeEnum.OMDB_NODE_PA.code
} else {
Log.e(
"qj",
"过滤不显示数据${renderEntity.table}"
)
continue
}
} else if (renderEntity.code == DataCodeEnum.OMDB_LANE_CONSTRUCTION.code) {
//特殊处理空数据,渲染原则使用
var startTime = renderEntity.properties["startTime"]
if (startTime == null || startTime == "") {
renderEntity.properties["startTime"] = "null"
}
} }
Log.d("ImportOMDBHelper", "解析===2子code处理") Log.d("ImportOMDBHelper", "解析===2子code处理")
++dataIndex ++insertIndex
Log.e("qj", "统计==${dataIndex}") Log.e("qj", "统计==${insertIndex}")
//移除该字段,减少数据量 //移除该字段,减少数据量
if(renderEntity.properties.containsKey("geometry")){ if (renderEntity.properties.containsKey("geometry")) {
renderEntity.properties.remove("geometry") renderEntity.properties.remove("geometry")
} }
Log.d("ImportOMDBHelper", "解析===1insert") Log.d("ImportOMDBHelper", "解析===1insert")
Realm.getInstance(currentInstallTaskConfig).insert(renderEntity) Realm.getInstance(currentInstallTaskConfig)
.insert(renderEntity)
Log.d("ImportOMDBHelper", "解析===2insert") Log.d("ImportOMDBHelper", "解析===2insert")
} }
if (currentConfig.table == "OMDB_RD_LINK") { if (currentConfig.code == DataCodeEnum.OMDB_RD_LINK.code.toInt()) {
listResult.add(renderEntity) listResult.add(renderEntity)
} }
} }
@@ -641,12 +726,30 @@ class ImportOMDBHelper @AssistedInject constructor(
listResult.associateBy { it.properties["linkPid"] } listResult.associateBy { it.properties["linkPid"] }
} }
// 1个文件发送一次flow流 // 1个文件发送一次flow流
emit("${++processIndex}/${tableNum}") emit("${processIndex}/${tableNum}")
Log.d("ImportOMDBHelper", "表解析===2${currentConfig.table }") Log.d("ImportOMDBHelper", "表解析===2${currentConfig.table}")
Log.d(
"ImportOMDBHelper",
"表解析===结束用时时间${(System.currentTimeMillis() - tableImportTime)}===${currentEntry.value.table}===$elementIndex"
)
elementIndex = 0
tableImportTime = System.currentTimeMillis()
if(insertIndex%20000==0){
Log.d(
"ImportOMDBHelper",
"表解析===结束用时时间===事物开始"
)
Realm.getInstance(currentInstallTaskConfig).commitTransaction()
Realm.getInstance(currentInstallTaskConfig).beginTransaction()
Log.d(
"ImportOMDBHelper",
"表解析===结束用时时间===事物结束"
) }
} }
} }
Realm.getInstance (currentInstallTaskConfig).commitTransaction() Realm.getInstance(currentInstallTaskConfig).commitTransaction()
Realm.getInstance(currentInstallTaskConfig).close() Realm.getInstance(currentInstallTaskConfig).close()
Log.d("ImportOMDBHelper", "表解析===结束用时时间${(System.currentTimeMillis() - dataImportTime)}===$dataIndex===插入$insertIndex")
Log.e("qj", "安装结束") Log.e("qj", "安装结束")
} catch (e: Exception) { } catch (e: Exception) {
if (Realm.getInstance(currentInstallTaskConfig).isInTransaction) { if (Realm.getInstance(currentInstallTaskConfig).isInTransaction) {

View File

@@ -382,7 +382,7 @@ class MainViewModel @Inject constructor(
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst() val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
if (res != null) { if (res != null) {
currentTaskBean = realm.copyFromRealm(res) currentTaskBean = realm.copyFromRealm(res)
planningPath(currentTaskBean!!) //planningPath(currentTaskBean!!)
} }
realm.close() realm.close()
} }

View File

@@ -294,7 +294,7 @@ class TaskViewModel @Inject constructor(
liveDataTaskLinks.value = taskBean.hadLinkDvoList liveDataTaskLinks.value = taskBean.hadLinkDvoList
showTaskLinks(taskBean) showTaskLinks(taskBean)
MapParamUtils.setTaskId(taskBean.id) MapParamUtils.setTaskId(taskBean.id)
Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH +"/${MapParamUtils.getTaskId()}") Constant.currentSelectTaskFolder = File(Constant.USER_DATA_PATH +"/${taskBean.id}")
Constant.currentSelectTaskConfig = RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder).name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true).schemaVersion(2).build() Constant.currentSelectTaskConfig = RealmConfiguration.Builder().directory(Constant.currentSelectTaskFolder).name("OMQS.realm").encryptionKey(Constant.PASSWORD).allowQueriesOnUiThread(true).schemaVersion(2).build()
MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig) MapParamUtils.setTaskConfig(Constant.currentSelectTaskConfig)
mapController.layerManagerHandler.updateOMDBVectorTileLayer() mapController.layerManagerHandler.updateOMDBVectorTileLayer()

View File

@@ -54,7 +54,7 @@ public class OMDBReferenceDataSource implements ITileDataSource {
if(MapParamUtils.getDataLayerEnum()!=null){ if(MapParamUtils.getDataLayerEnum()!=null){
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql(); sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
}else{ }else{
sql += " and 1=1"; sql += " and enable>=0";
} }
RealmQuery<ReferenceEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(ReferenceEntity.class) RealmQuery<ReferenceEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(ReferenceEntity.class)

View File

@@ -52,7 +52,7 @@ public class OMDBTileDataSource implements ITileDataSource {
if(MapParamUtils.getDataLayerEnum()!=null){ if(MapParamUtils.getDataLayerEnum()!=null){
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql(); sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
}else{ }else{
sql += " and 1=1"; sql += " and enable>=0";
} }
RealmQuery<RenderEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(RenderEntity.class).rawPredicate(sql); RealmQuery<RenderEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(RenderEntity.class).rawPredicate(sql);