caiaf 4 rokov pred
rodič
commit
d9bebca55a

+ 5 - 2
datacenter/src/main/kotlin/com/persagy/server/datacenter/models/wrapperobj/ClassCodeEnum.kt

@@ -16,13 +16,16 @@ enum class ClassCodeEnum(val cname: String,val value: Int) {
     ACATAH("空调机组",1),
     ACATFU("新风机组",1);
     companion object {
-        fun toSourceList(value: Int): List<String> {
+        fun toSourceList(value: Int?): List<String> {
             val list = ArrayList<String>() //Lists.newArrayList()其实和new ArrayList()几乎一模
             //  一样, 唯一它帮你做的(其实是javac帮你做的), 就是自动推导(不是"倒")尖括号里的数据类型.
             for (classCodeEnum in ClassCodeEnum.values()) {
-                if(classCodeEnum.value == value){
+                if(value == null){
                     list.add(classCodeEnum.name)
+                }else if(classCodeEnum.value == value){
+                        list.add(classCodeEnum.name)
                 }
+
             }
             return list
         }

+ 40 - 16
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/CalcSpecialService.kt

@@ -26,6 +26,7 @@
 
 package com.persagy.server.datacenter.services.relation_calc
 
+import com.persagy.base.extensions.toJson
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
@@ -290,15 +291,16 @@ open class CalcSpecialService {
                     //拿到所属id
                     val belong = connector.belongBimId
                     if(belong != null){
+                        eqBelongSet.add(belong)
                         //如果连接件有连接
-                        if (connector.connectedIds!!.size > 0 && belong != null) {
+                        if (connector.connectedIds!!.size > 0) {
                             val revitId = connector!!.connectedIds?.get(0)
                             var currentConnector = connectorMap[revitId!!]
                             val cBelong = currentConnector?.belongBimId
                             if (cBelong != null) {
-                                if(belongType == "Equipment"){
-                                    eqBelongSet.add(belong)
-                                }
+//                                if(belongType == "Equipment"){
+//                                    eqBelongSet.add(belong)
+//                                }
 
                                 if (belongMap.containsKey(belong)) {
                                     val belongs = belongMap[belong]!!
@@ -307,7 +309,11 @@ open class CalcSpecialService {
                                 } else {
                                     belongMap[belong] = hashSetOf(cBelong)
                                 }
+                            }else{
+                                belongMap[belong] = HashSet()
                             }
+                        }else {
+                            belongMap[belong] = HashSet()
                         }
                     }
                 }
@@ -316,12 +322,13 @@ open class CalcSpecialService {
                 var cBlockId = 0
                 val fBlockMap = HashMap<Int,HashSet<String>>()
 //                val dBlockMap = HashMap<Int,HashSet<String>>()
-                val enumList = ClassCodeEnum.toSourceList(1)
+                val enumList = ClassCodeEnum.toSourceList(null)
                 var fSet: HashSet<String>? = null
                 var dSet: HashSet<String>
+                println(eqBelongSet.size)
                 for (key in eqBelongSet) {
                     val e1 = dcEquipMap[key]
-                    if(e1 == null || enumList.contains(e1.classCode)){
+                    if(e1 == null || !enumList.contains(e1.classCode)){
                         continue
                     }
 
@@ -333,9 +340,13 @@ open class CalcSpecialService {
                     for (s in dSet!!) {
                         if(typeMap[s] == "Equipment" && key != s){
                             val e2 = dcEquipMap[s]
-                            if(e2 == null){
+                            if(e2 == null || !enumList.contains(e2.classCode)){
+                                continue
+                            }
+                            if(e1.classCode == e2.classCode){
                                 continue
                             }
+
                             val connectedBlock = ConnectedBlock()
                             connectedBlock.id1 = e1.id!!
                             connectedBlock.id2 = e2.id!!
@@ -357,6 +368,12 @@ open class CalcSpecialService {
 
                         }
                     }
+//                    if(listOf("Eq4403070003129ce8d657c94c648d2d164ccfc6802c",
+//                                    "Eq4403070003db010203b5e54a0e8e4de56234cb6ac9",
+//                                    "Eq4403070003666459bd6a7e434f8c091392bada823a",
+//                                    "Eq4403070003956fbc1b234a4007bdce0653ae7faba2").contains(e1.id!!)){
+//                        fSet = fullDist(HashSet(belongSet),belongMap)
+//                    }
 
                     for (block in fBlockMap.keys) {
                         val set = fBlockMap[block]!!
@@ -367,15 +384,24 @@ open class CalcSpecialService {
                         }
                     }
                     if(fSet == null){
-                        fSet = fullDist(HashSet(belongSet),belongMap,typeMap)
+                        fSet = fullDist(HashSet(belongSet),belongMap)
                         fBlockId ++
                         cBlockId = fBlockId
-                        fBlockMap[cBlockId] = fSet
+                        fBlockMap[cBlockId] = HashSet(fSet)
+                        if(cBlockId == 1){
+                            println(fBlockMap[cBlockId]!!.toJson())
+                        }
                     }
+//                    fSet = fullDist(HashSet(belongSet),belongMap)
+//                    println(fSet.contains(key))
+//                    println(fSet.size)
                     for (s in fSet!!) {
                         if(typeMap[s] == "Equipment" && key != s){
                             val e2 = dcEquipMap[s]
-                            if(e2 == null){
+                            if(e2 == null || !enumList.contains(e2.classCode)){
+                                continue
+                            }
+                            if(e1.classCode == e2.classCode){
                                 continue
                             }
 
@@ -499,14 +525,13 @@ open class CalcSpecialService {
 //        }
 //    }
 
-    fun fullDist(list: HashSet<String>, belongMap: HashMap<String,HashSet<String>>,typeMap: HashMap<String,String>): HashSet<String>{
+    fun fullDist(list: HashSet<String>, belongMap: HashMap<String,HashSet<String>>): HashSet<String>{
         val beforeList = HashSet<String>(list)
-        var belongs: HashSet<String>
         for (belong in beforeList) {
             if(belongMap[belong] == null){
                 continue
             }
-            belongs =  belongMap[belong]!!
+            val belongs =  HashSet<String>(belongMap[belong]!!)
 //            if(typeMap[belong] != "Equipment"){
 //                directList.addAll(belongs)
 //            }
@@ -515,18 +540,17 @@ open class CalcSpecialService {
         if(beforeList.containsAll(list)){
             return list
         }else{
-            return fullDist(list,belongMap,typeMap)
+            return fullDist(list,belongMap)
         }
     }
 
     fun directDist(directList:HashSet<String>, belongMap: HashMap<String,HashSet<String>>,typeMap: HashMap<String,String>): HashSet<String>{
         val beforeList = HashSet<String>(directList)
-        var belongs: HashSet<String>
         for (belong in beforeList) {
             if(belongMap[belong] == null){
                 continue
             }
-            belongs =  belongMap[belong]!!
+            val belongs =  HashSet<String>(belongMap[belong]!!)
             if(typeMap[belong] != "Equipment"){
                 directList.addAll(belongs)
             }