caiaf 4 anos atrás
pai
commit
11d24aecdc

+ 83 - 0
datacenter/src/main/kotlin/com/persagy/server/datacenter/models/entities/Duct.kt

@@ -0,0 +1,83 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+
+package com.persagy.server.datacenter.models.entities
+
+import cn.sagacloud.server.algorithm.models.entities.BaseComponent
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties
+import com.persagy.server.datacenter.models.entities.graphtype.MLocation
+import com.persagy.server.datacenter.models.entities.graphtype.MPoint
+import javax.persistence.Column
+import javax.persistence.Table
+
+/**
+ *风管
+ *
+ * @author jxing
+ */
+@Table(name = "revit.duct")
+@JsonIgnoreProperties(ignoreUnknown = true)
+class Duct : BaseComponent(){
+    /** 名称 */
+    @Column(name = "name")
+
+    var name: String? = null
+
+    /** 定位点 */
+    @Column(name = "location")
+    var location: MLocation? = null
+
+    /** 轮廓路径 */
+    @Column(name = "outline")
+    var outline: ArrayList<ArrayList<MPoint>>? = null
+
+    /** 所连接的连接件id */
+    @Column(name = "connected_ids")
+    var connectedIds: ArrayList<String>? = null
+
+    /** 管道系统类型名称 */
+    @Column(name = "mep_system_type")
+    var mepSystemType: String? = null
+
+    /** 形状 Circle|Rectangle|Ellipse */
+    @Column(name = "shape")
+    var shape: String? = null
+
+    /** 直径;当形状为Circle时有效 */
+    @Column(name = "diameter")
+    var diameter: Double? = null
+
+    /** 宽度 当形状为Rectangle或者Ellipse */
+    @Column(name = "width")
+    var width: Double? = null
+
+    /** 高度 当形状为Rectangle或者Ellipse */
+    @Column(name = "height")
+    var height: Double? = null
+
+    /** 参数列表 */
+    @Column(name = "parameters")
+    var parameters: ArrayList<Parameter>? = null
+
+    /** 管道类型 */
+    @Column(name = "riser_state")
+    var riserState: Int? = null
+}

+ 73 - 0
datacenter/src/main/kotlin/com/persagy/server/datacenter/models/entities/Pipe.kt

@@ -0,0 +1,73 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+
+package com.persagy.server.datacenter.models.entities
+
+import cn.sagacloud.server.algorithm.models.entities.BaseComponent
+import com.alibaba.fastjson.annotation.JSONField
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties
+import com.fasterxml.jackson.annotation.JsonProperty
+import com.persagy.server.datacenter.models.entities.graphtype.MLocation
+import com.persagy.server.datacenter.models.entities.graphtype.MPoint
+import javax.persistence.Column
+import javax.persistence.Table
+
+/**
+ * 水管
+ *
+ * @author jxing
+ */
+@Table(name = "revit.pipe")
+@JsonIgnoreProperties(ignoreUnknown = true)
+class Pipe  : BaseComponent(){
+
+    /** 名称 */
+    @Column(name = "name")
+    var name: String? = null
+
+    /** 定位点 */
+    @Column(name = "location")
+    var location: MLocation? = null
+
+    /** 设备轮廓 */
+    @Column(name = "outline")
+    var outline : ArrayList<ArrayList<MPoint>>? = null
+
+    /** 连接的连接件id */
+    @Column(name = "connected_ids")
+    var connectedIds: ArrayList<String>? = null
+
+    /** 管道系统类型名称 */
+    @Column(name = "mep_system_type")
+    var mepSystemType: String? = null
+
+    /** 直径 */
+    @Column(name = "diameter")
+    var diameter: Double? = null
+
+    /** 参数列表 */
+    @Column(name = "parameters")
+    var parameters: ArrayList<Parameter>? = null
+
+    /** 管道类型 */
+    @Column(name = "riser_state")
+    var riserState: Int? = null
+}

+ 47 - 41
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/CalcSpecialService.kt

@@ -34,6 +34,8 @@ import com.persagy.server.datacenter.datacenter.models.entities.graphtype.block.
 import com.persagy.server.datacenter.wanda.rel.REq2Eq
 import com.persagy.server.mappers.ICalcSpecialMapper
 import com.persagy.server.datacenter.models.entities.Connector
+import com.persagy.server.datacenter.models.entities.Duct
+import com.persagy.server.datacenter.models.entities.Pipe
 import com.persagy.server.datacenter.models.wrapperobj.ClassCodeEnum
 import com.persagy.server.datacenter.services.objects.BuildingService
 import com.persagy.server.datacenter.services.objects.EquipmentService
@@ -50,6 +52,10 @@ import com.persagy.service.models.responses.SBaseResponse
 import org.json.JSONObject
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Service
+import sun.java2d.pipe.LoopPipe
+import java.util.stream.Collectors
+import kotlin.math.pow
+import kotlin.math.sqrt
 
 /**
  * 关系计算-管网
@@ -72,6 +78,9 @@ open class CalcSpecialService {
     val relationTypeProjectservice = SBaseService(SMybatisDao(RelationTypeProject::class.java))
     val rEq2EqService = SObjectService(SMybatisDao(REq2Eq::class.java))
 
+    val ductService = SObjectService(SMybatisDao(Duct::class.java))
+    val pipeService = SObjectService(SMybatisDao(Pipe::class.java))
+
     /**
      * 管网系统设备分块
      *@param calcName   计算关系名称
@@ -500,38 +509,6 @@ open class CalcSpecialService {
         }
      }
 
-//    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>>): HashSet<String>{
         val beforeList = HashSet<String>(list)
         for (belong in beforeList) {
@@ -569,15 +546,44 @@ open class CalcSpecialService {
         }
     }
 
+    /**
+     * @Description: 立管连接
+     * @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()))
+        }
+        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(itemList.size > 0){
+                    itemMap[lowerDuct.id!!] = itemList
+                }
 
-
-//    fun calcNetworks(projectId: String,buildingId: String): SBaseResponse{
-//        val connectedBlocks = connectedBlockService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId)).exec()
-//        val classCodeList = ArrayList<String>()
-//        for (classCodeEnum in ClassCodeEnum.values()) {
-//            classCodeList.add(classCodeEnum.name)
-//        }
-//        val cb = connectedBlocks.filter { s -> classCodeList.contains(s.typeCode1)  || classCodeList.contains(s.typeCode2) }
-//    }
+            }
+        }
+    }
 
 } // Class CalcSpecialService