Browse Source

设备设备关系计算

caiaf 4 years ago
parent
commit
77e63b4bdf
19 changed files with 810 additions and 12 deletions
  1. 6 0
      data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/graphtype/MLocation.kt
  2. 8 0
      data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/graphtype/MPoint.kt
  3. 1 2
      datacenter/src/main/kotlin/com/persagy/server/controllers/TestController.kt
  4. 14 0
      datacenter/src/main/kotlin/com/persagy/server/controllers/relation_calc/CalcSpecialController.kt
  5. 11 0
      datacenter/src/main/kotlin/com/persagy/server/controllers/relation_calc/RelationCalcController.kt
  6. 19 0
      datacenter/src/main/kotlin/com/persagy/server/mappers/ICalcSpecialMapper.kt
  7. 37 0
      datacenter/src/main/kotlin/com/persagy/server/models/entities/BaseComponent.kt
  8. 105 0
      datacenter/src/main/kotlin/com/persagy/server/models/entities/Connector.kt
  9. 102 0
      datacenter/src/main/kotlin/com/persagy/server/models/entities/Door.kt
  10. 119 0
      datacenter/src/main/kotlin/com/persagy/server/models/entities/Equipment.kt
  11. 22 0
      datacenter/src/main/kotlin/com/persagy/server/models/entities/Parameter.kt
  12. 23 0
      datacenter/src/main/kotlin/com/persagy/server/models/entities/WindowDoorBase.kt
  13. 27 0
      datacenter/src/main/kotlin/com/persagy/server/models/object/TwicePoint.kt
  14. 11 0
      datacenter/src/main/kotlin/com/persagy/server/models/service/BaseDataService.kt
  15. 61 0
      datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/CalcSpecialService.kt
  16. 93 0
      datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/CommonService.kt
  17. 141 0
      datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/RelationCalcService.kt
  18. 8 8
      datacenter/src/main/resources/application-dev.yml
  19. 2 2
      datacenter/src/main/resources/logback-spring.xml

+ 6 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/graphtype/MLocation.kt

@@ -26,6 +26,8 @@
 
 package com.persagy.server.datacenter.models.entities.graphtype
 
+import com.alibaba.fastjson.annotation.JSONField
+import com.fasterxml.jackson.annotation.JsonProperty
 import java.io.Serializable
 
 /**
@@ -34,8 +36,12 @@ import java.io.Serializable
 class MLocation : Serializable {
 
 
+    @JSONField(name = "Type")
+    @JsonProperty("Type")
     val type : String? = null
 
+    @JSONField(name = "Points")
+    @JsonProperty("Points")
     var points : ArrayList<MPoint>? = null
 
 }

+ 8 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/graphtype/MPoint.kt

@@ -26,7 +26,9 @@
 
 package com.persagy.server.datacenter.models.entities.graphtype
 
+import com.alibaba.fastjson.annotation.JSONField
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties
+import com.fasterxml.jackson.annotation.JsonProperty
 
 /**
  *
@@ -34,10 +36,16 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
 @JsonIgnoreProperties(ignoreUnknown = true)
 class MPoint (x : Double, y : Double, z : Double){
 
+    @JSONField(name = "X")
+    @JsonProperty("X")
     var x : Double = x
 
+    @JSONField(name = "Y")
+    @JsonProperty("Y")
     var y : Double = y
 
+    @JSONField(name = "Z")
+    @JsonProperty("Z")
     var z : Double = z
 
     constructor() : this(0.0, 0.0 , 0.0)

+ 1 - 2
datacenter/src/main/kotlin/com/persagy/server/controllers/TestController.kt

@@ -27,7 +27,6 @@
 package com.persagy.server.controllers
 
 import com.persagy.server.Opt
-import com.persagy.server.controllers.objects.FloorController
 import com.persagy.server.jms.TopicSender
 import io.swagger.v3.oas.annotations.Operation
 import io.swagger.v3.oas.annotations.tags.Tag
@@ -50,7 +49,7 @@ import org.springframework.web.bind.annotation.RestController
 class TestController {
     companion object {
         // 日志
-        private val logger = LoggerFactory.getLogger(FloorController::class.java)
+        private val logger = LoggerFactory.getLogger(TestController::class.java)
     } // Companion object
 
     @Autowired

+ 14 - 0
datacenter/src/main/kotlin/com/persagy/server/controllers/relation_calc/CalcSpecialController.kt

@@ -27,6 +27,7 @@
 package com.persagy.server.controllers.relation_calc
 
 import com.persagy.server.services.relation_calc.CalcSpecialService
+import com.persagy.service.SPageContext
 import com.persagy.service.models.responses.SBaseResponse
 import io.swagger.v3.oas.annotations.Operation
 import io.swagger.v3.oas.annotations.tags.Tag
@@ -80,4 +81,17 @@ open class CalcSpecialController {
 //        return service.sysDirection(BuildingId, BlockId, SystemName, Domain, isSource)
 //    } // Function sysDirection()
 
+
+    /**
+     * @Description: 管网计算
+     * @Param:
+     * @Return:
+     */
+    @Operation(summary = "管网计算", description = "管网计算")
+    @PostMapping(value = ["/calcNetworks"])
+    fun calcNetworks(@RequestParam buildingId: String): SBaseResponse{
+        val projectId = SPageContext.getHeader("projectId").toString()
+        return service.calcNetworks(projectId,buildingId)
+    } // Function sysBolck()
+
 } // Class CalcSpecialController

