fix: 修改数据安装事务提交机制
This commit is contained in:
@@ -168,14 +168,15 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
|
|
||||||
// 遍历解压后的文件,读取该数据返回
|
// 遍历解压后的文件,读取该数据返回
|
||||||
for (importConfig in importConfigList) {
|
for (importConfig in importConfigList) {
|
||||||
|
val realm = Realm.getDefaultInstance()
|
||||||
try {
|
try {
|
||||||
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
for ((index, currentEntry) in importConfig.tableMap.entries.withIndex()) {
|
||||||
|
realm.beginTransaction()
|
||||||
val currentConfig = currentEntry.value
|
val currentConfig = currentEntry.value
|
||||||
val txtFile = unZipFiles.find {
|
val txtFile = unZipFiles.find {
|
||||||
it.name == currentConfig.table
|
it.name == currentConfig.table
|
||||||
}
|
}
|
||||||
// 将listResult数据插入到Realm数据库中
|
// 将listResult数据插入到Realm数据库中
|
||||||
val realm = Realm.getDefaultInstance()
|
|
||||||
val listResult = mutableListOf<RenderEntity>()
|
val listResult = mutableListOf<RenderEntity>()
|
||||||
currentConfig?.let {
|
currentConfig?.let {
|
||||||
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
|
||||||
@@ -619,24 +620,25 @@ class ImportOMDBHelper @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
listResult.add(renderEntity)
|
listResult.add(renderEntity)
|
||||||
|
realm.insert(renderEntity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 1个文件发送一次flow流
|
|
||||||
emit("${++processIndex}/${tableNum}")
|
|
||||||
realm.beginTransaction()
|
|
||||||
realm.insert(listResult)
|
|
||||||
realm.commitTransaction()
|
|
||||||
realm.close()
|
|
||||||
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
// 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
|
||||||
if (currentConfig.table == "OMDB_RD_LINK") {
|
if (currentConfig.table == "OMDB_RD_LINK") {
|
||||||
importConfig.preProcess.cacheRdLink =
|
importConfig.preProcess.cacheRdLink =
|
||||||
listResult.associateBy { it.properties["linkPid"] }
|
listResult.associateBy { it.properties["linkPid"] }
|
||||||
}
|
}
|
||||||
|
realm.commitTransaction()
|
||||||
|
// 1个文件发送一次flow流
|
||||||
|
emit("${++processIndex}/${tableNum}")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
realm.cancelTransaction()
|
||||||
throw e
|
throw e
|
||||||
|
} finally {
|
||||||
|
realm.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit("finish")
|
emit("finish")
|
||||||
|
|||||||
2
vtm
2
vtm
Submodule vtm updated: 985dc0a0d5...a087521b6e
Reference in New Issue
Block a user