From ab266bce3e68f478db44294e35157821ca33ef7c Mon Sep 17 00:00:00 2001
From: xiaoyan <xiaoyan159@163.com>
Date: Wed, 6 Sep 2023 09:31:07 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9realm=E6=8F=92?=
 =?UTF-8?q?=E5=85=A5=E5=A4=A7=E9=87=8F=E6=95=B0=E6=8D=AEOOM=E9=97=AE?=
 =?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../com/navinfo/omqs/db/ImportOMDBHelper.kt   | 60 +++++++++----------
 .../com/navinfo/omqs/db/ImportPreProcess.kt   | 34 +++++------
 2 files changed, 46 insertions(+), 48 deletions(-)

diff --git a/app/src/main/java/com/navinfo/omqs/db/ImportOMDBHelper.kt b/app/src/main/java/com/navinfo/omqs/db/ImportOMDBHelper.kt
index b3075f93..c7b0cbdd 100644
--- a/app/src/main/java/com/navinfo/omqs/db/ImportOMDBHelper.kt
+++ b/app/src/main/java/com/navinfo/omqs/db/ImportOMDBHelper.kt
@@ -177,7 +177,7 @@ class ImportOMDBHelper @AssistedInject constructor(
                                 it.name == currentConfig.table
                             }
                             // 将listResult数据插入到Realm数据库中
-                            val listResult = mutableListOf<RenderEntity>()
+//                            val listResult = mutableListOf<RenderEntity>()
                             currentConfig?.let {
                                 val list = FileIOUtils.readFile2List(txtFile, "UTF-8")
                                 Log.d("ImportOMDBHelper", "开始解析:${txtFile?.name}")
@@ -332,28 +332,28 @@ class ImportOMDBHelper @AssistedInject constructor(
                                             }
                                         }
 
-                                        //交限增加相同LinkIn与LinkOut过滤原则
-                                        if (renderEntity.code == DataCodeEnum.OMDB_RESTRICTION.code) {
-                                            if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
-                                                    "linkOut"
-                                                )
-                                            ) {
-                                                var linkIn = renderEntity.properties["linkIn"]
-                                                var linkOut = renderEntity.properties["linkOut"]
-                                                if (linkIn != null && linkOut != null) {
-                                                    var checkMsg = "$linkIn$linkOut"
-                                                    if (resHashMap.containsKey(checkMsg)) {
-                                                        Log.e(
-                                                            "qj",
-                                                            "${renderEntity.name}==过滤交限linkin与linkout相同且存在多条数据"
-                                                        )
-                                                        continue
-                                                    } else {
-                                                        resHashMap.put(checkMsg, renderEntity)
-                                                    }
-                                                }
-                                            }
-                                        }
+//                                        //交限增加相同LinkIn与LinkOut过滤原则
+//                                        if (renderEntity.code == DataCodeEnum.OMDB_RESTRICTION.code) {
+//                                            if (renderEntity.properties.containsKey("linkIn") && renderEntity.properties.containsKey(
+//                                                    "linkOut"
+//                                                )
+//                                            ) {
+//                                                var linkIn = renderEntity.properties["linkIn"]
+//                                                var linkOut = renderEntity.properties["linkOut"]
+//                                                if (linkIn != null && linkOut != null) {
+//                                                    var checkMsg = "$linkIn$linkOut"
+//                                                    if (resHashMap.containsKey(checkMsg)) {
+//                                                        Log.e(
+//                                                            "qj",
+//                                                            "${renderEntity.name}==过滤交限linkin与linkout相同且存在多条数据"
+//                                                        )
+//                                                        continue
+//                                                    } else {
+//                                                        resHashMap.put(checkMsg, renderEntity)
+//                                                    }
+//                                                }
+//                                            }
+//                                        }
 
                                         //遍历判断只显示与任务Link相关的任务数据
                                         if (currentConfig.checkLinkId) {
@@ -619,17 +619,17 @@ class ImportOMDBHelper @AssistedInject constructor(
                                                     renderEntity.properties["startTime"] = "null"
                                                 }
                                             }
-                                            listResult.add(renderEntity)
+//                                            listResult.add(renderEntity)
                                             realm.insert(renderEntity)
                                         }
                                     }
                                 }
                             }
-                            // 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
-                            if (currentConfig.table == "OMDB_RD_LINK") {
-                                importConfig.preProcess.cacheRdLink =
-                                    listResult.associateBy { it.properties["linkPid"] }
-                            }
+//                            // 如果当前解析的是OMDB_RD_LINK数据,将其缓存在预处理类中,以便后续处理其他要素时使用
+//                            if (currentConfig.table == "OMDB_RD_LINK") {
+//                                importConfig.preProcess.cacheRdLink =
+//                                    listResult.associateBy { it.properties["linkPid"] }
+//                            }
                             realm.commitTransaction()
                             // 1个文件发送一次flow流
                             emit("${++processIndex}/${tableNum}")
@@ -637,8 +637,6 @@ class ImportOMDBHelper @AssistedInject constructor(
                     } catch (e: Exception) {
                         realm.cancelTransaction()
                         throw e
-                    } finally {
-                        realm.close()
                     }
                 }
                 emit("finish")
diff --git a/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt b/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt
index 276e76f8..cf2396e8 100644
--- a/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt
+++ b/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt
@@ -20,23 +20,23 @@ class ImportPreProcess {
     val defaultTranslateDistance = 3.0
     val testFlag:Boolean = true
     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
-            }
-        }
+//        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
     }