+ 11 - 0
datacenter/src/main/kotlin/com/persagy/server/controllers/relation_calc/RelationCalcController.kt

@@ -339,4 +339,15 @@ class RelationCalcController {
         return service.setMarks(projectId)
     } // Function calcSy2Sp()
 
+    /**
+     * 空间交通关系
+     */
+    @Operation(summary = "空间交通关系", description = "")
+    @PostMapping(value = ["/sp2sp"])
+    fun sp2spV3(@RequestParam buildingId: String,@RequestParam objectType: String,@RequestParam type: String): SBaseResponse {
+        val projectId = SPageContext.getHeader("projectId").toString()
+        logger.debug("calcSy2Sp --------------$projectId")
+        return service.calcSp2Sp(projectId,buildingId,objectType,type)
+    } // Function calcSy2Sp()
+
 } // Class RelationCalcController

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

@@ -26,6 +26,7 @@
 
 package com.persagy.server.mappers
 
+import com.persagy.server.models.entities.Connector
 import org.apache.ibatis.annotations.Mapper
 import org.apache.ibatis.annotations.Select
 import org.springframework.stereotype.Repository
@@ -59,6 +60,24 @@ interface ICalcSpecialMapper {
     fun sysDirection(projectId: String, buildingId: String?, blockId: String, systemName: String,domain: String,isSource: Boolean): Boolean
 
 
+    /**
+     * @Description: 查询连接件并按指定顺序排序
+     * @Param: modelId 模型id
+     * @Return: List<Connector>
+     */
+    @Select(" SELECT * from revit.connector where model_id = #{modelId} order by case belong_type  " +
+            "when 'Equipment' then 1" +
+            "when 'EquipPart' then 2 " +
+            "when 'JoinObject' then 3 " +
+            "when 'Other' then 4 " +
+            "when 'Pipe' then 5 " +
+            "when 'FlexPipe' then 6" +
+            "when 'Duct' then 7 " +
+            "when 'FlexDuct' then 8 " +
+            "end asc")
+    fun connectorOrder(modelId:String): List<Connector>
+
+
 
 
 

+ 37 - 0
datacenter/src/main/kotlin/com/persagy/server/models/entities/BaseComponent.kt

@@ -0,0 +1,37 @@
+package cn.sagacloud.server.algorithm.models.entities
+
+import com.alibaba.fastjson.annotation.JSONField
+import com.fasterxml.jackson.annotation.JsonProperty
+import com.persagy.service.models.SBaseEntity
+import javax.persistence.Column
+import javax.persistence.Id
+
+/**
+ *
+ *
+ * @author jxing
+ */
+open class BaseComponent : SBaseEntity(){
+
+    /** 模型id */
+    @Column(name = "id", updatable = false)
+    @Id
+    var id: String? = null
+
+    /** 模型id(外键) */
+    @Column(name = "model_id")
+    var modelId: String? = null
+
+    @Column(name = "type")
+    var elementType : String? = null
+
+    @Column(name = "revit_id")
+    var revitId : String? = null
+
+    /** 对应Revit模型id */
+    @Column(name = "source_id")
+    var sourceId: String? = null
+
+    /** 模型所属楼层的id, 是uuid */
+    var modelFloorId: String? = null
+}

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

@@ -0,0 +1,105 @@
+package com.persagy.server.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.MPoint
+import javax.persistence.Column
+import javax.persistence.Table
+
+/**
+ *
+ *
+ * @author jxing
+ */
+@Table(name = "revit.connector")
+@JsonIgnoreProperties(ignoreUnknown = true)
+class Connector : BaseComponent(){
+
+    /** 所属对象的id */
+    @Column(name = "belong")
+    @JSONField(serialize = false)
+    var belong: String? = null
+
+    /** 所属对象的类型(pipe, duct, others, equipment, component) */
+    @Column(name = "belong_type")
+    @JSONField(serialize = false)
+    var belongType: String? = null
+
+    /** 名称 */
+    @Column(name = "name")
+    @JSONField(name = "name")
+    @JsonProperty("name")
+    var name: String? = null
+
+//    /** 对应Revit模型id */
+//    @ApiModelProperty(value = "对应Revit模型id")
+//    @Column(name = "source_id")
+//    @JSONField(name = "SourceId")
+//    @JsonProperty("SourceId")
+//    var sourceId: String? = null
+
+    /** 所属域 */
+    @Column(name = "domain")
+    @JSONField(name = "domain")
+    @JsonProperty("domain")
+    var domain: String? = null
+
+    /** 位置信息 */
+    @Column(name = "origin")
+    @JSONField(name = "origin")
+    @JsonProperty("origin")
+    var origin: MPoint? = null
+
+    /** 描述 */
+    @Column(name = "description")
+    @JSONField(name = "description")
+    @JsonProperty("description")
+    var description: String? = null
+
+    /** 是否连接其他连接件 */
+    @Column(name = "connected")
+    @JSONField(name = "isConnected")
+    @JsonProperty("isConnected")
+    var isConnected: Boolean? = null
+
+    /** 所属对象的revit_id */
+    @Column(name = "owner")
+    @JSONField(name = "owner")
+    @JsonProperty("owner")
+    var owner: String? = null
+
+    /** 连接的连接件id */
+    @Column(name = "connected_ids")
+    @JSONField(name = "connectedIds")
+    @JsonProperty("connectedIds")
+    var connectedIds: ArrayList<String>? = null
+
+    /** 管道系统类型名称 */
+    @Column(name = "mep_system_type")
+    @JSONField(name = "mepSystemTypeName")
+    @JsonProperty("mepSystemTypeName")
+    var mepSystemType: String? = null
+
+//    /** 连接件连接的连接件id */
+//    @ApiModelProperty(value = "连接件连接的连接件id")
+//    @Column(name = "connect_id")
+//    @JSONField(name = "ConnectId")
+//    @JsonProperty("ConnectId")
+//    var connectId: String? = null
+
+    /** 连接件连接的连接件id */
+    @Column(name = "connect_id_json")
+    @JSONField(name = "connectId")
+    @JsonProperty("connectId")
+    var connectIdJson: ArrayList<String>? = null
+
+    var isUsed: Boolean? = null
+
+    /** 所属BIMID */
+    @Column(name = "belong_bimid")
+    @JSONField(name = "belongBimId")
+    @JsonProperty("belongBimId")
+    var belongBimId: String? = null
+}

+ 102 - 0
datacenter/src/main/kotlin/com/persagy/server/models/entities/Door.kt

@@ -0,0 +1,102 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+package cn.sagacloud.server.algorithm.models.entities
+
+
+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.door")
+@JsonIgnoreProperties(ignoreUnknown = true)
+class Door : WindowDoorBase() {
+
+    /** 名称 */
+    @Column(name = "name")
+    var name: String? = null
+
+
+    /** 定位点 */
+    @Column(name = "location")
+    var location: MLocation? = null
+
+    /** 轮廓线 */
+    @Column(name = "outline")
+    var outline: ArrayList<ArrayList<MPoint>>? = null
+
+    /** 面方向 */
+    @Column(name = "face_direction")
+    var faceDirection : MPoint? = null
+
+    /** Hand方向 */
+    @Column(name = "hand_direction")
+    var handDirection : MPoint? = null
+
+    /** 类型中文名称 */
+    @Column(name = "family_name")
+    var familyName: String? = null
+
+    /** 族符号 */
+    @Column(name = "family_symbol")
+    var familySymbol: String? = null
+
+
+    @Column(name = "thick")
+    var thick : Double? = null
+
+    // 以下是json解析字段
+
+//    @JSONField(name = "Owner")
+//    var jsonOwner : String? = null //
+//
+//    @JSONField(name = "Location")
+//    var jsonLocation : Location? = null //
+//
+//    @JSONField(name = "OutLine")
+//    var jsonOutline : ArrayList<ArrayList<Point>>? = null //
+//
+//    @JSONField(name = "SourceId")
+//    var jsonSourceId : String? = null //
+//
+//    @JSONField(name = "FaceDirection")
+//    var jsonFaceDirection : Point? = null //
+//
+//    @JSONField(name = "HandDirection")
+//    var jsonHandDirection : Point? = null //
+//
+//    @JSONField(name = "Thick")
+//    var jsonThick : Double? = null //
+//
+//    @JSONField(name = "Id")
+//    var jsonId : String? = null //
+//
+//    @JSONField(name = "ElementType")
+//    var jsonElementType : String? = null //
+//
+//    @JSONField(name = "Name")
+//    var jsonName: String? = null  //
+}

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

@@ -0,0 +1,119 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+package com.persagy.server.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.Id
+import javax.persistence.Table
+/**
+ * 设备
+ *
+ * @author jxing
+ */
+@Table(name = "revit.equipment")
+@JsonIgnoreProperties(ignoreUnknown = true)
+class Equipment : BaseComponent(){
+
+    /** 名称 */
+
+    @Column(name = "name")
+    var name: String? = null
+
+    /** 补充信息 */
+
+    @Column(name = "tag")
+    var tag: String? = null
+
+    /** 本地编码 */
+
+    @Column(name = "local_id")
+    var localId: String? = null
+
+    /** 本地名称 */
+
+    @Column(name = "local_name")
+    var localName: String? = null
+
+    /** 4位部件类型编码 */
+
+    @Column(name = "family")
+    var family: String? = null
+    set(value) {
+        field = value?.trim()
+    }
+
+
+    /** 类型中文名称 */
+    @Column(name = "family_name")
+    var familyName: String? = null
+
+    /** 族符号 */
+    @Column(name = "family_symbol")
+    var familySymbol: String? = null
+
+    /** 定位点 */
+    @Column(name = "location")
+    var location: MLocation? = null
+
+    /** 设备轮廓 */
+    @Column(name = "outline")
+    var outline : ArrayList<ArrayList<MPoint>>? = null
+
+    /** 参数列表 */
+    @Column(name = "parameters")
+    var parameters: ArrayList<Parameter>? = null
+
+    /** 旋转角度 */
+    @Column(name = "rotation")
+    var rotation: Double? = null
+
+    /** 资产id */
+    @Column(name = "property_id")
+    var propertyId: String? = null
+
+    /** BIMID */
+    @Column(name = "bimid")
+    var bimId: String? = null
+
+
+    /** 万达BIMTypeID */
+    @Column(name = "bim_type_id")
+    var bimTypeID: String? = null
+
+    /** 系统分类 */
+    @Column(name = "sys_name")
+    var sysName: String? = null
+
+
+    /** 初始4位部件类型编码 */
+    @Column(name = "init_family")
+    var initFamily: String? = null
+
+    /** 转换后的信息点 */
+    @Column(name = "infos")
+    var infos: Map<String,String>? = null
+}

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

@@ -0,0 +1,22 @@
+package com.persagy.server.models.entities
+
+import com.alibaba.fastjson.annotation.JSONField
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties
+import com.fasterxml.jackson.annotation.JsonProperty
+
+/**
+ *
+ *
+ * @author jxing
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+class Parameter {
+
+    @JSONField(name = "Name")
+    @JsonProperty("Name")
+    var name : String? = null
+
+    @JSONField(name = "Value")
+    @JsonProperty("Value")
+    val value : String? = null
+}

+ 23 - 0
datacenter/src/main/kotlin/com/persagy/server/models/entities/WindowDoorBase.kt

@@ -0,0 +1,23 @@
+package cn.sagacloud.server.algorithm.models.entities
+
+import com.alibaba.fastjson.annotation.JSONField
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties
+import com.fasterxml.jackson.annotation.JsonProperty
+import javax.persistence.Column
+
+/**
+ *
+ *
+ * @author jxing
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+open class WindowDoorBase : BaseComponent() {
+
+    /** 所属墙 */
+    @Column(name = "wall_id")
+    var wallId: String? = null
+
+    /** 拥有者的RevitId */
+    @Column(name = "owner")
+    var owner: String? = null
+}

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

