Prechádzať zdrojové kódy

***********************WX*****************************
测试建筑 创建修改删除可以同步到物理世界

张维新 4 rokov pred
rodič
commit
5d4151b75b
28 zmenil súbory, kde vykonal 685 pridanie a 298 odobranie
  1. 5 33
      data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/objects/Tenant.kt
  2. 0 1
      data-core/src/main/kotlin/com/persagy/server/datacenter/models/jms/SynchronousMessage.kt
  3. 78 0
      data-core/src/main/kotlin/com/persagy/server/datacenter/models/jms/SynchronousMessageRel.kt
  4. 1 1
      datacenter/src/main/kotlin/com/persagy/server/controllers/dict/DictControllers.kt
  5. 2 2
      datacenter/src/main/kotlin/com/persagy/server/jms/RabbitMqService.kt
  6. 0 2
      datacenter/src/main/kotlin/com/persagy/server/jms/TopicReceiver.kt
  7. 6 0
      datacenter/src/main/kotlin/com/persagy/server/services/base/RService.kt
  8. 3 3
      datacenter/src/main/kotlin/com/persagy/server/services/base/ServiceSpace.kt
  9. 1 1
      datacenter/src/main/kotlin/com/persagy/server/services/objects/BuildingService.kt
  10. 2 2
      datacenter/src/main/kotlin/com/persagy/server/services/objects/EquipmentService.kt
  11. 14 1
      datacenter/src/main/kotlin/com/persagy/server/services/objects/GeneralSystemService.kt
  12. 9 4
      datacenter/src/main/kotlin/com/persagy/server/services/rel/REq2SpService.kt
  13. 11 224
      datacenter/src/main/kotlin/com/persagy/server/services/rel/REqInSpBaseService.kt
  14. 2 0
      datasyn/src/main/kotlin/com/persagy/server/syn/Configure.kt
  15. 76 1
      datasyn/src/main/kotlin/com/persagy/server/syn/jms/DataCenterSync.kt
  16. 31 0
      datasyn/src/main/kotlin/com/persagy/server/syn/jms/MessageProcessing.kt
  17. 7 4
      datasyn/src/main/kotlin/com/persagy/server/syn/jms/MessageReceiver.kt
  18. 7 0
      datasyn/src/main/kotlin/com/persagy/server/syn/models/api/obj/FloorApi.kt
  19. 7 1
      datasyn/src/main/kotlin/com/persagy/server/syn/models/api/obj/SystemApi.kt
  20. 1 0
      datasyn/src/main/kotlin/com/persagy/server/syn/models/tools/ShaftUtil.kt
  21. 4 4
      datasyn/src/main/kotlin/com/persagy/server/syn/models/tools/SpaceUtil.kt
  22. 1 1
      datasyn/src/main/kotlin/com/persagy/server/syn/models/tools/SystemUtil.kt
  23. 176 0
      datasyn/src/main/kotlin/com/persagy/server/syn/models/tools/VOTnUtil.kt
  24. 18 8
      datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/DataCenterEquipment.kt
  25. 9 5
      datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/DataCenterFloor.kt
  26. 104 0
      datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/DataCenterVOTn.kt
  27. 50 0
      datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/rel/EquipinSpaceSync.kt
  28. 60 0
      datasyn/src/main/kotlin/com/persagy/server/syn/task/SchedulerTaskRel.kt

+ 5 - 33
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/objects/Tenant.kt

@@ -47,86 +47,58 @@ class Tenant : BaseInfo() {
     @Schema(description = "租户id")
     @Id
     @Column(name = "id")
-    @JSONField(name = "TenantID")
     var id: String? = null
 
     /** 租户名称 */
     @Schema(description = "租户名称")
     @Column(name = "name")
-    @JSONField(name = "TenantName")
     var name: String? = null
 
     /** 租户本地编码 */
     @Schema(description = "租户本地编码")
     @Column(name = "local_id")
-    @JSONField(name = "TenantLocalID")
     var localId: String? = null
 
     /** 租户本地名称 */
     @Schema(description = "租户本地名称")
     @Column(name = "local_name")
-    @JSONField(name = "TenantLocalName")
     var localName: String? = null
 
     /** 租户本地编码2 */
     @Schema(description = "租户本地编码2")
     @Column(name = "local_id2")
-    @JSONField(name = "TenantLocalID2")
     var localId2: String? = null
 
     /** 租户本地名称2 */
     @Schema(description = "租户本地名称2")
     @Column(name = "local_name2")
-    @JSONField(name = "TenantLocalName2")
     var localName2: String? = null
 
     /** 项目id */
     @Schema(description = "项目id")
     @Column(name = "project_id")
-    @JSONField(name = "ProjectId")
     var projectId: String? = null
 
-    /** 租赁信息 */
-    @Schema(description = "租赁信息")
-    @Column(name = "lease_info")
-    @JSONField(name = "LeaseInfo")
-    var leaseInfo: HashMap<String,Any?>? = null
-
-    /** 能耗信息 */
-    @Schema(description = "能耗信息")
-    @Column(name = "consumption_info")
-    @JSONField(name = "ConsumptionInfo")
-    var consumptionInfo: HashMap<String,Any?>? = null
-
-    /** 动态信息 */
-    @Schema(description = "动态信息")
-    @Column(name = "dynamic_infor")
-    @JSONField(name = "DynamicInfor")
-    var dynamicInfor: HashMap<String,Any?>? = null
-
-    /** 自定义信息点 */
-    @Schema(description = "自定义信息点")
-    @Column(name = "custom_param")
-    @JSONField(name = "CustomParam")
-    var customParam: HashMap<String,Any?>? = null
+    /** 信息点 */
+    @Schema(description = "信息点")
+    @Column(name = "infos")
+    var infos: HashMap<String,Any?>? = null
+
 
     /** 对象类型 */
     @Schema(description = "对象类型")
     @Column(name = "object_type")
-    @JSONField(name = "ObjectType")
     override var objectType: String? = "Tenant"
 
 
     /** 租户租赁的租户业务空间  self = true  同样的对象查询时 id可以互相调换查询   */
     @Schema(description = "级联-租户租赁的租户业务空间")
     @SCascade(table="relationship.r_tn2sp", idColumn="tn_id", childIdColumn="sp_id", self = false,filter = "type = 'tn2sp' and zone_type = 'TenantZone'")
-    @JSONField(name = "ZoneTenantList")
     var zoneTenantList: ArrayList<ZoneSpace>? = null
 
     /** 租户租赁的默认业务空间  self = true  同样的对象查询时 id可以互相调换查询   */
     @Schema(description = "级联-租户租赁的默认业务空间")
     @SCascade(table="relationship.r_tn2sp", idColumn="tn_id", childIdColumn="sp_id", self = false,filter = "type = 'tn2sp' and zone_type = 'GeneralZone'")
-    @JSONField(name = "ZoneGeneraltList")
     var zoneGeneraltList: ArrayList<ZoneSpace>? = null
 
 } // Class Tenant

+ 0 - 1
data-core/src/main/kotlin/com/persagy/server/datacenter/models/jms/SynchronousMessage.kt

