caiaf 4 年之前
父節點
當前提交
475a5bf9cc

+ 22 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/rel/RelEq2SpForEquip.kt

@@ -0,0 +1,22 @@
+package com.persagy.server.datacenter.wanda.rel
+
+import com.persagy.service.models.annotations.SCascade
+import io.swagger.v3.oas.annotations.media.Schema
+import javax.persistence.Table
+
+/**
+ * 设备和建筑的关系
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2021/2/25 18:16
+ */
+@Schema(description = "设备信息实体类")
+@Table(name = "equipment")
+class RelEq2SpForEquip: EquipmentBase() {
+
+    /** 级联-设备服务的建筑 */
+    @Schema(description = "级联-设备服务的建筑")
+    @SCascade(table="relationship.r_eq2sp", idColumn="eq_id", childIdColumn="sp_id" ,filter = "graph_code = 'MechForArch'")
+    var objectInfo: ArrayList<RelZoneSpaceBd>? = null
+
+}

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

@@ -95,6 +95,10 @@ class Connector : BaseComponent(),Cloneable{
 //    @JsonProperty("belongBimId")
     var belongBimId: String? = null
 
+    /** 立管状态 */
+    @Column(name = "riser_state")
+    var riserState: Int? = null
+
     @Override
     public override fun clone(): Connector {
         return super.clone() as Connector

+ 37 - 23
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/graphtype/GraphicTypeMapperService.kt

@@ -111,7 +111,7 @@ open class GraphicTypeMapperService {
     /**
      * 查询数量
      */
-    fun queryCounts(): SQueryResponse<GraphicType> {
+    fun queryCounts(relType:String?,graphCode: String?,graphicId: String?): SQueryResponse<GraphicType> {
         return try {
 
 
@@ -120,61 +120,75 @@ open class GraphicTypeMapperService {
             val projectId = SPageContext.getHeader("projectId")
             val graphicTypeService = RService(SMybatisDao(GraphicType::class.java))
             val relationTypeProjectService = RService(SMybatisDao(RelationTypeProject::class.java))
-            val graphicTypeList = graphicTypeService.select(SFilter.not(SFilter.isNull("parentId"))).exec()
+            var graphicTypeList: ArrayList<GraphicType>
+            if(graphicId != null){
+                graphicTypeList = graphicTypeService.select(SFilter.eq("id",graphicId)).exec()
+            }else {
+                graphicTypeList = graphicTypeService.select(SFilter.not(SFilter.isNull("parentId"))).exec()
+            }
+            var relationType: String?
+            var graphicTypeCode: String?
+            if(relType!= null && graphCode != null){
+                relationType = relType
+                graphicTypeCode = graphCode
+            }
+
             for(graphicType in graphicTypeList){
                 val relationTypeProjectList = relationTypeProjectService.select(SFilter.eq("graphicId",graphicType.graphTypeId!!),SFilter.eq("projectId",projectId!!)).exec()
 
                 for(relationTypeProject in relationTypeProjectList){
+                    relationType = relationTypeProject.relationType
+                    graphicTypeCode = relationTypeProject.graphicType
                     val tableName = relationTypeProject.tableName
                     if(!relationTypeProject.tableName.isNullOrEmpty()){
                         var count = 0
-                        if (relationTypeProject.graphicType == "ArchSubset") {
+                        if (graphicTypeCode == "ArchSubset") {
                             /** 建筑从属关系 */
-                            if (relationTypeProject.relationType == "Bd2Sp"){
+                            if (relationType == "Bd2Sp"){
                                 /** 空间所在建筑 */
                                 val zoneSpaceList = ZoneSpaceBaseService.select(SFilter.eq("projectId", projectId), SFilter.not(SFilter.isNull("buildingId"))).exec()
                                 count = zoneSpaceList.size
-                            } else if(relationTypeProject.relationType == "Fl2Sp") {
+                            } else if(relationType == "Fl2Sp") {
                                 /** 空间所在楼层 */
                                 val zoneSpaceList = ZoneSpaceBaseService.select(SFilter.eq("projectId", projectId), SFilter.not(SFilter.isNull("floorId"))).exec()
                                 count = zoneSpaceList.size
                             }
 
-                        }else if (relationTypeProject.graphicType == "MechInArch") {
+                        }else if (graphicTypeCode == "MechInArch") {
                             /** 机电类所在区域关系 */
-                            if (relationTypeProject.relationType == "Eq2Bd"){
+                            if (relationType == "Eq2Bd"){
                                 /** 建筑下的设备  */
                                 val equipmentList = EquipmentService.select(SFilter.eq("projectId", projectId), SFilter.not(SFilter.isNull("buildingId"))).exec()
                                 count = equipmentList.size
-                            } else if (relationTypeProject.relationType == "Eq2Fl"){
+                            } else if (relationType == "Eq2Fl"){
                                 /** 楼层下的设备 */
                                 val equipmentList = EquipmentService.select(SFilter.eq("projectId", projectId), SFilter.not(SFilter.isNull("floorId"))).exec()
                                 count = equipmentList.size
-                            }else if (relationTypeProject.relationType == "Eq2Sp"){
+                            }else if (relationType == "Eq2Sp"){
                                 /** 设备所在的空间 */
-                                val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", relationTypeProject.graphicType!!),
-                                        SFilter.eq("type", relationTypeProject.relationType!!), SFilter.eq("zoneType", relationTypeProject.zoneType!!)).exec()
+                                val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicType!!),
+                                        SFilter.eq("type", relationType!!), SFilter.eq("zoneType", relationTypeProject.zoneType!!)).exec()
                                 count = rEq2SpList.size
                             }
-                        } else if (relationTypeProject.graphicType == "ArchForArch") {
+                        } else if (graphicTypeCode == "ArchForArch") {
                             /** 区域服务关系 */
-                            if (relationTypeProject.relationType == "Sp2Sp") {
-                                val rSp2SpList = rSp2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", relationTypeProject.graphicType!!),
-                                        SFilter.eq("type", relationTypeProject.relationType!!)).exec()
+                            if (relationType == "Sp2Sp") {
+                                val rSp2SpList = rSp2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicType!!),
+                                        SFilter.eq("type", relationType!!)).exec()
                                 count = rSp2SpList.size
                             }
-                        }else if (relationTypeProject.graphicType == "MechSubset") {
+                        }else if (graphicTypeCode == "MechSubset") {
                             /** 机电从属关系 */
-                            if (relationTypeProject.relationType == "Sy2Eq") {
-                                val rEq2SyList = rEq2SyService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", relationTypeProject.graphicType!!),
-                                        SFilter.eq("type", relationTypeProject.relationType!!)).exec()
+                            if (relationType == "Sy2Eq") {
+                                val rEq2SyList = rEq2SyService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicType!!),
+                                        SFilter.eq("type", relationType!!)).exec()
                                 count = rEq2SyList.size
                             }
-                        }else if (relationTypeProject.graphicType == "MechForArch") {
+                        }else if (graphicTypeCode == "MechForArch") {
                             /** 机电类服务区域关系 */
-                            if (relationTypeProject.relationType == "Eq2Sp") {
-                                val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", relationTypeProject.graphicType!!),
-                                        SFilter.eq("type", relationTypeProject.relationType!!), SFilter.eq("zoneType", relationTypeProject.zoneType!!)).exec()
+                            if (relationType == "Eq2Sp") {
+                                val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicType!!),
+                                        SFilter.eq("type", relationType!!), SFilter.eq("zoneType", relationTypeProject.zoneType!!)).exec()
                                 count = rEq2SpList.size
                             }
                         }

+ 126 - 75
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/CalcSpecialService.kt

@@ -80,6 +80,7 @@ open class CalcSpecialService {
 
     val ductService = SObjectService(SMybatisDao(Duct::class.java))
     val pipeService = SObjectService(SMybatisDao(Pipe::class.java))
+    val connectorService = SObjectService(SMybatisDao(Connector::class.java))
 
     /**
      * 管网系统设备分块
@@ -267,15 +268,31 @@ open class CalcSpecialService {
      */
     fun calcNetworks(projectId: String): SBaseResponse{
         val buildings = BuildingService.select(SFilter.eq("projectId",projectId)).exec()
+        val fMap = HashMap<String,HashSet<String>>()
+        val dMap = HashMap<String,HashSet<String>>()
+        val modelIds  = ArrayList<String>()
+
         for (building in buildings) {
             val buildingId = building.id!!
             val floors = FloorService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId)).exec()
-            val connectedBlocks = ArrayList<ConnectedBlock>()
             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)
+                    modelIds.add(floor.modelId!!)
+                }
+
+            }
+            val riserMap = riserConnect("DomainHvac","",modelIds)
+
+
+            val connectedBlocks = ArrayList<ConnectedBlock>()
+//            for (floor in floors) {
+//                if (!floor.modelId.isNullOrEmpty()) {
+//                    val connectors = mapper.connectorOrder(floor.modelId!!)
+                    val connectors = connectorService.select(SFilter.inList("modelId",modelIds)).exec()
+
+//                    val dcEquipments = EquipmentService.select(SFilter.eq("projectId",projectId), SFilter.eq("floorId",floor.id!!)).exec()
+                    val dcEquipments = EquipmentService.select(SFilter.eq("projectId",projectId),SFilter.eq("buildingId",building.id!!)).exec()
+                    val dcEquipMap = HashMap<String, Equipment>(4096)
                     for (equipment in dcEquipments) {
                         if(!equipment.bimId.isNullOrEmpty()){
                             dcEquipMap[equipment.bimId!!] = equipment
@@ -285,16 +302,22 @@ open class CalcSpecialService {
 
                     val connectorMap = HashMap<String, Connector>(100000)
                     val typeMap = HashMap<String, String>(20000)
+                    val eqBelongMap = HashMap<String, String>(20000)
                     for (connector in connectors) {
-                        connectorMap[connector.revitId!!] = connector
+                        connectorMap[connector.id!!] = connector
 
                         val belong = connector.belongBimId ?: continue
                         val belongType = connector.belongType
+                        val id = connector.id!!
                         if (belongType != null) {
-                            typeMap[belong] = belongType
+                            typeMap[id] = belongType
+                        }
+                        if(belongType == "Equipment"){
+                            eqBelongMap[id] = belong
                         }
 
                     }
+
                     val belongMap = HashMap<String, HashSet<String>>()
                     val eqBelongSet = HashSet<String>()
                     //遍历连接件
@@ -302,14 +325,15 @@ open class CalcSpecialService {
                         //拿到所属类
                         val belongType = connector.belongType
                         //拿到所属id
-                        val belong = connector.belongBimId
+                        val belong = connector.id
                         if(belong != null){
+                            belongMap[belong] = HashSet()
                             eqBelongSet.add(belong)
                             //如果连接件有连接
-                            if (connector.connectedIds!!.size > 0) {
-                                val revitId = connector!!.connectedIds?.get(0)
-                                var currentConnector = connectorMap[revitId!!]
-                                val cBelong = currentConnector?.belongBimId
+                            if (connector.connectIdJson!!.size > 0) {
+                                val connectorId = connector!!.connectIdJson?.get(0)
+                                var currentConnector = connectorMap[connectorId!!]
+                                val cBelong = currentConnector?.id
                                 if (cBelong != null) {
 //                                if(belongType == "Equipment"){
 //                                    eqBelongSet.add(belong)
@@ -328,6 +352,15 @@ open class CalcSpecialService {
                             }else {
                                 belongMap[belong] = HashSet()
                             }
+                            if(connector.riserState != null && connector.riserState!! > 0 && listOf("Duct","Pipe").contains(connector.belongType)){
+                                for (key in riserMap.keys) {
+                                    if(key == belong){
+                                        belongMap[belong]!!.addAll(riserMap[key]!!)
+
+                                        break
+                                    }
+                                }
+                            }
                         }
                     }
                     var fBlockId: Int =0
@@ -340,7 +373,7 @@ open class CalcSpecialService {
                     var dSet: HashSet<String>
                     println(eqBelongSet.size)
                     for (key in eqBelongSet) {
-                        val e1 = dcEquipMap[key]
+                        val e1 = dcEquipMap[eqBelongMap[key]]
                         if(e1 == null || !enumList.contains(e1.classCode)){
                             continue
                         }
@@ -352,7 +385,7 @@ open class CalcSpecialService {
 
                         for (s in dSet!!) {
                             if(typeMap[s] == "Equipment" && key != s){
-                                val e2 = dcEquipMap[s]
+                                val e2 = dcEquipMap[eqBelongMap[key]]
                                 if(e2 == null || !enumList.contains(e2.classCode)){
                                     continue
                                 }
@@ -365,8 +398,8 @@ open class CalcSpecialService {
                                 connectedBlock.id2 = e2.id!!
                                 connectedBlock.type1 = "Equipment"
                                 connectedBlock.type2 = "Equipment"
-                                connectedBlock.modelId1 = floor.modelId
-                                connectedBlock.modelId2 = floor.modelId
+                                connectedBlock.modelId1 = connectorMap[key]!!.modelId
+                                connectedBlock.modelId2 = connectorMap[s]!!.modelId
 //                                connectedBlock.domain = connector.domain
 //                                connectedBlock.mepSystemType = connector.mepSystemType
                                 connectedBlock.projectId = projectId
@@ -381,12 +414,6 @@ 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]!!
@@ -408,9 +435,12 @@ open class CalcSpecialService {
 //                    fSet = fullDist(HashSet(belongSet),belongMap)
 //                    println(fSet.contains(key))
 //                    println(fSet.size)
+
+                        fMap[key] = fSet
+                        dMap[key] = dSet
                         for (s in fSet!!) {
                             if(typeMap[s] == "Equipment" && key != s){
-                                val e2 = dcEquipMap[s]
+                                val e2 = dcEquipMap[eqBelongMap[key]]
                                 if(e2 == null || !enumList.contains(e2.classCode)){
                                     continue
                                 }
@@ -424,8 +454,8 @@ open class CalcSpecialService {
                                 connectedBlock.id2 = e2.id!!
                                 connectedBlock.type1 = "Equipment"
                                 connectedBlock.type2 = "Equipment"
-                                connectedBlock.modelId1 = floor.modelId
-                                connectedBlock.modelId2 = floor.modelId
+                                connectedBlock.modelId1 = connectorMap[key]!!.modelId
+                                connectedBlock.modelId2 = connectorMap[s]!!.modelId
 //                                connectedBlock.domain = connector.domain
 //                                connectedBlock.mepSystemType = connector.mepSystemType
                                 connectedBlock.projectId = projectId
@@ -440,34 +470,14 @@ open class CalcSpecialService {
 
                             }
                         }
-//                    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!!) {
-//
 //                    }
+//                }
+
+
+
 
-                    }
-                }
 
 
             }
@@ -477,7 +487,6 @@ open class CalcSpecialService {
             connectedBlockService.createList(request)
         }
 
-
         return SBaseResponse(SResponseType.success, "")
 
     }
@@ -551,39 +560,81 @@ open class CalcSpecialService {
      * @Param:
      * @Return:
      */
-    fun riserConnect(projectId: String,domain: String,memSystemType: String,modelIds: List<String>){
-        val ducts = ArrayList<List<Duct>>()
-        val ductList = ductService.select(SFilter.inList("modelId",modelIds), SFilter.gt("riserState",0)).exec()
-        for (modelId in modelIds) {
-            ducts.add(ductList.stream().filter { duct -> duct.modelId == modelId }.collect(Collectors.toList()))
-        }
+    fun riserConnect(domain: String,memSystemType: String,modelIds: List<String>): HashMap<String,ArrayList<String>>{
         val itemMap = HashMap<String,ArrayList<String>>()
-        for (index in ducts.indices-1) {
-            //低楼层管道
-            val lowerDucts = ducts[index].filter { d -> d.riserState == 2 || d.riserState == 3 }
-            //高楼层管道
-            val higherDucts = ducts[index+1].filter { d -> d.riserState == 1 || d.riserState == 3 }
-            for (lowerDuct in lowerDucts) {
-                val itemList = ArrayList<String>()
-               //允许的距离误差范围
-                val distance = if(lowerDuct.diameter!! > 0) lowerDuct.diameter!! /2 else (lowerDuct.width!!).coerceAtMost(lowerDuct.height!!) /2
-                val lpoint = lowerDuct.location?.points?.get(0) ?: continue
-                for (higherDuct in higherDucts) {
-                    val hpoint = higherDuct.location?.points?.get(0)
-                    if(hpoint != null){
-                        // 求两个点的距离 是否在允许的误差范围内
-                        val connected = sqrt((lpoint.x - hpoint.x).pow(2.0) + (lpoint.y - hpoint.y).pow(2.0)) < distance
-                        if(connected){
-                            itemList.add(higherDuct.id!!)
+        //风管立管连接
+        if(domain == "DomainHvac"){
+            val ducts = ArrayList<List<Duct>>()
+            val ductList = ductService.select(SFilter.inList("modelId",modelIds), SFilter.gt("riserState",0)).exec()
+            for (modelId in modelIds) {
+                ducts.add(ductList.stream().filter { duct -> duct.modelId == modelId }.collect(Collectors.toList()))
+            }
+            for (index in ducts.indices-1) {
+                //低楼层管道
+                val lowerDucts = ducts[index].filter { d -> d.riserState == 2 || d.riserState == 3 }
+                //高楼层管道
+                val higherDucts = ducts[index+1].filter { d -> d.riserState == 1 || d.riserState == 3 }
+                for (lowerDuct in lowerDucts) {
+                    val itemList = ArrayList<String>()
+                    //允许的距离误差范围
+                    val distance = if(lowerDuct.diameter!! > 0) lowerDuct.diameter!! /2 else (lowerDuct.width!!).coerceAtMost(lowerDuct.height!!) /2
+                    val lpoint = lowerDuct.location?.points?.get(0) ?: continue
+                    for (higherDuct in higherDucts) {
+                        val hpoint = higherDuct.location?.points?.get(0)
+                        if(hpoint != null){
+                            // 求两个点的距离 是否在允许的误差范围内
+                            val connected = sqrt((lpoint.x - hpoint.x).pow(2.0) + (lpoint.y - hpoint.y).pow(2.0)) < distance
+                            if(connected){
+                                itemList.add(higherDuct.id!!)
+                            }
                         }
                     }
+                    if(itemList.size > 0){
+                        itemMap[lowerDuct.id!!] = itemList
+                    }
+
                 }
-                if(itemList.size > 0){
-                    itemMap[lowerDuct.id!!] = itemList
-                }
+            }
+        //水管的立管连接
+        }else if(domain == "DomainPiping"){
+            val pipes = ArrayList<List<Pipe>>()
+            val pipeList = pipeService.select(SFilter.inList("modelId",modelIds), SFilter.gt("riserState",0)).exec()
+            for (modelId in modelIds) {
+                pipes.add(pipeList.stream().filter { pipe -> pipe.modelId == modelId }.collect(Collectors.toList()))
+            }
+            for (index in pipes.indices-1) {
+                //低楼层管道
+                val lowerPipes = pipes[index].filter { d -> d.riserState == 2 || d.riserState == 3 }
+                //高楼层管道
+                val higherPipes = pipes[index+1].filter { d -> d.riserState == 1 || d.riserState == 3 }
+                for (lowerPipe in lowerPipes) {
+                    val itemList = ArrayList<String>()
+                    //允许的距离误差范围
+                    val distance = lowerPipe.diameter!! /2
+                    val lpoint = lowerPipe.location?.points?.get(0) ?: continue
+                    for (higherPipe in higherPipes) {
+                        val hpoint = higherPipe.location?.points?.get(0)
+                        if(hpoint != null){
+                            // 求两个点的距离 是否在允许的误差范围内
+                            val connected = sqrt((lpoint.x - hpoint.x).pow(2.0) + (lpoint.y - hpoint.y).pow(2.0)) < distance
+                            if(connected){
+                                itemList.add(higherPipe.id!!)
+                            }
+                        }
+                    }
+                    if(itemList.size > 0){
+                        itemMap[lowerPipe.id!!] = itemList
+                    }
 
+                }
             }
+
+
         }
+
+        return itemMap
     }
 
+
+
 } // Class CalcSpecialService

+ 11 - 9
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/ManualRelationCalcAddService.kt

@@ -477,7 +477,7 @@ class ManualRelationCalcAddService {
                 sCreateResponse.errorType = "1"
                 return sCreateResponse
             }
-
+            val relZoneSpaceLists = ArrayList<RelZoneSpace>()
             for (fromContent in relationAddRequest.fromContent!!) {
                 val relZoneSpaceList = relZoneSpaceService.select(SFilter.eq("projectId", projectId), SFilter.eq(relationAddRequest.type!!, fromContent!!), SFilter.eq("classCode", relationAddRequest.zoneType!!)).exec()
                 if (relZoneSpaceList.size < 1) {
@@ -494,6 +494,7 @@ class ManualRelationCalcAddService {
                     sCreateResponse.errorType = "2"
                     return sCreateResponse
                 }
+                relZoneSpaceLists.addAll(relZoneSpaceList)
             }
 
             /** 处理关系 */
@@ -502,10 +503,10 @@ class ManualRelationCalcAddService {
                 setCode.add(fromContent)
             }
             /** 查询空间 */
-            val relZoneSpaceList = relZoneSpaceService.select(SFilter.eq("projectId", projectId!!), SFilter.eq(relationAddRequest.type!!, relationAddRequest.mainContent!!),
-                    SFilter.eq("classCode", relationAddRequest.zoneType!!)).exec()
+//            val relZoneSpaceList = relZoneSpaceService.select(SFilter.eq("projectId", projectId!!), SFilter.eq(relationAddRequest.type!!, relationAddRequest.fromContent!!),
+//                    SFilter.eq("classCode", relationAddRequest.zoneType!!)).exec()
             /** 遍历 */
-            for (zoneSpace in relZoneSpaceList) {
+            for (zoneSpace in relZoneSpaceLists) {
                 val rEq2Sp = REq2Sp()
                 rEq2Sp.id1 = equipmentList[0].id
                 rEq2Sp.id2 = zoneSpace.id
@@ -550,7 +551,7 @@ class ManualRelationCalcAddService {
                 sCreateResponse.errorType = "1"
                 return sCreateResponse
             }
-
+            val relZoneSpaceLists = ArrayList<RelZoneSpace>()
             for (fromContent in relationAddRequest.fromContent!!) {
                 val relZoneSpaceList = relZoneSpaceService.select(SFilter.eq("projectId", projectId), SFilter.eq(relationAddRequest.type!!, fromContent!!), SFilter.eq("classCode", relationAddRequest.zoneType!!)).exec()
                 if (relZoneSpaceList.size < 1) {
@@ -567,6 +568,7 @@ class ManualRelationCalcAddService {
                     sCreateResponse.errorType = "2"
                     return sCreateResponse
                 }
+                relZoneSpaceLists.addAll(relZoneSpaceList)
             }
 
             /** 处理关系 */
@@ -574,11 +576,11 @@ class ManualRelationCalcAddService {
             for (fromContent in relationAddRequest.fromContent!!) {
                 setCode.add(fromContent)
             }
-            /** 查询空间 */
-            val relZoneSpaceList = relZoneSpaceService.select(SFilter.eq("projectId", projectId!!), SFilter.eq(relationAddRequest.type!!, relationAddRequest.mainContent!!),
-                    SFilter.eq("classCode", relationAddRequest.zoneType!!)).exec()
+//            /** 查询空间 */
+//            val relZoneSpaceList = relZoneSpaceService.select(SFilter.eq("projectId", projectId!!), SFilter.eq(relationAddRequest.type!!, relationAddRequest.mainContent!!),
+//                    SFilter.eq("classCode", relationAddRequest.zoneType!!)).exec()
             /** 遍历 */
-            for (zoneSpace in relZoneSpaceList) {
+            for (zoneSpace in relZoneSpaceLists) {
                 val rEq2Sp = REq2Sp()
                 rEq2Sp.id1 = equipmentList[0].id
                 rEq2Sp.id2 = zoneSpace.id

+ 120 - 4
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/ManualRelationCalcService.kt

@@ -117,6 +117,10 @@ open class ManualRelationCalcService {
     private val rEq2SpTwoService = SObjectService(SMybatisDao(REq2SpTwo::class.java))
     /** 设备所在的空间-设备 */
     private val relEq2SpEquipService = SObjectService(SMybatisDao(RelEq2SpEquip::class.java))
+
+    /** 设备服务空间-设备 */
+    private val relEq2SpForEquipService = SObjectService(SMybatisDao(RelEq2SpForEquip::class.java))
+
     /** 设备和空间关系 */
     private val rEq2SpService = SObjectService(SMybatisDao(REq2Sp::class.java))
 
@@ -186,7 +190,7 @@ open class ManualRelationCalcService {
             } else if (manualRelationCalcRequest.graphicType == "MechInArch" && manualRelationCalcRequest.relType == "Eq2Sp") {
             return queryEq2Sp(manualRelationCalcRequest)
             }else if (manualRelationCalcRequest.graphicType == "MechForArch" && manualRelationCalcRequest.relType == "Eq2Sp"){
-            return queryEq2Sp(manualRelationCalcRequest)
+            return queryEq2SpFor(manualRelationCalcRequest)
             }
         return ManualRelationCalcResponse()
 
@@ -1039,7 +1043,7 @@ open class ManualRelationCalcService {
     }
 
     /**
-     * 空间和空间
+     * 设备所在空间
      */
     fun queryEq2Sp(manualRelationCalcRequest: ManualRelationCalcRequest): ManualRelationCalcResponse{
         val sQueryRequest = SQueryRequest()
@@ -1057,6 +1061,7 @@ open class ManualRelationCalcService {
         /** 级联资产 */
         val sCascadeQuery = SCascadeQuery()
         sCascadeQuery.name = "objectInfo"
+        sCascadeQuery.filters = "classCode = '${manualRelationCalcRequest.zoneType!!}'"
         sCascadeQueryList.add(sCascadeQuery)
         sQueryRequest.cascade = sCascadeQueryList
 
@@ -1066,8 +1071,12 @@ open class ManualRelationCalcService {
         list.add(SFilter.eq("projectId",Opt.projectId!!))
         val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("graphCode", manualRelationCalcRequest.graphicType!!), SFilter.eq("type", manualRelationCalcRequest.relType!!)
                 , SFilter.eq("zoneType", manualRelationCalcRequest.zoneType!!)).exec()
+        val equipIds  = ArrayList<String>()
         if (rEq2SpList.size>0) {
+            equipIds.addAll(rEq2SpList.map { r -> r.id1!! })
             if (manualRelationCalcRequest.objectType == "1") {
+                //限制结果为存在关联关系的数据
+                list.add(SFilter.inList("id",equipIds))
                 if (!manualRelationCalcRequest.categoryFrom.isNullOrEmpty()){
                     list.add(SFilter.eq("classCode",manualRelationCalcRequest.categoryFrom!!))
                 }
@@ -1141,6 +1150,113 @@ open class ManualRelationCalcService {
 
 
     /**
+     * 设备服务空间
+     */
+    fun queryEq2SpFor(manualRelationCalcRequest: ManualRelationCalcRequest): ManualRelationCalcResponse{
+        val sQueryRequest = SQueryRequest()
+        if(manualRelationCalcRequest.pageNumber>0&&manualRelationCalcRequest.pageSize>0){
+            SQueryRequest.maxRow = 400000
+            sQueryRequest.pageSize= manualRelationCalcRequest.pageSize
+            sQueryRequest.pageNumber = manualRelationCalcRequest.pageNumber
+        }else{
+            /** 控制条数 */
+            SQueryRequest.maxRow = 100000
+            sQueryRequest.pageSize= 100000
+        }
+
+        val sCascadeQueryList = ArrayList<SCascadeQuery>()
+        /** 级联资产 */
+        val sCascadeQuery = SCascadeQuery()
+        sCascadeQuery.name = "objectInfo"
+        sCascadeQuery.filters = "classCode = '${manualRelationCalcRequest.zoneType!!}'"
+        sCascadeQueryList.add(sCascadeQuery)
+        sQueryRequest.cascade = sCascadeQueryList
+
+        val manualRelationCalcResponse = ManualRelationCalcResponse()
+        manualRelationCalcResponse.direction = "Left"
+        val list = ArrayList<SFilter>()
+        list.add(SFilter.eq("projectId",Opt.projectId!!))
+        val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("graphCode", manualRelationCalcRequest.graphicType!!), SFilter.eq("type", manualRelationCalcRequest.relType!!)
+                , SFilter.eq("zoneType", manualRelationCalcRequest.zoneType!!)).exec()
+        val equipIds  = ArrayList<String>()
+        if (rEq2SpList.size>0) {
+            equipIds.addAll(rEq2SpList.map { r -> r.id1!! })
+            if (manualRelationCalcRequest.objectType == "1") {
+                //限制结果为存在关联关系的数据
+                list.add(SFilter.inList("id",equipIds))
+                if (!manualRelationCalcRequest.categoryFrom.isNullOrEmpty()){
+                    list.add(SFilter.eq("classCode",manualRelationCalcRequest.categoryFrom!!))
+                }
+                if (!manualRelationCalcRequest.vagueFrom.isNullOrEmpty()) {
+                    list.add(SFilter.or(SFilter.contain("codeName",manualRelationCalcRequest.vagueFrom!!),SFilter.contain("localId1",manualRelationCalcRequest.vagueFrom!!)
+                            ,SFilter.contain("bimTypeId",manualRelationCalcRequest.vagueFrom!!),SFilter.contain("systemCategotry",manualRelationCalcRequest.vagueFrom!!)))
+                }
+
+                val pageQuery = relEq2SpForEquipService.pageQuery(sQueryRequest, list)
+                manualRelationCalcResponse.content = pageQuery.content
+                manualRelationCalcResponse.message = pageQuery.message
+                manualRelationCalcResponse.pageNumber = pageQuery.pageNumber
+                manualRelationCalcResponse.pageSize = pageQuery.pageSize
+                manualRelationCalcResponse.result = pageQuery.result
+                manualRelationCalcResponse.total = pageQuery.total
+            }else if (manualRelationCalcRequest.objectType == "2" ||manualRelationCalcRequest.objectType == "3"){
+                if (!manualRelationCalcRequest.categoryFrom.isNullOrEmpty()){
+                    list.add(SFilter.eq("classCode",manualRelationCalcRequest.categoryFrom!!))
+                }
+                if (!manualRelationCalcRequest.vagueFrom.isNullOrEmpty()) {
+                    list.add(SFilter.or(SFilter.contain("codeName",manualRelationCalcRequest.vagueTo!!),SFilter.contain("localId1",manualRelationCalcRequest.vagueTo!!)
+                            ,SFilter.contain("bimTypeId",manualRelationCalcRequest.vagueTo!!),SFilter.contain("systemCategotry",manualRelationCalcRequest.vagueTo!!)))
+                }
+
+                if (!manualRelationCalcRequest.vagueTo.isNullOrEmpty()){
+                    list.add(SFilter.or(SFilter.contain("localName2",manualRelationCalcRequest.vagueTo!!),SFilter.contain("localId2",manualRelationCalcRequest.vagueTo!!)))
+                }
+                if (!manualRelationCalcRequest.zoneType.isNullOrEmpty()){
+                    list.add(SFilter.eq("zoneType",manualRelationCalcRequest.zoneType!!))
+                }
+                val rEq2SpTwoList = rEq2SpTwoService.select(list).exec()
+                if (rEq2SpTwoList.size>0){
+                    for (rEq2SpTwo in rEq2SpTwoList){
+
+                    }
+
+                    val listId1 = ArrayList<String>()
+                    val listId2 = ArrayList<String>()
+                    for (rEq2SpTwo in rEq2SpTwoList){
+                        listId1.add(rEq2SpTwo.id1!!)
+                        listId2.add(rEq2SpTwo.id2!!)
+                    }
+
+                    val listSF = ArrayList<SFilter>()
+                    sCascadeQuery.filters = "id in ${listId2.toJson()}"
+                    listSF.add(SFilter.inList("id",listId1.toList()))
+                    listSF.add(SFilter.eq("projectId",Opt.projectId!!))
+                    val pageQuery = relEq2SpForEquipService.pageQuery(sQueryRequest, listSF)
+                    manualRelationCalcResponse.content = pageQuery.content
+                    manualRelationCalcResponse.message = pageQuery.message
+                    manualRelationCalcResponse.pageNumber = pageQuery.pageNumber
+                    manualRelationCalcResponse.pageSize = pageQuery.pageSize
+                    manualRelationCalcResponse.result = pageQuery.result
+                    manualRelationCalcResponse.total = pageQuery.total
+                }else {
+                    manualRelationCalcResponse.content = ArrayList()
+                    manualRelationCalcResponse.result = SResponseType.success
+                }
+
+            } else {
+                manualRelationCalcResponse.content = ArrayList()
+                manualRelationCalcResponse.result = SResponseType.success
+            }
+
+        }else {
+            manualRelationCalcResponse.content = ArrayList()
+            manualRelationCalcResponse.result = SResponseType.success
+        }
+        return  manualRelationCalcResponse
+    }
+
+
+    /**
      * 删除关系
      */
     fun delRel(manualRelationCalcDel: ManualRelationCalcDel):SBaseResponse{
@@ -1165,11 +1281,11 @@ open class ManualRelationCalcService {
 
                 if (manualRelationCalcDel.graphicType == "ArchSubset" && manualRelationCalcDel.relType == "Bd2Sp") {
                     val relZoneSpace = RelZoneSpace()
-                    relZoneSpace.id = manualRelationCalcDel.fromId
+                    relZoneSpace.id = manualRelationCalcDel.toId
                     delete = relZoneSpaceService.update(relZoneSpace, arrayListOf("buildingId", "floorId"))
                 } else if (manualRelationCalcDel.graphicType == "ArchSubset" && manualRelationCalcDel.relType == "Fl2Sp") {
                     val relZoneSpace = RelZoneSpace()
-                    relZoneSpace.id = manualRelationCalcDel.fromId
+                    relZoneSpace.id = manualRelationCalcDel.toId
                     delete = relZoneSpaceService.update(relZoneSpace, arrayListOf( "floorId"))
                 } else if (manualRelationCalcDel.graphicType == "MechInArch" && manualRelationCalcDel.relType == "Eq2Bd") {
                     val equipment = Equipment()

+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/GraphicTypeController.kt

@@ -82,8 +82,8 @@ open class GraphicTypeController {
      */
     @Operation(summary = "查询总览数量", description = "")
     @PostMapping(value = ["/query/count"])
-    fun queryCount(): SQueryResponse<GraphicType> {
-        return graphicTypeMapperService.queryCounts()
+    fun queryCount(@RequestParam(required = false) relType: String?,@RequestParam(required = false) graphCode: String?,@RequestParam(required = false) graphicId: String?): SQueryResponse<GraphicType> {
+        return graphicTypeMapperService.queryCounts(relType,graphCode,graphicId)
     }
 
     /**