@@ -0,0 +1,27 @@
+package com.persagy.server.models.`object`
+
+/**
+ *
+ * @author  Cainga
+ * @date  2021/2/13 14:47
+ */
+open class TwicePoint(x1: Double,y1:Double,x2:Double,y2:Double) {
+
+
+
+    var x1: Double? = null
+
+    var x2: Double? = null
+
+    var y1: Double? = null
+
+    var y2: Double? = null
+
+    //init代码块中可以访问主构造方法中的变量
+    init {
+        this.x1=x1
+        this.y1=y1
+        this.x2 = x2
+        this.y2 = y2
+    }
+}

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

@@ -0,0 +1,11 @@
+package com.persagy.server.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.service.SObjectService
+
+object BaseDataService {
+    val doorService = SObjectService(SMybatisDao(Door::class.java))
+    val connectorService = SObjectService(SMybatisDao(Connector::class.java))
+}

+ 61 - 0
datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/CalcSpecialService.kt

@@ -32,7 +32,11 @@ import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProje
 import com.persagy.server.datacenter.models.entities.graphtype.block.ConnectedBlock
 import com.persagy.server.datacenter.models.entities.rel.REq2Eq
 import com.persagy.server.mappers.ICalcSpecialMapper
+import com.persagy.server.models.entities.Connector
+import com.persagy.server.models.service.BaseDataService
 import com.persagy.server.services.assistant.RUpDateEquipAndSapceService
