Browse Source

管网连接计算

caiaf 4 years ago
parent
commit
5ca06605b8
20 changed files with 293 additions and 137 deletions
  1. 1 1
      data-core/src/main/kotlin/com/persagy/server/datacenter/datacenter/models/entities/graphtype/block/ConnectedBlock.kt
  2. 2 0
      data-core/src/main/kotlin/com/persagy/server/datacenter/datacenter/models/entities/graphtype/block/ConnectedBlockFamilyItem.kt
  3. 2 2
      datacenter/src/main/kotlin/com/persagy/server/datacenter/mappers/ICalcSpecialMapper.kt
  4. 2 2
      datacenter/src/main/kotlin/com/persagy/server/datacenter/mappers/IRelationCalcMapper.kt
  5. 0 0
      datacenter/src/main/kotlin/com/persagy/server/datacenter/models/entities/BaseComponent.kt
  6. 2 2
      datacenter/src/main/kotlin/com/persagy/server/models/entities/Connector.kt
  7. 0 0
      datacenter/src/main/kotlin/com/persagy/server/datacenter/models/entities/Door.kt
  8. 1 1
      datacenter/src/main/kotlin/com/persagy/server/models/entities/Equipment.kt
  9. 1 1
      datacenter/src/main/kotlin/com/persagy/server/models/entities/Parameter.kt
  10. 0 0
      datacenter/src/main/kotlin/com/persagy/server/datacenter/models/entities/WindowDoorBase.kt
  11. 2 2
      datacenter/src/main/kotlin/com/persagy/server/models/service/BaseDataService.kt
  12. 32 0
      datacenter/src/main/kotlin/com/persagy/server/datacenter/models/wrapperobj/ClassCodeEnum.kt
  13. 2 2
      datacenter/src/main/kotlin/com/persagy/server/models/object/NetWork.kt
  14. 1 1
      datacenter/src/main/kotlin/com/persagy/server/models/object/TwicePoint.kt
  15. 176 72
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/CalcSpecialService.kt
  16. 1 2
      datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/CommonService.kt
  17. 1 1
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/MepSystemCalcService.kt
  18. 64 17
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/RelationCalcService.kt
  19. 3 3
      datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/RelationCalcController.kt
  20. 0 28
      datacenter/src/main/kotlin/com/persagy/server/models/object/ClassCodeEnum.kt

+ 1 - 1
data-core/src/main/kotlin/com/persagy/server/datacenter/datacenter/models/entities/graphtype/block/ConnectedBlock.kt

@@ -24,7 +24,7 @@
  * *********************************************************************************************************************
  */
 
-package com.persagy.server.datacenter.models.entities.graphtype.block
+package com.persagy.server.datacenter.datacenter.models.entities.graphtype.block
 
 import com.persagy.server.datacenter.models.entities.base.RBaseInfo
 import io.swagger.v3.oas.annotations.media.Schema

+ 2 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/datacenter/models/entities/graphtype/block/ConnectedBlockFamilyItem.kt

@@ -120,4 +120,6 @@ open class ConnectedBlockFamilyItem : RBaseInfo() {
     @Column(name = "is_source")
     var isSource: Boolean? = null
 
+
+
 }

+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/datacenter/mappers/ICalcSpecialMapper.kt

@@ -27,7 +27,7 @@
 package com.persagy.server.mappers
 
 import com.persagy.server.datacenter.utils.JsonTypeHandler
-import com.persagy.server.models.entities.Connector
+import com.persagy.server.datacenter.models.entities.Connector
 import org.apache.ibatis.annotations.Mapper
 import org.apache.ibatis.annotations.Result
 import org.apache.ibatis.annotations.Results
@@ -75,7 +75,7 @@ interface ICalcSpecialMapper {
             "when 'JoinObject' then 3 " +
             "when 'Other' then 4 " +
             "when 'Pipe' then 5 " +
-            "when 'FlexPipe' then 6" +
+            "when 'FlexPipe' then 6 " +
             "when 'Duct' then 7 " +
             "when 'FlexDuct' then 8 " +
             "end asc")

+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/datacenter/mappers/IRelationCalcMapper.kt

