Selaa lähdekoodia

fix bug: 修复门,窗,柱,墙未同步物理世界的问题

lijie 2 vuotta sitten
vanhempi
commit
fcff0d1883

+ 233 - 5
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/backstage/sync/SyncEquipment.kt

@@ -2,12 +2,17 @@ package cn.sagacloud.server.algorithm.backstage.sync
 
 import cn.sagacloud.server.algorithm.backstage.model.datacenter.DCEquipment
 import cn.sagacloud.server.algorithm.backstage.model.datacenter.DCFloor
-import cn.sagacloud.server.algorithm.models.entities.Equipment
+import cn.sagacloud.server.algorithm.models.config.MyProperties
+import cn.sagacloud.server.algorithm.models.entities.*
+import cn.sagacloud.server.algorithm.models.jsonAnalyzer.Location
 import cn.sagacloud.server.algorithm.models.jsonAnalyzer.Point
 import cn.sagacloud.server.algorithm.models.modelFile.FloorModel
 import cn.sagacloud.server.algorithm.services.BaseDataService
 import cn.sagacloud.server.algorithm.services.CommonService
 import cn.sagacloud.server.algorithm.services.datacenter.DataCenterService
+import cn.sagacloud.server.datacenter.models.entities.graphtype.MLocation
+import cn.sagacloud.server.datacenter.models.entities.graphtype.MPoint
+import com.alibaba.fastjson.JSONObject
 import com.sybotan.database.SFilter
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.context.annotation.Scope
@@ -22,7 +27,7 @@ import org.springframework.stereotype.Component
 @Suppress("UNCHECKED_CAST")
 @Component
 @Scope("prototype")