+import com.persagy.server.services.objects.EquipmentService
+import com.persagy.server.services.objects.FloorService
 import com.persagy.server.utils.IdUtils
 import com.persagy.service.SBaseService
 import com.persagy.service.SObjectService
@@ -245,4 +249,61 @@ open class CalcSpecialService {
         }
     } // Fun
 
+    /**
+     * @Description: 管网计算
+     * @Param:
+     * @Return:
+     */
+    fun calcNetworks(projectId: String,buildingId: String): SBaseResponse{
+        val floors = FloorService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId)).exec()
+        val rEq2Eqs = ArrayList<REq2Eq>()
+        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,String>(1024)
+                for (equipment in dcEquipments) {
+                    dcEquipMap[equipment.bimId!!] = equipment.id!!
+                }
+
+
+                var currentConnector: Connector? = null
+                val map = HashMap<String,Connector>(100000)
+                for (connector in connectors) {
+                    map[connector.revitId!!] = connector
+                }
+                for (connector in connectors) {
+                    if(connector.isUsed == true){
+                        continue
+                    }
+                    currentConnector = connector
+                    val id1 = dcEquipMap[connector.belongBimId]
+                    if(id1 == null){
+                        continue
+                    }
+                    while(currentConnector!!.connectedIds!!.size == 1){
+                        val revitId = currentConnector!!.connectedIds?.get(0)
+                        currentConnector = map[revitId]!!
+                        if(currentConnector!!.belongType == "Equipment" && connector!!.belongType == "Equipment" && currentConnector != connector){
+
+                            val id2 = dcEquipMap[currentConnector.belongBimId]
+                            if(id2 != null){
+                                val rEq2Eq = REq2Eq()
+                                rEq2Eq.id1 = id1
+                                rEq2Eq.id2 = id2
+                            }
+
+
+
+                        }
+                        currentConnector.isUsed = true
+                    }
+                }
+            }
+
+        }
+        return SBaseResponse(SResponseType.failure, "e.message!!")
+
+    }
+
 } // Class CalcSpecialService

