|
@@ -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.DCEquipment
|
|
import cn.sagacloud.server.algorithm.backstage.model.datacenter.DCFloor
|
|
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.jsonAnalyzer.Point
|
|
import cn.sagacloud.server.algorithm.models.modelFile.FloorModel
|
|
import cn.sagacloud.server.algorithm.models.modelFile.FloorModel
|
|
import cn.sagacloud.server.algorithm.services.BaseDataService
|
|
import cn.sagacloud.server.algorithm.services.BaseDataService
|
|
import cn.sagacloud.server.algorithm.services.CommonService
|
|
import cn.sagacloud.server.algorithm.services.CommonService
|
|
import cn.sagacloud.server.algorithm.services.datacenter.DataCenterService
|
|
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 com.sybotan.database.SFilter
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
import org.springframework.context.annotation.Scope
|
|
import org.springframework.context.annotation.Scope
|
|
@@ -22,7 +27,7 @@ import org.springframework.stereotype.Component
|
|
@Suppress("UNCHECKED_CAST")
|
|
@Suppress("UNCHECKED_CAST")
|
|
@Component
|
|
@Component
|
|
@Scope("prototype")
|
|
@Scope("prototype")
|
|
-class SyncEquipment : SyncObject{
|
|
|
|
|
|
+class SyncEquipment : SyncObject {
|
|
var modelId: String? = null
|
|
var modelId: String? = null
|
|
var floor: FloorModel? = null
|
|
var floor: FloorModel? = null
|
|
var dcFloors : ArrayList<DCFloor>? = null
|
|
var dcFloors : ArrayList<DCFloor>? = null
|
|
@@ -31,6 +36,8 @@ class SyncEquipment : SyncObject{
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
lateinit var dataCenterService: DataCenterService
|
|
lateinit var dataCenterService: DataCenterService
|
|
|
|
+ @Autowired
|
|
|
|
+ lateinit var properties: MyProperties
|
|
|
|
|
|
val dataService = BaseDataService
|
|
val dataService = BaseDataService
|
|
|
|
|
|
@@ -67,20 +74,239 @@ class SyncEquipment : SyncObject{
|
|
* 准备模型数据
|
|
* 准备模型数据
|
|
*/
|
|
*/
|
|
override fun prepareModelData() : 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
|
|
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 {
|
|
override fun prepareDataCenterData(): SyncObject {
|
|
- if(floor == null || floor!!.projectId == null)
|
|
|
|
|
|
+ if(floor == null || floor!!.projectId == null) {
|
|
return this
|
|
return this
|
|
|
|
+ }
|
|
val result = dataCenterService.getEquipmentByBIMIDPrefix(bimIdPrefix!!, floor!!.projectId!!)
|
|
val result = dataCenterService.getEquipmentByBIMIDPrefix(bimIdPrefix!!, floor!!.projectId!!)
|
|
val cadIdResult = dataCenterService.getEquipmentByCADID(floor!!.projectId!!)
|
|
val cadIdResult = dataCenterService.getEquipmentByCADID(floor!!.projectId!!)
|
|
- if(result == null || cadIdResult == null)
|
|
|
|
|
|
+ if(result == null || cadIdResult == null) {
|
|
throw Exception("从数据中心获取设备失败!")
|
|
throw Exception("从数据中心获取设备失败!")
|
|
|
|
+ }
|
|
if(result.isNotEmpty()) {
|
|
if(result.isNotEmpty()) {
|
|
dataCenter = result
|
|
dataCenter = result
|
|
}
|
|
}
|
|
@@ -313,5 +539,7 @@ class SyncEquipment : SyncObject{
|
|
dcEquip.cadId = "${dcEquip.localId}:${dcEquip.localName}"
|
|
dcEquip.cadId = "${dcEquip.localId}:${dcEquip.localName}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ const val WIDTH_INFO_KEY = "width"
|
|
}
|
|
}
|
|
}
|
|
}
|