Conflicts:
	app/src/main/java/com/navinfo/omqs/db/ImportOMDBHelper.kt
	app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt
This commit is contained in:
qiji4215 2023-10-30 10:34:42 +08:00
commit db2ecd45be
11 changed files with 1521 additions and 1547 deletions

View File

@ -83,6 +83,7 @@
"name": "车道边界类型",
"zoomMin": 18,
"zoomMax": 20,
"isDependOnOtherTable": true,
"checkLinkId": false,
"filterData": true,
"catch": true,
@ -125,11 +126,6 @@
"zoomMin": 15,
"zoomMax": 17
},
"2097":{
"table": "OMDB_PHY_LANENUM",
"code": 2097,
"name": "物理车道数"
},
"2083": {
"table": "OMDB_RDBOUND_BOUNDARYTYPE",
"code": 2083,
@ -145,7 +141,6 @@
"code": 2090,
"name": "车道施工",
"existSubCode": true,
"checkLinkId": false,
"catch": true,
"zoomMin": 18,
"zoomMax": 20
@ -155,6 +150,7 @@
"code": 2092,
"name": "车道类型",
"catch": true,
"isDependOnOtherTable": true,
"zoomMin": 18,
"zoomMax": 20,
"transformer": [
@ -166,12 +162,18 @@
}
]
},
"2097": {
"table": "OMDB_PHY_LANENUM",
"code": 2097,
"name": "物理车道数"
},
"2201": {
"table": "OMDB_BRIDGE",
"code": 2201,
"name": "桥",
"catch": true,
"existSubCode": true,
"isDependOnOtherTable": true,
"zoomMin": 15,
"zoomMax": 20,
"transformer": [
@ -348,6 +350,7 @@
"code": 4001,
"name": "路口",
"zoomMin": 15,
"isDependOnOtherTable": true,
"zoomMax": 17,
"catch": true,
"transformer": [
@ -449,6 +452,7 @@
"zoomMin": 15,
"zoomMax": 17,
"filterData": true,
"isDependOnOtherTable": true,
"catch": true,
"transformer": [
{
@ -488,6 +492,7 @@
"code": 4009,
"name": "警示信息",
"catch": true,
"isDependOnOtherTable": true,
"zoomMin": 15,
"zoomMax": 20,
"transformer": [
@ -576,6 +581,7 @@
"code": 4601,
"name": "车信",
"catch": true,
"isDependOnOtherTable": true,
"zoomMin": 15,
"zoomMax": 17,
"transformer": [
@ -604,6 +610,7 @@
"code": 5001,
"name": "车道中心线",
"catch": false,
"isDependOnOtherTable": true,
"checkLinkId": false,
"zoomMin": 18,
"zoomMax": 20,
@ -686,7 +693,6 @@
"zoomMin": 15,
"zoomMax": 17
}
}
}
]

View File

@ -20,14 +20,12 @@ class ImportConfig {
@Expose
var checked: Boolean = true
val preProcess: ImportPreProcess = ImportPreProcess()
fun transformProperties(renderEntity: RenderEntity, realm: Realm): RenderEntity? {
fun transformProperties(renderEntity: RenderEntity, realm: Realm?): RenderEntity? {
preProcess.realm = realm
val transformList = tableMap[renderEntity.code.toString()]?.transformer
if (transformList.isNullOrEmpty()) {
Log.e("qj", "子表转换为空===${renderEntity.code}")
return renderEntity
}
Log.e("qj", "子表转换不为空===${renderEntity.code}")
for (transform in transformList) {
// 开始执行转换
val key: String = transform.k
@ -144,7 +142,7 @@ class TableInfo {
val checkLinkId: Boolean = true//是否需要校验linkid
val filterData: Boolean = false//是否需要过滤数据
val existSubCode: Boolean = false//是否存在子编码
val isDependOnOtherTable = false//是否依赖其他表
val catch: Boolean =
false//是否需要捕捉 // 需要根据丹丹提供的捕捉原则进行设置参考文档W行设置条件https://navinfo.feishu.cn/sheets/shtcnfsxKZhekU26ezBcHgl7aWh?sheet=BZd6yM
val name: String = ""

View File

@ -2,24 +2,19 @@ package com.navinfo.omqs.db
import android.content.Context
import android.database.Cursor.*
import android.os.Build
import android.provider.ContactsContract.Data
import android.util.Log
import androidx.annotation.RequiresApi
import com.blankj.utilcode.util.FileIOUtils
import com.blankj.utilcode.util.ZipUtils
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.utils.DeflaterUtil
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.StrZipUtil
import com.navinfo.omqs.Constant
import com.navinfo.omqs.Constant.Companion.currentInstallTaskConfig
import com.navinfo.omqs.Constant.Companion.currentInstallTaskFolder
import com.navinfo.omqs.Constant.Companion.installTaskid
import com.navinfo.omqs.bean.ImportConfig
import com.navinfo.omqs.bean.TableInfo
import com.navinfo.omqs.db.deep.LinkList
import com.navinfo.omqs.hilt.OMDBDataBaseHiltFactory
import com.navinfo.omqs.util.CMLog
@ -27,23 +22,19 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import io.realm.Realm
import io.realm.RealmConfiguration
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.withContext
import org.locationtech.jts.geom.Geometry
import org.locationtech.jts.geom.GeometryFactory
import org.locationtech.jts.geom.LineString
import org.locationtech.jts.geom.MultiLineString
import kotlinx.coroutines.sync.Mutex
import org.spatialite.database.SQLiteDatabase
import java.io.BufferedReader
import java.io.File
import java.io.FileReader
import java.util.*
import javax.inject.Inject
import kotlin.collections.HashMap
import kotlin.streams.toList
/**
* 导入omdb数据的帮助类
@ -56,11 +47,12 @@ class ImportOMDBHelper @AssistedInject constructor(
@Inject
lateinit var gson: Gson
private val database by lazy {
omdbHiltFactory.obtainOmdbDataBaseHelper(
context, omdbFile.absolutePath, 1
).writableDatabase
}
// private val database by lazy {
// omdbHiltFactory.obtainOmdbDataBaseHelper(
// context, omdbFile.absolutePath, 1
// ).writableDatabase
// }
private val configFile: File = File("${Constant.USER_DATA_PATH}", Constant.OMDB_CONFIG)
private val importConfigList by lazy {
@ -82,90 +74,94 @@ class ImportOMDBHelper @AssistedInject constructor(
}
}
/**
* 读取指定数据表的数据集
* */
@RequiresApi(Build.VERSION_CODES.N)
suspend fun getOMDBTableData(table: String): Flow<List<Map<String, Any>>> =
withContext(Dispatchers.IO) {
val listResult: MutableList<Map<String, Any>> = mutableListOf()
flow<List<Map<String, Any>>> {
if (database.isOpen) {
val comumns = mutableListOf<String>()
// 获取要读取的列名
val columns = getColumns(database, table)
// 处理列名如果列名是GEOMETRY则使用spatialite函数ST_AsText读取blob数据
val finalColumns = columns.stream().map {
val column = it.replace("\"", "", true)
if ("GEOMETRY".equals(column, ignoreCase = true)) {
"ST_AsText($column)"
} else {
column
}
}.toList()
// /**
// * 读取指定数据表的数据集
// * */
// @RequiresApi(Build.VERSION_CODES.N)
// suspend fun getOMDBTableData(table: String): Flow<List<Map<String, Any>>> =
// withContext(Dispatchers.IO) {
// val listResult: MutableList<Map<String, Any>> = mutableListOf()
// flow<List<Map<String, Any>>> {
// if (database.isOpen) {
// val comumns = mutableListOf<String>()
// // 获取要读取的列名
// val columns = getColumns(database, table)
// // 处理列名如果列名是GEOMETRY则使用spatialite函数ST_AsText读取blob数据
// val finalColumns = columns.stream().map {
// val column = it.replace("\"", "", true)
// if ("GEOMETRY".equals(column, ignoreCase = true)) {
// "ST_AsText($column)"
// } else {
// column
// }
// }.toList()
//
// val cursor = database.query(
// table,
// finalColumns.toTypedArray(),
// "1=1",
// mutableListOf<String>().toTypedArray(),
// null,
// null,
// null,
// null
// )
// with(cursor) {
// if (moveToFirst()) {
// while (moveToNext()) {
// val rowMap = mutableMapOf<String, Any>()
// for (columnIndex in 0 until columnCount) {
// var columnName = getColumnName(columnIndex)
// if (columnName.startsWith("ST_AsText(")) {
// columnName = columnName.replace("ST_AsText(", "")
// .substringBeforeLast(")")
// }
// when (getType(columnIndex)) {
// 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)
// }
// }
// listResult.add(rowMap)
// }
// }
// }
// emit(listResult)
// cursor.close()
// }
// }
// }
val cursor = database.query(
table,
finalColumns.toTypedArray(),
"1=1",
mutableListOf<String>().toTypedArray(),
null,
null,
null,
null
)
with(cursor) {
if (moveToFirst()) {
while (moveToNext()) {
val rowMap = mutableMapOf<String, Any>()
for (columnIndex in 0 until columnCount) {
var columnName = getColumnName(columnIndex)
if (columnName.startsWith("ST_AsText(")) {
columnName = columnName.replace("ST_AsText(", "")
.substringBeforeLast(")")
}
when (getType(columnIndex)) {
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)
}
}
listResult.add(rowMap)
}
}
}
emit(listResult)
cursor.close()
}
}
}
/**
* 从zip文件中导入数据到Realm中
* @param omdbZipFile omdb数据抽取生成的Zip文件
* @param configFile 对应的配置文件
* */
suspend fun importOmdbZipFile(omdbZipFile: File, task: TaskBean): Flow<String> =
withContext(Dispatchers.IO) {
suspend fun importOmdbZipFile(
omdbZipFile: File, task: TaskBean, scope: CoroutineScope
): Boolean {
val channel = Channel<List<RenderEntity>>(Channel.RENDEZVOUS)
installTaskid = task.id.toString()
currentInstallTaskFolder = File(Constant.USER_DATA_PATH + "/$installTaskid")
if (!currentInstallTaskFolder.exists()) currentInstallTaskFolder.mkdirs()
currentInstallTaskConfig =
RealmConfiguration.Builder().directory(currentInstallTaskFolder).name("OMQS.realm")
RealmConfiguration.Builder().directory(currentInstallTaskFolder)
.name("OMQS.realm")
.encryptionKey(Constant.PASSWORD)
// .allowQueriesOnUiThread(true)
.schemaVersion(2).build()
val unZipFolder = File(omdbZipFile.parentFile, "result")
flow {
val unZipFolder = File(omdbZipFile.parentFile, "result")
if (unZipFolder.exists()) {
unZipFolder.deleteRecursively()
}
@ -175,20 +171,7 @@ class ImportOMDBHelper @AssistedInject constructor(
// 先获取当前配置的所有图层的个数,方便后续计算数据解析进度
var tableNum = 0
var processIndex = 0
//下载数据统计
var dataIndex = 0
//数据库插入的统计
var insertIndex = 0
//单个表要素统计
var elementIndex = 0
//单个表要素时间统计
// var tableImportTime = System.currentTimeMillis()
//总表要素统计时间
// var dataImportTime = System.currentTimeMillis()
// Realm.compactRealm(currentInstallTaskConfig)
var realm = Realm.getInstance(currentInstallTaskConfig)
realm.beginTransaction()
for (importConfig in importConfigList) {
tableNum += importConfig.tableMap.size
}
@ -202,53 +185,113 @@ class ImportOMDBHelper @AssistedInject constructor(
// lineList[index] = GeometryTools.createGeometry(it.geometry) as LineString
// index++
}
val resHashMap: HashMap<String, RenderEntity> = HashMap() //define empty hashmap
val listRenderEntity = mutableListOf<RenderEntity>()
//需要关联查询的表
val listDependOnEntry =
mutableMapOf<MutableMap.MutableEntry<String, TableInfo>, ImportConfig>()
//协程池
val listJob = mutableListOf<Job>()
try {
// var multipLine = MultiLineString(lineList, GeometryFactory())
// 遍历解压后的文件,读取该数据返回
// Log.d("ImportOMDBHelper", "表解析===开始时间$dataImportTime===")
CMLog.writeLogtoFile(
ImportOMDBHelper::class.java.name,
"importOmdbZipFile",
"开始"
)
for (importConfig in importConfigList) {
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
processIndex += 1
val currentConfig = currentEntry.value
CMLog.writeLogtoFile(
ImportOMDBHelper::class.java.name,
"importOmdbZipFile",
"${currentConfig.table}开始"
if (currentEntry.value.isDependOnOtherTable) {
listDependOnEntry[currentEntry] = importConfig
continue
}
val job = scope.launch(Dispatchers.IO) {
importData(
channel,
unZipFiles,
currentEntry,
task,
importConfig,
hashMap
)
}
listJob.add(job)
}
}
val channelJob = scope.launch(Dispatchers.IO) {
val iterator = channel.iterator()
while (iterator.hasNext()) {
val next = iterator.next()
val realm = Realm.getInstance(currentInstallTaskConfig)
realm.executeTransaction {
it.copyToRealm(next)
}
realm.close()
}
}
listJob.joinAll()
channel.close()
channelJob.join()
Log.e("jingo", "channel close 等待结束")
for ((currentEntry, importConfig) in listDependOnEntry) {
importData(
channel,
unZipFiles,
currentEntry,
task,
importConfig,
hashMap,
false
)
}
Log.e("jingo", "安装结束")
} catch (e: Exception) {
Log.e("jingo", "安装报错1 ${e.message}")
return false
}
return true
}
private suspend fun importData(
f: Channel<List<RenderEntity>>,
unZipFiles: List<File>,
currentEntry: MutableMap.MutableEntry<String, TableInfo>,
task: TaskBean,
importConfig: ImportConfig,
hashMap: HashMap<Long, HadLinkDvoBean>,
isEmit: Boolean = true
) {
val resHashMap: HashMap<String, RenderEntity> = HashMap() //define empty hashmap
var listRenderEntity = mutableListOf<RenderEntity>()
//单个表要素统计
var elementIndex = 0
val currentConfig = currentEntry.value
// CMLog.writeLogtoFile(
// ImportOMDBHelper::class.java.name,
// "importOmdbZipFile",
// "${currentConfig.table}开始"
// )
try {
var realm: Realm? = null
if (!isEmit) {
realm = Realm.getInstance(currentInstallTaskConfig)
realm.beginTransaction()
}
val txtFile = unZipFiles.find {
it.name == currentConfig.table
}
Log.e("qj", "开始遍历文件==${currentConfig.table}")
if (txtFile != null && txtFile.exists()) {
try {
Log.e("qj", "开始遍历文件1")
val fileReader = FileReader(txtFile)
val bufferedReader = BufferedReader(fileReader)
var line: String? = bufferedReader.readLine()
var time = System.currentTimeMillis()
var newTime = 0L
while (line != null) {
if (line == null || line.trim() == "") {
line = bufferedReader.readLine()
continue
}
newTime = System.currentTimeMillis()
Log.e(
"jingo",
"安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size} ${newTime - time}"
)
time = newTime
elementIndex += 1
dataIndex += 1
val map = gson.fromJson<Map<String, Any>>(
line, object : TypeToken<Map<String, Any>>() {}.type
).toMutableMap()
@ -270,54 +313,40 @@ class ImportOMDBHelper @AssistedInject constructor(
// 在外层记录当前数据的linkPid
if (map.containsKey("linkPid")) {
renderEntity.linkPid =
map["linkPid"].toString().split(",")[0]
renderEntity.linkPid = map["linkPid"].toString().split(",")[0]
} else if (map.containsKey("linkList")) {
val linkList = map["linkList"].toString()
if (!linkList.isNullOrEmpty() && linkList != "null") {
val list: List<LinkList> = gson.fromJson(
linkList,
object : TypeToken<List<LinkList>>() {}.type
linkList, object : TypeToken<List<LinkList>>() {}.type
)
renderEntity.linkPid = list[0].linkPid
}
}
Log.e(
"jingo",
"安装数据 ${renderEntity.table} ${renderEntity.linkPid} $elementIndex $insertIndex"
)
renderEntity.geometry = map["geometry"].toString()
Log.e("jingo", "map解析开始")
for ((key, value) in map) {
when (value) {
is String -> renderEntity.properties[key] = value
is Int -> renderEntity.properties[key] =
value.toInt().toString()
is Int -> renderEntity.properties[key] = value.toInt().toString()
is Double -> renderEntity.properties[key] =
value.toDouble().toString()
else -> renderEntity.properties[key] =
value.toString()
else -> renderEntity.properties[key] = value.toString()
}
}
// 如果properties中不包含name那么自动将要素名称添加进properties中
if (!renderEntity.properties.containsKey("name")) {
renderEntity.properties["name"] = renderEntity.name;
}
Log.e("jingo", "map解析结束")
if (currentConfig.filterData) {
when (renderEntity.code.toInt()) {
DataCodeEnum.OMDB_POLE.code.toInt() -> {
//过滤树类型的杆状物,无需导入到数据库中
val poleType =
renderEntity.properties["poleType"]
val poleType = renderEntity.properties["poleType"]
if (poleType != null && poleType.toInt() == 2) {
line = bufferedReader.readLine()
continue
@ -325,8 +354,7 @@ class ImportOMDBHelper @AssistedInject constructor(
}
DataCodeEnum.OMDB_LANE_MARK_BOUNDARYTYPE.code.toInt() -> {
val boundaryType =
renderEntity.properties["boundaryType"]
val boundaryType = renderEntity.properties["boundaryType"]
if (boundaryType != null) {
when (boundaryType.toInt()) {
0, 1, 6, 8, 9 -> {
@ -339,8 +367,7 @@ class ImportOMDBHelper @AssistedInject constructor(
}
DataCodeEnum.OMDB_RDBOUND_BOUNDARYTYPE.code.toInt() -> {
val boundaryType =
renderEntity.properties["boundaryType"]
val boundaryType = renderEntity.properties["boundaryType"]
if (boundaryType != null) {
when (boundaryType.toInt()) {
0, 1, 3, 4, 5, 7, 9 -> {
@ -353,8 +380,7 @@ class ImportOMDBHelper @AssistedInject constructor(
}
DataCodeEnum.OMDB_OBJECT_STOPLOCATION.code.toInt() -> {
val locationType =
renderEntity.properties["locationType"]
val locationType = renderEntity.properties["locationType"]
if (locationType != null) {
when (locationType.toInt()) {
3, 4 -> {
@ -371,10 +397,8 @@ class ImportOMDBHelper @AssistedInject constructor(
"linkOut"
)
) {
val linkIn =
renderEntity.properties["linkIn"]
val linkOut =
renderEntity.properties["linkOut"]
val linkIn = renderEntity.properties["linkIn"]
val linkOut = renderEntity.properties["linkOut"]
if (linkIn != null && linkOut != null) {
val checkMsg = "$linkIn$linkOut"
if (resHashMap.containsKey(checkMsg)) {
@ -396,7 +420,6 @@ class ImportOMDBHelper @AssistedInject constructor(
val currentLinkPid = renderEntity.linkPid
if (!currentLinkPid.isNullOrEmpty() && currentLinkPid != "null") {
val list = currentLinkPid.split(",")
@ -419,15 +442,11 @@ class ImportOMDBHelper @AssistedInject constructor(
if (renderEntity.properties["linkList"] != null) {
val linkList =
renderEntity.properties["linkList"]
val linkList = renderEntity.properties["linkList"]
if (!linkList.isNullOrEmpty() && linkList != "null") {
val list: List<LinkList> = gson.fromJson(
linkList,
object :
TypeToken<List<LinkList>>() {}.type
linkList, object : TypeToken<List<LinkList>>() {}.type
)
m@ for (link in list) {
@ -459,15 +478,16 @@ class ImportOMDBHelper @AssistedInject constructor(
renderEntity.catchEnable = 0
}
var resultEntity = importConfig.transformProperties(renderEntity, realm)
// 对renderEntity做预处理后再保存
val resultEntity = importConfig.transformProperties(renderEntity, realm)
if (resultEntity != null) {
//对code编码需要特殊处理 存在多个属性值时渲染优先级SA>PA,存在多个属性值时渲染优先级FRONTAGE>MAIN_SIDE_A CCESS
if (currentConfig.existSubCode) {
when (renderEntity.code.toInt()) {
DataCodeEnum.OMDB_LINK_ATTRIBUTE.code.toInt() -> {
var type = renderEntity.properties["sa"]
var type = renderEntity.properties["sa"]
if (type != null && type == "1") {
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_SA.code
@ -477,16 +497,14 @@ class ImportOMDBHelper @AssistedInject constructor(
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_PA.code
} else {
type =
renderEntity.properties["frontage"]
type = renderEntity.properties["frontage"]
if (type != null && type == "1") {
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_FORNTAGE.code
renderEntity.zoomMin = 15
renderEntity.zoomMax = 17
} else {
type =
renderEntity.properties["mainSideAccess"]
type = renderEntity.properties["mainSideAccess"]
if (type != null && type == "1") {
renderEntity.code =
DataCodeEnum.OMDB_LINK_ATTRIBUTE_MAIN_SIDE_ACCESS.code
@ -496,8 +514,7 @@ class ImportOMDBHelper @AssistedInject constructor(
renderEntity.enable = 0
renderEntity.zoomMin = 15
renderEntity.zoomMax = 17
line =
bufferedReader.readLine()
line = bufferedReader.readLine()
continue
}
}
@ -509,18 +526,16 @@ class ImportOMDBHelper @AssistedInject constructor(
when (renderEntity.properties["bridgeType"]) {
"1" -> renderEntity.code =
DataCodeEnum.OMDB_BRIDGE_1.code
"2" -> renderEntity.code =
DataCodeEnum.OMDB_BRIDGE_2.code
// "3" -> renderEntity.code = DataCodeEnum.OMDB_BRIDGE_3.code
else -> DataCodeEnum.OMDB_BRIDGE.code
}
}
DataCodeEnum.OMDB_RAMP.code.toInt() -> {
//*匝道*//*
val formWay =
renderEntity.properties["formOfWay"]
/*匝道*/
val formWay = renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay.toInt()) {
93 -> renderEntity.code =
@ -548,9 +563,8 @@ class ImportOMDBHelper @AssistedInject constructor(
}
DataCodeEnum.OMDB_LINK_FORM1.code.toInt() -> {
//*道路形态1*//*
val formWay =
renderEntity.properties["formOfWay"]
/*道路形态1*/
val formWay = renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay.toInt()) {
35 -> renderEntity.code =
@ -566,9 +580,8 @@ class ImportOMDBHelper @AssistedInject constructor(
}
DataCodeEnum.OMDB_LINK_FORM2.code.toInt() -> {
//*道路形态2*//*
val formWay =
renderEntity.properties["formOfWay"]
/*道路形态2*/
val formWay = renderEntity.properties["formOfWay"]
if (formWay != null) {
when (formWay.toInt()) {
10 -> renderEntity.code =
@ -615,35 +628,29 @@ class ImportOMDBHelper @AssistedInject constructor(
DataCodeEnum.OMDB_LANE_CONSTRUCTION.code.toInt() -> {
//特殊处理空数据,渲染原则使用
val startTime =
renderEntity.properties["startTime"]
val startTime = renderEntity.properties["startTime"]
if (startTime == null || startTime == "") {
renderEntity.properties["startTime"] =
"null"
renderEntity.properties["startTime"] = "null"
}
}
}
if (renderEntity.table == DataCodeEnum.OMDB_NODE_FORM.name) {//特殊处理因为code相同使用表名判断
//过滤不需要渲染的要素
val formOfWay =
renderEntity.properties["formOfWay"]
val formOfWay = renderEntity.properties["formOfWay"]
if (formOfWay != null && formOfWay.toInt() == 30) {
renderEntity.enable = 2
renderEntity.code =
DataCodeEnum.OMDB_NODE_FORM.code
renderEntity.code = DataCodeEnum.OMDB_NODE_FORM.code
} else {
line = bufferedReader.readLine()
continue
}
} else if (renderEntity.table == DataCodeEnum.OMDB_NODE_PA.name) {//特殊处理因为code相同使用表名判断
//过滤不需要渲染的要素
val attributeType =
renderEntity.properties["attributeType"]
val attributeType = renderEntity.properties["attributeType"]
if (attributeType != null && attributeType.toInt() == 30) {
renderEntity.enable = 2
renderEntity.code =
DataCodeEnum.OMDB_NODE_PA.code
renderEntity.code = DataCodeEnum.OMDB_NODE_PA.code
} else {
line = bufferedReader.readLine()
continue
@ -651,7 +658,6 @@ class ImportOMDBHelper @AssistedInject constructor(
}
}
++insertIndex
//移除该字段,减少数据量
if (renderEntity.properties.containsKey("geometry")) {
@ -668,8 +674,7 @@ class ImportOMDBHelper @AssistedInject constructor(
if (renderEntity.linkRelation == null) {
renderEntity.linkRelation = LinkRelation()
}
renderEntity.linkRelation!!.linkPid =
renderEntity.linkPid
renderEntity.linkRelation!!.linkPid = renderEntity.linkPid
renderEntity.linkRelation!!.sNodeId =
renderEntity.properties["snodePid"]
renderEntity.linkRelation!!.eNodeId =
@ -681,102 +686,88 @@ class ImportOMDBHelper @AssistedInject constructor(
renderEntity.properties.remove("shapeList")
}
var gsonStr = gson.toJson(renderEntity.properties).toByteArray()
renderEntity.propertiesDb = DeflaterUtil.compress(gsonStr)//StrZipUtil.compress(gsonStr)
renderEntity.propertiesDb = StrZipUtil.compress(
gson.toJson(renderEntity.properties).toString()
)
listRenderEntity.add(renderEntity)
}
if (listRenderEntity.size > 50000) {
Log.e("jingo", "50000刷新")
realm.copyToRealmOrUpdate(listRenderEntity)
realm.commitTransaction()
realm.close()
listRenderEntity.clear()
insertIndex = 0
if (listRenderEntity.size > 20000) {
Log.e(
"jingo",
"安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size}"
)
if (isEmit) {
f.send(listRenderEntity)
delay(20)
} else {
realm!!.copyToRealm(listRenderEntity)
realm!!.commitTransaction()
realm!!.close()
realm = Realm.getInstance(currentInstallTaskConfig)
realm.beginTransaction()
}
listRenderEntity = mutableListOf()
//
}
line = bufferedReader.readLine()
}
// CMLog.writeLogtoFile(
// ImportOMDBHelper::class.java.name,
// "importOmdbZipFile",
// "结束===总量$elementIndex"
// )
if (isEmit) {
f.send(listRenderEntity)
delay(20)
bufferedReader.close()
} catch (e: Exception) {
CMLog.writeLogtoFile(
ImportOMDBHelper::class.java.name,
"importOmdbZipFile",
"${currentConfig.table}安装异常"
)
}
} else {
CMLog.writeLogtoFile(
ImportOMDBHelper::class.java.name,
"importOmdbZipFile",
"文件不存在"
)
}
// 1个文件发送一次flow流
emit("${processIndex}/${tableNum}")
CMLog.writeLogtoFile(
ImportOMDBHelper::class.java.name,
"importOmdbZipFile",
"${currentConfig.table}结束==$elementIndex"
)
elementIndex = 0
bufferedReader.close()
realm!!.copyToRealm(listRenderEntity)
realm!!.commitTransaction()
}
}
CMLog.writeLogtoFile(
ImportOMDBHelper::class.java.name,
"importOmdbZipFile",
"结束===总量$dataIndex"
)
realm.copyToRealmOrUpdate(listRenderEntity)
realm.commitTransaction()
realm.close()
listRenderEntity.clear()
Log.e("qj", "安装结束")
if (!isEmit) {
realm!!.close()
}
} catch (e: Exception) {
if (realm.isInTransaction) {
realm.cancelTransaction()
realm.close()
}
Log.e("jingo", "安装报错 ${currentConfig.table} ${elementIndex} ${e.message}")
throw e
}
emit("finish")
}
Log.e("jingo", "完成 ${currentConfig.table}")
}
// 获取指定数据表的列名
fun getColumns(db: SQLiteDatabase, tableName: String): List<String> {
val columns = mutableListOf<String>()
// 查询 sqlite_master 表获取指定数据表的元数据信息
val cursor = db.query(
"sqlite_master",
arrayOf("sql"),
"type='table' AND name=?",
arrayOf(tableName),
null,
null,
null
)
// 从元数据信息中解析出列名
if (cursor.moveToFirst()) {
val sql = cursor.getString(0)
val startIndex = sql.indexOf("(") + 1
val endIndex = sql.lastIndexOf(")")
val columnDefs = sql.substring(startIndex, endIndex).split(",")
for (columnDef in columnDefs) {
val columnName = columnDef.trim().split(" ")[0]
if (!columnName.startsWith("rowid", true)) { // 排除 rowid 列
columns.add(columnName)
}
}
}
cursor.close()
return columns
}
// // 获取指定数据表的列名
// fun getColumns(db: SQLiteDatabase, tableName: String): List<String> {
// val columns = mutableListOf<String>()
//
// // 查询 sqlite_master 表获取指定数据表的元数据信息
// val cursor = db.query(
// "sqlite_master",
// arrayOf("sql"),
// "type='table' AND name=?",
// arrayOf(tableName),
// null,
// null,
// null
// )
//
// // 从元数据信息中解析出列名
// if (cursor.moveToFirst()) {
// val sql = cursor.getString(0)
// val startIndex = sql.indexOf("(") + 1
// val endIndex = sql.lastIndexOf(")")
// val columnDefs = sql.substring(startIndex, endIndex).split(",")
// for (columnDef in columnDefs) {
// val columnName = columnDef.trim().split(" ")[0]
// if (!columnName.startsWith("rowid", true)) { // 排除 rowid 列
// columns.add(columnName)
// }
// }
// }
// cursor.close()
// return columns
// }
}

View File

@ -728,6 +728,7 @@ class ImportPreProcess {
* 生成车道中心线面宽度
* */
fun generateAddWidthLine(renderEntity: RenderEntity) {
var newTime = 0L
// 添加车道中心面渲染原则,根据车道宽度进行渲染
val angleReference = ReferenceEntity()
// angleReference.renderEntityId = renderEntity.id
@ -952,11 +953,8 @@ class ImportPreProcess {
private fun insertData(list: List<RealmModel>) {
realm?.let {
Log.e("qj", "子表插入==")
if (list != null && list.isNotEmpty()) {
Log.e("qj", "子表插入开始==")
it.copyToRealm(list)
Log.e("qj", "子表插入结束==")
}
}
}

View File

@ -155,9 +155,8 @@ class TaskDownloadScope(
fileNew
)
if (task != null) {
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task).collect {
Log.e("jingo", "数据安装 $it")
if (it == "finish") {
if (importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task, this)) {
// if (it == "finish") {
change(FileDownloadStatus.DONE)
Log.e("jingo", "数据安装结束")
withContext(Dispatchers.Main) {
@ -167,9 +166,9 @@ class TaskDownloadScope(
}
}
} else {
change(FileDownloadStatus.IMPORTING, it)
}
change(FileDownloadStatus.IMPORTING, "anzhuang")
}
// }
}
} catch (e: Exception) {
Log.e("jingo", "数据安装失败 ${e.toString()}")

View File

@ -81,30 +81,30 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
R.id.personal_center_menu_offline_map ->
findNavController().navigate(R.id.OfflineMapFragment)
R.id.personal_center_menu_obtain_data -> { // 生成数据根据sqlite文件生成对应的zip文件
fileChooser.openChooseFileDialog(object : FileChooserCallback() {
override fun onCancel(reason: String) {
}
@RequiresApi(Build.VERSION_CODES.N)
override fun onResult(uri: Uri) {
val file = UriUtils.uri2File(uri)
// 开始导入数据
// 656e6372797000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
CoroutineUtils.launchWithLoading(
requireContext(),
loadingMessage = "生成数据..."
) {
val importOMDBHelper: ImportOMDBHelper =
importOMDBHiltFactory.obtainImportOMDBHelper(
requireContext(),
file
)
viewModel.obtainOMDBZipData(importOMDBHelper)
}
}
})
}
// R.id.personal_center_menu_obtain_data -> { // 生成数据根据sqlite文件生成对应的zip文件
// fileChooser.openChooseFileDialog(object : FileChooserCallback() {
// override fun onCancel(reason: String) {
// }
//
// @RequiresApi(Build.VERSION_CODES.N)
// override fun onResult(uri: Uri) {
// val file = UriUtils.uri2File(uri)
// // 开始导入数据
// // 656e6372797000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
// CoroutineUtils.launchWithLoading(
// requireContext(),
// loadingMessage = "生成数据..."
// ) {
// val importOMDBHelper: ImportOMDBHelper =
// importOMDBHiltFactory.obtainImportOMDBHelper(
// requireContext(),
// file
// )
// viewModel.obtainOMDBZipData(importOMDBHelper)
// }
// }
// })
// }
R.id.personal_center_menu_import_data -> { // 导入zip数据
fileChooser.openChooseFileDialog(object : FileChooserCallback() {

View File

@ -1,17 +1,12 @@
package com.navinfo.omqs.ui.fragment.personalcenter
import android.net.Uri
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.blankj.utilcode.util.FileIOUtils
import com.blankj.utilcode.util.UriUtils
import com.blankj.utilcode.util.ZipUtils
import com.google.gson.Gson
import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.omqs.bean.ScProblemTypeBean
import com.navinfo.omqs.bean.ScRootCauseAnalysisBean
import com.navinfo.omqs.bean.ScWarningCodeBean
@ -24,7 +19,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.apache.commons.io.input.BOMInputStream
import java.io.*
import java.util.*
import javax.inject.Inject
@ -37,119 +31,119 @@ class PersonalCenterViewModel @Inject constructor(
val liveDataMessage = MutableLiveData<String>()
/**
* 导入OMDB数据
* */
@RequiresApi(Build.VERSION_CODES.N)
suspend fun obtainOMDBZipData(importOMDBHelper: ImportOMDBHelper) {
Log.d("OMQSApplication", "开始生成数据")
val gson = Gson()
val hadLinkFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK.txt")
val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
val hadLinkDirectFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_DIRECT.txt")
val hadSpeedLimitFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT.txt")
val hadSpeedLimitCondFile =
File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_COND.txt")
val hadSpeedLimitVarFile =
File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_VAR.txt")
for (tableName in listOf<String>(
"HAD_LINK", "HAD_SPEEDLIMIT", "HAD_SPEEDLIMIT_COND", "HAD_SPEEDLIMIT_VAR"
)/*listOf<String>("HAD_LINK")*/) {
importOMDBHelper.getOMDBTableData(tableName).collect {
for (map in it) {
if ("HAD_LINK" == tableName) {
// 根据HAD_Link生成json文件
val hadLink = HAD_LINK()
hadLink.LINK_PID = map["LINK_PID"].toString()
hadLink.MESH = map["MESH"].toString()
hadLink.S_NODE_PID = map["S_NODE_PID"].toString()
hadLink.E_NODE_PID = map["E_NODE_PID"].toString()
hadLink.GEOMETRY = map["GEOMETRY"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadLinkFile, gson.toJson(hadLink) + "\r", true
)
val hadLinkDirect = HAD_LINK_DIRECT()
hadLinkDirect.LINK_PID = map["LINK_PID"].toString()
hadLinkDirect.MESH = map["MESH"].toString()
hadLinkDirect.DIRECT = map["DIRECT"].toString().toInt()
hadLinkDirect.GEOMETRY = map["GEOMETRY"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadLinkDirectFile, gson.toJson(hadLinkDirect) + "\r", true
)
val hadLinkKind = HAD_LINK_KIND()
hadLinkKind.LINK_PID = map["LINK_PID"].toString()
hadLinkKind.MESH = map["MESH"].toString()
hadLinkKind.KIND = map["KIND"].toString().toInt()
hadLinkKind.GEOMETRY = map["GEOMETRY"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadLinkKindFile, gson.toJson(hadLinkKind) + "\r", true
)
} else if ("HAD_SPEEDLIMIT" == tableName) {
val hadSpeedlimit = HAD_SPEEDLIMIT()
hadSpeedlimit.SPEED_ID = map["SPEED_ID"].toString()
hadSpeedlimit.MESH = map["MESH"].toString()
hadSpeedlimit.LINK_PID = map["LINK_PID"].toString()
hadSpeedlimit.GEOMETRY = map["GEOMETRY"].toString()
hadSpeedlimit.DIRECT = map["DIRECT"].toString().toInt()
hadSpeedlimit.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
hadSpeedlimit.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
hadSpeedlimit.MIN_SPEED = map["MIN_SPEED"].toString().toInt()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadSpeedLimitFile, gson.toJson(hadSpeedlimit) + "\r", true
)
} else if ("HAD_SPEEDLIMIT_COND" == tableName) {
val hadSpeedlimitCond = HAD_SPEEDLIMIT_COND()
hadSpeedlimitCond.SPEED_COND_ID = map["SPEED_COND_ID"].toString()
hadSpeedlimitCond.MESH = map["MESH"].toString()
hadSpeedlimitCond.LINK_PID = map["LINK_PID"].toString()
hadSpeedlimitCond.GEOMETRY = map["GEOMETRY"].toString()
hadSpeedlimitCond.DIRECT = map["DIRECT"].toString().toInt()
hadSpeedlimitCond.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
hadSpeedlimitCond.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
hadSpeedlimitCond.SPEED_DEPENDENT =
map["SPEED_DEPENDENT"].toString().toInt()
hadSpeedlimitCond.VEHICLE_TYPE = map["VEHICLE_TYPE"].toString().toInt()
hadSpeedlimitCond.VALID_PERIOD = map["VALID_PERIOD"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadSpeedLimitCondFile, gson.toJson(hadSpeedlimitCond) + "\r", true
)
} else if ("HAD_SPEEDLIMIT_VAR" == tableName) {
val hadSpeedlimitVar = HAD_SPEEDLIMIT_VAR()
hadSpeedlimitVar.SPEED_VAR_ID = map["SPEED_ID"].toString()
hadSpeedlimitVar.MESH = map["MESH"].toString()
hadSpeedlimitVar.LINK_PID = map["LINK_PID"].toString()
hadSpeedlimitVar.GEOMETRY = map["GEOMETRY"].toString()
hadSpeedlimitVar.DIRECT = map["DIRECT"].toString().toInt()
hadSpeedlimitVar.LOCATION = map["LOCATION"].toString()
// 将该数据写入到对应的txt文件
FileIOUtils.writeFileFromString(
hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
)
}
}
}
}
ZipUtils.zipFiles(
mutableListOf(
hadLinkFile,
hadLinkKindFile,
hadLinkDirectFile,
hadSpeedLimitFile,
hadSpeedLimitCondFile,
hadSpeedLimitVarFile
), File(importOMDBHelper.omdbFile.parentFile, "output.zip")
)
Log.d("OMQSApplication", "生成数据完成")
}
// /**
// * 导入OMDB数据
// * */
// @RequiresApi(Build.VERSION_CODES.N)
// suspend fun obtainOMDBZipData(importOMDBHelper: ImportOMDBHelper) {
// Log.d("OMQSApplication", "开始生成数据")
// val gson = Gson()
// val hadLinkFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK.txt")
// val hadLinkKindFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_KIND.txt")
// val hadLinkDirectFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_LINK_DIRECT.txt")
// val hadSpeedLimitFile = File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT.txt")
// val hadSpeedLimitCondFile =
// File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_COND.txt")
// val hadSpeedLimitVarFile =
// File(importOMDBHelper.omdbFile.parentFile, "HAD_SPEEDLIMIT_VAR.txt")
//
// for (tableName in listOf<String>(
// "HAD_LINK", "HAD_SPEEDLIMIT", "HAD_SPEEDLIMIT_COND", "HAD_SPEEDLIMIT_VAR"
// )/*listOf<String>("HAD_LINK")*/) {
// importOMDBHelper.getOMDBTableData(tableName).collect {
// for (map in it) {
// if ("HAD_LINK" == tableName) {
// // 根据HAD_Link生成json文件
// val hadLink = HAD_LINK()
// hadLink.LINK_PID = map["LINK_PID"].toString()
// hadLink.MESH = map["MESH"].toString()
// hadLink.S_NODE_PID = map["S_NODE_PID"].toString()
// hadLink.E_NODE_PID = map["E_NODE_PID"].toString()
// hadLink.GEOMETRY = map["GEOMETRY"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadLinkFile, gson.toJson(hadLink) + "\r", true
// )
//
// val hadLinkDirect = HAD_LINK_DIRECT()
// hadLinkDirect.LINK_PID = map["LINK_PID"].toString()
// hadLinkDirect.MESH = map["MESH"].toString()
// hadLinkDirect.DIRECT = map["DIRECT"].toString().toInt()
// hadLinkDirect.GEOMETRY = map["GEOMETRY"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadLinkDirectFile, gson.toJson(hadLinkDirect) + "\r", true
// )
//
// val hadLinkKind = HAD_LINK_KIND()
// hadLinkKind.LINK_PID = map["LINK_PID"].toString()
// hadLinkKind.MESH = map["MESH"].toString()
// hadLinkKind.KIND = map["KIND"].toString().toInt()
// hadLinkKind.GEOMETRY = map["GEOMETRY"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadLinkKindFile, gson.toJson(hadLinkKind) + "\r", true
// )
// } else if ("HAD_SPEEDLIMIT" == tableName) {
// val hadSpeedlimit = HAD_SPEEDLIMIT()
// hadSpeedlimit.SPEED_ID = map["SPEED_ID"].toString()
// hadSpeedlimit.MESH = map["MESH"].toString()
// hadSpeedlimit.LINK_PID = map["LINK_PID"].toString()
// hadSpeedlimit.GEOMETRY = map["GEOMETRY"].toString()
// hadSpeedlimit.DIRECT = map["DIRECT"].toString().toInt()
// hadSpeedlimit.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
// hadSpeedlimit.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
// hadSpeedlimit.MIN_SPEED = map["MIN_SPEED"].toString().toInt()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadSpeedLimitFile, gson.toJson(hadSpeedlimit) + "\r", true
// )
// } else if ("HAD_SPEEDLIMIT_COND" == tableName) {
// val hadSpeedlimitCond = HAD_SPEEDLIMIT_COND()
// hadSpeedlimitCond.SPEED_COND_ID = map["SPEED_COND_ID"].toString()
// hadSpeedlimitCond.MESH = map["MESH"].toString()
// hadSpeedlimitCond.LINK_PID = map["LINK_PID"].toString()
// hadSpeedlimitCond.GEOMETRY = map["GEOMETRY"].toString()
// hadSpeedlimitCond.DIRECT = map["DIRECT"].toString().toInt()
// hadSpeedlimitCond.SPEED_FLAG = map["SPEED_FLAG"].toString().toInt()
// hadSpeedlimitCond.MAX_SPEED = map["MAX_SPEED"].toString().toInt()
// hadSpeedlimitCond.SPEED_DEPENDENT =
// map["SPEED_DEPENDENT"].toString().toInt()
// hadSpeedlimitCond.VEHICLE_TYPE = map["VEHICLE_TYPE"].toString().toInt()
// hadSpeedlimitCond.VALID_PERIOD = map["VALID_PERIOD"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadSpeedLimitCondFile, gson.toJson(hadSpeedlimitCond) + "\r", true
// )
// } else if ("HAD_SPEEDLIMIT_VAR" == tableName) {
// val hadSpeedlimitVar = HAD_SPEEDLIMIT_VAR()
// hadSpeedlimitVar.SPEED_VAR_ID = map["SPEED_ID"].toString()
// hadSpeedlimitVar.MESH = map["MESH"].toString()
// hadSpeedlimitVar.LINK_PID = map["LINK_PID"].toString()
// hadSpeedlimitVar.GEOMETRY = map["GEOMETRY"].toString()
// hadSpeedlimitVar.DIRECT = map["DIRECT"].toString().toInt()
// hadSpeedlimitVar.LOCATION = map["LOCATION"].toString()
// // 将该数据写入到对应的txt文件
// FileIOUtils.writeFileFromString(
// hadSpeedLimitVarFile, gson.toJson(hadSpeedlimitVar) + "\r", true
// )
// }
// }
// }
// }
// ZipUtils.zipFiles(
// mutableListOf(
// hadLinkFile,
// hadLinkKindFile,
// hadLinkDirectFile,
// hadSpeedLimitFile,
// hadSpeedLimitCondFile,
// hadSpeedLimitVarFile
// ), File(importOMDBHelper.omdbFile.parentFile, "output.zip")
// )
//
// Log.d("OMQSApplication", "生成数据完成")
// }
/**
* 导入OMDB数据
@ -158,15 +152,12 @@ class PersonalCenterViewModel @Inject constructor(
viewModelScope.launch(Dispatchers.IO) {
Log.d("OMQSApplication", "开始导入数据")
if (task != null) {
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task).collect {
Log.d("importOMDBData", it)
}
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task, this)
} else {
val newTask = TaskBean()
newTask.id = -1
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, newTask).collect {
Log.d("importOMDBData", it)
}
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, newTask, this)
}
Log.d("OMQSApplication", "导入数据完成")
}

View File

@ -214,7 +214,7 @@ public class CMLog {
if (!flag&&MYLOG_WRITE_TO_FILE) {
flag = true;
try {
Log.e("jingo", "日志写入0");
Log.e("qj", "日志写入0");
// 新建或打开日志文件
Date nowtime = new Date();
String needWriteFiel = logfile.format(nowtime);
@ -232,11 +232,11 @@ public class CMLog {
new File(Constant.USER_DATA_LOG_PATH).mkdirs();
}
File file = new File(Constant.USER_DATA_LOG_PATH, needWriteFiel + MYLOGFILEName);
Log.e("jingo", "日志写入1");
Log.e("qj", "日志写入1");
if (!file.exists())
file.createNewFile();
Log.e("jingo", "日志写入2");
Log.e("qj", "日志写入2");
FileWriter filerWriter = new FileWriter(file, true);//后面这个参数代表是不是要接上文件中原来的数据不进行覆盖
BufferedWriter bufWriter = new BufferedWriter(filerWriter);
@ -244,7 +244,7 @@ public class CMLog {
bufWriter.newLine();
bufWriter.close();
filerWriter.close();
Log.e("jingo", "日志写入结束");
Log.e("qj", "日志写入结束");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();

View File

@ -1,20 +1,14 @@
package com.navinfo.omqs.util
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.NiLocation
import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.utils.FootAndDistance
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.omqs.db.RealmOperateHelper
import io.realm.Realm
import org.oscim.core.GeoPoint
import java.time.LocalDate
import java.time.LocalDateTime
class NaviEngineNew(
private val realmOperateHelper: RealmOperateHelper,
@ -38,7 +32,6 @@ class NaviEngineNew(
geoPoint: GeoPoint,
realm:Realm
) {
// val geoPoint = GeoPoint(niLocation.latitude, niLocation.longitude)
var latestRoute: HadLinkDvoBean? = null
var lastDis = -1.0

View File

@ -49,7 +49,6 @@ class GeometryToolsKt {
}
}
}
println("YGeometry-time:" + (System.currentTimeMillis() - startTime))
}
/**
@ -93,7 +92,6 @@ class GeometryToolsKt {
}
}
}
println("XGeometry-time:" + (System.currentTimeMillis() - startTime))
}
fun getMasterPoint(wkt: String): String {

2
vtm

@ -1 +1 @@
Subproject commit 9e0cc6dcdce04d1082ed6459e8810d6329e8cfdc
Subproject commit c046e788f5c739612a31c308639fca2de639669a