+ 93 - 0
datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/CommonService.kt

@@ -0,0 +1,93 @@
+package com.persagy.server.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
+
+
+
+/**
+ *
+ *
+ * @author jxing
+ */
+object CommonService {
+
+
+    /**
+     * 获取MD5值
+     */
+    fun getMD5(btInput : ByteArray) : String {
+        return DigestUtils.md5DigestAsHex(btInput)
+    }
+
+    /**
+     * 获取文件服务器中的文件路径
+     */
+    fun getFilePathInFileService(uploadPath : String, modelId : String) : String{
+        return "${uploadPath}${modelId}.rvt"
+    }
+
+    /**
+     * 获取文件服务器中的key
+     */
+    fun getFileKeyInFileService(dir : String, modelId : String) : String{
+        return "${dir}/${modelId}.rvt"
+    }
+
+    /**
+     * 是否点在多边形内
+     */
+    fun isPointInPolygonCheckWithJdkGeneralPath(point: MPoint, polygon: ArrayList<PointPosition>): Boolean {
+        if(polygon.isEmpty())
+            return false
+        val p = getGeneralPath(polygon)
+        val newPoint = Point2D.Double()
+        newPoint.x = point.x
+        newPoint.y = point.y
+        return p.contains(newPoint)
+    }
+
+    /**
+     * 生成bimid前缀
+     */
+    fun generateBIMIDPrefix(projectId : String, folderId : String, floorName : String, hasColon : Boolean): String{
+        if(hasColon){
+            return "${projectId}${folderId}${floorName}:"
+        }
+        return "${projectId}${folderId}${floorName}"
+    }
+
+
+    /**
+     * 根据点数组获取围成的GeneralPath对象
+     */
+    fun getGeneralPath(polygon : ArrayList<PointPosition>) : GeneralPath{
+        val p = GeneralPath()
+        val first = polygon[0]
+        p.moveTo(first.x!!, first.y!!)
+        for (index in polygon.indices) {
+            if(index == 0)
+                continue
+            val tmpPoint = polygon[index]
+            p.lineTo(tmpPoint.x!!, tmpPoint.y!!)
+        }
+        p.lineTo(first.x!!, first.y!!)
+        p.closePath()
+        return p
+    }
+
+
+
+
+    /**
+     * 获取异常的堆栈信息
+     */
+    fun getStackTrace(e : Throwable): String? {
+        return org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e)
+    }
+}