-class SyncEquipment : SyncObject{
+class SyncEquipment : SyncObject {
     var modelId: String? = null
     var floor: FloorModel? = null
     var dcFloors : ArrayList<DCFloor>? = null
@@ -31,6 +36,8 @@ class SyncEquipment : SyncObject{
 
     @Autowired
     lateinit var dataCenterService: DataCenterService
+    @Autowired
+    lateinit var properties: MyProperties
 
     val dataService = BaseDataService
 
@@ -67,20 +74,239 @@ class SyncEquipment : SyncObject{
      * 准备模型数据
      */
     override fun prepareModelData() : SyncObject{
-        modelArr = dataService.equipmentService.select(SFilter.eq("modelId", modelId!!)).exec()
+        modelArr.addAll(dataService.equipmentService.select(SFilter.eq("modelId", modelId!!)).exec())
+        // 加上墙,门,窗,柱设备的同步
+        // 墙
+        val wallArr:ArrayList<Wall> = dataService.wallService.select(SFilter.eq("modelId", modelId!!)).exec()
+        // 门
+        val doorArr:ArrayList<Door> = dataService.doorService.select(SFilter.eq("modelId", modelId!!)).exec()
+        // 窗
+        val windowArr:ArrayList<Window> = dataService.windowService.select(SFilter.eq("modelId", modelId!!)).exec()
+        // 柱
+        val columnArr:ArrayList<Column> = dataService.columnService.select(SFilter.eq("modelId", modelId!!)).exec()
+        // 转换为设备对象
+        transferWallToEquipment(wallArr)
+        transferDoorToEquipment(doorArr)
+        transferWindowToEquipment(windowArr)
+        transferColumnToEquipment(columnArr)
         return this
     }
+    /**
+     * 将柱对象转换为设备对象
+     * @param arr : 柱对象列表
+     * @author : lijie
+     * Update By 2022/2/12 18:34
+     */
+    private fun transferColumnToEquipment(arr: List<Column>) {
+        if (arr.isNullOrEmpty()){
+            return
+        }
+        arr.forEach {
+            val columnEquip = Equipment()
+            columnEquip.localId=it.sourceId
+            columnEquip.localName=it.name
+            columnEquip.modelId=it.modelId
+            columnEquip.location=it.location
+            columnEquip.outline=it.outline
+            columnEquip.sourceId=it.sourceId
+            columnEquip.name=it.name
+            columnEquip.family=getFamilyFromFamilyName(it.familyName,properties.datacenter.equipColumn,false)
+            if (columnEquip.family.isNullOrEmpty()){
+                return
+            }
+            if (it.familyName.isNullOrBlank()){
+                columnEquip.familyName=columnEquip.family+"-"+columnEquip.name
+            }
+            columnEquip.familySymbol=it.familySymbol
+            modelArr.add(columnEquip)
+        }
+    }
+
+    /**
+     * 将窗数据转换为设备
+     * @param arr : 窗数据
+     * @author : lijie
+     * Update By 2022/2/12 18:28
+     */
+    private fun transferWindowToEquipment(arr: List<Window>) {
+        if (arr.isNullOrEmpty()){
+            return
+        }
+        arr.forEach {
+            val windowEquip = Equipment()
+            windowEquip.localId=it.sourceId
+            windowEquip.localName=it.name
+            windowEquip.modelId=it.modelId
+            windowEquip.location=transferMLocationToLocation(it.location)
+            windowEquip.outline=transferMoutlineToOutline(it.outline)
+            windowEquip.sourceId=it.sourceId
+            windowEquip.name=it.name
+            windowEquip.family=getFamilyFromFamilyName(it.familyName,properties.datacenter.equipWindow,false)
+            if (windowEquip.family.isNullOrEmpty()){
+                return
+            }
+            if (it.familyName.isNullOrBlank()){
+                windowEquip.familyName=windowEquip.family+"-"+windowEquip.name
+            }
+            windowEquip.familySymbol=it.familySymbol
+            modelArr.add(windowEquip)
+        }
+    }
+    /**
+     * 转换outline
+     * @author : lijie
+     * Update By 2022/2/12 18:49
+     */
+    private fun transferMoutlineToOutline(outline: List<List<MPoint>>?): ArrayList<ArrayList<Point>>? {
+        if (null==outline){
+            return null
+        }
+        val points=ArrayList<ArrayList<Point>>()
+        outline.forEach {
+            run {
+                val subPoints = ArrayList<Point>()
+                it.forEach {
+                    subPoints.add(JSONObject.parseObject(JSONObject.toJSONString(it), Point::class.java))
+                }
+                points.add(subPoints)
+            }
+        }
+        return points
+    }
+    /**
+     * 转换location
+     * @author : lijie
+     * Update By 2022/2/12 18:49
+     */
+    private fun transferMLocationToLocation(location: MLocation?): Location? {
+        if (null==location){
+            return null
+        }
+        return JSONObject.parseObject(JSONObject.toJSONString(location),Location::class.java)
+    }
+
+    /**
+     * 将门数据转换为设备
+     * @param arr : 门的数据
+     * @author : lijie
+     * Update By 2022/2/12 17:17
+     */
+    private fun transferDoorToEquipment(arr: List<Door>) {
+        if (arr.isNullOrEmpty()){
+            return
+        }
+        arr.forEach {
+            val doorEquip = Equipment()
+            doorEquip.localId=it.sourceId
+            doorEquip.localName=it.name
+            doorEquip.modelId=it.modelId
+            doorEquip.location=transferMLocationToLocation(it.location)
+            doorEquip.outline=transferMoutlineToOutline(it.outline)
+            doorEquip.sourceId=it.sourceId
+            doorEquip.name=it.name
+            doorEquip.family=getFamilyFromFamilyName(it.familyName,properties.datacenter.equipDoor,true)
+            if (doorEquip.family.isNullOrEmpty()){
+                return
+            }
+            if (it.familyName.isNullOrBlank()){
+                doorEquip.familyName=doorEquip.family+"-"+doorEquip.name
+            }
+            doorEquip.familySymbol=it.familySymbol
+            modelArr.add(doorEquip)
+        }
+    }
+
+    /**
+     * 将墙数据转换为设备数据
+     * @param arr : 墙的数据
+     * @author : lijie
+     * Update By 2022/2/12 10:28
+     */
+    private fun transferWallToEquipment(arr: List<Wall>) {
+        if (arr.isNullOrEmpty()){
+            return
+        }
+        arr.forEach {
+            val wallEquip = Equipment()
+            val infos = HashMap<String,String>()
+            if (null!=it.width){
+                infos[WIDTH_INFO_KEY] = it.width.toString()
+            }
+            wallEquip.infos=infos
+            wallEquip.localId=it.sourceId
+            wallEquip.localName=it.name
+            wallEquip.modelId=it.modelId
+            wallEquip.location=it.location
+            wallEquip.outline=it.outline
+            wallEquip.sourceId=it.sourceId
+            wallEquip.name=it.name
+            wallEquip.family=getFamilyFromName(it.name,properties.datacenter.equipWall)
+            if (wallEquip.family.isNullOrEmpty()){
+                return
+            }
+            wallEquip.familyName=wallEquip.family+"-"+wallEquip.name
+            modelArr.add(wallEquip)
+        }
+    }
+    /**
+     * 获取设备的镞编码
+     * @param name : 名称
+     * @param classCodes : 设备类编码
+     * @author : lijie
+     * Update By 2022/2/12 11:39
+     */
+    private fun getFamilyFromName(name: String?, classCodes: List<String>): String? {
+        if (classCodes.isNullOrEmpty()){
+            return null
+        }
+        if (!name.isNullOrEmpty()) {
+            val index = name.indexOf("-")
+            if(index != -1){
+                val family = name.substring(0, index)
+                classCodes.forEach { if (it.endsWith(family)){return it} }
+            }
+        }
+        return classCodes[0]
+    }
+    /**
+     * 获取设备的镞编码
+     * @param familyName : 名称
+     * @param classCodes : 设备类编码
+     * @author : lijie
+     * Update By 2022/2/12 11:39
+     */
+    private fun getFamilyFromFamilyName(familyName: String?, classCodes: List<String>,doorFlag:Boolean): String? {
+        if (classCodes.isNullOrEmpty()){
+            return null
+        }
+        if (!familyName.isNullOrEmpty()) {
+            val index = familyName.indexOf("-")
+            if(index != -1){
+                val family = familyName.substring(0, index)
+                classCodes.forEach { if (it.endsWith(family)){return it} }
+            }
+            if (doorFlag){
+                // 从名称中获取,如果族名称含有防火门关键字则返回防火门编码
+                if (familyName.contains("防火门")){
+                    return "FFFRDW"
+                }
+            }
+        }
+        return classCodes[0]
+    }
 
     /**
      * 准备数据中心数据
      */
     override fun prepareDataCenterData(): SyncObject {
-        if(floor == null || floor!!.projectId == null)
+        if(floor == null || floor!!.projectId == null) {
             return this
+        }
         val result = dataCenterService.getEquipmentByBIMIDPrefix(bimIdPrefix!!, floor!!.projectId!!)
         val cadIdResult = dataCenterService.getEquipmentByCADID(floor!!.projectId!!)
-        if(result == null || cadIdResult == null)
+        if(result == null || cadIdResult == null) {
             throw Exception("从数据中心获取设备失败!")
+        }
         if(result.isNotEmpty()) {
             dataCenter = result
         }
@@ -313,5 +539,7 @@ class SyncEquipment : SyncObject{
                 dcEquip.cadId = "${dcEquip.localId}:${dcEquip.localName}"
             }
         }
+
+        const val WIDTH_INFO_KEY = "width"
     }
 }

+ 4 - 0
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/models/config/DataCenterConfig.kt

@@ -14,6 +14,10 @@ class DataCenterConfig {
     lateinit var equipDelete: String
     lateinit var equipQuery: String
     lateinit var equipUpdate: String
+    lateinit var equipWall: List<String>
+    lateinit var equipDoor: List<String>
+    lateinit var equipWindow: List<String>
+    lateinit var equipColumn: List<String>
     lateinit var ispaceCreate: String
     lateinit var ispaceDelete: String
     lateinit var ispaceQuery: String

+ 0 - 4
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/models/entities/Door.kt

@@ -20,18 +20,14 @@
 
 package cn.sagacloud.server.algorithm.models.entities
 
-import cn.sagacloud.server.algorithm.models.jsonAnalyzer.Location
-import cn.sagacloud.server.algorithm.models.jsonAnalyzer.Point
 import cn.sagacloud.server.datacenter.models.entities.graphtype.MLocation
 import cn.sagacloud.server.datacenter.models.entities.graphtype.MPoint
 import com.alibaba.fastjson.annotation.JSONField
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties
 import com.fasterxml.jackson.annotation.JsonProperty
-import com.sybotan.service.models.SBaseEntity
 import io.swagger.annotations.ApiModel
 import io.swagger.annotations.ApiModelProperty
 import javax.persistence.Column
-import javax.persistence.Id
 import javax.persistence.Table
 /**
  * 门

+ 1 - 4
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/models/entities/Equipment.kt

@@ -26,11 +26,9 @@ import cn.sagacloud.server.algorithm.models.jsonAnalyzer.Point
 import com.alibaba.fastjson.annotation.JSONField
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties
 import com.fasterxml.jackson.annotation.JsonProperty
-import com.sybotan.service.models.SBaseEntity
 import io.swagger.annotations.ApiModel
 import io.swagger.annotations.ApiModelProperty
 import javax.persistence.Column
-import javax.persistence.Id
 import javax.persistence.Table
 /**
  * 设备
@@ -129,7 +127,6 @@ class Equipment : BaseComponent(){
     @JsonProperty("BimId")
     var bimId: String? = null
 
-
     /** 万达BIMTypeID */
     @ApiModelProperty(value = "万达BIMTypeID")
     @Column(name = "bim_type_id")
@@ -144,7 +141,6 @@ class Equipment : BaseComponent(){
     @JsonProperty("SysName")
     var sysName: String? = null
 
-
     /** 初始4位部件类型编码 */
     @ApiModelProperty(value = "初始4位部件类型编码")
     @Column(name = "init_family")
@@ -156,4 +152,5 @@ class Equipment : BaseComponent(){
     @ApiModelProperty(value = "转换后的信息点")
     @Column(name = "infos")
     var infos: Map<String,String>? = null
+
 }

+ 15 - 0
revit-algorithm/src/main/resources-dev/application.yml

@@ -136,6 +136,21 @@ properties:
     equipDelete: ${properties.datacenter.url}object/equip/delete
     equipQuery: ${properties.datacenter.url}object/equip/query
     equipUpdate: ${properties.datacenter.url}object/equip/update
+    # 墙,门,窗,柱设备类的配置,数组第一个为默认设备类编码
+    equipWall:
+      - CFCSWL
+    equipDoor:
+      - CFBEDR
+      - FFFRDW
+      - SPEGFG
+      - SPEGDR
+    equipWindow:
+      - CFBEWN
+      - FFSCVW
+      - FFFRDW
+    equipColumn:
+      - CFCSCL
+      - WEGMLP
     # 元空间相关接口
     ispaceCreate: ${properties.datacenter.url}object/ispace/create
     ispaceDelete: ${properties.datacenter.url}object/ispace/delete