@@ -77,8 +77,8 @@ interface IRelationCalcMapper {
      *@param projectId 项目id
      */
     // @Select(" SELECT * from public.f_rel_eq2sp(#{tables},#{outTables},#{projectId},#{sign1},#{sign2}) ")
-    @Select("select public.f_rel_calc('rel_eq2sp', #{projectId}, 'zone_space_base','relationship.r_eq2sp', 2, 2)")
-    fun calcEq2Sp( projectId: String): Int?
+    @Select("select public.f_rel_calc('rel_eq2sp', #{projectId}, 'zone_space_base','relationship.r_eq2sp', 2, 2,#{graphCode})")
+    fun calcEq2Sp( projectId: String,graphCode: String): Int?
 
 //    /**
 //     * 删除关联业务空间

datacenter/src/main/kotlin/com/persagy/server/models/entities/BaseComponent.kt → datacenter/src/main/kotlin/com/persagy/server/datacenter/models/entities/BaseComponent.kt


+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/models/entities/Connector.kt

@@ -1,4 +1,4 @@
-package com.persagy.server.models.entities
+package com.persagy.server.datacenter.models.entities
 
 import cn.sagacloud.server.algorithm.models.entities.BaseComponent
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties
@@ -96,7 +96,7 @@ class Connector : BaseComponent(),Cloneable{
     var belongBimId: String? = null
 
     @Override
-    public override fun clone():Connector{
+    public override fun clone(): Connector {
         return super.clone() as Connector
     }
 

datacenter/src/main/kotlin/com/persagy/server/models/entities/Door.kt → datacenter/src/main/kotlin/com/persagy/server/datacenter/models/entities/Door.kt


+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/models/entities/Equipment.kt

@@ -18,7 +18,7 @@
  * ********************************************************************************************************************
  */
 
-package com.persagy.server.models.entities
+package com.persagy.server.datacenter.models.entities
 
 import cn.sagacloud.server.algorithm.models.entities.BaseComponent
 import com.alibaba.fastjson.annotation.JSONField

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/models/entities/Parameter.kt

@@ -1,4 +1,4 @@
-package com.persagy.server.models.entities
+package com.persagy.server.datacenter.models.entities
 
 import com.alibaba.fastjson.annotation.JSONField
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties

datacenter/src/main/kotlin/com/persagy/server/models/entities/WindowDoorBase.kt → datacenter/src/main/kotlin/com/persagy/server/datacenter/models/entities/WindowDoorBase.kt


+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/models/service/BaseDataService.kt

@@ -1,8 +1,8 @@
-package com.persagy.server.models.service
+package com.persagy.server.datacenter.models.service
 
 import cn.sagacloud.server.algorithm.models.entities.Door
 import com.persagy.mybatis.SMybatisDao
-import com.persagy.server.models.entities.Connector
+import com.persagy.server.datacenter.models.entities.Connector
 import com.persagy.service.SObjectService
 
 object BaseDataService {

+ 32 - 0
datacenter/src/main/kotlin/com/persagy/server/datacenter/models/wrapperobj/ClassCodeEnum.kt

@@ -0,0 +1,32 @@
+package com.persagy.server.datacenter.models.wrapperobj
+
+import java.util.*
+
+
+/**
+ *
+ * @author  Cainga
+ * @date  2021/2/24 10:32
+ */
+enum class ClassCodeEnum(val cname: String,val value: Int) {
+    ACVTIO("通风风口",0),
+    FFSCIO("排烟风口",0),
+    ACATIO("空调风口",0),
+    ACVTSF("通风风机",1),
+    ACATAH("空调机组",1),
+    ACATFU("新风机组",1);
+    companion object {
+        fun toSourceList(value: Int): List<String> {
+            val list = ArrayList<String>() //Lists.newArrayList()其实和new ArrayList()几乎一模
+            //  一样, 唯一它帮你做的(其实是javac帮你做的), 就是自动推导(不是"倒")尖括号里的数据类型.
+            for (classCodeEnum in ClassCodeEnum.values()) {
+                if(classCodeEnum.value == value){
+                    list.add(classCodeEnum.name)
+                }
+            }
+            return list
+        }
+    }
+
+
+}

+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/models/object/NetWork.kt

@@ -1,4 +1,4 @@
-package com.persagy.server.models.`object`
+package com.persagy.server.datacenter.models.wrapperobj
 
 /**
  *
@@ -9,7 +9,7 @@ open class NetWork {
 
     var fullConnectors: HashSet<String>? = null
 
-    constructor(fullConnectors: HashSet<String>?, directConnectors: HashSet<String>?) {
+    constructor(fullConnectors: HashSet<String>?, directConnectors: HashSet<String>) {
         this.fullConnectors = fullConnectors
         this.directConnectors = directConnectors
     }

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/models/object/TwicePoint.kt

@@ -1,4 +1,4 @@
-package com.persagy.server.models.`object`
+package com.persagy.server.datacenter.models.wrapperobj
 
 /**
  *

+ 176 - 72
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/CalcSpecialService.kt

@@ -29,11 +29,13 @@ package com.persagy.server.datacenter.services.relation_calc
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
-import com.persagy.server.datacenter.models.entities.graphtype.block.ConnectedBlock
+import com.persagy.server.datacenter.datacenter.models.entities.graphtype.block.ConnectedBlock
 import com.persagy.server.datacenter.wanda.rel.REq2Eq
 import com.persagy.server.mappers.ICalcSpecialMapper
-import com.persagy.server.models.`object`.NetWork
-import com.persagy.server.models.entities.Connector
+import com.persagy.server.datacenter.models.entities.Connector
+import com.persagy.server.datacenter.models.wrapperobj.ClassCodeEnum
+import com.persagy.server.datacenter.services.objects.EquipmentService
+import com.persagy.server.datacenter.wanda.obj.Equipment
 import com.persagy.server.services.assistant.RUpDateEquipAndSapceService
 import com.persagy.server.services.objects.FloorService
 import com.persagy.server.utils.IdUtils
@@ -255,39 +257,24 @@ open class CalcSpecialService {
     fun calcNetworks(projectId: String,buildingId: String): SBaseResponse{
         val floors = FloorService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId),SFilter.eq("id","Fl440307000355ee6382da6d42cf87f19551cc4b4e60")).exec()
         val connectedBlocks = ArrayList<ConnectedBlock>()
-//        val connectorList = listOf("Equipment","JoinObject")
         for (floor in floors) {
             if (!floor.modelId.isNullOrEmpty()) {
                 val connectors = mapper.connectorOrder(floor.modelId!!)
-//                val dcEquipments = EquipmentService.select(SFilter.eq("projectId",projectId), SFilter.eq("floorId",floor.id!!)).exec()
-//                val dcEquipMap = HashMap<String,Equipment>(1024)
-//                for (equipment in dcEquipments) {
-//                    if(!equipment.bimId.isNullOrEmpty()){
-//                        dcEquipMap[equipment.bimId!!] = equipment
-//                    }
-//
-//                }
+                val dcEquipments = EquipmentService.select(SFilter.eq("projectId",projectId), SFilter.eq("floorId",floor.id!!)).exec()
+                val dcEquipMap = HashMap<String, Equipment>(1024)
+                for (equipment in dcEquipments) {
+                    if(!equipment.bimId.isNullOrEmpty()){
+                        dcEquipMap[equipment.bimId!!] = equipment
+                    }
 
+                }
 
-                val equipmentsConnector = ArrayList<Connector>()
-//                val map = HashMap<String, ArrayList<Connector>>(10000)
                 val connectorMap = HashMap<String, Connector>(100000)
-                val typeMap = HashMap<String, String>(10000)
+                val typeMap = HashMap<String, String>(20000)
                 for (connector in connectors) {
                     connectorMap[connector.revitId!!] = connector
-                    if (connector.belongType == "Equipment") {
-                        equipmentsConnector.add(connector)
-                    }
 
-                    val belong = connector.belong ?: continue
-                    //                    if (map.containsKey(belong)) {
-//                        val connectorss = map[belong]!!
-//                        connectorss.add(connector)
-//                        map[belong] = connectorss
-//
-//                    } else {
-//                        map[belong] = arrayListOf(connector)
-//                    }
+                    val belong = connector.belongBimId ?: continue
                     val belongType = connector.belongType
                     if (belongType != null) {
                         typeMap[belong] = belongType
@@ -295,44 +282,63 @@ open class CalcSpecialService {
 
                 }
                 val belongMap = HashMap<String, HashSet<String>>()
-
+                val eqBelongSet = HashSet<String>()
                 //遍历连接件
                 for (connector in connectors) {
                     //拿到所属类
                     val belongType = connector.belongType
                     //拿到所属id
-                    val belong = connector.belong
-
-
-//                    //如果连接件有连接
-                    if (connector.connectedIds!!.size > 0 && belong != null) {
-                        val revitId = connector!!.connectedIds?.get(0)
-                        var currentConnector = connectorMap[revitId!!]
-                        val cBelong = currentConnector?.belong
-                        if (cBelong != null) {
-
-                            if (belongMap.containsKey(belong)) {
-                                val belongs = belongMap[belong]!!
-                                belongs.add(cBelong)
-                                belongMap[belong] = belongs
-                            } else {
-                                belongMap[belong] = hashSetOf(cBelong)
+                    val belong = connector.belongBimId
+                    if(belong != null){
+                        //如果连接件有连接
+                        if (connector.connectedIds!!.size > 0 && belong != null) {
+                            val revitId = connector!!.connectedIds?.get(0)
+                            var currentConnector = connectorMap[revitId!!]
+                            val cBelong = currentConnector?.belongBimId
+                            if (cBelong != null) {
+                                if(belongType == "Equipment"){
+                                    eqBelongSet.add(belong)
+                                }
+
+                                if (belongMap.containsKey(belong)) {
+                                    val belongs = belongMap[belong]!!
+                                    belongs.add(cBelong)
+                                    belongMap[belong] = belongs
+                                } else {
+                                    belongMap[belong] = hashSetOf(cBelong)
+                                }
                             }
                         }
                     }
                 }
-                for (key in belongMap.keys) {
-                    if(typeMap[key] != "Equipment"){
+                var fBlockId: Int =0
+                var dBlockId: Int =0
+                var cBlockId = 0
+                val fBlockMap = HashMap<Int,HashSet<String>>()
+//                val dBlockMap = HashMap<Int,HashSet<String>>()
+                val enumList = ClassCodeEnum.toSourceList(1)
+                var fSet: HashSet<String>? = null
+                var dSet: HashSet<String>
+                for (key in eqBelongSet) {
+                    val e1 = dcEquipMap[key]
+                    if(e1 == null || enumList.contains(e1.classCode)){
                         continue
                     }
+
                     val belongSet = belongMap[key]!!
-                    val newWork = dist(belongSet,belongSet, belongMap,typeMap,belongSet)
-                    for (s in newWork.fullConnectors!!) {
-                        if(typeMap[s] == "Equipment" && key != s){
 
+                    dSet = directDist(HashSet(belongSet),belongMap,typeMap)
+                    dBlockId ++
+
+                    for (s in dSet!!) {
+                        if(typeMap[s] == "Equipment" && key != s){
+                            val e2 = dcEquipMap[s]
+                            if(e2 == null){
+                                continue
+                            }
                             val connectedBlock = ConnectedBlock()
-                            connectedBlock.id1 = key
-                            connectedBlock.id2 = s
+                            connectedBlock.id1 = e1.id!!
+                            connectedBlock.id2 = e2.id!!
                             connectedBlock.type1 = "Equipment"
                             connectedBlock.type2 = "Equipment"
                             connectedBlock.modelId1 = floor.modelId
@@ -341,21 +347,42 @@ open class CalcSpecialService {
 //                                connectedBlock.mepSystemType = connector.mepSystemType
                             connectedBlock.projectId = projectId
                             connectedBlock.buildingId = buildingId
-                            connectedBlock.depth = 1
-//                                connectedBlock.typeCode1 = e1?.classCode
-//                                connectedBlock.typeCode2 = e2?.classCode
+                            connectedBlock.depth = 0
+                            connectedBlock.blockId = dBlockId.toString()
+                            connectedBlock.typeCode1 = e1?.classCode
+                            connectedBlock.typeCode2 = e2?.classCode
                             if (!connectedBlocks.contains(connectedBlock)) {
                                 connectedBlocks.add(connectedBlock)
                             }
 
                         }
                     }
-                    for (s in newWork.directConnectors!!) {
+
+                    for (block in fBlockMap.keys) {
+                        val set = fBlockMap[block]!!
+                        if(set.contains(key)){
+                            fSet = set
+                            cBlockId = block
+                            break
+                        }
+                    }
+                    if(fSet == null){
+                        fSet = fullDist(HashSet(belongSet),belongMap,typeMap)
+                        fBlockId ++
+                        cBlockId = fBlockId
+                        fBlockMap[cBlockId] = fSet
+                    }
+                    for (s in fSet!!) {
                         if(typeMap[s] == "Equipment" && key != s){
+                            val e2 = dcEquipMap[s]
+                            if(e2 == null){
+                                continue
+                            }
 
                             val connectedBlock = ConnectedBlock()
-                            connectedBlock.id1 = key
-                            connectedBlock.id2 = s
+
+                            connectedBlock.id1 = e1.id!!
+                            connectedBlock.id2 = e2.id!!
                             connectedBlock.type1 = "Equipment"
                             connectedBlock.type2 = "Equipment"
                             connectedBlock.modelId1 = floor.modelId
@@ -364,15 +391,41 @@ open class CalcSpecialService {
 //                                connectedBlock.mepSystemType = connector.mepSystemType
                             connectedBlock.projectId = projectId
                             connectedBlock.buildingId = buildingId
-                            connectedBlock.depth = 0
-//                                connectedBlock.typeCode1 = e1?.classCode
-//                                connectedBlock.typeCode2 = e2?.classCode
+                            connectedBlock.depth = 1
+                            connectedBlock.blockId = cBlockId.toString()
+                            connectedBlock.typeCode1 = e1?.classCode
+                            connectedBlock.typeCode2 = e2?.classCode
                             if (!connectedBlocks.contains(connectedBlock)) {
                                 connectedBlocks.add(connectedBlock)
                             }
 
                         }
                     }
+//                    for (block in dBlockMap.keys) {
+//                        val set = dBlockMap[block]!!
+//                        if(set.contains(key)){
+//                            dSet = set
+//                            cBlockId = block
+//                            break
+//                        }
+//                    }
+//                    if(dSet == null){
+//                        dSet = directDist(HashSet(belongSet),belongMap,typeMap)
+//                        dBlockId ++
+//                        cBlockId = dBlockId
+//                        dBlockMap[cBlockId] = dSet
+//                    }
+
+
+//                    val newWork = dist(ArrayList(belongSet),ArrayList(belongSet), belongMap,typeMap,ArrayList(belongSet),0)
+//                    val newWork = dist(HashSet(belongSet),HashSet(belongSet), belongMap,typeMap)
+//                    newWork.fullConnectors!!.removeAll(newWork.directConnectors!!)
+//                    for (s in newWork.fullConnectors!!) {
+//
+//                    }
+//                    for (s in newWork.directConnectors!!) {
+//
+//                    }
 
                 }
             }
@@ -387,12 +440,14 @@ open class CalcSpecialService {
 
     }
 
+
+
     /**
      * @Description:递归查找连接
      * @Param:
      * @Return:
      */
-     fun searchConnector(connector: Connector,currentConnector: Connector,map: HashMap<String,ArrayList<Connector>>,connectorMap: HashMap<String,Connector>): Connector?{
+     fun searchConnector(connector: Connector, currentConnector: Connector, map: HashMap<String,ArrayList<Connector>>, connectorMap: HashMap<String, Connector>): Connector?{
         val belong = currentConnector.belong ?: return null
         if(currentConnector.belongType == "Equipment" && currentConnector != connector){
             return currentConnector
@@ -412,25 +467,74 @@ open class CalcSpecialService {
         }
      }
 
-    fun dist(list: HashSet<String>,directList:HashSet<String>, belongMap: HashMap<String,HashSet<String>>,typeMap: HashMap<String,String>,newList: HashSet<String>): NetWork{
-//        val list = belongMap[key]!!
-//                    val connectList = ArrayList<String>()
-//        while(list)
+//    fun dist(list: ArrayList<String>,directList:ArrayList<String>, belongMap: HashMap<String,HashSet<String>>,typeMap: HashMap<String,String>,beforeList: ArrayList<String>,index: Int): NetWork {
+//        var belong: String? = null
+//        for(i in index until beforeList.size){
+//            belong = beforeList[i]
+//            if(belongMap[belong] != null){
+//                val belongList = belongMap[belong]!!
+//                for (s in belongList) {
+////                    if(!directList.contains(s)){
+////
+////                    }
+//                    if(!list.contains(s)){
+//                        list.add(s)
+//                        if(typeMap[belong] != "Equipment"){
+//                            directList.add(s)
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//
+//        return if(beforeList.containsAll(list)){
+//            NetWork(list, directList)
+//        }else{
+////            newList.clear()
+////            newList.addAll(list)
+////            newList.removeAll(beforeList)
+//            println(list.size)
+//            println("${HashSet<String>(list).size}=====")
+//            dist(list,beforeList,belongMap,typeMap,ArrayList(list),beforeList.size)
+//        }
+//    }
+
+    fun fullDist(list: HashSet<String>, belongMap: HashMap<String,HashSet<String>>,typeMap: HashMap<String,String>): HashSet<String>{
         val beforeList = HashSet<String>(list)
-        for (belong in newList) {
+        var belongs: HashSet<String>
+        for (belong in beforeList) {
+            if(belongMap[belong] == null){
+                continue
+            }
+            belongs =  belongMap[belong]!!
+//            if(typeMap[belong] != "Equipment"){
+//                directList.addAll(belongs)
+//            }
+            list.addAll(belongs)
+        }
+        if(beforeList.containsAll(list)){
+            return list
+        }else{
+            return fullDist(list,belongMap,typeMap)
+        }
+    }
+
+    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]!!
             if(typeMap[belong] != "Equipment"){
-                directList.addAll(belongMap[belong]!!)
+                directList.addAll(belongs)
             }
-            list.addAll(belongMap[belong]!!)
         }
-        if(beforeList.containsAll(list)){
-            return NetWork(list,directList)
+        if(beforeList.containsAll(directList)){
+            return directList
         }else{
-            newList.removeAll(beforeList)
-            return dist(list,beforeList,belongMap,typeMap,newList)
+            return directDist(directList,belongMap,typeMap)
         }
     }
 

+ 1 - 2
datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/CommonService.kt

@@ -1,10 +1,9 @@
-package com.persagy.server.services.relation_calc
+package com.persagy.server.datacenter.services.relation_calc
 
 
 import com.persagy.server.datacenter.models.entities.assistant.PointPosition
 import com.persagy.server.datacenter.models.entities.graphtype.MPoint
 import org.springframework.util.DigestUtils
-import java.awt.geom.Area
 import java.awt.geom.GeneralPath
 import java.awt.geom.Point2D
 

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/MepSystemCalcService.kt

@@ -29,7 +29,7 @@ package com.persagy.server.datacenter.services.relation_calc
 import com.persagy.database.SFilter
 import com.persagy.database.SOrder
 import com.persagy.mybatis.SMybatisDao
-import com.persagy.server.datacenter.models.entities.graphtype.block.ConnectedBlock
+import com.persagy.server.datacenter.datacenter.models.entities.graphtype.block.ConnectedBlock
 import com.persagy.server.datacenter.models.entities.graphtype.block.ConnectedBlockSource
 import com.persagy.server.datacenter.models.entities.graphtype.block.EquipIdUUIDMap
 import com.persagy.server.datacenter.models.entities.graphtype.block.MepSourceTypeEntity

+ 64 - 17
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/RelationCalcService.kt

@@ -29,6 +29,8 @@ package com.persagy.server.datacenter.services.relation_calc
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.Opt
+import com.persagy.server.datacenter.datacenter.models.entities.graphtype.block.ConnectedBlock
+import com.persagy.server.datacenter.datacenter.models.entities.rel.REq2Sp
 import com.persagy.server.datacenter.models.entities.graphtype.MPoint
 import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
 import com.persagy.server.datacenter.services.base.RService
@@ -37,14 +39,16 @@ import com.persagy.server.datacenter.services.objects.ZoneSpaceBaseService
 import com.persagy.server.datacenter.wanda.rel.RSp2Sp
 import com.persagy.server.jms.RabbitMqService
 import com.persagy.server.mappers.IRelationCalcMapper
-import com.persagy.server.models.`object`.TwicePoint
-import com.persagy.server.models.service.BaseDataService
+import com.persagy.server.datacenter.models.wrapperobj.TwicePoint
+import com.persagy.server.datacenter.models.service.BaseDataService
+import com.persagy.server.datacenter.models.wrapperobj.ClassCodeEnum
 import com.persagy.server.services.assistant.RUpDateEquipAndSapceService
+import com.persagy.server.services.graphtype.ConnectedBlockService
 import com.persagy.server.services.objects.FloorService
 import com.persagy.server.services.rel.REq2SpService
-import com.persagy.server.services.relation_calc.CommonService
 import com.persagy.server.utils.IdUtils
 import com.persagy.service.SBaseService
+import com.persagy.service.SObjectService
 import com.persagy.service.models.enums.SResponseType
 import com.persagy.service.models.responses.SBaseResponse
 import com.persagy.service.utils.SSpringContextUtil
@@ -68,6 +72,7 @@ open class RelationCalcService {
     val rabbitMqService by lazy {
         SSpringContextUtil.getBean(RabbitMqService::class.java) as RabbitMqService
     }
+    val connectedBlockService = SObjectService(SMybatisDao(ConnectedBlock::class.java))
 
     /** 关系总览服务 */
     val relationTypeProjectservice = SBaseService(SMybatisDao(RelationTypeProject::class.java))
@@ -256,7 +261,7 @@ open class RelationCalcService {
      *  @param  projectId   项目id
      *  @param  sign        是否要删除自动维护的关系(不填默认为false), boolean型, 值为true或false (true表示删除自动和手动维护的关系, false表示只删除手动计算的的关系)
      */
-    fun calcEq2Sp(tables: String?, projectId: String, sign: Boolean): SBaseResponse {
+    fun calcEq2Sp(tables: String?, projectId: String, sign: Boolean,graphCode: String): SBaseResponse {
         try {
             var tablesName = ""
             var outTablesName = ""
@@ -367,7 +372,7 @@ open class RelationCalcService {
             } catch (e: Exception) {
                 e.printStackTrace()
             }
-            val result = mapper.calcEq2Sp(projectId)
+            val result = mapper.calcEq2Sp(projectId,graphCode)
             if (result != null && result == 0) {
                 try {
                     /** 发送消息 */
@@ -1015,7 +1020,7 @@ open class RelationCalcService {
      *  @param  projectId   项目id
      *  @param  sign        是否要删除自动维护的关系(不填默认为false), boolean型, 值为true或false (true表示删除自动和手动维护的关系, false表示只删除手动计算的的关系)
      */
-    fun calcss2Sp(projectId: String): SBaseResponse {
+    fun calcss2Sp(projectId: String,graphCode: String): SBaseResponse {
         try {
 
             try {
@@ -1031,7 +1036,7 @@ open class RelationCalcService {
                 e.printStackTrace()
             }
             /** 启动计算 */
-            val result = mapper.calcEq2Sp(projectId!!)
+            val result = mapper.calcEq2Sp(projectId!!,graphCode)
             if (result != null && result == 0) {
                 try {
                     /** 发送消息 */
@@ -1091,14 +1096,16 @@ open class RelationCalcService {
     }
 
     /**
-     * 设备所在业务空间  风口(空调风口、通风风口)
+     * 设备服务业务空间  风口(空调风口、通风风口)
      *
      *  @param  tables      参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone FunctionZone,FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
      *  @param  projectId   项目id
      *  @param  sign        是否要删除自动维护的关系(不填默认为false), boolean型, 值为true或false (true表示删除自动和手动维护的关系, false表示只删除手动计算的的关系)
      */
-    fun calcEqForSp(tables: String?, projectId: String): SBaseResponse {
+    fun calcEqForSp(tables: String?, projectId: String,graphCode: String): SBaseResponse {
+        val codeList= ClassCodeEnum.toSourceList(1)
 
+        val connectedBlocks = connectedBlockService.select(SFilter.eq("projectId",projectId), SFilter.or(SFilter.inList("typeCode1",codeList), SFilter.inList("typeCode2",codeList))).exec()
 
         try {
 
@@ -1115,7 +1122,7 @@ open class RelationCalcService {
                 e.printStackTrace()
             }
             /** 启动计算   ******************************/
-            val result = mapper.calcEq2Sp(projectId)
+            val result = mapper.calcEq2Sp(projectId,graphCode)
 //            var result = 0
             logger.debug("计算结果= ${result}")
 
@@ -1125,7 +1132,7 @@ open class RelationCalcService {
 
 //            REq2SpService.delete(SFilter.eq("projectId", projectId),
 //                     SFilter.eq("type", "eq2sp_for"))
-            val r2 = mapper.insertsp(projectId)
+//            val r2 = mapper.insertsp(projectId)
 //                logger.debug("设备关联业务空间计算结果= ${r1}+${r2}")
 
 
@@ -1145,25 +1152,65 @@ open class RelationCalcService {
                     e.printStackTrace()
                 }
 
-
+                val sourceList = ClassCodeEnum.toSourceList(0)
                 /** 处理关系 */
                 val equipmentList = EquipmentService.select(SFilter.eq("projectId", projectId),
                         SFilter.inList("classCode",
                                 arrayListOf("ACATIO", "ACVTIO","ACATFC","ACVTAC","FFSCIO"))).exec()
+                val typeMap = HashMap<String,String>();
                 if (equipmentList.size > 0) {
                     var listId = ArrayList<String>()
                     for (equipment in equipmentList) {
                         listId.add(equipment.id!!)
+                        typeMap[equipment.id!!] = equipment.classCode!!
                     }
                     val rEq2SpList = REq2SpService.select(SFilter.eq("projectId", projectId),
                             SFilter.inList("id1", listId)
-                            , SFilter.eq("type", "eq2sp_in")).exec()
+                            , SFilter.eq("graphCode", graphCode)).exec()
+                    val rEq2Sps = ArrayList<REq2Sp>()
                     if (rEq2SpList.size > 0) {
                         for (rEq2Sp in rEq2SpList) {
-                            rEq2Sp.type = "eq2sp_for"
-                            REq2SpService.replace(rEq2Sp)
+                            rEq2Sp.type = "Eq2Sp"
+                            rEq2Sp.graphCode = graphCode
+                            rEq2Sps.add(rEq2Sp)
+//                            REq2SpService.replace(rEq2Sp)
+                            //获取设备类型
+                            val typeCode = typeMap[rEq2Sp.id1]
+                            //如果是风口才计算关系
+                            if( typeCode!= null && sourceList.contains(typeCode)){
+                                for (connectedBlock in connectedBlocks) {
+                                    val typeCode1 = connectedBlock.typeCode1
+                                    val typeCode2 = connectedBlock.typeCode2
+                                    if(sourceList.contains(typeCode1)){
+                                        val fullREq2Sp = REq2Sp()
+                                        fullREq2Sp.type = "Eq2Sp"
+                                        fullREq2Sp.graphCode = graphCode
+                                        fullREq2Sp.projectId = projectId
+                                        fullREq2Sp.id1 = connectedBlock.id2
+                                        fullREq2Sp.id2 = rEq2Sp.id2
+                                        fullREq2Sp.zoneType = tables
+                                        fullREq2Sp.sign =2
+                                        rEq2Sps.add(fullREq2Sp)
+                                    }else if(sourceList.contains(typeCode2)){
+                                        val fullREq2Sp = REq2Sp()
+                                        fullREq2Sp.type = "Eq2Sp"
+                                        fullREq2Sp.graphCode = graphCode
+                                        fullREq2Sp.projectId = projectId
+                                        fullREq2Sp.id1 = connectedBlock.id1
+                                        fullREq2Sp.id2 = rEq2Sp.id2
+                                        fullREq2Sp.zoneType = tables
+                                        fullREq2Sp.sign =2
+                                        rEq2Sps.add(fullREq2Sp)
+                                    }
+                                }
+                            }
+
                         }
                     }
+                    for (rEq2Sp in rEq2Sps) {
+                        REq2SpService.replace(rEq2Sp)
+                    }
+
                 }
                 /** 发送消息 */
                 rabbitMqService.sendRel(Opt.projectId!!, "fengkou_for", "20", "123", "456")
@@ -1211,7 +1258,7 @@ open class RelationCalcService {
                         val k = get_points(point1.x,point1.y,point2.x,point2.y)
                         var twicePoint: TwicePoint
                         if(k== null){
-                            twicePoint = TwicePoint(point.x,point.y+distance,point.x,point.y-distance)
+                            twicePoint = TwicePoint(point.x, point.y + distance, point.x, point.y - distance)
                         }else{
 //                            val distance = get_segment_distance(point1.x,point1.y,point2.x,point2.y)
                             twicePoint = get_point_by_distance(point.x,point.y,k,distance*2)
@@ -1318,7 +1365,7 @@ open class RelationCalcService {
         val vector_x2 = -vector_x1
         val vector_y1 = k * vector_x1
         val vector_y2 = k * vector_x2
-        return TwicePoint(base_x + vector_x1,base_y + vector_y1,base_x + vector_x2,base_y + vector_y2)
+        return TwicePoint(base_x + vector_x1, base_y + vector_y1, base_x + vector_x2, base_y + vector_y2)
     }
 
 } // Class RelationCalcService

+ 3 - 3
datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/RelationCalcController.kt

@@ -113,7 +113,7 @@ class RelationCalcController {
     fun calcEq2Sp(@RequestParam objectTypes: String?): SBaseResponse {
         val projectId = SPageContext.getHeader("projectId").toString()
         logger.debug("calcEq2Sp --------------  $projectId")
-        return service.calcEq2Sp(objectTypes,projectId, false)
+        return service.calcEq2Sp(objectTypes,projectId, false,"MechInArch")
     } // Function calcEq2Sp()
 
     /**
@@ -313,7 +313,7 @@ class RelationCalcController {
     fun ss2Sp(): SBaseResponse {
         val projectId = SPageContext.getHeader("projectId").toString()
         logger.debug("calcSs2Sp --------------  $projectId")
-        return service.calcss2Sp(projectId)
+        return service.calcss2Sp(projectId,"MechInArch")
     }
 
     /**
@@ -324,7 +324,7 @@ class RelationCalcController {
     fun eqForSp(@RequestParam objectTypes: String?): SBaseResponse {
         val projectId = SPageContext.getHeader("projectId").toString()
         logger.debug("calcEq2Sp --------------  $projectId")
-        return service.calcEqForSp(objectTypes,projectId)
+        return service.calcEqForSp(objectTypes,projectId,"MechForArch")
     }
 
     /**

+ 0 - 28
datacenter/src/main/kotlin/com/persagy/server/models/object/ClassCodeEnum.kt

@@ -1,28 +0,0 @@
-package com.persagy.server.models.`object`
-
-import java.util.*
-
-
-/**
- *
- * @author  Cainga
- * @date  2021/2/24 10:32
- */
-enum class ClassCodeEnum(val cname: String) {
-    ACVTIO("通风风口"),
-    FFSCIO("排烟风口"),
-    ACATIO("空调风口"),
-    ACVTSF("通风风机"),
-    ACATAH("空调机组"),
-    ACATFU("新风机组");
-
-    open fun toList(): List<String> {
-        val list = ArrayList<String>() //Lists.newArrayList()其实和new ArrayList()几乎一模
-        //  一样, 唯一它帮你做的(其实是javac帮你做的), 就是自动推导(不是"倒")尖括号里的数据类型.
-        for (classCodeEnum in ClassCodeEnum.values()) {
-            list.add(classCodeEnum.name)
-        }
-        return list
-    }
-
-}