+ 141 - 0
datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/RelationCalcService.kt

@@ -29,12 +29,18 @@ package com.persagy.server.services.relation_calc
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.Opt
+import com.persagy.server.datacenter.models.entities.graphtype.MPoint
 import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
 import com.persagy.server.datacenter.models.entities.rel.REq2Sp
+import com.persagy.server.datacenter.models.entities.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.services.assistant.RUpDateEquipAndSapceService
+import com.persagy.server.services.base.RService
 import com.persagy.server.services.objects.EquipmentService
+import com.persagy.server.services.objects.FloorService
 import com.persagy.server.services.objects.ZoneSpaceBaseService
 import com.persagy.server.services.rel.REq2SpService
 import com.persagy.server.utils.IdUtils
@@ -1181,4 +1187,139 @@ open class RelationCalcService {
         }
     }
 
+
+    /**
+     * @Description: 空间交通关系
+     * @Param:
+     * @Return:
+     */
+    fun calcSp2Sp(projectId: String,buildingId: String,objectType: String,type: String):SBaseResponse{
+        val distance = 100.00
+        val floors = FloorService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId)).exec()
+        val rSp2Sps =  ArrayList<RSp2Sp>()
+        for (floor in floors) {
+            if(!floor.modelId.isNullOrEmpty()){
+                val zoneSpaces = ZoneSpaceBaseService.select(SFilter.eq("projectId",projectId), SFilter.eq("floorId",floor.id!!), SFilter.eq("classCode",objectType)).exec()
+                val doors = BaseDataService.doorService.select(SFilter.eq("modelId",floor.modelId!!)).exec()
+                val pointList = ArrayList<TwicePoint>()
+
+                for (door in doors) {
+                    val outline = door.outline
+                    val point = door!!.location!!.points?.get(0)!!
+                    if(!outline.isNullOrEmpty()){
+                        val point1 = outline[0]!![0]
+                        val point2 = outline[0]!![1]
+                        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)
+                        }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)
+                        }
+                        pointList.add(twicePoint)
+                    }
+                }
+
+                val map = HashMap<Int,ArrayList<String>>()
+                for (index in 0 until pointList.size) {
+                    val mPoint1= MPoint(pointList[index].x1!!,pointList[index].y1!!,0.00)
+                    val mPoint2= MPoint(pointList[index].x2!!,pointList[index].y2!!,0.00)
+                    var isLocal1: Boolean
+                    var isLocal2: Boolean
+
+                    for (zoneSpace in zoneSpaces) {
+                        val zoneOutline = zoneSpace.outline
+                        if(zoneOutline.isNullOrEmpty()){
+                            continue
+                        }
+                        isLocal1 = CommonService.isPointInPolygonCheckWithJdkGeneralPath(mPoint1, zoneOutline?.get(0)?.get(0)!!)
+                        isLocal2 = CommonService.isPointInPolygonCheckWithJdkGeneralPath(mPoint2, zoneOutline?.get(0)?.get(0)!!)
+                        val spaceId = zoneSpace.id!!
+                        if(isLocal1 || isLocal2)
+                            if(map.containsKey(index)){
+                                val list = map[index]!!
+                                list.add(spaceId)
+                                map[index] = list
+                            }else{
+                                map[index] = arrayListOf(spaceId)
+                            }
+
+                    }
+
+                }
+                //map遍历
+                for (v in map.values) {
+
+                    val key = v[0] !!
+                    if(v.size > 1){
+                        for (index in  1 until v.size) {
+                            val rSp2SP = RSp2Sp()
+                            rSp2SP.id1 = key
+                            rSp2SP.id2 = v[index]
+                            rSp2SP.projectId = projectId
+                            rSp2SP.sign = 1
+                            rSp2SP.type = type
+                            rSp2SP.zoneType = objectType
+                            if(!rSp2Sps.contains(rSp2SP)){
+                                rSp2Sps.add(rSp2SP)
+                            }
+                        }
+                    }
+
+
+
+                }
+            }
+            val rSp2SpService = RService(SMybatisDao(RSp2Sp::class.java))
+            for (rSp2Sp in rSp2Sps) {
+                rSp2SpService.replace(rSp2Sp)
+            }
+        }
+        return SBaseResponse(SResponseType.success,"")
+    }
+
+
+    fun get_points(x1: Double, y1: Double , x2: Double, y2: Double): Double?{
+        if (x1 == y1 && x2 == y2){
+            return null
+        }
+        var k:Double? = null
+        // 计算当前线段的 k
+        if (x1 == x2){
+
+        }else{
+            k = (y2 - y1) / (x2 - x1)
+        }
+        var k2:Double?
+        //计算垂直方向的k
+        if (k == null){
+            k2 = 0.00
+        }else if(k == 0.00){
+            k2 = null
+        }else{
+            k2 = 1/k
+        }
+        return k2
+    }
+
+    //获取两点之间的距离
+    fun get_segment_distance(x1: Double, y1: Double , x2: Double, y2: Double): Double{
+        val x_diff = x2 - x1
+        val y_diff = y2 - y1
+        return Math.sqrt(x_diff * x_diff + y_diff * y_diff)
+    }
+
+    //获取坐标
+    fun  get_point_by_distance(base_x: Double, base_y: Double, k: Double, distance: Double): TwicePoint {
+        if(k == null){
+            return TwicePoint(base_x, base_y + distance, base_x, base_y - distance)
+        }
+        val vector_x1 = Math.sqrt(distance * distance / (1 + k * k))
+        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)
+    }
+
 } // Class RelationCalcService

