Conflicts:
	vtm
This commit is contained in:
qiji4215
2023-06-28 11:14:12 +08:00
82 changed files with 2165 additions and 431 deletions

View File

@@ -2,6 +2,8 @@ package com.navinfo.omqs.bean
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.omqs.db.ImportPreProcess
import kotlin.reflect.KFunction
import kotlin.reflect.KParameter
import kotlin.reflect.full.declaredMemberFunctions
@@ -11,7 +13,7 @@ class ImportConfig {
var checked : Boolean = true
val preProcess: ImportPreProcess = ImportPreProcess()
fun transformProperties(renderEntity: RenderEntity): RenderEntity {
fun transformProperties(renderEntity: RenderEntity): RenderEntity? {
val transformList = tableMap[renderEntity.code.toString()]?.transformer
if (transformList.isNullOrEmpty()) {
return renderEntity
@@ -29,23 +31,66 @@ class ImportConfig {
// 如果key和value都为空说明当前数据需要增加一个新字段
if (key.isNullOrEmpty()&&value.isNullOrEmpty()&&!renderEntity.properties.containsKey(keylib)) {
renderEntity.properties[keylib] = valuelib
continue
}
// 开始解析key和value并对数据进行匹配
m@ for (k in processKeyOrValue(key)) {
if (renderEntity.properties.containsKey(k)) { // json配置的key可以匹配到数据
for (v in processKeyOrValue(value)) {
if ("~" == v ) { // ~符可以匹配任意元素
if (valuelib.endsWith("()")) { // 以()结尾说明该value配置是一个function需要通过反射调用指定方法
val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") }
method.call(preProcess, renderEntity)
if (valuelib.endsWith(")")) { // 以()结尾说明该value配置是一个function需要通过反射调用指定方法
// 获取方法名
val methodName = valuelib.substringBefore("(")
// 获取参数
val params: List<String> = valuelib.substringAfter("(").substringBefore(")").split(",").filter{ it.isNotEmpty() }.map { it.trim() }
val method = preProcess::class.members.filter { it.name == methodName }.first() as KFunction<*>
val methodParams = method.parameters
val callByParams = mutableMapOf<KParameter, Any>(
methodParams[0] to preProcess,
methodParams[1] to renderEntity
)
for ((index, value) in params.withIndex()) {
// 前2个参数确定为对象本身和RenderEntity因此自定义参数从index+2开始设置
if (methodParams.size>index+2) {
callByParams[methodParams[index+2]] = value
}
}
when(val result = method.callBy(callByParams)) { // 如果方法返回的数据类型是boolean且返回为false则该数据不处理
is Boolean ->
if (!result) {
return null
}
}
} else {
renderEntity.properties[keylib] = valuelib
}
break@m
} else if (renderEntity.properties[k] == v) { // 完全匹配
if (valuelib.endsWith("()")) { // 以()结尾说明该value配置是一个function需要通过反射调用指定方法
val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") }
method.call(preProcess, renderEntity)
if (valuelib.endsWith(")")) { // 以()结尾说明该value配置是一个function需要通过反射调用指定方法
// 获取方法名
val methodName = valuelib.substringBefore("(")
// 获取参数
val params: List<String> = valuelib.substringAfter("(").substringBefore(")").split(",").filter{ it.isNotEmpty() }.map { it.trim() }
val method = preProcess::class.members.filter { it.name == methodName }.first() as KFunction<*>
val methodParams = method.parameters
val callByParams = mutableMapOf<KParameter, Any>(
methodParams[0] to preProcess,
methodParams[1] to renderEntity
)
for ((index, value) in params.withIndex()) {
// 前2个参数确定为对象本身和RenderEntity因此自定义参数从index+2开始设置
if (methodParams.size>index+2) {
callByParams[methodParams[index+2]] = value
}
}
when(val result = method.callBy(callByParams)) {
is Boolean ->
if (!result) {
return null
}
}
} else {
renderEntity.properties[keylib] = valuelib
}

View File

@@ -0,0 +1,49 @@
package com.navinfo.omqs.bean
data class RoadNameBean(
/**
* 道路名称
*/
val name: String = "",
/**
* 0 普通
* 1 立交桥名(连接路)
* 2 立交桥名 (主路)
* 3 风景线路
* 5 隧道
* 6 虚拟名称
*/
val type: Int = 0,
/**
* 1 不论“名称分类”是官方名别名还是曾用名都统一从1开始递增
* 2 若取第一官方名时,需判断“名称”分类 [nameClass]=="官方名",且[seqNum] 最小的
*/
val seqNum: Int = 1,
/**
* 1 官方名
* 2 别名
* 3 曾用名
*/
val nameClass: Int = 1,
) {
fun getNameClassStr(): String {
when (nameClass) {
1 -> return "官方名"
2 -> return "别名"
3 -> return "曾用名"
}
return ""
}
fun getTypeStr(): String {
when (type) {
0 -> return "普通"
1 -> return "立交桥名(连接路)"
2 -> return "立交桥名(主路)"
3 -> return "风景线路"
5 -> return "隧道"
6 -> return "虚拟名称"
}
return ""
}
}

View File

@@ -1,6 +1,7 @@
package com.navinfo.omqs.bean
import android.os.Parcelable
import com.navinfo.collect.library.data.entity.RenderEntity
import kotlinx.parcelize.Parcelize
@Parcelize
@@ -11,20 +12,14 @@ data class SignBean(
val distance: Int = 0,
//左上图标中的文字
val iconText: String = "",
//绑定的要素id
val elementId: String = "",
//绑定的linkid
val linkId: String,
//坐标
val geometry: String,
//名称
val name: String,
//是否要展示详细信息
val isMoreInfo: Boolean = false,
//底部右侧文字
val bottomRightText: String = "",
//要素code类型
val elementCode: Int,
//需要展示更多的内容
val moreText: String = "",
//左上角信息
val topRightText: String = ""
//捕捉数据
val renderEntity: RenderEntity
) : Parcelable