@@ -76,7 +76,6 @@ class SynchronousMessage : Serializable {
     var toId: String? = null
 
     /** 最后更新日期 */
-
     @Column(name = "last_update", updatable = false, insertable = false)
     var lastUpdate: Date? = null
 

+ 78 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/models/jms/SynchronousMessageRel.kt

@@ -0,0 +1,78 @@
+/*
+ * *********************************************************************************************************************
+ *
+ *          !!
+ *        .F88X
+ *        X8888Y
+ *      .}888888N;
+ *        i888888N;        .:!              .I$WI:
+ *          R888888I      .'N88~            i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
+ *          .R888888I    .;N8888~          .X8'  "8I.!,/8"  !%NY8`"8I8~~8>,88I
+ *            +888888N;  .8888888Y                                  "&&8Y.}8,
+ *            ./888888N;  .R888888Y        .'}~    .>}'.`+>  i}!    "i'  +/'  .'i~  !11,.:">,  .~]!  .i}i
+ *              ~888888%:  .I888888l      .]88~`1/iY88Ii+1'.R$8$8]"888888888>  Y8$  W8E  X8E  W8888'188Il}Y88$*
+ *              18888888    E8888881    .]W%8$`R8X'&8%++N8i,8N%N8+l8%`  .}8N:.R$RE%N88N%N$K$R  188,FE$8%~Y88I
+ *            .E888888I  .i8888888'      .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
+ *            8888888I  .,N888888~        ~88i"8W,!N8*.I88.}888%F,i$88"F88"  888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
+ *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
+ *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
+ *      .:R888888I
+ *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *        ~8888'
+ *        .!88~                                                                     All rights reserved.
+ *
+ * *********************************************************************************************************************
+ */
+
+package com.persagy.server.datacenter.models.jms
+
+import java.io.Serializable
+import java.util.*
+import javax.persistence.Column
+import javax.persistence.Id
+import javax.persistence.Table
+
+/**
+ * 同步消息体
+ *
+ * @author 张维新
+ */
+@Table(name = "synchronization.sync_data_relation")
+class SynchronousMessageRel : Serializable {
+
+    /** 同步任务 id */
+    @Column(name = "id")
+    @Id
+    var id: String? = null
+
+    /** 项目 id */
+    @Column(name = "project_id")
+    var projectId: String? = null
+
+    /** 操作类型 ,创建、修改、删除 */
+    @Column(name = "type")
+    var type: String? = null
+
+    /** 标记 0已处理,1待处理,2处理失败 */
+    @Column(name = "sign")
+    var sign: Int? = null
+
+    /** 操作符 */
+    @Column(name = "ops")
+    var ops: String? = null
+    /** 主 id */
+    @Column(name = "from_id")
+    var fromId: String? = null
+    /** 从 id */
+    @Column(name = "to_id")
+    var toId: String? = null
+
+    /** 最后更新日期 */
+    @Column(name = "last_update", updatable = false, insertable = false)
+    var lastUpdate: Date? = null
+
+    /** 创建时间 */
+    @Column(name = "create_time", updatable = false, insertable = false)
+    var createTime: Date? = null
+
+} // Class SynchronousMessageObj

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/controllers/dict/DictControllers.kt

@@ -79,7 +79,7 @@ class DictControllers {
      * @param request   查询条件
      * @return 查询结构
      */
-    @Operation(summary ="查询项目下类型的信息点",description = "")
+    @Operation(summary ="查询项目下类型的信息点",description = " 租户(VOTn)")
     @PostMapping(value = ["/query"])
     fun categoryInfoQuery(@RequestBody request: DictSQueryRequest): SQueryResponse<DefFuncId>{
         return DictDefClassService.categoryInfoQuery(request)

+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/jms/RabbitMqService.kt

@@ -155,11 +155,11 @@ class RabbitMqService: RabbitMqBaseService() {
      * @param fromId        主 id
      * @param toId          从 id
      */
-    fun sendRel(projectId: String,type: String,fromId: String,toId: String){
+    fun sendRel(projectId: String,type: String,ops: String,fromId: String,toId: String){
         /** 生成 id */
         val id = UUID.randomUUID().toString().replace("-", "")
         /** 消息对象 */
-        val messageNotice = MessageNotice(projectId, "rel", type, null, id,
+        val messageNotice = MessageNotice(projectId, "rel", type, ops, id,
             null, fromId, toId)
         /** 发送消息 */
         sendMessage(Opt.exchange!!,Opt.routingKey!!,messageNotice)

+ 0 - 2
datacenter/src/main/kotlin/com/persagy/server/jms/TopicReceiver.kt

@@ -26,8 +26,6 @@
 
 package com.persagy.server.jms
 
-import org.springframework.amqp.rabbit.annotation.RabbitHandler
-import org.springframework.amqp.rabbit.annotation.RabbitListener
 import org.springframework.stereotype.Component
 
 /**

+ 6 - 0
datacenter/src/main/kotlin/com/persagy/server/services/base/RService.kt

@@ -28,7 +28,9 @@ package com.persagy.server.services.base
 
 import com.persagy.database.SAbstractDao
 import com.persagy.server.datacenter.models.entities.base.RBaseInfo
+import com.persagy.server.jms.RabbitMqService
 import com.persagy.service.SObjectService
+import com.persagy.service.utils.SSpringContextUtil
 
 /**
  * 关系处理服务基类
@@ -48,6 +50,10 @@ open class RService<ENTITY : RBaseInfo>(daoClass: SAbstractDao<ENTITY>) : SObjec
 //        val kafkaService by lazy {
 //            SSpringContextUtil.getBean(KafkaService::class.java) as KafkaService
 //        }
+        /** RabbitMQ消息对象 */
+        val rabbitMqService by lazy {
+            SSpringContextUtil.getBean(RabbitMqService::class.java) as RabbitMqService
+        }
     } // Companion object
 
 

+ 3 - 3
datacenter/src/main/kotlin/com/persagy/server/services/base/ServiceSpace.kt

@@ -234,8 +234,8 @@ open class ServiceSpace<ENTITY : SBaseEntity>(daoClass: SAbstractDao<ENTITY>) :
     override fun onUpdateSuccess(entityList: ArrayList<ENTITY>) {
         try {
             val projectId = SPageContext.getHeader("projectId")
-            val comming = SPageContext.getHeader("Coming")
-            val account = SPageContext.getHeader("Account")
+            val comming = SPageContext.getHeader("coming")
+            val account = SPageContext.getHeader("account")
             val jsonObject = JSONObject()
             jsonObject.put("type", "7")
             jsonObject.put("projectId", projectId)
@@ -294,7 +294,7 @@ open class ServiceSpace<ENTITY : SBaseEntity>(daoClass: SAbstractDao<ENTITY>) :
             jsonObject.put("infos", jsonArray)
             logger.debug("修改发送消息$jsonObject")
             /** 发送消息 */
-            messageHandler.sendMessage(jsonObject.toString())
+//            messageHandler.sendMessage(jsonObject.toString())
         } catch (e: Exception) {
             e.printStackTrace()
         }

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/services/objects/BuildingService.kt

@@ -83,7 +83,7 @@ object BuildingService : Service<Building>(SMybatisDao(Building::class.java)) {
             val account = SPageContext.getHeader("account")
             entity.projectId = projectId
 
-            val exec = FloorService.select(SFilter.eq("buildId", entity.id!!)).exec()
+            val exec = FloorService.select(SFilter.eq("buildingId", entity.id!!)).exec()
 
             /** 日志 */
             DataCenterLogsService.addLogs(projectId!!,"delete","building",

+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/services/objects/EquipmentService.kt

@@ -296,7 +296,7 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
                 e.printStackTrace()
             }
             try {
-                val entity = EquipmentService.select(SFilter.eq("equipId", it.keyValue("id")!!)).entity()
+                val entity = EquipmentService.select(SFilter.eq("id", it.keyValue("id")!!)).entity()
                 if (entity != null) {
                     try {
                         /** 日志 */
@@ -324,7 +324,7 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
         try {
             for (entity in entityList) {
                 try {
-                    val equip = EquipmentService.select(SFilter.eq("equipId", entity.keyValue("id")!!)).entity()
+                    val equip = EquipmentService.select(SFilter.eq("id", entity.keyValue("id")!!)).entity()
                     if (equip != null) {
                         /** 日志 */
                         DataCenterLogsService.addLogs(Opt.projectId!!,"update-after",entity.objectType!!,

+ 14 - 1
datacenter/src/main/kotlin/com/persagy/server/services/objects/GeneralSystemService.kt

@@ -69,7 +69,20 @@ object GeneralSystemService : Service<GeneralSystem>(SMybatisDao(GeneralSystem::
      */
     override fun onCreateBefore(generalSystem: GeneralSystem): Boolean {
         val projectId = SPageContext.getHeader("projectId")
-
+        if (generalSystem.projectId.isNullOrEmpty()) {
+            generalSystem.projectId = projectId
+        }
+        if (generalSystem.classCode.isNullOrEmpty()) {
+            return false
+        }
+        if (!generalSystem.id.isNullOrEmpty()){
+            val isWith = generalSystem.id!!.startsWith("Sy")
+            if (!isWith) {
+                generalSystem.id = IdUtils.systemIdCreate(projectId!!)
+            }
+        }else {
+            generalSystem.id = IdUtils.systemIdCreate(projectId!!)
+        }
         return true
     } // Function onCreateBefore()
 

+ 9 - 4
datacenter/src/main/kotlin/com/persagy/server/services/rel/REq2SpService.kt

@@ -29,6 +29,9 @@ package com.persagy.server.services.rel
 import com.persagy.server.synchronize.MessageHandler
 import com.persagy.server.datacenter.models.entities.rel.REq2Sp
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
+import com.persagy.server.jms.RabbitMqService
+import com.persagy.server.services.base.RService
 import com.persagy.service.SObjectService
 import com.persagy.service.SPageContext
 import com.persagy.service.utils.SSpringContextUtil
@@ -36,9 +39,9 @@ import org.json.JSONObject
 
 object REq2SpService: SObjectService<REq2Sp>(SMybatisDao(REq2Sp::class.java)) {
 
-    /** MQ消息对象 */
-    val messageHandler by lazy {
-        SSpringContextUtil.getBean(MessageHandler::class.java) as MessageHandler
+    /** RabbitMQ消息对象 */
+    val rabbitMqService by lazy {
+        SSpringContextUtil.getBean(RabbitMqService::class.java) as RabbitMqService
     }
 
     override fun onDeleteSuccess(rEqInSpZoneLightingList: ArrayList<REq2Sp>) {
@@ -52,7 +55,9 @@ object REq2SpService: SObjectService<REq2Sp>(SMybatisDao(REq2Sp::class.java)) {
             jsonObject.put("linkId",rEqInSpZoneLighting.id1)
 
             /** 发送消息 */
-            messageHandler.sendMessage(jsonObject.toString())
+//            messageHandler.sendMessage(jsonObject.toString())
+            /** 发送消息 */
+            rabbitMqService.sendRel(Opt.projectId!!, "EquipinSpace","12",rEqInSpZoneLighting.id1!!,rEqInSpZoneLighting.id2!!)
 //            kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "EquipinSpace", "12", IdUtils.uuidCreate(), rEqInSpZoneLighting.spaceId!!, rEqInSpZoneLighting.equipId),false)
         }
     } // Fun onDeleteSuccess

+ 11 - 224
datacenter/src/main/kotlin/com/persagy/server/services/rel/REqInSpBaseService.kt

@@ -27,12 +27,15 @@
 package com.persagy.server.services.rel
 
 import com.persagy.base.extensions.toJson
+import com.persagy.database.extensions.keyValue
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.rel.REq2Sp
 import com.persagy.server.datacenter.models.entities.rel.REqInSpBase
 import com.persagy.server.datacenter.models.entities.rel.REqInSpBaseList
 import com.persagy.server.datacenter.models.entities.rel.RSpInEqBaseList
 import com.persagy.server.services.base.RService
+import com.persagy.server.services.base.Service
 import com.persagy.service.SObjectService
 import com.persagy.service.SPageContext
 import com.persagy.service.models.enums.SResponseType
@@ -81,120 +84,15 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
 
                         /** 发送消息 */
 //                        messageHandler.sendMessage(jsonObject.toString())
+                        /** 发送消息 */
+                        rabbitMqService.sendRel(Opt.projectId!!, "EquipinSpace","11",rEqInSpBase.equipId!!,rEqInSpBase.spaceId!!)
                     }
                 } catch (e: Exception) {
                     e.printStackTrace()
                 }
             }
             SCreateResponse(SResponseType.success)
-//            if (type == "HeatingZone"){
-//                REqInSpZoneHeatingService.create(rEqInSpBaseList.content)
-//            }else if (type == "CleanZone"){
-//                val list = ArrayList<REqInSpZoneClean>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneClean = REqInSpZoneClean()
-//                    rEqInSpZoneClean.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneClean.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneClean)
-//                }
-//                REqInSpZoneCleanService.create(list)
-//            }else if (type == "DomesticWaterSupplyZone"){
-//                val list = ArrayList<REqInSpZoneDomesticWaterSupply>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneDomesticWaterSupply = REqInSpZoneDomesticWaterSupply()
-//                    rEqInSpZoneDomesticWaterSupply.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZoneDomesticWaterSupply.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZoneDomesticWaterSupply)
-//                }
-//
-//                REqInSpZoneDomesticWaterSupplyService.create(list)
-//            }else if (type == "NetworkZone" ){
-//                val list= ArrayList<REqInSpZoneNetwork>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneNetwork = REqInSpZoneNetwork()
-//                    rEqInSpZoneNetwork.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneNetwork.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneNetwork)
-//                }
-//
-//                REqInSpZoneNetworkService.create(list)
-//            }else if (type == "TenantZone"){
-//                val list = ArrayList<REqInSpZoneTenant>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneTenant = REqInSpZoneTenant()
-//                    rEqInSpZoneTenant.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZoneTenant.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZoneTenant)
-//                }
-//                REqInSpZoneTenantService.create(list)
-//            }else if (type == "AirConditioningZone"){
-//                val list = ArrayList<REqInSpZoneAirConditioning>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneAirConditioning = REqInSpZoneAirConditioning()
-//                    rEqInSpZoneAirConditioning.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneAirConditioning.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneAirConditioning)
-//                }
-//                REqInSpZoneAirConditioningService.create(list)
-//            }else if (type == "FunctionZone"){
-//                val list = ArrayList<REqInSpZoneFunction>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneFunction = REqInSpZoneFunction()
-//                    rEqInSpZoneFunction.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZoneFunction.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZoneFunction)
-//                }
-//                REqInSpZoneFunctionService.create(list)
-//            }else if (type == "FireZone"){
-//                val list = ArrayList<REqInSpZoneFire>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneFire = REqInSpZoneFire()
-//                    rEqInSpZoneFire.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneFire.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneFire)
-//                }
-//                REqInSpZoneFireService.create(list)
-//            }else if (type == "SecurityZone"){
-//                val list = ArrayList<REqInSpZoneSecurity>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneSecurity = REqInSpZoneSecurity()
-//                    rEqInSpZoneSecurity.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZoneSecurity.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZoneSecurity)
-//                }
-//                REqInSpZoneSecurityService.create(list)
-//            }else if (type == "GeneralZone"){
-//                val list = ArrayList<REqInSpZoneGeneral>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneGeneral = REqInSpZoneGeneral()
-//                    rEqInSpZoneGeneral.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneGeneral.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneGeneral)
-//                }
-//                REqInSpZoneGeneralService.create(list)
-//            }else if (type == "PowerSupplyZone"){
-//                val list =ArrayList<REqInSpZonePowerSupply>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZonePowerSupply = REqInSpZonePowerSupply()
-//                    rEqInSpZonePowerSupply.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZonePowerSupply.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZonePowerSupply)
-//                }
-//                REqInSpZonePowerSupplyService.create(list)
-//            }else if (type == "LightingZone"){
-//                val list = ArrayList<REqInSpZoneLighting>()
-//                for (rEqInSpBase in rEqInSpBaseList.content){
-//                    val rEqInSpZoneLighting = REqInSpZoneLighting()
-//                    rEqInSpZoneLighting.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneLighting.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneLighting)
-//                }
-//                REqInSpZoneLightingService.create(list)
-//            }else{
-//                val sCreateResponse = SCreateResponse<REqInSpBase>(SResponseType.failure)
-//                sCreateResponse.message = "空间分区类型不存在:$type"
-//                sCreateResponse
-//            }
+
         } catch (e: Exception){
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
@@ -221,120 +119,6 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
             }
             REq2SpService.deleteByKeysList(list)
 
-//            if (type == "HeatingZone"){
-//                val list= ArrayList<REqInSpZoneHeating>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneHeating = REqInSpZoneHeating()
-//                    rEqInSpZoneHeating.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZoneHeating.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZoneHeating)
-//                }
-//                REqInSpZoneHeatingService.deleteByKeysList(list)
-//            }else if (type == "CleanZone"){
-//                val list = ArrayList<REqInSpZoneClean>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneClean = REqInSpZoneClean()
-//                    rEqInSpZoneClean.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneClean.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneClean)
-//                }
-//                REqInSpZoneCleanService.deleteByKeysList(list)
-//            }else if (type == "DomesticWaterSupplyZone"){
-//                val list = ArrayList<REqInSpZoneDomesticWaterSupply>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneDomesticWaterSupply = REqInSpZoneDomesticWaterSupply()
-//                    rEqInSpZoneDomesticWaterSupply.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZoneDomesticWaterSupply.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZoneDomesticWaterSupply)
-//                }
-//                REqInSpZoneDomesticWaterSupplyService.deleteByKeysList(list)
-//            }else if (type == "NetworkZone" ){
-//                val list= ArrayList<REqInSpZoneNetwork>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneNetwork = REqInSpZoneNetwork()
-//                    rEqInSpZoneNetwork.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneNetwork.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneNetwork)
-//                }
-//                REqInSpZoneNetworkService.deleteByKeysList(list)
-//            }else if (type == "TenantZone"){
-//                val list = ArrayList<REqInSpZoneTenant>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneTenant = REqInSpZoneTenant()
-//                    rEqInSpZoneTenant.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZoneTenant.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZoneTenant)
-//                }
-//                REqInSpZoneTenantService.deleteByKeysList(list)
-//            }else if (type == "AirConditioningZone"){
-//                val list = ArrayList<REqInSpZoneAirConditioning>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneAirConditioning = REqInSpZoneAirConditioning()
-//                    rEqInSpZoneAirConditioning.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneAirConditioning.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneAirConditioning)
-//                }
-//                REqInSpZoneAirConditioningService.deleteByKeysList(list)
-//            }else if (type == "FunctionZone"){
-//                val list = ArrayList<REqInSpZoneFunction>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneFunction = REqInSpZoneFunction()
-//                    rEqInSpZoneFunction.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZoneFunction.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZoneFunction)
-//                }
-//                REqInSpZoneFunctionService.deleteByKeysList(list)
-//            }else if (type == "FireZone"){
-//                val list = ArrayList<REqInSpZoneFire>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneFire = REqInSpZoneFire()
-//                    rEqInSpZoneFire.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneFire.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneFire)
-//                }
-//                REqInSpZoneFireService.deleteByKeysList(list)
-//            }else if (type == "SecurityZone"){
-//                val list = ArrayList<REqInSpZoneSecurity>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneSecurity = REqInSpZoneSecurity()
-//                    rEqInSpZoneSecurity.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZoneSecurity.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZoneSecurity)
-//                }
-//                REqInSpZoneSecurityService.deleteByKeysList(list)
-//            }else if (type == "GeneralZone"){
-//                val list = ArrayList<REqInSpZoneGeneral>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneGeneral = REqInSpZoneGeneral()
-//                    rEqInSpZoneGeneral.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneGeneral.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneGeneral)
-//                }
-//
-//                REqInSpZoneGeneralService.deleteByKeysList(list)
-//            }else if (type == "PowerSupplyZone"){
-//                val list =ArrayList<REqInSpZonePowerSupply>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZonePowerSupply = REqInSpZonePowerSupply()
-//                    rEqInSpZonePowerSupply.spaceId = rEqInSpBase.spaceId
-//                    rEqInSpZonePowerSupply.equipId = rEqInSpBase.equipId
-//                    list.add(rEqInSpZonePowerSupply)
-//                }
-//                REqInSpZonePowerSupplyService.deleteByKeysList(list)
-//            }else if (type == "LightingZone"){
-//                val list = ArrayList<REqInSpZoneLighting>()
-//                for (rEqInSpBase in rEqInSpBaseList){
-//                    val rEqInSpZoneLighting = REqInSpZoneLighting()
-//                    rEqInSpZoneLighting.equipId = rEqInSpBase.equipId
-//                    rEqInSpZoneLighting.spaceId = rEqInSpBase.spaceId
-//                    list.add(rEqInSpZoneLighting)
-//                }
-//                REqInSpZoneLightingService.deleteByKeysList(list)
-//            }else{
-//                val sCreateResponse = SCreateResponse<REqInSpBase>(SResponseType.failure)
-//                sCreateResponse.message = "空间分区类型不存在:$type"
-//                sCreateResponse
-//            }
         } catch (e: Exception) {
             e.printStackTrace()
             return SBaseResponse(SResponseType.failure, e.message!!)
@@ -376,7 +160,8 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
 
                 /** 发送消息 */
 //                RService.messageHandler.sendMessage(jsonObject.toString())
-
+                /** 发送消息 */
+                rabbitMqService.sendRel(Opt.projectId!!, "EquipinSpace","13",rEqInSpBaseList.equipId!!,successList.toJson()!!)
                 val sCreateResponse = SCreateResponse<REqInSpBase>(SResponseType.success)
                 if (failureList.size>0){
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -426,7 +211,8 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
 
                 /** 发送消息 */
 //                RService.messageHandler.sendMessage(jsonObject.toString())
-
+                /** 发送消息 */
+                rabbitMqService.sendRel(Opt.projectId!!, "EquipinSpace","13",rEqInSpBaseList.spaceId!!,successList.toJson()!!)
                 if (failureList.size>0){
                     val sCreateResponse = SCreateResponse<REqInSpBase>(SResponseType.success)
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -485,6 +271,7 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
                         jsonObject.put("linkId",successList.toJson())
                         /** 发送消息 */
 //                        messageHandler.sendMessage(jsonObject.toString())
+                        rabbitMqService.sendRel(Opt.projectId!!, "EquipinSpace","14",rEqInSpBaseList.spaceId!!,successList.toJson()!!)
                         if (failureList.size>0){
                             val sCreateResponse = SCreateResponse<RSpInEqBaseList>(SResponseType.success)
                             sCreateResponse.message ="失败对象:"+failureList.toJson()

+ 2 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/Configure.kt

@@ -60,6 +60,8 @@ object Configure {
     const val SYSTEM = "system"
     /** 对象类型 - 部件 */
     const val COMPONENT = "component"
+    /** 租户 */
+    const val VOTN = "VOTn"
 
     /** 创建 */
     const val CREATE = "create"

+ 76 - 1
datasyn/src/main/kotlin/com/persagy/server/syn/jms/DataCenterSync.kt

@@ -27,8 +27,10 @@
 package com.persagy.server.syn.jms
 
 import com.persagy.server.datacenter.models.jms.SynchronousMessage
+import com.persagy.server.datacenter.models.jms.SynchronousMessageRel
 import com.persagy.server.syn.Configure
 import com.persagy.server.syn.services.jms.*
+import com.persagy.server.syn.services.jms.rel.EquipinSpaceSync
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Service
 
@@ -61,7 +63,12 @@ class DataCenterSync {
     /** 空间 */
     @Autowired
     lateinit var dataCenterSpace: DataCenterSpace
-
+    /** 租户 */
+    @Autowired
+    lateinit var dataCenterVOTn: DataCenterVOTn
+    /** 设备所在的业务空间 */
+    @Autowired
+    lateinit var equipInSpaceSync: EquipinSpaceSync
 
     /**
      * 数据中心到 - 中台数据
@@ -100,10 +107,78 @@ class DataCenterSync {
                     /** 空间 */
                     dataCenterSpace.spaceType(message)
                 }
+                Configure.VOTN -> {
+                    /** 租户 */
+//                    dataCenterVOTn.tenantType(message)
+                }
+
             }
         }
         return true
     }
 
 
+    /**
+     * 处理关系数据到数据中台
+     */
+    fun  dataSyncRel(messageList:ArrayList<SynchronousMessageRel>){
+        for (message in messageList){
+            when(message.type){
+                "EquipinSpace" -> {
+                    /** 设备所在的空间  */
+                    when(message.ops){
+
+                        "11" -> { // 创建关系
+                            equipInSpaceSync.equipInSpaceCreate(message)
+                        }
+                        "12" -> { // 删除关系
+
+                        }
+                        "13" -> { // 清除之前的关系,替换
+
+                        }
+                        "14" -> {  // 添加不替换
+
+                        }
+
+                    }
+
+
+                }
+                "SystemEquip" -> {
+                    /** 系统包含的的设备 */
+                }
+                "Sy2Sh" -> {
+                    /** 竖井和系统的关系 */
+                }
+                "Sy2Sp" -> {
+                    /** 空间和系统的关系 */
+                }
+                "Eq2Bd" -> {
+                    /** 设备服务于建筑的关系 */
+                }
+                "Eq2Fl" -> {
+                    /** 设备服务于楼层的关系 */
+                }
+                "Eq2Sh" -> {
+                    /** 设备服务于竖井的关系 */
+                }
+                "EquipforSpace" -> {
+                    /** 设备服务于业务空间的关系 */
+                }
+                "EquipinShaft" -> {
+                    /** 设备所在竖井的关系 */
+                }
+                "Fl2Fl" -> {
+                    /** 楼层贯通关系 */
+                }
+                "Sh2Sh" -> {
+                    /** 竖井贯通关系 */
+                }
+
+            }
+        }
+    }
+
+
 }

+ 31 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/jms/MessageProcessing.kt

@@ -29,6 +29,7 @@ package com.persagy.server.syn.jms
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.jms.SynchronousMessage
+import com.persagy.server.datacenter.models.jms.SynchronousMessageRel
 import com.persagy.server.syn.jms.bean.SyncRwdDatacenterMessage
 import com.persagy.service.SObjectService
 import org.springframework.beans.factory.annotation.Autowired
@@ -44,6 +45,7 @@ class MessageProcessing {
 
     /** 缓存对象数据服务 - 数据中心到数据中台  */
     var synchronousMessageObjService = SObjectService(SMybatisDao(SynchronousMessage::class.java))
+    var synchronousMessageRelService = SObjectService(SMybatisDao(SynchronousMessageRel::class.java))
     /** 缓存对象数据 - 数据中台到数据中心 */
     var syncRwdMessageService = SObjectService(SMybatisDao(SyncRwdDatacenterMessage::class.java))
 
@@ -56,6 +58,7 @@ class MessageProcessing {
 
     var messageTypeRwd = 1
     var messageTypeDataCerten = 1
+    var messageTypeDataCenterRel = 1
     /**
      * 处理数据中台的消息到数据中心
      */
@@ -124,7 +127,35 @@ class MessageProcessing {
         }
     }
 
+    /**
+     * 处理关系数据到数据中台
+     */
+    fun syncDataCenterRel(){
 
+        try {
+            /** 不等于 0 时候执行同步 */
+            if (messageTypeDataCenterRel!=0){
+                /** 设置为 0  防止重复执行 */
+                messageTypeDataCenterRel =0
+                /** 查询待处理的消息 */
+                val messageList =
+                        synchronousMessageRelService.select(SFilter.not(SFilter.eq("sign", 0))).order("createTime").exec()
+                if (messageList.size>0) {
+                    /** 处理消息 */
+                    dataCenterSync.dataSyncRel(messageList)
+                    /** 开启执行 */
+                    messageTypeDataCenterRel = 1
+                    /** 查询是否有待处理的消息 */
+                    syncDataCenter()
+                } else {
+                    /** 开启下次执行 */
+                    messageTypeDataCenterRel = 1
+                }
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+    }
 
 
 

+ 7 - 4
datasyn/src/main/kotlin/com/persagy/server/syn/jms/MessageReceiver.kt

@@ -29,6 +29,7 @@ package com.persagy.server.syn.jms
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.jms.MessageNotice
 import com.persagy.server.datacenter.models.jms.SynchronousMessage
+import com.persagy.server.datacenter.models.jms.SynchronousMessageRel
 import com.persagy.server.syn.Configure
 import com.persagy.server.syn.jms.bean.SyncRwdDatacenterMessage
 import com.persagy.service.SObjectService
@@ -57,6 +58,8 @@ class MessageReceiver {
 
     /** 缓存对象数据服务 - 数据中心到数据中台  */
     var synchronousMessageObjService = SObjectService(SMybatisDao(SynchronousMessage::class.java))
+    /** 数据中心到数据中台关系 */
+    var synchronousMessageRelService = SObjectService(SMybatisDao(SynchronousMessageRel::class.java))
     /** 缓存对象数据 - 数据中台到数据中心 */
     var syncRwdMessageService = SObjectService(SMybatisDao(SyncRwdDatacenterMessage::class.java))
     /** 消息处理 */
@@ -67,8 +70,8 @@ class MessageReceiver {
     /**
      * 接收中台消息
      */
-    @RabbitListener(queues = ["queue-center-syn"])
-    @RabbitHandler
+//    @RabbitListener(queues = ["queue-center-syn"])
+//    @RabbitHandler
     fun process(mess: String) {
         logger.debug("接收中台消息:${mess}")
         /** 解析消息 */
@@ -137,7 +140,7 @@ class MessageReceiver {
                     }
                     "rel" -> {
                         /** 关系消息对象 */
-                        val messageRel = SynchronousMessage()
+                        val messageRel = SynchronousMessageRel()
                         messageRel.projectId = messageNotice.projectId
                         messageRel.id = UUID.randomUUID().toString().replace("-", "")
                         messageRel.sign = 1
@@ -145,7 +148,7 @@ class MessageReceiver {
                         messageRel.type = messageNotice.type
                         messageRel.fromId = messageNotice.fromId
                         messageRel.toId = messageNotice.toId
-                        synchronousMessageObjService.insert(messageRel)
+                        synchronousMessageRelService.insert(messageRel)
                     }
                 }
                 /** 处理消息 */

+ 7 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/models/api/obj/FloorApi.kt

@@ -27,12 +27,14 @@
 package com.persagy.server.syn.models.api.obj
 
 import com.alibaba.fastjson.JSONObject
+import com.persagy.base.extensions.toJson
 import com.persagy.base.utils.SHttpUtil
 import com.persagy.server.datacenter.models.entities.objects.Floor
 import com.persagy.server.syn.Opts
 import com.persagy.server.syn.models.obj.MiddleGroundDataRespose
 import com.persagy.server.syn.models.tools.FloorUtil
 import com.persagy.service.utils.SSpringContextUtil
+import org.slf4j.LoggerFactory
 
 /**
  * 楼层 API - 中台
@@ -41,6 +43,9 @@ import com.persagy.service.utils.SSpringContextUtil
  * @date  2020/10/20 10:18
  */
 object FloorApi {
+
+    /** 日志 */
+    private val logger = LoggerFactory.getLogger(FloorApi::class.java)
     /** 配置实例 */
     private val opts: Opts by lazy {
         SSpringContextUtil.getBean(Opts::class.java) as Opts
@@ -77,7 +82,9 @@ object FloorApi {
      */
     fun  createObj(groupCode: String,projectId: String, floor: Floor): Boolean {
         val url = "${opts.dataPlatform}/rwd/instance/object/create?groupCode=$groupCode&projectId=${projectId}&appId=datacenter"
+        logger.debug("url = ${url}")
         val buildingTools = FloorUtil.floorTools(projectId, floor)
+        logger.debug("boby = ${buildingTools.toJson()}")
         val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, buildingTools)
         if (postObject.result == "success") {
             return true

+ 7 - 1
datasyn/src/main/kotlin/com/persagy/server/syn/models/api/obj/SystemApi.kt

@@ -27,10 +27,12 @@
 package com.persagy.server.syn.models.api.obj
 
 import com.alibaba.fastjson.JSONObject
+import com.persagy.base.extensions.toJson
 import com.persagy.base.utils.SHttpUtil
 import com.persagy.server.syn.Opts
 import com.persagy.server.syn.models.obj.MiddleGroundDataRespose
 import com.persagy.service.utils.SSpringContextUtil
+import org.slf4j.LoggerFactory
 
 /**
  * 系统 API 中台
@@ -39,6 +41,9 @@ import com.persagy.service.utils.SSpringContextUtil
  * @date  2020/10/21 19:29
  */
 object SystemApi {
+
+    /** 日志 */
+    private val logger = LoggerFactory.getLogger(SystemApi::class.java)
     /** 配置实例 */
     private val opts: Opts by lazy {
         SSpringContextUtil.getBean(Opts::class.java) as Opts
@@ -54,11 +59,12 @@ object SystemApi {
         val url = "${opts.dataPlatform}/rwd/instance/object/query?groupCode=$groupCode&projectId=${projectId}"
         val jsonObject = JSONObject()
         val jsonObject2 = JSONObject()
-        jsonObject2["classCode"] = "system"
+        jsonObject2["objType"] = "system"
         jsonObject2["valid"] = 1
         jsonObject["criteria"] = jsonObject2
 
         val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, jsonObject)
+        logger.debug("结果= ${postObject.toJson()}")
         if (postObject.result == "success"&&!postObject.data.isNullOrEmpty()) {
             return postObject.data!!
         }

+ 1 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/models/tools/ShaftUtil.kt

@@ -78,6 +78,7 @@ object ShaftUtil {
 
         val shaft = Shaft()
         shaft.projectId = projectId
+
         for (key in mapObj.keys) {
             val containsKey = mapEx.containsKey(key)
             if (containsKey){

+ 4 - 4
datasyn/src/main/kotlin/com/persagy/server/syn/models/tools/SpaceUtil.kt

@@ -519,12 +519,12 @@ object SpaceUtil {
                         }
                         "outline" -> {
                             try {
-                                val replace1 = mapObj[key].toString().replace("X", "x")
-                                val replace2 = replace1.replace("Y", "y")
-                                val replace3 = replace2.replace("Z", "z")
+//                                val replace1 = mapObj[key].toString().replace("X", "x")
+//                                val replace2 = replace1.replace("Y", "y")
+//                                val replace3 = replace2.replace("Z", "z")
                                 val type = object : TypeToken<ArrayList<ArrayList<ArrayList<PointPosition>>>>() {
                                 }.type
-                                var outline=  Gson().fromJson<ArrayList<ArrayList<ArrayList<PointPosition>>>>(replace3,type)
+                                var outline=  Gson().fromJson<ArrayList<ArrayList<ArrayList<PointPosition>>>>(mapObj[key].toString(),type)
                                 zoneSpace.outline = outline
                             } catch (e: Exception) {
                                 e.printStackTrace()

+ 1 - 1
datasyn/src/main/kotlin/com/persagy/server/syn/models/tools/SystemUtil.kt

@@ -76,7 +76,7 @@ object SystemUtil {
 
         val generalSystem = GeneralSystem()
         generalSystem.projectId = projectId
-
+        generalSystem.classCode = mapObj["classCode"]!!.toString()
         for (key in mapObj.keys) {
             val containsKey = mapEx.containsKey(key)
             if (containsKey){

+ 176 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/models/tools/VOTnUtil.kt

@@ -0,0 +1,176 @@
+package com.persagy.server.syn.models.tools
+
+import com.persagy.base.extensions.toInt
+import com.persagy.base.extensions.toJson
+import com.persagy.database.SFilter
+import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.datacenter.models.entities.dictnew.DefFuncId
+import com.persagy.server.datacenter.models.entities.objects.Tenant
+import com.persagy.service.SObjectService
+import org.slf4j.LoggerFactory
+
+/**
+ * 租户工具
+ */
+object VOTnUtil {
+
+    /** 日志 */
+    private val logger = LoggerFactory.getLogger(ProjectUtil::class.java)
+    /** 信息点 */
+    private val dictDefFuncIdService = SObjectService(SMybatisDao(DefFuncId::class.java))
+
+    /**
+     * 设备转换
+     */
+    fun equipSyns(projectId: String,groupCode: String, mapObj: HashMap<String, Any?>): Tenant {
+        /** 查建楼层型字典 */
+        val dictDefFuncIdList = dictDefFuncIdService.select(SFilter.eq("groupCode", groupCode), SFilter.eq("projectId", projectId), SFilter.eq("classCode", mapObj["classCode"].toString())).exec()
+        val mapEx = HashMap<String, Any?>()
+        val mapCode = HashMap<String, Any?>()
+        /** 遍历项目类型字典 */
+        for (explainProject in dictDefFuncIdList) {
+            /** 输入类型 */
+            mapEx[explainProject.code!!] = explainProject.dataType
+            mapCode[explainProject.code!!] = explainProject.category
+        }
+        logger.debug("打印= ${mapObj.toJson()}")
+        val tenant = Tenant()
+        tenant.projectId = projectId
+        for (key in mapObj.keys) {
+            val containsKey = mapEx.containsKey(key)
+            if (containsKey){
+                if (key != "id"&& key!="name"&&key!="localId"&&key!="localName"&&key!="defaultQRCode"
+                        &&key!="qRCodePic"&&key!="rfId"&&key!="cadId"&&key!="bimFamilyName"&&key!="bimFamilySymbol"
+                        &&key!="bimTypeId"&&key!="bimId"&&key!="bimLocation"&&key!="equipSerial"){
+                    val containsKey1 = mapCode.containsKey(key)
+                    if (containsKey1){
+                        val any = mapCode[key].toString()
+                        if (any == "STATIC"){
+                            when(mapEx[key].toString()) {
+                                "INTEGER" -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toInt()
+                                }
+                                "DOUBLE" -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toString().toDoubleOrNull()
+                                }
+                                "BOOLEAN" -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toString().toBoolean()
+                                }
+                                "STRING" -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toString()
+                                }
+                                "DATETIME" -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toString()
+                                }
+                                "ATTACHMENT" -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toString()
+                                }
+                                "OBJECT" -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toString()
+                                }
+                                "ENUM" -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toString()
+                                }
+                                "MENUM" -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toString()
+                                }
+                                else -> {
+                                    if (tenant.infos.isNullOrEmpty()){
+                                        tenant.infos = HashMap<String,Any?>()
+                                    }
+                                    tenant.infos!![key] = mapObj[key]!!.toString()
+                                }
+                            }
+                        }else{
+                            if (tenant.infos.isNullOrEmpty()){
+                                tenant.infos = HashMap<String,Any?>()
+                            }
+                            tenant.infos!![key] = mapObj[key]!!.toString()
+                        }
+                    }
+
+                } else {
+                    when(key) {
+                        "id" -> tenant.id =  mapObj[key]!!.toString()
+                        "name" -> tenant.name =  mapObj[key]!!.toString()
+                        "localId" -> tenant.localId =  mapObj[key]!!.toString()
+                        "localName" -> tenant.localName =  mapObj[key]!!.toString()
+                    }
+                }
+
+            } else {
+//                if (equipment.infos.isNullOrEmpty()){
+//                    equipment.infos = HashMap<String,Any?>()
+//                }
+//                equipment.infos!![key] =  mapObj[key]!!.toString()
+            }
+        }
+
+        return tenant
+    }
+
+
+
+
+    /**
+     * 设备工具
+     *
+     * @param projectId     项目 id
+     * @param equipment     设备对象
+     * @return 返回结果
+     */
+    fun equipTools(projectId: String,tenant: Tenant): ArrayList<HashMap<String,Any?>> {
+        var list = ArrayList<HashMap<String,Any?>>()
+        val hashMap = HashMap<String, Any?>()
+        hashMap["id"] = tenant.id
+        hashMap["name"] = tenant.name
+        hashMap["projectId"] = projectId
+        hashMap["objType"] = "VOTn"
+        hashMap["classCode"] = "VOTn"
+        if (!tenant.localName.isNullOrEmpty()){
+            hashMap["localName"] = tenant.localName
+        }
+        if (!tenant.localId.isNullOrEmpty()){
+            hashMap["localId"] = tenant.localId
+        }
+
+        if (!tenant.infos.isNullOrEmpty()){
+            for (key in tenant.infos!!.keys){
+                hashMap[key] = tenant.infos!![key]
+            }
+        }
+
+        list.add(hashMap)
+        return list
+    }
+
+
+
+}

+ 18 - 8
datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/DataCenterEquipment.kt

@@ -74,15 +74,25 @@ class DataCenterEquipment {
                         /** 成功 */
                         message.sign = 0
 
+
                         if (dictProject!=null){
-                            val toJsonObjArray =
-                                Configure.toJsonObjArray("MechInArch", "Eq2Bd", equip.id!!, equip.buildingId!!)
-                            val toJsonObjArray2 =
-                                Configure.toJsonObjArray("MechInArch", "Eq2Fl", equip.id!!, equip.floorId!!)
-                            toJsonObjArray.plus(toJsonObjArray2[0])
-                            val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
-                            if (!createRel){
-                                message.sign = 2
+                            if (!equip.buildingId.isNullOrEmpty()&&!equip.floorId.isNullOrEmpty()){
+                                val toJsonObjArray =
+                                        Configure.toJsonObjArray("MechInArch", "Eq2Bd", equip.id!!, equip.buildingId!!)
+                                val toJsonObjArray2 =
+                                        Configure.toJsonObjArray("MechInArch", "Eq2Fl", equip.id!!, equip.floorId!!)
+                                toJsonObjArray.plus(toJsonObjArray2[0])
+                                val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
+                                if (!createRel){
+                                    message.sign = 2
+                                }
+                            }else if (!equip.buildingId.isNullOrEmpty()) {
+                                val toJsonObjArray =
+                                        Configure.toJsonObjArray("MechInArch", "Eq2Bd", equip.id!!, equip.buildingId!!)
+                                val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
+                                if (!createRel){
+                                    message.sign = 2
+                                }
                             }
                         } else {
                             /** 失败 */

+ 9 - 5
datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/DataCenterFloor.kt

@@ -75,11 +75,15 @@ class DataCenterFloor {
                         message.sign = 0
 
                         if (dictProject!=null) {
-                            /** 关系列表 */
-                            val ObjArray = toJsonObjArray("ArchSubset", "Bd2Fl", floor.buildingId!!, floor.id!!)
-                            val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, ObjArray)
-                            if (!createRel){
-                                message.sign = 2
+                            try {
+                                /** 关系列表 */
+                                val ObjArray = toJsonObjArray("ArchSubset", "Bd2Fl", floor.buildingId!!, floor.id!!)
+                                val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, ObjArray)
+                                if (!createRel){
+                                    message.sign = 2
+                                }
+                            } catch (e: Exception) {
+                                e.printStackTrace()
                             }
                         } else {
                             message.sign = 2

+ 104 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/DataCenterVOTn.kt

@@ -0,0 +1,104 @@
+package com.persagy.server.syn.services.jms
+
+import com.persagy.base.extensions.toJson
+import com.persagy.database.SFilter
+import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.datacenter.models.entities.dictnew.DictProject
+import com.persagy.server.datacenter.models.entities.objects.Tenant
+import com.persagy.server.datacenter.models.jms.SynchronousMessage
+import com.persagy.server.syn.Configure
+import com.persagy.server.syn.models.api.obj.EquipApi
+import com.persagy.server.syn.models.tools.VOTnUtil
+import com.persagy.service.SBaseService
+import com.persagy.service.SObjectService
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+/**
+ * 租户
+ */
+@Service
+class DataCenterVOTn {
+
+    companion object {
+        /** 日志 */
+        private val logger = LoggerFactory.getLogger(DataCenterBuilding::class.java)
+    } // Companion object
+    /** 租户服务 */
+    private val tenantService = SBaseService(SMybatisDao(Tenant::class.java))
+    /** 缓存对象数据服务 - 数据中心到数据中台  */
+    var synchronousMessageObjService = SObjectService(SMybatisDao(SynchronousMessage::class.java))
+    /** 字典项目服务 */
+    private val dictProjectService = SBaseService(SMybatisDao(DictProject::class.java))
+    /**
+     * 处理 数据中心到 - 数据中台的租户
+     */
+    fun tenantType(message: SynchronousMessage) {
+        val dictProject = dictProjectService.select(SFilter.eq("id", message.projectId!!)).entity()
+        logger.debug(" 处理租户***********************************")
+        when (message.type) {
+            Configure.CREATE -> {
+                /**查询租户信息 */
+                val tenant = tenantService.select(
+                        SFilter.eq("projectId", message.projectId!!),
+                        SFilter.eq("id", message.objId!!)
+                ).entity()
+                logger.debug(" 处理租户对象${tenant?.toJson()}***********************************")
+                /** 租户不为空 */
+                if (tenant!=null) {
+                    val tenantList = VOTnUtil.equipTools(message.projectId!!, tenant)
+                    val sign = EquipApi.createObj(dictProject!!.groupCode!!,message.projectId!!, tenantList)
+                    if (sign){
+                        /** 成功 */
+                        message.sign = 0
+                    }else {
+                        /** 失败 */
+                        message.sign = 2
+                    }
+                    /** 更改标记 */
+                    synchronousMessageObjService.update(message, arrayListOf("sign"))
+                }
+            }
+            Configure.UPDATE -> {
+                /** 修改 */
+                /**查询租户信息 */
+                val tenant = tenantService.select(
+                        SFilter.eq("projectId", message.projectId!!),
+                        SFilter.eq("id", message.objId!!)
+                ).entity()
+                /** 租户不为空 */
+                if (tenant!=null) {
+                    val equipList = VOTnUtil.equipTools(message.projectId!!, tenant)
+                    val sign = EquipApi.updateObj(dictProject!!.groupCode!!,message.projectId!!, equipList)
+                    if (sign){
+                        /** 成功 */
+                        message.sign = 0
+                    }else {
+                        /** 失败 */
+                        message.sign = 2
+                    }
+                    /** 更改标记 */
+                    synchronousMessageObjService.update(message, arrayListOf("sign"))
+                }
+            }
+            Configure.DELETE -> {
+                /** 删除 */
+                val sign = EquipApi.deleteObj(dictProject!!.groupCode!!,message.projectId!!, message.objId!!)
+                if (sign){
+                    /** 成功 */
+                    message.sign = 0
+                }else {
+                    /** 失败 */
+                    message.sign = 2
+                }
+                /** 更改标记 */
+                synchronousMessageObjService.update(message, arrayListOf("sign"))
+            }
+        }
+    }
+
+
+
+
+
+}

+ 50 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/rel/EquipinSpaceSync.kt

@@ -0,0 +1,50 @@
+package com.persagy.server.syn.services.jms.rel
+
+import com.persagy.database.SFilter
+import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.datacenter.models.entities.dictnew.DictProject
+import com.persagy.server.datacenter.models.jms.SynchronousMessageRel
+import com.persagy.server.syn.Configure
+import com.persagy.server.syn.models.api.obj.EquipApi
+import com.persagy.service.SObjectService
+import org.springframework.stereotype.Service
+
+/**
+ * 设备所在的业务空间
+ */
+@Service
+class EquipinSpaceSync {
+
+    /** 缓存对象数据服务 - 数据中心到数据中台  */
+    var synchronousMessageRelService = SObjectService(SMybatisDao(SynchronousMessageRel::class.java))
+    /** 项目所属的集团 */
+    private val dictProjectService = SObjectService(SMybatisDao(DictProject::class.java))
+    /**
+     * 创建关系
+     */
+    fun equipInSpaceCreate(synchronousMessageRel: SynchronousMessageRel){
+        try {
+            val dictProject = dictProjectService.select(SFilter.eq("id", synchronousMessageRel.projectId!!)).entity()
+            if (dictProject!=null) {
+                synchronousMessageRel.sign = 0
+                /** 关系列表 */
+                val toJsonObjArray =
+                        Configure.toJsonObjArray("MechInArch", "Eq2Sp", synchronousMessageRel.fromId!!, synchronousMessageRel.toId!!)
+
+                val createRel = EquipApi.createRel(dictProject.groupCode!!, synchronousMessageRel.projectId!!, toJsonObjArray)
+                if (!createRel ){
+                    synchronousMessageRel.sign = 2
+                }
+            } else {
+                synchronousMessageRel.sign = 2
+            }
+            /** 更改标记 */
+            synchronousMessageRelService.update(synchronousMessageRel, arrayListOf("sign"))
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+    }
+
+
+
+}

+ 60 - 0
datasyn/src/main/kotlin/com/persagy/server/syn/task/SchedulerTaskRel.kt

@@ -0,0 +1,60 @@
+/*
+ * *********************************************************************************************************************
+ *
+ *          !!
+ *        .F88X
+ *        X8888Y
+ *      .}888888N;
+ *        i888888N;        .:!              .I$WI:
+ *          R888888I      .'N88~            i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
+ *          .R888888I    .;N8888~          .X8'  "8I.!,/8"  !%NY8`"8I8~~8>,88I
+ *            +888888N;  .8888888Y                                  "&&8Y.}8,
+ *            ./888888N;  .R888888Y        .'}~    .>}'.`+>  i}!    "i'  +/'  .'i~  !11,.:">,  .~]!  .i}i
+ *              ~888888%:  .I888888l      .]88~`1/iY88Ii+1'.R$8$8]"888888888>  Y8$  W8E  X8E  W8888'188Il}Y88$*
+ *              18888888    E8888881    .]W%8$`R8X'&8%++N8i,8N%N8+l8%`  .}8N:.R$RE%N88N%N$K$R  188,FE$8%~Y88I
+ *            .E888888I  .i8888888'      .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
+ *            8888888I  .,N888888~        ~88i"8W,!N8*.I88.}888%F,i$88"F88"  888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
+ *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
+ *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
+ *      .:R888888I
+ *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *        ~8888'
+ *        .!88~                                                                     All rights reserved.
+ *
+ * *********************************************************************************************************************
+ */
+
+package com.persagy.server.syn.task
+
+import com.persagy.server.syn.jms.MessageProcessing
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.scheduling.annotation.Scheduled
+import org.springframework.stereotype.Service
+
+/**
+ * 任务 数据中心到数据中台
+ *
+ * @author wx  <zhangweixin@sagacloud.com>
+ * @date  2020/11/4 11:39
+ */
+@Service
+class SchedulerTaskRel {
+
+    var a = 0
+    companion object {
+        // 日志
+        private val logger = LoggerFactory.getLogger(SchedulerTaskRel::class.java)
+    } // Companion object
+
+    @Autowired
+    lateinit var messageProcessing: MessageProcessing
+
+    //cron表达式:每隔5秒执行一次
+//    @Scheduled(cron = "0 */3 * * * ?")
+    @Scheduled(cron="0/5 * *  * * ? ")   //每5秒执行一次
+    fun scheduled() {
+        logger.info("同步数据中心任务开始至数据中台")
+        messageProcessing.syncDataCenter()
+    }
+}