+ 8 - 8
datacenter/src/main/resources/application-dev.yml

@@ -34,7 +34,7 @@ spring:
     type:                               com.alibaba.druid.pool.DruidDataSource
     driver-class-name:                  org.postgresql.Driver
 #    url:                                jdbc:postgresql://60.205.177.43:5432/datacenterlabsl
-    url:                                jdbc:postgresql://39.102.40.239:5432/datacenter
+    url:                                jdbc:postgresql://192.168.64.15:5432/datacenterwanda
     username:                           postgres
 #    password:                           persagy_2020qwe!@#
     password:                           cGVyc2FneV8yMDIwcXdlIUAj
@@ -45,13 +45,13 @@ spring:
       max-file-size:                   500MB        # 限制单个文件的最大值
 
     #配置rabbitMq 服务器
-#  rabbitmq:
-#    host: 39.102.43.179
-#    port: 9936
-#    username: admin
-#    password: brzj123456
-#    #虚拟host 可以不设置,使用 server 默认 host
-#    virtual-host: /test
+  rabbitmq:
+    host: 192.168.64.15
+    port: 9936
+    username: admin
+    password: brzj123456
+    #虚拟host 可以不设置,使用 server 默认 host
+    virtual-host: /test
 
 mqtopid: # 消息
   exchange:                           exchange-dmp

+ 2 - 2
datacenter/src/main/resources/logback-spring.xml

@@ -38,12 +38,12 @@
     </appender>
 
     <!-- 定义cn.sagacloud包的日志级别 -->
-    <logger name="com.persagy" level="ERROR" additivity="false">
+    <logger name="com.persagy" level="DEBUG" additivity="false">
         <appender-ref ref="STDOUT"/>
     </logger>
 
     <!-- 定义com.persagy包的日志级别 -->
-    <logger name="com.persagy" level="ERROR" additivity="false">
+    <logger name="com.persagy" level="DEBUG" additivity="false">
         <appender-ref ref="STDOUT"/>
     </logger>