浏览代码

***********************WX*****************************

张维新 4 年之前
父节点
当前提交
024f597485
共有 26 个文件被更改,包括 412 次插入1106 次删除
  1. 1 2
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqForBdController.kt
  2. 1 1
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqForFlController.kt
  3. 1 1
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqForShController.kt
  4. 1 1
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqForSpConreoller.kt
  5. 1 1
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqInShController.kt
  6. 1 1
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqInSpController.kt
  7. 1 1
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/RFlThroughFlController.kt
  8. 0 26
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/RShContainSpBaseController.kt
  9. 1 13
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/RShaftThroughShaftController.kt
  10. 1 1
      datacenter/src/main/kotlin/com/persagy/server/controllers/rel/RSyEqController.kt
  11. 11 7
      datacenter/src/main/kotlin/com/persagy/server/jms/RabbitMqService.kt
  12. 0 2
      datacenter/src/main/kotlin/com/persagy/server/services/rel/REq2SpService.kt
  13. 14 46
      datacenter/src/main/kotlin/com/persagy/server/services/rel/REqForBdService.kt
  14. 14 46
      datacenter/src/main/kotlin/com/persagy/server/services/rel/REqForFlService.kt
  15. 13 45
      datacenter/src/main/kotlin/com/persagy/server/services/rel/REqForShService.kt
  16. 14 432
      datacenter/src/main/kotlin/com/persagy/server/services/rel/REqForSpBaseService.kt
  17. 16 63
      datacenter/src/main/kotlin/com/persagy/server/services/rel/REqInShService.kt
  18. 9 11
      datacenter/src/main/kotlin/com/persagy/server/services/rel/REqInSpBaseService.kt
  19. 11 41
      datacenter/src/main/kotlin/com/persagy/server/services/rel/RFlThroughFlService.kt
  20. 29 172
      datacenter/src/main/kotlin/com/persagy/server/services/rel/RShContainSpBaseService.kt
  21. 16 54
      datacenter/src/main/kotlin/com/persagy/server/services/rel/RShaftThroughShaftService.kt
  22. 60 118
      datacenter/src/main/kotlin/com/persagy/server/services/rel/RSyEqService.kt
  23. 58 0
      datasyn/src/main/kotlin/com/persagy/server/syn/Configure.kt
  24. 20 6
      datasyn/src/main/kotlin/com/persagy/server/syn/jms/DataCenterSync.kt
  25. 112 5
      datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/rel/EquipinSpaceSync.kt
  26. 6 10
      equip-component/src/main/kotlin/com/persagy/server/service/objects/ZoneSpaceBaseService.kt

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

@@ -105,5 +105,4 @@ class REqForBdController {
         logger.debug("build =${rEqForBd.toJson()}")
         return REqForBdService.createsBd(rEqForBd)
     } // Function createSy()
-
-} // Class RSyForBdController
+}

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqForFlController.kt

@@ -106,4 +106,4 @@ class REqForFlController {
         return REqForFlService.createsFl(rEqForFl)
     } // Function createSy()
 
-} // Class REqForFlController
+}

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqForShController.kt

@@ -107,4 +107,4 @@ class REqForShController {
         return REqForShService.createsSh(rEqForSh)
     } // Function createEq()
 
-} // Class REqForShController
+}

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqForSpConreoller.kt

@@ -94,4 +94,4 @@ class REqForSpConreoller {
         return REqForSpBaseService.createsSpEq(type,rEqForSpBase)
     } // Function createEq()
 
-} // Class REqForSpBaseConreoller
+}

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqInShController.kt

@@ -120,4 +120,4 @@ class REqInShController {
         return  REqInShService.createsShEq(rEqInSh)
     } // Function createEq()
 
-} // Class REqInShController
+}

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/controllers/rel/REqInSpController.kt

@@ -91,4 +91,4 @@ class REqInSpController {
         return REqInSpBaseService.createsSpEq(type,rEqInSpBase)
     } // Function createEq()
 
-} // Class REqInSpController
+}

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/controllers/rel/RFlThroughFlController.kt

@@ -106,4 +106,4 @@ class RFlThroughFlController {
         return RFlThroughFlService.createsFl(rFlThroughFl)
     } // Function createFl()
 
-} // Class RFlThroughFlController
+}

+ 0 - 26
datacenter/src/main/kotlin/com/persagy/server/controllers/rel/RShContainSpBaseController.kt

@@ -83,32 +83,6 @@ class RShContainSpBaseController {
         return RShContainSpBaseService.deletes(type,rShContainSpBase)
     } // Function delete()
 
-//    /**
-//     * 创建竖井下的业务空间关系
-//     *
-//     * @param   rShContainSpBase     竖井和业务空间的关系对象
-//     * @return                       创建的结果信息
-//     */
-//    @Operation(summary = "竖井下的业务空间,竖井一对多", description = "必填项:SpaceIdList(业务空间id列表)、ShaftID(竖井id),此方法会覆盖以前的记录")
-//    @PostMapping(value = ["link-sp"])
-//    fun createSp(@RequestBody rShContainSpBase: RShContainSpBaseList): SCreateResponse<RShContainSpBase> {
-//        logger.debug("space =${rShContainSpBase.toJson()}")
-//        return RShContainSpBaseService.createSh(rShContainSpBase)
-//    } // Function createSp()
-//
-//    /**
-//     * 创建竖井下的业务空间关系
-//     *
-//     * @param    rShContainSpBase     竖井和业务空间的关系对象
-//     * @return                        创建的结果信息
-//     */
-//    @Operation(summary = "业务空间关联竖井,业务空间一对多", description = "必填项:SpaceId(业务空间id)、ShaftIDList(竖井id列表),此方法会覆盖以前的记录")
-//    @PostMapping(value = ["/link-sh"])
-//    fun createSh(@RequestBody rShContainSpBase: RSpContainShBaseList): SCreateResponse<RShContainSpBase> {
-//        logger.debug("space =${rShContainSpBase.toJson()}")
-//        return RShContainSpBaseService.createsSp(rShContainSpBase)
-//    } // Function createSh()
-
 
     /**
      * 创建竖井下的业务空间关系

+ 1 - 13
datacenter/src/main/kotlin/com/persagy/server/controllers/rel/RShaftThroughShaftController.kt

@@ -105,17 +105,5 @@ class RShaftThroughShaftController {
         return RShaftThroughShaftService.createShaftAll(rFlThroughFl)
     } // Function createOr()
 
-//    /**
-//     * 创建楼层的贯通关系
-//     *
-//     * @param   rFlThroughFl    其他楼层和楼层列表关系对象
-//     * @return                  创建的结果信息
-//     */
-//    @Operation(summary = "楼层的贯通,其他楼层一对多",description = "必填项:FloorIdList(楼层id列表)、FloorOtherId(其他楼层id),测方法会覆盖以前的记录")
-//    @PostMapping(value = ["link-fl"])
-//    fun createFl(@RequestBody rFlThroughFl: RFloorOtherThroughFloorList): SCreateResponse<RFlThroughFl>{
-//        logger.debug("floor =${rFlThroughFl.toJson()}")
-//        return RFlThroughFlService.createsFl(rFlThroughFl)
-//    } // Function createFl()
 
-} // Class RFlThroughFlController
+}

+ 1 - 1
datacenter/src/main/kotlin/com/persagy/server/controllers/rel/RSyEqController.kt

@@ -132,4 +132,4 @@ class RSyEqController {
         return RSyEqService.deleteByKeysList(idList)
     } // Function deleteRSyEq()
 
-} // Class RSyEqController
+}

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

@@ -156,13 +156,17 @@ class RabbitMqService: RabbitMqBaseService() {
      * @param toId          从 id
      */
     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, ops, id,
-            null, fromId, toId)
-        /** 发送消息 */
-        sendMessage(Opt.exchange!!,Opt.routingKey!!,messageNotice)
+        try {
+            /** 生成 id */
+            val id = UUID.randomUUID().toString().replace("-", "")
+            /** 消息对象 */
+            val messageNotice = MessageNotice(projectId, "rel", type, ops, id,
+                null, fromId, toId)
+            /** 发送消息 */
+            sendMessage(Opt.exchange!!,Opt.routingKey!!,messageNotice)
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
     }
 
 

+ 0 - 2
datacenter/src/main/kotlin/com/persagy/server/services/rel/REq2SpService.kt

@@ -26,12 +26,10 @@
 
 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

+ 14 - 46
datacenter/src/main/kotlin/com/persagy/server/services/rel/REqForBdService.kt

@@ -28,6 +28,7 @@ package com.persagy.server.services.rel
 
 import com.persagy.base.extensions.toJson
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.rel.RBdForEqList
 import com.persagy.server.datacenter.models.entities.rel.REqForBd
 import com.persagy.server.datacenter.models.entities.rel.REqForBdList
@@ -57,16 +58,8 @@ object REqForBdService: RService<REqForBd>(SMybatisDao(REqForBd::class.java)) {
             rEqForBd.projectId = projectId
             val isInsert = insert(rEqForBd)
             if (isInsert){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "11")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForBd.equipId)
-                jsonObject.put("obj_type", "Eq2Bd")
-                jsonObject.put("linkId",rEqForBd.buildingId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Bd","11",rEqForBd.equipId!!,rEqForBd.buildingId!!)
                 SCreateResponse(SResponseType.success)
             }else{
                 SCreateResponse(SResponseType.failure)
@@ -75,7 +68,7 @@ object REqForBdService: RService<REqForBd>(SMybatisDao(REqForBd::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } //Function create()
+    }
 
     /**
      * 根据对象删除
@@ -85,20 +78,11 @@ object REqForBdService: RService<REqForBd>(SMybatisDao(REqForBd::class.java)) {
      */
     fun deletes(rEqForBd: REqForBd): SBaseResponse {
         return try {
-            val projectId = SPageContext.getHeader("ProjectId")
             val isDelete = delete(rEqForBd)
             /** 删除成功 */
             if (isDelete) {
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "12")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForBd.equipId)
-                jsonObject.put("obj_type", "Eq2Bd")
-                jsonObject.put("linkId",rEqForBd.buildingId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Bd","12",rEqForBd.equipId!!,rEqForBd.buildingId!!)
                 val sBaseResponse = SBaseResponse(SResponseType.success)
                 sBaseResponse.message = rEqForBd.toJson()
                 sBaseResponse
@@ -109,7 +93,7 @@ object REqForBdService: RService<REqForBd>(SMybatisDao(REqForBd::class.java)) {
             e.printStackTrace()
             return SBaseResponse(SResponseType.failure, e.message!!)
         }
-    } // Function deletes()
+    }
 
     /**
      * 创建设备服务于建筑关系
@@ -122,30 +106,22 @@ object REqForBdService: RService<REqForBd>(SMybatisDao(REqForBd::class.java)) {
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
-            delete("equipID = '${rEqForBdList.equipId}'")
-            val projectId = SPageContext.getHeader("ProjectId")
+            delete("equipId = '${rEqForBdList.equipId}'")
             for (buildingId in rEqForBdList.buildingIdList!!){
                 val rEqForBd = REqForBd()
                 rEqForBd.equipId = rEqForBdList.equipId
                 rEqForBd.buildingId = buildingId
-                rEqForBd.projectId = projectId
+                rEqForBd.projectId = Opt.projectId
                 val replace = replace(rEqForBd)
                 if (replace){
-                    successList.add(rEqForBd)
+                    successList.add(buildingId)
                 }else{
                     failureList.add(rEqForBd)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForBdList.equipId)
-                jsonObject.put("obj_type", "Eq2Bd")
-                jsonObject.put("linkId",successList.toJson())
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Bd","13",rEqForBdList.equipId!!,successList.toJson()!!)
                 val sCreateResponse = SCreateResponse<REqForBd>(SResponseType.success)
                 if (failureList.size>0){
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -158,7 +134,7 @@ object REqForBdService: RService<REqForBd>(SMybatisDao(REqForBd::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createEq()
+    }
 
     /**
      * 创建服务于建筑的设备关系
@@ -180,21 +156,14 @@ object REqForBdService: RService<REqForBd>(SMybatisDao(REqForBd::class.java)) {
                 rEqForBd.projectId = projectId
                 val replace = replace(rEqForBd)
                 if (replace){
-                    successList.add(rEqForBd)
+                    successList.add(equipId)
                 }else{
                     failureList.add(rEqForBd)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForBdList.buildingId)
-                jsonObject.put("obj_type", "Eq2Bd")
-                jsonObject.put("linkId",successList.toJson())
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Bd","13",rEqForBdList.buildingId!!,successList.toJson()!!)
                 if (failureList.size>0){
                     val sCreateResponse = SCreateResponse<REqForBd>(SResponseType.success)
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -210,6 +179,5 @@ object REqForBdService: RService<REqForBd>(SMybatisDao(REqForBd::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createsBd()
-
-} // Class REqForBdService
+    }
+}

+ 14 - 46
datacenter/src/main/kotlin/com/persagy/server/services/rel/REqForFlService.kt

@@ -28,6 +28,7 @@ package com.persagy.server.services.rel
 
 import com.persagy.base.extensions.toJson
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.rel.REqForFl
 import com.persagy.server.datacenter.models.entities.rel.REqForFlList
 import com.persagy.server.datacenter.models.entities.rel.RFlForEqList
@@ -56,16 +57,8 @@ object REqForFlService: RService<REqForFl>(SMybatisDao(REqForFl::class.java)) {
             rEqForFl.projectId = projectId
             val isInsert = insert(rEqForFl)
             if (isInsert){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "11")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForFl.equipId)
-                jsonObject.put("obj_type", "Eq2Fl")
-                jsonObject.put("linkId",rEqForFl.floorId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Fl","11",rEqForFl.equipId!!,rEqForFl.floorId!!)
                 SCreateResponse(SResponseType.success)
             }else{
                 SCreateResponse(SResponseType.failure)
@@ -74,7 +67,7 @@ object REqForFlService: RService<REqForFl>(SMybatisDao(REqForFl::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } //Function create()
+    }
 
     /**
      * 根据对象删除
@@ -83,20 +76,11 @@ object REqForFlService: RService<REqForFl>(SMybatisDao(REqForFl::class.java)) {
      */
     fun deletes(rEqForFl: REqForFl): SBaseResponse {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
             val isDelete = delete(rEqForFl)
             /** 删除成功 */
             if (isDelete) {
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "12")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForFl.equipId)
-                jsonObject.put("obj_type", "Eq2Fl")
-                jsonObject.put("linkId",rEqForFl.floorId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Fl","12",rEqForFl.equipId!!,rEqForFl.floorId!!)
                 val sBaseResponse = SBaseResponse(SResponseType.success)
                 sBaseResponse.message = rEqForFl.toJson()
                 sBaseResponse
@@ -121,29 +105,21 @@ object REqForFlService: RService<REqForFl>(SMybatisDao(REqForFl::class.java)) {
             /** 失败集合 */
             val failureList = ArrayList<Any>()
             delete("equipId = '${rEqForFlList.equipId}'")
-            val projectId = SPageContext.getHeader("projectId")
             for (floorId in rEqForFlList.floorIdList!!){
                 val rEqForFl = REqForFl()
                 rEqForFl.equipId = rEqForFlList.equipId
                 rEqForFl.floorId = floorId
-                rEqForFl.projectId = projectId
+                rEqForFl.projectId = Opt.projectId
                 val replace = replace(rEqForFl)
                 if (replace){
-                    successList.add(rEqForFl)
+                    successList.add(floorId)
                 }else{
                     failureList.add(rEqForFl)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForFlList.equipId)
-                jsonObject.put("obj_type", "Eq2Fl")
-                jsonObject.put("linkId",successList.toJson())
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-                
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Fl","13",rEqForFlList.equipId!!,successList.toJson()!!)
                 val sCreateResponse = SCreateResponse<REqForFl>(SResponseType.success)
                 if (failureList.size>0){
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -156,7 +132,7 @@ object REqForFlService: RService<REqForFl>(SMybatisDao(REqForFl::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createEq()
+    }
 
     /**
      * 创建服务于楼层的设备关系
@@ -169,30 +145,22 @@ object REqForFlService: RService<REqForFl>(SMybatisDao(REqForFl::class.java)) {
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
-            delete("floorID = '${rEqForFlList.floorId}'")
-            val projectId = SPageContext.getHeader("projectId")
+            delete("floorId = '${rEqForFlList.floorId}'")
             for (equipId in rEqForFlList.equipIdList!!){
                 val rEqForFl = REqForFl()
                 rEqForFl.floorId = rEqForFlList.floorId
                 rEqForFl.equipId = equipId
-                rEqForFl.projectId = projectId
+                rEqForFl.projectId = Opt.projectId
                 val replace = replace(rEqForFl)
                 if (replace){
-                    successList.add(rEqForFl)
+                    successList.add(equipId)
                 }else{
                     failureList.add(rEqForFl)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForFlList.floorId)
-                jsonObject.put("obj_type", "Eq2Fl")
-                jsonObject.put("linkId",successList.toJson())
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Fl","13",rEqForFlList.floorId!!,successList.toJson()!!)
                 if (failureList.size>0){
                     val sCreateResponse = SCreateResponse<REqForFl>(SResponseType.success)
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -208,6 +176,6 @@ object REqForFlService: RService<REqForFl>(SMybatisDao(REqForFl::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createsFl()
+    }
 
-} // Object REqForFlService
+}

+ 13 - 45
datacenter/src/main/kotlin/com/persagy/server/services/rel/REqForShService.kt

@@ -28,6 +28,7 @@ package com.persagy.server.services.rel
 
 import com.persagy.base.extensions.toJson
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.rel.REqForSh
 import com.persagy.server.datacenter.models.entities.rel.REqForShList
 import com.persagy.server.datacenter.models.entities.rel.RShForEqList
@@ -52,20 +53,11 @@ object REqForShService: RService<REqForSh>(SMybatisDao(REqForSh::class.java)) {
      */
     fun create(rEqForSh: REqForSh): SCreateResponse<REqForSh> {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
-            rEqForSh.projectId = projectId
+            rEqForSh.projectId = Opt.projectId
             val isInsert = insert(rEqForSh)
             if (isInsert){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "11")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForSh.equipId)
-                jsonObject.put("obj_type", "Eq2Sh")
-                jsonObject.put("linkId",rEqForSh.shaftId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Eq2Sh", "11", IdUtils.uuidCreate(), rEqForSh.equipId!!,rEqForSh.shaftId!!),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Sh","11",rEqForSh.equipId!!,rEqForSh.shaftId!!)
                 SCreateResponse(SResponseType.success)
             }else{
                 SCreateResponse(SResponseType.failure)
@@ -83,20 +75,11 @@ object REqForShService: RService<REqForSh>(SMybatisDao(REqForSh::class.java)) {
      */
     fun deletes(rEqForSh: REqForSh): SBaseResponse {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
             val isDelete = delete(rEqForSh)
             /** 删除成功 */
             if (isDelete) {
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "12")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForSh.equipId)
-                jsonObject.put("obj_type", "Eq2Sh")
-                jsonObject.put("linkId",rEqForSh.shaftId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Eq2Sh", "12", IdUtils.uuidCreate(), rEqForSh.equipId!!,rEqForSh.shaftId!!),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Sh","12",rEqForSh.equipId!!,rEqForSh.shaftId!!)
                 val sBaseResponse = SBaseResponse(SResponseType.success)
                 sBaseResponse.message = rEqForSh.toJson()
                 sBaseResponse
@@ -129,21 +112,14 @@ object REqForShService: RService<REqForSh>(SMybatisDao(REqForSh::class.java)) {
                 rEqForSh.projectId = projectId
                 val replace = replace(rEqForSh)
                 if (replace){
-                    successList.add(rEqForSh)
+                    successList.add(shaftId)
                 }else{
                     failureList.add(rEqForSh)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForShList.equipId)
-                jsonObject.put("obj_type", "Eq2Sh")
-                jsonObject.put("linkId",successList.toJson())
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Eq2Sh", "13", IdUtils.uuidCreate(), rEqForShList.equipId!!,null),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Sh","13",rEqForShList.equipId!!,successList.toJson()!!)
                 val sCreateResponse = SCreateResponse<REqForSh>(SResponseType.success)
                 if (failureList.size>0){
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -156,7 +132,7 @@ object REqForShService: RService<REqForSh>(SMybatisDao(REqForSh::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createEq()
+    }
 
     /**
      * 创建服务于竖井的设备关系
@@ -169,30 +145,22 @@ object REqForShService: RService<REqForSh>(SMybatisDao(REqForSh::class.java)) {
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
-            delete("shaftID = '${rEqForShList.shaftId}'")
-            val projectId = SPageContext.getHeader("projectId")
+            delete("shaftId = '${rEqForShList.shaftId}'")
             for (equipId in rEqForShList.equipIdList!!){
                 val rEqForSh = REqForSh()
                 rEqForSh.shaftId = rEqForShList.shaftId
                 rEqForSh.equipId = equipId
-                rEqForSh.projectId = projectId
+                rEqForSh.projectId = Opt.projectId
                 val replace = replace(rEqForSh)
                 if (replace){
-                    successList.add(rEqForSh)
+                    successList.add(equipId)
                 }else{
                     failureList.add(rEqForSh)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForShList.shaftId)
-                jsonObject.put("obj_type", "Eq2Sh")
-                jsonObject.put("linkId",successList.toJson())
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Eq2Sh", "13", IdUtils.uuidCreate(), rEqForShList.shaftId!!,null),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "Eq2Sh","13",rEqForShList.shaftId!!,successList.toJson()!!)
                 if (failureList.size>0){
                     val sCreateResponse = SCreateResponse<REqForSh>(SResponseType.success)
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -208,6 +176,6 @@ object REqForShService: RService<REqForSh>(SMybatisDao(REqForSh::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createsSh()
+    }
 
-} // Object REqForShService
+}

+ 14 - 432
datacenter/src/main/kotlin/com/persagy/server/services/rel/REqForSpBaseService.kt

@@ -28,9 +28,11 @@ package com.persagy.server.services.rel
 
 import com.persagy.base.extensions.toJson
 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.REqForSpBase
 import com.persagy.server.datacenter.models.entities.rel.RSpForEqBaseList
+import com.persagy.server.services.base.RService
 import com.persagy.service.SBaseService
 import com.persagy.service.SObjectService
 import com.persagy.service.SPageContext
@@ -45,7 +47,7 @@ import org.json.JSONObject
  *
  * @author 付国宝
  */
-object REqForSpBaseService: SBaseService<REqForSpBase>(SMybatisDao(REqForSpBase::class.java)){
+object REqForSpBaseService: RService<REqForSpBase>(SMybatisDao(REqForSpBase::class.java)){
 
 
     var rEq2SpService = SObjectService(SMybatisDao( REq2Sp::class.java))
@@ -57,29 +59,20 @@ object REqForSpBaseService: SBaseService<REqForSpBase>(SMybatisDao(REqForSpBase:
      */
     fun create(type: String, rEqForSpBase: SCreateRequest<REqForSpBase>): SCreateResponse<REqForSpBase> {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
-
             for (rEqForSp in rEqForSpBase.content){
 
                 try {
                     val rEq2Sp = REq2Sp()
                     rEq2Sp.id1 = rEqForSp.equipId
                     rEq2Sp.id2 = rEqForSp.spaceId
-                    rEq2Sp.projectId =projectId
+                    rEq2Sp.projectId = Opt.projectId
                     rEq2Sp.sign = 1
                     rEq2Sp.zoneType = type
                     rEq2Sp.type = "eq2sp_for"
                     val isInsert = rEq2SpService.insert(rEq2Sp)
                     if (isInsert){
-                        val jsonObject = JSONObject()
-                        jsonObject.put("type", "11")
-                        jsonObject.put("projectId", projectId)
-                        jsonObject.put("id", rEqForSp.spaceId)
-                        jsonObject.put("obj_type", "EquipforSpace")
-                        jsonObject.put("linkId",rEqForSp.equipId)
-
                         /** 发送消息 */
-//                        RService.messageHandler.sendMessage(jsonObject.toString())
+                        rabbitMqService.sendRel(Opt.projectId!!, "EquipforSpace","11",rEqForSp.equipId!!,rEqForSp.spaceId!!)
                     }else{
 
                     }
@@ -89,149 +82,11 @@ object REqForSpBaseService: SBaseService<REqForSpBase>(SMybatisDao(REqForSpBase:
             }
             SCreateResponse(SResponseType.success)
 
-
-//            if (type == "HeatingZone"){
-//                val list = ArrayList<REqForSpZoneHeating>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneHeating = REqForSpZoneHeating()
-//                    rEqForSpZoneHeating.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneHeating.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneHeating.projectId =projectId
-//
-//                    list.add(rEqForSpZoneHeating)
-//                }
-//                REqForSpZoneHeatingService.create(list)
-//            }else if (type == "CleanZone"){
-//                val list = ArrayList<REqForSpZoneClean>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneClean = REqForSpZoneClean()
-//                    rEqForSpZoneClean.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneClean.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneClean.projectId =projectId
-//
-//                    list.add(rEqForSpZoneClean)
-//                }
-//                REqForSpZoneCleanService.create(list)
-//            }else if (type == "DomesticWaterSupplyZone"){
-//                val list = ArrayList<REqForSpZoneDomesticWaterSupply>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneDomesticWaterSupply = REqForSpZoneDomesticWaterSupply()
-//                    rEqForSpZoneDomesticWaterSupply.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneDomesticWaterSupply.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneDomesticWaterSupply.projectId =projectId
-//
-//                    list.add(rEqForSpZoneDomesticWaterSupply)
-//                }
-//                REqForSpZoneDomesticWaterSupplyService.create(list)
-//            }else if (type == "NetworkZone" ){
-//                val list = ArrayList<REqForSpZoneNetwork>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneNetwork = REqForSpZoneNetwork()
-//                    rEqForSpZoneNetwork.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneNetwork.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneNetwork.projectId =projectId
-//
-//                    list.add(rEqForSpZoneNetwork)
-//                }
-//                REqForSpZoneNetworkService.create(list)
-//            }else if (type == "TenantZone"){
-//                val list = ArrayList<REqForSpZoneTenant>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneTenant = REqForSpZoneTenant()
-//                    rEqForSpZoneTenant.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneTenant.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneTenant.projectId =projectId
-//
-//                    list.add(rEqForSpZoneTenant)
-//                }
-//                REqForSpZoneTenantService.create(list)
-//            }else if (type == "AirConditioningZone"){
-//                val list = ArrayList<REqForSpZoneAirConditioning>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneAirConditioning = REqForSpZoneAirConditioning()
-//                    rEqForSpZoneAirConditioning.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneAirConditioning.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneAirConditioning.projectId =projectId
-//
-//                    list.add(rEqForSpZoneAirConditioning)
-//                }
-//                REqForSpZoneAirConditioningService.create(list)
-//            }else if (type == "FunctionZone"){
-//                val list = ArrayList<REqForSpZoneFunction>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneFunction = REqForSpZoneFunction()
-//                    rEqForSpZoneFunction.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneFunction.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneFunction.projectId =projectId
-//
-//                    list.add(rEqForSpZoneFunction)
-//                }
-//                REqForSpZoneFunctionService.create(list)
-//            }else if (type == "FireZone"){
-//                val list = ArrayList<REqForSpZoneFire>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneFire = REqForSpZoneFire()
-//                    rEqForSpZoneFire.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneFire.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneFire.projectId =projectId
-//
-//                    list.add(rEqForSpZoneFire)
-//                }
-//                REqForSpZoneFireService.create(list)
-//            }else if (type == "SecurityZone"){
-//                val list = ArrayList<REqForSpZoneSecurity>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneSecurity = REqForSpZoneSecurity()
-//                    rEqForSpZoneSecurity.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneSecurity.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneSecurity.projectId =projectId
-//
-//                    list.add(rEqForSpZoneSecurity)
-//                }
-//                REqForSpZoneSecurityService.create(list)
-//            }else if (type == "GeneralZone"){
-//                val list = ArrayList<REqForSpZoneGeneral>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneGeneral = REqForSpZoneGeneral()
-//                    rEqForSpZoneGeneral.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneGeneral.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneGeneral.projectId =projectId
-//
-//                    list.add(rEqForSpZoneGeneral)
-//                }
-//                REqForSpZoneGeneralService.create(list)
-//            }else if (type == "PowerSupplyZone"){
-//                val list = ArrayList<REqForSpZonePowerSupply>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZonePowerSupply = REqForSpZonePowerSupply()
-//                    rEqForSpZonePowerSupply.equipId = rEqForSpBase.equipId
-//                    rEqForSpZonePowerSupply.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZonePowerSupply.projectId =projectId
-//
-//                    list.add(rEqForSpZonePowerSupply)
-//                }
-//                REqForSpZonePowerSupplyService.create(list)
-//            }else if (type == "LightingZone"){
-//                val list = ArrayList<REqForSpZoneLighting>()
-//                for (rEqForSpBase in rEqForSpBase.content){
-//                    val rEqForSpZoneLighting = REqForSpZoneLighting()
-//                    rEqForSpZoneLighting.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneLighting.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneLighting.projectId =projectId
-//
-//                    list.add(rEqForSpZoneLighting)
-//                }
-//                REqForSpZoneLightingService.create(list)
-//            }else{
-//                val sCreateResponse = SCreateResponse<REqForSpBase>(SResponseType.failure)
-//                sCreateResponse.message = "空间分区类型不存在:$type"
-//                sCreateResponse
-//            }
         } catch (e: Exception){
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } //Function create()
+    }
 
     /**
      * 根据对象删除
@@ -240,262 +95,30 @@ object REqForSpBaseService: SBaseService<REqForSpBase>(SMybatisDao(REqForSpBase:
      */
     fun deletes(type: String, rEqForSpBaseList: ArrayList<REqForSpBase>): SBaseResponse {
         return try {
-
-            val projectId = SPageContext.getHeader("projectId")
             for (rEqForSpBase in rEqForSpBaseList){
                 try {
                     /** 删除成功 */
                     val rEq2Sp = REq2Sp()
-                    rEq2Sp.projectId = projectId
+                    rEq2Sp.projectId = Opt.projectId
                     rEq2Sp.id1 = rEqForSpBase.equipId
                     rEq2Sp.id2 = rEqForSpBase.spaceId
                     rEq2Sp.zoneType = type
                     rEq2Sp.type = "eq2sp_for"
                     val isDelete = rEq2SpService.delete(rEq2Sp)
                     if (isDelete) {
-                        val jsonObject = JSONObject()
-                        jsonObject.put("type", "12")
-                        jsonObject.put("projectId", projectId)
-                        jsonObject.put("id", rEqForSpBase.spaceId)
-                        jsonObject.put("obj_type", "EquipforSpace")
-                        jsonObject.put("linkId",rEqForSpBase.equipId)
-
                         /** 发送消息 */
-//                        RService.messageHandler.sendMessage(jsonObject.toString())
-    //                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "EquipforSpace", "12", IdUtils.uuidCreate(), rEqForSpZoneHeating.spaceId!!,rEqForSpZoneHeating.equipId),false)
+                        rabbitMqService.sendRel(Opt.projectId!!, "EquipforSpace","12",rEqForSpBase.equipId!!,rEqForSpBase.spaceId!!)
                     }
                 } catch (e: Exception) {
                     e.printStackTrace()
                 }
             }
-
             SBaseResponse(SResponseType.success)
-
-//            if (type == "HeatingZone"){
-//                val list = ArrayList<REqForSpZoneHeating>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneHeating = REqForSpZoneHeating()
-//                    rEqForSpZoneHeating.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneHeating.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneHeating.projectId =projectId
-//
-//                    list.add(rEqForSpZoneHeating)
-//                }
-//                REqForSpZoneHeatingService.deleteByKeysList(list)
-//            }else if (type == "CleanZone"){
-//                val list = ArrayList<REqForSpZoneClean>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneClean = REqForSpZoneClean()
-//                    rEqForSpZoneClean.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneClean.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneClean.projectId =projectId
-//
-//                    list.add(rEqForSpZoneClean)
-//                }
-//                REqForSpZoneCleanService.deleteByKeysList(list)
-//            }else if (type == "DomesticWaterSupplyZone"){
-//                val list = ArrayList<REqForSpZoneDomesticWaterSupply>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneDomesticWaterSupply = REqForSpZoneDomesticWaterSupply()
-//                    rEqForSpZoneDomesticWaterSupply.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneDomesticWaterSupply.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneDomesticWaterSupply.projectId =projectId
-//
-//                    list.add(rEqForSpZoneDomesticWaterSupply)
-//                }
-//                REqForSpZoneDomesticWaterSupplyService.deleteByKeysList(list)
-//            }else if (type == "NetworkZone" ){
-//                val list = ArrayList<REqForSpZoneNetwork>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneNetwork = REqForSpZoneNetwork()
-//                    rEqForSpZoneNetwork.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneNetwork.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneNetwork.projectId =projectId
-//
-//                    list.add(rEqForSpZoneNetwork)
-//                }
-//                REqForSpZoneNetworkService.deleteByKeysList(list)
-//            }else if (type == "TenantZone"){
-//                val list = ArrayList<REqForSpZoneTenant>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneTenant = REqForSpZoneTenant()
-//                    rEqForSpZoneTenant.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneTenant.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneTenant.projectId =projectId
-//
-//                    list.add(rEqForSpZoneTenant)
-//                }
-//                REqForSpZoneTenantService.deleteByKeysList(list)
-//            }else if (type == "AirConditioningZone"){
-//                val list = ArrayList<REqForSpZoneAirConditioning>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneAirConditioning = REqForSpZoneAirConditioning()
-//                    rEqForSpZoneAirConditioning.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneAirConditioning.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneAirConditioning.projectId =projectId
-//
-//                    list.add(rEqForSpZoneAirConditioning)
-//                }
-//                REqForSpZoneAirConditioningService.deleteByKeysList(list)
-//            }else if (type == "FunctionZone"){
-//                val list = ArrayList<REqForSpZoneFunction>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneFunction = REqForSpZoneFunction()
-//                    rEqForSpZoneFunction.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneFunction.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneFunction.projectId =projectId
-//
-//                    list.add(rEqForSpZoneFunction)
-//                }
-//                REqForSpZoneFunctionService.deleteByKeysList(list)
-//            }else if (type == "FireZone"){
-//                val list = ArrayList<REqForSpZoneFire>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneFire = REqForSpZoneFire()
-//                    rEqForSpZoneFire.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneFire.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneFire.projectId =projectId
-//
-//                    list.add(rEqForSpZoneFire)
-//                }
-//                REqForSpZoneFireService.deleteByKeysList(list)
-//            }else if (type == "SecurityZone"){
-//                val list = ArrayList<REqForSpZoneSecurity>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneSecurity = REqForSpZoneSecurity()
-//                    rEqForSpZoneSecurity.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneSecurity.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneSecurity.projectId =projectId
-//
-//                    list.add(rEqForSpZoneSecurity)
-//                }
-//                REqForSpZoneSecurityService.deleteByKeysList(list)
-//            }else if (type == "GeneralZone"){
-//                val list = ArrayList<REqForSpZoneGeneral>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneGeneral = REqForSpZoneGeneral()
-//                    rEqForSpZoneGeneral.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneGeneral.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneGeneral.projectId =projectId
-//
-//                    list.add(rEqForSpZoneGeneral)
-//                }
-//                REqForSpZoneGeneralService.deleteByKeysList(list)
-//            }else if (type == "PowerSupplyZone"){
-//                val list = ArrayList<REqForSpZonePowerSupply>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZonePowerSupply = REqForSpZonePowerSupply()
-//                    rEqForSpZonePowerSupply.equipId = rEqForSpBase.equipId
-//                    rEqForSpZonePowerSupply.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZonePowerSupply.projectId =projectId
-//
-//                    list.add(rEqForSpZonePowerSupply)
-//                }
-//                REqForSpZonePowerSupplyService.deleteByKeysList(list)
-//            }else if (type == "LightingZone"){
-//                val list = ArrayList<REqForSpZoneLighting>()
-//                for (rEqForSpBase in rEqForSpBaseList){
-//                    val rEqForSpZoneLighting = REqForSpZoneLighting()
-//                    rEqForSpZoneLighting.equipId = rEqForSpBase.equipId
-//                    rEqForSpZoneLighting.spaceId = rEqForSpBase.spaceId
-//                    rEqForSpZoneLighting.projectId =projectId
-//
-//                    list.add(rEqForSpZoneLighting)
-//                }
-//                REqForSpZoneLightingService.deleteByKeysList(list)
-//            }else{
-//                val sCreateResponse = SBaseResponse(SResponseType.failure)
-//                sCreateResponse.message = "空间分区类型不存在:$type"
-//                sCreateResponse
-//            }
         } catch (e: Exception) {
             e.printStackTrace()
             return SBaseResponse(SResponseType.failure, e.message!!)
         }
-    } // Function deletes()
-
-//    /**
-//     * 创建设备服务于业务空间关系
-//     *
-//     * @param    rEqForSpBaseList    设备和业务空间关系的对象列表
-//     */
-//    fun createEq(rEqForSpBaseList: REqForSpBaseList): SCreateResponse<REqForSpBase> {
-//        return try {
-//            /** 成功集合 */
-//            val successList = ArrayList<Any>()
-//            /** 失败集合 */
-//            val failureList = ArrayList<Any>()
-//            delete("equipId = '${rEqForSpBaseList.equipId}'")
-//            val projectId = SPageContext.getHeader("projectId")
-//            for (spaceId in rEqForSpBaseList.spaceIdList!!){
-//                val rEqForSpBase = REqForSpBase()
-//                rEqForSpBase.equipId = rEqForSpBaseList.equipId
-//                rEqForSpBase.spaceId = spaceId
-//                rEqForSpBase.projectId = projectId
-//                val replace = replace(rEqForSpBase)
-//                if (replace){
-//                    successList.add(rEqForSpBase)
-//                }else{
-//                    failureList.add(rEqForSpBase)
-//                }
-//            }
-//            if (successList.size>0){
-//                val sCreateResponse = SCreateResponse<REqForSpBase>(SResponseType.success)
-//                if (failureList.size>0){
-//                    sCreateResponse.message ="失败对象:"+failureList.toJson()
-//                }
-//                sCreateResponse
-//            }else{
-//                SCreateResponse(SResponseType.failure)
-//            }
-//        } catch (e: Exception) {
-//            e.printStackTrace()
-//            SCreateResponse(SResponseType.failure,e.message.toString())
-//        }
-//    } // Function createEq()
-
-//    /**
-//     * 创建服务于业务空间的设备关系
-//     *
-//     * @param    rEqForSpBaseList    设备和业务空间关系的对象列表
-//     */
-//    fun createsSp(rEqForSpBaseList: RSpForEqBaseList): SCreateResponse<REqForSpBase> {
-//        return try {
-//            /** 成功集合 */
-//            val successList = ArrayList<Any>()
-//            /** 失败集合 */
-//            val failureList = ArrayList<Any>()
-//            delete("spaceID = '${rEqForSpBaseList.spaceId}'")
-//            val projectId = SPageContext.getHeader("projectId")
-//            for (equipId in rEqForSpBaseList.equipIdList!!){
-//                val rEqForSpBase = REqForSpBase()
-//                rEqForSpBase.spaceId = rEqForSpBaseList.spaceId
-//                rEqForSpBase.equipId = equipId
-//                rEqForSpBase.projectId = projectId
-//                val replace = replace(rEqForSpBase)
-//                if (replace){
-//                    successList.add(rEqForSpBase)
-//                }else{
-//                    failureList.add(rEqForSpBase)
-//                }
-//            }
-//            if (successList.size>0){
-//                if (failureList.size>0){
-//                    val sCreateResponse = SCreateResponse<REqForSpBase>(SResponseType.success)
-//                    sCreateResponse.message ="失败对象:"+failureList.toJson()
-//                    sCreateResponse
-//                }else{
-//                    val sCreateResponse = SCreateResponse<REqForSpBase>(SResponseType.success)
-//                    sCreateResponse
-//                }
-//            }else{
-//                SCreateResponse(SResponseType.failure)
-//            }
-//        } catch (e:Exception){
-//            e.printStackTrace()
-//            SCreateResponse(SResponseType.failure,e.message.toString())
-//        }
-//    } // Function createsSp()
+    }
 
     /**
      * 创建服务于业务空间的设备关系
@@ -509,33 +132,23 @@ object REqForSpBaseService: SBaseService<REqForSpBase>(SMybatisDao(REqForSpBase:
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
-            val projectId = SPageContext.getHeader("projectId")
             for (equipId in rEqForSpBaseList.equipIdList!!){
                 val rEq2Sp = REq2Sp()
                 rEq2Sp.id2 = rEqForSpBaseList.spaceId
                 rEq2Sp.id1 = equipId
-                rEq2Sp.projectId = projectId
+                rEq2Sp.projectId = Opt.projectId
                 rEq2Sp.sign = 1
                 rEq2Sp.zoneType = type
                 rEq2Sp.type = "eq2sp_for"
                 val replace = rEq2SpService.replace(rEq2Sp)
                 if (replace){
-                    successList.add(rEq2Sp)
+                    successList.add(equipId)
                 }else{
                     failureList.add(rEq2Sp)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "14")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqForSpBaseList.spaceId)
-                jsonObject.put("obj_type", "EquipforSpace")
-                jsonObject.put("linkId",successList.toJson())
-
-                /** 发送消息 */
-//                RService.messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "EquipforSpace", "14", IdUtils.uuidCreate(), rSpForEqZoneHeatingList.spaceId!!,null),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "EquipforSpace","14",rEqForSpBaseList.spaceId!!,successList.toJson()!!)
                 if (failureList.size>0){
                     val sCreateResponse = SCreateResponse<RSpForEqBaseList>(SResponseType.success)
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -547,41 +160,10 @@ object REqForSpBaseService: SBaseService<REqForSpBase>(SMybatisDao(REqForSpBase:
             }else{
                 SCreateResponse(SResponseType.failure)
             }
-
-
-//            if (type == "HeatingZone"){
-//                REqForSpZoneHeatingService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "CleanZone"){
-//                REqForSpZoneCleanService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "DomesticWaterSupplyZone"){
-//                REqForSpZoneDomesticWaterSupplyService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "NetworkZone" ){
-//                REqForSpZoneNetworkService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "TenantZone"){
-//                REqForSpZoneTenantService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "AirConditioningZone"){
-//                REqForSpZoneAirConditioningService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "FunctionZone"){
-//                REqForSpZoneFunctionService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "FireZone"){
-//                REqForSpZoneFireService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "SecurityZone"){
-//                REqForSpZoneSecurityService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "GeneralZone"){
-//                REqForSpZoneGeneralService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "PowerSupplyZone"){
-//                REqForSpZonePowerSupplyService.createsSpEq(rEqForSpBaseList)
-//            }else if (type == "LightingZone"){
-//                REqForSpZoneLightingService.createsSpEq(rEqForSpBaseList)
-//            }else{
-//                val sCreateResponse = SCreateResponse<RSpForEqBaseList>(SResponseType.failure)
-//                sCreateResponse.message = "空间分区类型不存在:$type"
-//                sCreateResponse
-//            }
         } catch (e:Exception){
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createsSp()
+    }
 
-} // Object REqForSpBaseService
+}

+ 16 - 63
datacenter/src/main/kotlin/com/persagy/server/services/rel/REqInShService.kt

@@ -28,6 +28,7 @@ package com.persagy.server.services.rel
 
 import com.persagy.base.extensions.toJson
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.rel.REqInSh
 import com.persagy.server.datacenter.models.entities.rel.REqInShList
 import com.persagy.server.datacenter.models.entities.rel.RShInEqList
@@ -56,19 +57,8 @@ object REqInShService: RService<REqInSh>(SMybatisDao(REqInSh::class.java)) {
             rEqInSh.projectId = projectId
             val isInsert = insert(rEqInSh)
             if (isInsert){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "11")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqInSh.equipId)
-                jsonObject.put("obj_type", "EquipinShaft")
-                jsonObject.put("linkId",rEqInSh.shaftId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "EquipinShaft", "11", IdUtils.uuidCreate(),  rEqInSh.equipId!!,
-//                        rEqInSh.shaftId!!),false)
-
-
+                rabbitMqService.sendRel(Opt.projectId!!, "EquipinShaft","11",rEqInSh.equipId!!,rEqInSh.shaftId!!)
                 SCreateResponse(SResponseType.success)
             }else{
                 SCreateResponse(SResponseType.failure)
@@ -87,22 +77,11 @@ object REqInShService: RService<REqInSh>(SMybatisDao(REqInSh::class.java)) {
      */
     fun deletes(rEqInSh: REqInSh): SBaseResponse{
         return try {
-            val projectId = SPageContext.getHeader("projectId")
             val isDelete = delete(rEqInSh)
             /** 删除成功 */
             if (isDelete) {
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "12")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqInSh.equipId)
-                jsonObject.put("obj_type", "EquipinShaft")
-                jsonObject.put("linkId",rEqInSh.shaftId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "EquipinShaft", "12", IdUtils.uuidCreate(),  rEqInSh.equipId!!,
-//                        rEqInSh.shaftId!!),false)
-
+                rabbitMqService.sendRel(Opt.projectId!!, "EquipinShaft","12",rEqInSh.equipId!!,rEqInSh.shaftId!!)
                 val sBaseResponse = SBaseResponse(SResponseType.success)
                 sBaseResponse.message = rEqInSh.toJson()
                 sBaseResponse
@@ -126,30 +105,22 @@ object REqInShService: RService<REqInSh>(SMybatisDao(REqInSh::class.java)) {
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
-            delete("equipID = '${rEqInShList.equipId}'")
-            val projectId = SPageContext.getHeader("projectId")
+            delete("equipId = '${rEqInShList.equipId}'")
             for (shaftId in rEqInShList.shaftIdList!!){
                 val rEqInSh = REqInSh()
                 rEqInSh.equipId = rEqInShList.equipId
                 rEqInSh.shaftId = shaftId
-                rEqInSh.projectId = projectId
+                rEqInSh.projectId = Opt.projectId
                 val replace = replace(rEqInSh)
                 if (replace){
-                    successList.add(rEqInSh)
+                    successList.add(shaftId)
                 }else{
                     failureList.add(rEqInSh)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rEqInShList.equipId)
-                jsonObject.put("obj_type", "EquipinShaft")
-                jsonObject.put("linkId",successList.toJson())
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "EquipinShaft", "13", IdUtils.uuidCreate(),  rEqInShList.equipId!!,null),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "EquipinShaft","13",rEqInShList.equipId!!,successList.toJson()!!)
                 val sCreateResponse = SCreateResponse<REqInSh>(SResponseType.success)
                 if (failureList.size>0){
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -162,7 +133,7 @@ object REqInShService: RService<REqInSh>(SMybatisDao(REqInSh::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createEq()
+    }
 
     /**
      * 创建所在竖井的设备关系
@@ -184,21 +155,14 @@ object REqInShService: RService<REqInSh>(SMybatisDao(REqInSh::class.java)) {
                 rEqInSh.projectId = projectId
                 val replace = replace(rEqInSh)
                 if (replace){
-                    successList.add(rEqInSh)
+                    successList.add(equipId)
                 }else{
                     failureList.add(rEqInSh)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rShInEqList.shaftId)
-                jsonObject.put("obj_type", "EquipinShaft")
-                jsonObject.put("linkId",successList.toJson())
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "EquipinShaft", "13", IdUtils.uuidCreate(),  rShInEqList.shaftId!!,null),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "EquipinShaft","13",rShInEqList.shaftId!!,successList.toJson()!!)
                 if (failureList.size>0){
                     val sCreateResponse = SCreateResponse<REqInSh>(SResponseType.success)
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -214,7 +178,7 @@ object REqInShService: RService<REqInSh>(SMybatisDao(REqInSh::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createsSh()
+    }
 
     /**
      * 创建所在竖井的设备关系
@@ -227,31 +191,20 @@ object REqInShService: RService<REqInSh>(SMybatisDao(REqInSh::class.java)) {
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
-//            delete("shaftID = '${rShInEqList.shaftId}'")
-            val projectId = SPageContext.getHeader("projectId")
             for (equipId in rShInEqList.equipIdList!!){
                 val rEqInSh = REqInSh()
                 rEqInSh.shaftId = rShInEqList.shaftId
                 rEqInSh.equipId = equipId
-                rEqInSh.projectId = projectId
+                rEqInSh.projectId = Opt.projectId
                 val replace = replace(rEqInSh)
                 if (replace){
-                    successList.add(rEqInSh)
+                    successList.add(equipId)
                 }else{
                     failureList.add(rEqInSh)
                 }
             }
             if (successList.size>0){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "14")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rShInEqList.shaftId)
-                jsonObject.put("obj_type", "EquipinShaft")
-                jsonObject.put("linkId",successList.toJson())
-
-                /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "EquipinShaft", "14", IdUtils.uuidCreate(),  rShInEqList.shaftId!!,null),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "EquipinShaft","14",rShInEqList.shaftId!!,successList.toJson()!!)
                 if (failureList.size>0){
                     val sCreateResponse = SCreateResponse<REqInSh>(SResponseType.success)
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -267,6 +220,6 @@ object REqInShService: RService<REqInSh>(SMybatisDao(REqInSh::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createsSh()
+    }
 
-} // Object REqInShService
+}

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

@@ -136,16 +136,15 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
-            delete("equipId = '${rEqInSpBaseList.equipId}'")
-            val projectId = SPageContext.getHeader("projectId")
+            REq2SpService.delete("id1 = '${rEqInSpBaseList.equipId}'")
             for (spaceId in rEqInSpBaseList.spaceIdList!!){
                 val rEqInSpBase = REqInSpBase()
                 rEqInSpBase.equipId = rEqInSpBaseList.equipId
                 rEqInSpBase.spaceId = spaceId
-                rEqInSpBase.projectId = projectId
+                rEqInSpBase.projectId = Opt.projectId
                 val replace = replace(rEqInSpBase)
                 if (replace){
-                    successList.add(rEqInSpBase)
+                    successList.add(spaceId)
                 }else{
                     failureList.add(rEqInSpBase)
                 }
@@ -153,7 +152,7 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
             if (successList.size>0){
                 val jsonObject = JSONObject()
                 jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
+                jsonObject.put("projectId", Opt.projectId)
                 jsonObject.put("id", rEqInSpBaseList.equipId)
                 jsonObject.put("obj_type", "EquipinSpace")
                 jsonObject.put("linkId",successList.toJson())
@@ -187,16 +186,15 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
-            delete("spaceID = '${rEqInSpBaseList.spaceId}'")
-            val projectId = SPageContext.getHeader("projectId")
+            REq2SpService.delete("id2 = '${rEqInSpBaseList.spaceId}'")
             for (equipId in rEqInSpBaseList.equipIdList!!){
                 val rEqInSpBase = REqInSpBase()
                 rEqInSpBase.spaceId = rEqInSpBaseList.spaceId
                 rEqInSpBase.equipId = equipId
-                rEqInSpBase.projectId = projectId
+                rEqInSpBase.projectId = Opt.projectId
                 val replace = replace(rEqInSpBase)
                 if (replace){
-                    successList.add(rEqInSpBase)
+                    successList.add(equipId)
                 }else{
                     failureList.add(rEqInSpBase)
                 }
@@ -204,7 +202,7 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
             if (successList.size>0){
                 val jsonObject = JSONObject()
                 jsonObject.put("type", "13")
-                jsonObject.put("projectId", projectId)
+                jsonObject.put("projectId", Opt.projectId)
                 jsonObject.put("id", rEqInSpBaseList.spaceId)
                 jsonObject.put("obj_type", "EquipinSpace")
                 jsonObject.put("linkId",successList.toJson())
@@ -256,7 +254,7 @@ object REqInSpBaseService: RService<REqInSpBase>(SMybatisDao(REqInSpBase::class.
                         rEq2Sp.zoneType =  type
                         val replace = rEq2SpService.replace(rEq2Sp)
                         if (replace){
-                            successList.add(rEq2Sp)
+                            successList.add(rEq2Sp.id1!!)
                         }else{
                             failureList.add(rEq2Sp)
                         }

+ 11 - 41
datacenter/src/main/kotlin/com/persagy/server/services/rel/RFlThroughFlService.kt

@@ -28,6 +28,7 @@ package com.persagy.server.services.rel
 
 import com.persagy.base.extensions.toJson
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.rel.RFlThroughFl
 import com.persagy.server.datacenter.models.entities.rel.RFloorOtherThroughFloorList
 import com.persagy.server.datacenter.models.entities.rel.RFloorThroughFloorOtherList
@@ -56,16 +57,8 @@ object RFlThroughFlService : RService<RFlThroughFl>(SMybatisDao(RFlThroughFl::cl
             rFlThroughFl.projectId = projectId
             val isInsert = insert(rFlThroughFl)
             if (isInsert){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "11")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rFlThroughFl.floorId)
-                jsonObject.put("obj_type", "Fl2Fl")
-                jsonObject.put("linkId",rFlThroughFl.floorOtherId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Fl2Fl", "11", IdUtils.uuidCreate(),  rFlThroughFl.floorId!!, rFlThroughFl.floorOtherId!!),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "Fl2Fl","11",rFlThroughFl.floorId!!,rFlThroughFl.floorOtherId!!)
                 SCreateResponse(SResponseType.success)
             }else{
                 SCreateResponse(SResponseType.failure)
@@ -83,20 +76,11 @@ object RFlThroughFlService : RService<RFlThroughFl>(SMybatisDao(RFlThroughFl::cl
      */
     fun deletes(rFlThroughFl: RFlThroughFl): SBaseResponse {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
             val isDelete = delete(rFlThroughFl)
             /** 删除成功 */
             if (isDelete) {
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "12")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rFlThroughFl.floorId)
-                jsonObject.put("obj_type", "Fl2Fl")
-                jsonObject.put("linkId",rFlThroughFl.floorOtherId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Fl2Fl", "12", IdUtils.uuidCreate(),  rFlThroughFl.floorId!!, rFlThroughFl.floorOtherId!!),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "Fl2Fl","12",rFlThroughFl.floorId!!,rFlThroughFl.floorOtherId!!)
                 val sBaseResponse = SBaseResponse(SResponseType.success)
                 sBaseResponse.message = rFlThroughFl.toJson()
                 sBaseResponse
@@ -127,30 +111,23 @@ object RFlThroughFlService : RService<RFlThroughFl>(SMybatisDao(RFlThroughFl::cl
             } catch (e: Exception) {
                 e.printStackTrace()
             }
-            val projectId = SPageContext.getHeader("projectId")
             if (rFloorThroughFloorOtherList.floorOtherIdList!=null&&rFloorThroughFloorOtherList.floorOtherIdList!!.isNotEmpty()){
                 for (floorOtherId in rFloorThroughFloorOtherList.floorOtherIdList!!){
                     val rFlThroughFl = RFlThroughFl()
                     rFlThroughFl.floorId = rFloorThroughFloorOtherList.floorId
                     rFlThroughFl.floorOtherId = floorOtherId
-                    rFlThroughFl.projectId = projectId
+                    rFlThroughFl.projectId = Opt.projectId
                     val replace = replace(rFlThroughFl)
                     if (replace){
-                        successList.add(rFlThroughFl)
+                        successList.add(floorOtherId)
                     }else{
                         failureList.add(rFlThroughFl)
                     }
                 }
                 if (successList.size>0){
-                    val jsonObject = JSONObject()
-                    jsonObject.put("type", "13")
-                    jsonObject.put("projectId", projectId)
-                    jsonObject.put("id", rFloorThroughFloorOtherList.floorId)
-                    jsonObject.put("obj_type", "Fl2Fl")
-                    jsonObject.put("linkId",successList.toJson())
                     /** 发送消息 */
-//                    messageHandler.sendMessage(jsonObject.toString())
-//                    kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Fl2Fl", "13", IdUtils.uuidCreate(),  rFloorThroughFloorOtherList.floorId!!, null),false)
+                    rabbitMqService.sendRel(Opt.projectId!!, "Fl2Fl","13",rFloorThroughFloorOtherList.floorId!!,successList.toJson()!!)
+
                     val sCreateResponse = SCreateResponse<RFlThroughFl>(SResponseType.success)
                     if (failureList.size>0){
                         sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -196,21 +173,14 @@ object RFlThroughFlService : RService<RFlThroughFl>(SMybatisDao(RFlThroughFl::cl
                     rFlThroughFl.projectId = projectId
                     val replace = replace(rFlThroughFl)
                     if (replace){
-                        successList.add(rFlThroughFl)
+                        successList.add(floorId)
                     }else{
                         failureList.add(rFlThroughFl)
                     }
                 }
                 if (successList.size>0){
-                    val jsonObject = JSONObject()
-                    jsonObject.put("type", "13")
-                    jsonObject.put("projectId", projectId)
-                    jsonObject.put("id", rFollrOtherThroughFloorList.floorOtherId)
-                    jsonObject.put("obj_type", "Fl2Fl")
-                    jsonObject.put("linkId",successList.toJson())
                     /** 发送消息 */
-//                    messageHandler.sendMessage(jsonObject.toString())
-//                    kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Fl2Fl", "13", IdUtils.uuidCreate(),  rFollrOtherThroughFloorList.floorOtherId!!, null),false)
+                    rabbitMqService.sendRel(Opt.projectId!!, "Fl2Fl","13",rFollrOtherThroughFloorList.floorOtherId!!,successList.toJson()!!)
                     if (failureList.size>0){
                         val sCreateResponse = SCreateResponse<RFlThroughFl>(SResponseType.success)
                         sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -230,6 +200,6 @@ object RFlThroughFlService : RService<RFlThroughFl>(SMybatisDao(RFlThroughFl::cl
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Tenant createsFL()
+    }
 
-} // Object RFlThroughFlService()
+}

+ 29 - 172
datacenter/src/main/kotlin/com/persagy/server/services/rel/RShContainSpBaseService.kt

@@ -29,6 +29,7 @@ package com.persagy.server.services.rel
 import com.persagy.base.extensions.toJson
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.dict.SpaceInfoDic
 import com.persagy.server.datacenter.models.entities.objects.ZoneSpace
 import com.persagy.server.datacenter.models.entities.rel.RSh2Sp
@@ -50,7 +51,7 @@ import com.persagy.service.models.responses.SQueryResponse
  *
  * @author 付国宝
  */
-object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShContainSpBase::class.java)) {
+object RShContainSpBaseService: RService<RShContainSpBase>(SMybatisDao(RShContainSpBase::class.java)) {
 
     val rSh2SpService = RService(SMybatisDao(RSh2Sp::class.java))
 
@@ -62,61 +63,28 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
     fun create(rShContainSpBaseList: SCreateRequest<RShContainSpBase>): SCreateResponse<RShContainSpBase> {
         return try {
 
-            val projectId = SPageContext.getHeader("projectId")
             for (rShContainSpBase in rShContainSpBaseList.content){
                 val rSh2Sp = RSh2Sp()
                 rSh2Sp.id2 = rShContainSpBase.spaceId
                 rSh2Sp.id1 = rShContainSpBase.shaftId
-                rSh2Sp.projectId = projectId
+                rSh2Sp.projectId = Opt.projectId
                 rSh2Sp.sign = 1
                 rSh2Sp.zoneType = rShContainSpBase.objectType
                 rSh2Sp.type = "sh2sp"
                 val isInsert = rSh2SpService.insert(rSh2Sp)
-//                if (isInsert){
-//                    SCreateResponse(SResponseType.success)
-//                }else{
-//                    SCreateResponse(SResponseType.failure)
-//                }
+                if (isInsert){
+                    /** 发送消息 */
+                    rabbitMqService.sendRel(Opt.projectId!!, "sh2sp","11",rShContainSpBase.shaftId!!,rShContainSpBase.spaceId!!)
+                }
             }
 
-//            for (rShContainSpBase in rShContainSpBaseList.content){
-//                if (rShContainSpBase.objectType == "HeatingZone"){
-//                    RShContainSpZoneHeatingService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "CleanZone"){
-//                    RShContainSpZoneCleanService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "DomesticWaterSupplyZone"){
-//                    RShContainSpZoneDomesticWaterSupplyService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "NetworkZone" ){
-//                    RShContainSpZoneNetworkService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "TenantZone"){
-//                    RShContainSpZoneTenantService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "AirConditioningZone"){
-//                    RShContainSpZoneAirConditioningService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "FunctionZone"){
-//                    RShContainSpZoneFunctionService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "FireZone"){
-//                    RShContainSpZoneFireService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "SecurityZone"){
-//                    RShContainSpZoneSecurityService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "GeneralZone"){
-//                    RShContainSpZoneGeneralService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "PowerSupplyZone"){
-//                    RShContainSpZonePowerSupplyService.create(rShContainSpBase)
-//                }else if (rShContainSpBase.objectType == "LightingZone"){
-//                    RShContainSpZoneLightingService.create(rShContainSpBase)
-//                }else{
-//                    val sCreateResponse = SCreateResponse<RShContainSpBase>(SResponseType.failure)
-//                    sCreateResponse.message = "空间分区类型不存在:" + rShContainSpBase.objectType
-//                    sCreateResponse
-//                }
-//            }
             val sCreateResponse = SCreateResponse<RShContainSpBase>(SResponseType.success)
             sCreateResponse
         } catch (e: Exception) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function create()
+    }
 
     /**
      * 根据对象删除
@@ -127,59 +95,27 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
     fun deletes(type: String, rShContainSpBaseList: ArrayList<RShContainSpBase>): SBaseResponse {
         return try {
 
-            val projectId = SPageContext.getHeader("projectId")
             for (rShContainSpBase in rShContainSpBaseList){
                 val rSh2Sp = RSh2Sp()
                 rSh2Sp.id2 = rShContainSpBase.spaceId
                 rSh2Sp.id1 = rShContainSpBase.shaftId
-                rSh2Sp.projectId = projectId
+                rSh2Sp.projectId = Opt.projectId
                 rSh2Sp.zoneType = type
                 rSh2Sp.type = "sh2sp"
                 val isDelete = rSh2SpService.delete(rSh2Sp)
                 if (isDelete) {
-
-                } else {
-
+                    /** 发送消息 */
+                    rabbitMqService.sendRel(Opt.projectId!!, "sh2sp","12",rShContainSpBase.shaftId!!,rShContainSpBase.spaceId!!)
                 }
             }
             val sBaseResponse = SBaseResponse(SResponseType.success)
             sBaseResponse
 
-
-//            if (type == "HeatingZone"){
-//                RShContainSpZoneHeatingService.deletes(rShContainSpBaseList)
-//            }else if (type == "CleanZone"){
-//                RShContainSpZoneCleanService.deletes(rShContainSpBaseList)
-//            }else if (type == "DomesticWaterSupplyZone"){
-//                RShContainSpZoneDomesticWaterSupplyService.deletes(rShContainSpBaseList)
-//            }else if (type == "NetworkZone" ){
-//                RShContainSpZoneNetworkService.deletes(rShContainSpBaseList)
-//            }else if (type == "TenantZone"){
-//                RShContainSpZoneTenantService.deletes(rShContainSpBaseList)
-//            }else if (type == "AirConditioningZone"){
-//                RShContainSpZoneAirConditioningService.deletes(rShContainSpBaseList)
-//            }else if (type == "FunctionZone"){
-//                RShContainSpZoneFunctionService.deletes(rShContainSpBaseList)
-//            }else if (type == "FireZone"){
-//                RShContainSpZoneFireService.deletes(rShContainSpBaseList)
-//            }else if (type == "SecurityZone"){
-//                RShContainSpZoneSecurityService.deletes(rShContainSpBaseList)
-//            }else if (type == "GeneralZone"){
-//                RShContainSpZoneGeneralService.deletes(rShContainSpBaseList)
-//            }else if (type == "PowerSupplyZone"){
-//                RShContainSpZonePowerSupplyService.deletes(rShContainSpBaseList)
-//            }else if (type == "LightingZone"){
-//                RShContainSpZoneLightingService.deletes(rShContainSpBaseList)
-//            }else{
-//                val sCreateResponse = SCreateResponse<RShContainSpBase>(SResponseType.failure)
-//                sCreateResponse.message = "空间分区类型不存在:$type"
-//                sCreateResponse
-//            }
         } catch (e: Exception) {
             e.printStackTrace()
             return SBaseResponse(SResponseType.failure, e.message!!)
         }
-    } // Function deletes()
+    }
 
     /**
      * 创建竖井下业务空间关系
@@ -192,7 +128,7 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
-            rSh2SpService.delete("Id1 = '${rShContainSpBaseList.shaftId}'")
+            rSh2SpService.delete("id1 = '${rShContainSpBaseList.shaftId}'")
             val projectId = SPageContext.getHeader("projectId")
             for (spaceId in rShContainSpBaseList.spaceIdList!!){
                 val rSh2Sp = RSh2Sp()
@@ -204,12 +140,14 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
                 rSh2Sp.type = "sh2sp"
                 val replace = rSh2SpService.replace(rSh2Sp)
                 if (replace){
-                    successList.add(rSh2Sp)
+                    successList.add(spaceId)
                 }else{
                     failureList.add(rSh2Sp)
                 }
             }
             if (successList.size>0){
+                /** 发送消息 */
+                rabbitMqService.sendRel(Opt.projectId!!, "sh2sp","13",rShContainSpBaseList.shaftId!!,successList.toJson()!!)
                 val sCreateResponse = SCreateResponse<RShContainSpBase>(SResponseType.success)
                 if (failureList.size>0){
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -236,23 +174,25 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
             /** 失败集合 */
             val failureList = ArrayList<Any>()
             rSh2SpService.delete("id2 = '${rShContainSpBaseList.spaceId}'")
-            val projectId = SPageContext.getHeader("projectId")
+
             for (shaftId in rShContainSpBaseList.shaftIdList!!){
                 val rSh2Sp = RSh2Sp()
                 rSh2Sp.id2 = rShContainSpBaseList.spaceId
                 rSh2Sp.id1 = shaftId
-                rSh2Sp.projectId = projectId
+                rSh2Sp.projectId = Opt.projectId
                 rSh2Sp.zoneType = rShContainSpBaseList.zoneType
                 rSh2Sp.sign = 1
                 rSh2Sp.type = "sh2sp"
                 val replace = rSh2SpService.replace(rSh2Sp)
                 if (replace){
-                    successList.add(rSh2Sp)
+                    successList.add(shaftId)
                 }else{
                     failureList.add(rSh2Sp)
                 }
             }
             if (successList.size>0){
+                /** 发送消息 */
+                rabbitMqService.sendRel(Opt.projectId!!, "sh2sp","13",rShContainSpBaseList.spaceId!!,successList.toJson()!!)
                 if (failureList.size>0){
                     val sCreateResponse = SCreateResponse<RShContainSpBase>(SResponseType.success)
                     sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -294,12 +234,14 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
                     rSh2Sp.type = "sh2sp"
                     val replace = rSh2SpService.replace(rSh2Sp)
                     if (replace){
-                        successList.add(rSh2Sp)
+                        successList.add(spaceId)
                     }else{
                         failureList.add(rSh2Sp)
                     }
                 }
                 if (successList.size>0){
+                    /** 发送消息 */
+                    rabbitMqService.sendRel(Opt.projectId!!, "sh2sp","14",rShContainSpBaseList.shaftId!!,successList.toJson()!!)
                     try {
                         /** 处理关系标记 */
                         val listType = ArrayList<String>()
@@ -328,37 +270,6 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
                 sCreateResponse.message = "空间类型和空间列表不能为空"
                 sCreateResponse
             }
-
-
-//            if (type == "HeatingZone"){
-//                RShContainSpZoneHeatingService.createShSps(rShContainSpBaseList)
-//            }else if (type == "CleanZone"){
-//                RShContainSpZoneCleanService.createShSps(rShContainSpBaseList)
-//            }else if (type == "DomesticWaterSupplyZone"){
-//                RShContainSpZoneDomesticWaterSupplyService.createShSps(rShContainSpBaseList)
-//            }else if (type == "NetworkZone" ){
-//                RShContainSpZoneNetworkService.createShSps(rShContainSpBaseList)
-//            }else if (type == "TenantZone"){
-//                RShContainSpZoneTenantService.createShSps(rShContainSpBaseList)
-//            }else if (type == "AirConditioningZone"){
-//                RShContainSpZoneAirConditioningService.createShSps(rShContainSpBaseList)
-//            }else if (type == "FunctionZone"){
-//                RShContainSpZoneFunctionService.createShSps(rShContainSpBaseList)
-//            }else if (type == "FireZone"){
-//                RShContainSpZoneFireService.createShSps(rShContainSpBaseList)
-//            }else if (type == "SecurityZone"){
-//                RShContainSpZoneSecurityService.createShSps(rShContainSpBaseList)
-//            }else if (type == "GeneralZone"){
-//                RShContainSpZoneGeneralService.createShSps(rShContainSpBaseList)
-//            }else if (type == "PowerSupplyZone"){
-//                RShContainSpZonePowerSupplyService.createShSps(rShContainSpBaseList)
-//            }else if (type == "LightingZone"){
-//                RShContainSpZoneLightingService.createShSps(rShContainSpBaseList)
-//            }else{
-//                val sCreateResponse = SCreateResponse<RShContainSpBaseList>(SResponseType.failure)
-//                sCreateResponse.message = "空间分区类型不存在:$type"
-//                sCreateResponse
-//            }
         } catch (e: Exception) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
@@ -396,6 +307,9 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
                     }
                 }
                 if (successList.size>0){
+                    /** 发送消息 */
+                    rabbitMqService.sendRel(Opt.projectId!!, "sh2sp","14",rSpContainShBaseList.spaceId!!,successList.toJson()!!)
+
                     if (failureList.size>0){
                         val sCreateResponse = SCreateResponse<RSpContainShBaseList>(SResponseType.success)
                         sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -404,6 +318,7 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
                         val sCreateResponse = SCreateResponse<RSpContainShBaseList>(SResponseType.success)
                         sCreateResponse
                     }
+
                 }else{
                     SCreateResponse(SResponseType.failure)
                 }
@@ -411,35 +326,6 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
                 SCreateResponse(SResponseType.success)
             }
 
-//            if (type == "HeatingZone"){
-//                RShContainSpZoneHeatingService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "CleanZone"){
-//                RShContainSpZoneCleanService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "DomesticWaterSupplyZone"){
-//                RShContainSpZoneDomesticWaterSupplyService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "NetworkZone" ){
-//                RShContainSpZoneNetworkService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "TenantZone"){
-//                RShContainSpZoneTenantService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "AirConditioningZone"){
-//                RShContainSpZoneAirConditioningService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "FunctionZone"){
-//                RShContainSpZoneFunctionService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "FireZone"){
-//                RShContainSpZoneFireService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "SecurityZone"){
-//                RShContainSpZoneSecurityService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "GeneralZone"){
-//                RShContainSpZoneGeneralService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "PowerSupplyZone"){
-//                RShContainSpZonePowerSupplyService.createSpShs(rSpContainShBaseList)
-//            }else if (type == "LightingZone"){
-//                RShContainSpZoneLightingService.createSpShs(rSpContainShBaseList)
-//            }else{
-//                val sCreateResponse = SCreateResponse<RSpContainShBaseList>(SResponseType.failure)
-//                sCreateResponse.message = "空间分区类型不存在:$type"
-//                sCreateResponse
-//            }
         } catch (e: Exception) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
@@ -531,35 +417,6 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
                 SCreateResponse(SResponseType.success)
             }
 
-//            if (type == "HeatingZone"){
-//                RShContainSpZoneHeatingService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "CleanZone"){
-//                RShContainSpZoneCleanService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "DomesticWaterSupplyZone"){
-//                RShContainSpZoneDomesticWaterSupplyService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "NetworkZone" ){
-//                RShContainSpZoneNetworkService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "TenantZone"){
-//                RShContainSpZoneTenantService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "AirConditioningZone"){
-//                RShContainSpZoneAirConditioningService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "FunctionZone"){
-//                RShContainSpZoneFunctionService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "FireZone"){
-//                RShContainSpZoneFireService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "SecurityZone"){
-//                RShContainSpZoneSecurityService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "GeneralZone"){
-//                RShContainSpZoneGeneralService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "PowerSupplyZone"){
-//                RShContainSpZonePowerSupplyService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else if (type == "LightingZone"){
-//                RShContainSpZoneLightingService.createShSpsReplace(spaceIdList,rShContainSpBaseList)
-//            }else{
-//                val sCreateResponse = SCreateResponse<RShContainSpBaseList>(SResponseType.failure)
-//                sCreateResponse.message = "空间分区类型不存在:$type"
-//                sCreateResponse
-//            }
         } catch (e: Exception) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
@@ -584,4 +441,4 @@ object RShContainSpBaseService: SBaseService<RShContainSpBase>(SMybatisDao(RShCo
     } //  Fun spaceTypeQuery
 
 
-} // Object RShContainSpBaseService
+}

+ 16 - 54
datacenter/src/main/kotlin/com/persagy/server/services/rel/RShaftThroughShaftService.kt

@@ -29,6 +29,7 @@ package com.persagy.server.services.rel
 import com.persagy.base.extensions.toJson
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.rel.RShaftThroughShaft
 import com.persagy.server.datacenter.models.entities.rel.RShaftThroughShaftOtherList
 import com.persagy.server.services.base.RService
@@ -57,21 +58,12 @@ object RShaftThroughShaftService : RService<RShaftThroughShaft>(SMybatisDao(RSha
      */
     fun create(rFlThroughFl: RShaftThroughShaft): SCreateResponse<RShaftThroughShaft> {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
-            rFlThroughFl.projectId = projectId
+
+            rFlThroughFl.projectId = Opt.projectId
             val isInsert = insert(rFlThroughFl)
             if (isInsert){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "11")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rFlThroughFl.shaftId)
-                jsonObject.put("obj_type", "Sh2Sh")
-                jsonObject.put("linkId",rFlThroughFl.shaftOtherId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Sh2Sh", "11", IdUtils.uuidCreate(),  rFlThroughFl.shaftId!!,
-//                        rFlThroughFl.shaftOtherId!!),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "Sh2Sh","11",rFlThroughFl.shaftId!!,rFlThroughFl.shaftOtherId!!)
                 SCreateResponse(SResponseType.success)
             }else{
                 SCreateResponse(SResponseType.failure)
@@ -89,7 +81,7 @@ object RShaftThroughShaftService : RService<RShaftThroughShaft>(SMybatisDao(RSha
      */
     fun deletes(rFlThroughFl: RShaftThroughShaft): SBaseResponse {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
+
             val isDelete = delete(rFlThroughFl)
 
             val rShaftThroughShaft = RShaftThroughShaft()
@@ -104,7 +96,7 @@ object RShaftThroughShaftService : RService<RShaftThroughShaft>(SMybatisDao(RSha
                     val listType = ArrayList<String>()
                     listType.add("sh2sh")
                     for (type in listType){
-                        val entity = EquipmentService.relationTypeProjectservice.select(SFilter.eq("projectId", projectId!!), SFilter.eq("relationType", type)).entity()
+                        val entity = EquipmentService.relationTypeProjectservice.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("relationType", type)).entity()
                         if (entity!=null){
                             entity.computationalState = 2
                             EquipmentService.relationTypeProjectservice.update(entity)
@@ -113,17 +105,8 @@ object RShaftThroughShaftService : RService<RShaftThroughShaft>(SMybatisDao(RSha
                 } catch (e: Exception) {
                     e.printStackTrace()
                 }
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "12")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rFlThroughFl.shaftId)
-                jsonObject.put("obj_type", "Sh2Sh")
-                jsonObject.put("linkId",rFlThroughFl.shaftOtherId)
-
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Sh2Sh", "12", IdUtils.uuidCreate(),  rFlThroughFl.shaftId!!,
-//                        rFlThroughFl.shaftOtherId!!),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "Sh2Sh","12",rFlThroughFl.shaftId!!,rFlThroughFl.shaftOtherId!!)
                 val sBaseResponse = SBaseResponse(SResponseType.success)
                 sBaseResponse.message = rFlThroughFl.toJson()
                 sBaseResponse
@@ -154,30 +137,22 @@ object RShaftThroughShaftService : RService<RShaftThroughShaft>(SMybatisDao(RSha
             } catch (e: Exception) {
                 e.printStackTrace()
             }
-            val projectId = SPageContext.getHeader("projectId")
             if (rFloorThroughFloorOtherList.shaftOtherIdList!=null&&rFloorThroughFloorOtherList.shaftOtherIdList!!.isNotEmpty()){
                 for (floorOtherId in rFloorThroughFloorOtherList.shaftOtherIdList!!){
                     val rFlThroughFl = RShaftThroughShaft()
                     rFlThroughFl.shaftId = rFloorThroughFloorOtherList.shaftId
                     rFlThroughFl.shaftOtherId = floorOtherId
-                    rFlThroughFl.projectId = projectId
+                    rFlThroughFl.projectId = Opt.projectId
                     val replace = replace(rFlThroughFl)
                     if (replace){
-                        successList.add(rFlThroughFl)
+                        successList.add(floorOtherId)
                     }else{
                         failureList.add(rFlThroughFl)
                     }
                 }
                 if (successList.size>0){
-                    val jsonObject = JSONObject()
-                    jsonObject.put("type", "13")
-                    jsonObject.put("projectId", projectId)
-                    jsonObject.put("id", rFloorThroughFloorOtherList.shaftId)
-                    jsonObject.put("obj_type", "Sh2Sh")
-                    jsonObject.put("linkId",successList.toJson())
                     /** 发送消息 */
-//                    messageHandler.sendMessage(jsonObject.toString())
-//                    kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Sh2Sh", "13", IdUtils.uuidCreate(),  rFloorThroughFloorOtherList.shaftId!!, null),false)
+                    rabbitMqService.sendRel(Opt.projectId!!, "Sh2Sh","13",rFloorThroughFloorOtherList.shaftId!!,successList.toJson()!!)
                     val sCreateResponse = SCreateResponse<RShaftThroughShaft>(SResponseType.success)
                     if (failureList.size>0){
                         sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -209,23 +184,17 @@ object RShaftThroughShaftService : RService<RShaftThroughShaft>(SMybatisDao(RSha
             /** 失败集合 */
             val failureList = ArrayList<Any>()
 
-            try {
-//                delete("floorId = '${rFloorThroughFloorOtherList.shaftId}'")
-//                delete("floorOtherId = '${rFloorThroughFloorOtherList.shaftId}'")
-            } catch (e: Exception) {
-                e.printStackTrace()
-            }
-            val projectId = SPageContext.getHeader("projectId")
+
             if (rFloorThroughFloorOtherList.shaftOtherIdList!=null&&rFloorThroughFloorOtherList.shaftOtherIdList!!.isNotEmpty()){
                 for (floorOtherId in rFloorThroughFloorOtherList.shaftOtherIdList!!){
                     val rFlThroughFl = RShaftThroughShaft()
                     rFlThroughFl.shaftId = rFloorThroughFloorOtherList.shaftId
                     rFlThroughFl.shaftOtherId = floorOtherId
-                    rFlThroughFl.projectId = projectId
+                    rFlThroughFl.projectId = Opt.projectId
                     logger.debug("关系= ${rFlThroughFl.toJson()}")
                     val replace = replace(rFlThroughFl)
                     if (replace){
-                        successList.add(rFlThroughFl)
+                        successList.add(floorOtherId)
                     }else{
                         failureList.add(rFlThroughFl)
                     }
@@ -237,7 +206,7 @@ object RShaftThroughShaftService : RService<RShaftThroughShaft>(SMybatisDao(RSha
                         val listType = ArrayList<String>()
                         listType.add("sh2sh")
                         for (type in listType){
-                            val entity = EquipmentService.relationTypeProjectservice.select(SFilter.eq("projectId", projectId!!), SFilter.eq("relationType", type)).entity()
+                            val entity = EquipmentService.relationTypeProjectservice.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("relationType", type)).entity()
                             if (entity!=null){
                                 entity.computationalState = 2
                                 EquipmentService.relationTypeProjectservice.update(entity)
@@ -247,15 +216,8 @@ object RShaftThroughShaftService : RService<RShaftThroughShaft>(SMybatisDao(RSha
                         e.printStackTrace()
                     }
 
-                    val jsonObject = JSONObject()
-                    jsonObject.put("type", "14")
-                    jsonObject.put("projectId", projectId)
-                    jsonObject.put("id", rFloorThroughFloorOtherList.shaftId)
-                    jsonObject.put("obj_type", "Sh2Sh")
-                    jsonObject.put("linkId",successList.toJson())
                     /** 发送消息 */
-//                    messageHandler.sendMessage(jsonObject.toString())
-//                    kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "Sh2Sh", "14", IdUtils.uuidCreate(),  rFloorThroughFloorOtherList.shaftId!!, null),false)
+                    rabbitMqService.sendRel(Opt.projectId!!, "Sh2Sh","14",rFloorThroughFloorOtherList.shaftId!!,successList.toJson()!!)
                     val sCreateResponse = SCreateResponse<RShaftThroughShaft>(SResponseType.success)
                     if (failureList.size>0){
                         sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -275,4 +237,4 @@ object RShaftThroughShaftService : RService<RShaftThroughShaft>(SMybatisDao(RSha
     } // Tenant createShaftAll()
 
 
-} // Object RShaftThroughShaftService()
+}

+ 60 - 118
datacenter/src/main/kotlin/com/persagy/server/services/rel/RSyEqService.kt

@@ -29,6 +29,7 @@ package com.persagy.server.services.rel
 import com.persagy.base.extensions.toJson
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.rel.REqSyList
 import com.persagy.server.datacenter.models.entities.rel.RSyEq
 import com.persagy.server.datacenter.models.entities.rel.RSyEqList
@@ -57,21 +58,11 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
      */
     fun create(rSyEq: RSyEq): SCreateResponse<RSyEq> {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
-//            rSyEq.id = IdUtils.uuidCreate()
-            rSyEq.projectId = projectId
+            rSyEq.projectId = Opt.projectId
             val isInsert = replace(rSyEq)
             if (isInsert){
-                val jsonObject = JSONObject()
-                jsonObject.put("type", "11")
-                jsonObject.put("projectId", projectId)
-                jsonObject.put("id", rSyEq.sysId)
-                jsonObject.put("obj_type", "SystemEquip")
-                jsonObject.put("linkId",rSyEq.equipId)
                 /** 发送消息 */
-//                messageHandler.sendMessage(jsonObject.toString())
-//                kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "SystemEquip", "11", IdUtils.uuidCreate(),  rSyEq.sysId!!,
-//                        rSyEq.equipId!!),false)
+                rabbitMqService.sendRel(Opt.projectId!!, "SystemEquip","11",rSyEq.sysId!!,rSyEq.equipId!!)
                 SCreateResponse(SResponseType.success)
             }else{
                 SCreateResponse(SResponseType.failure)
@@ -80,7 +71,7 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function create()
+    }
 
     /**
      * 根据对象删除
@@ -90,11 +81,9 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
      */
      fun deletes(rSyEq: RSyEq): SBaseResponse {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
                 val isDelete = delete(rSyEq)
                 /** 删除成功 */
                 if (isDelete) {
-
                     try {
                         /** 处理关系标记 */
                         val listtype = ArrayList<String>()
@@ -103,7 +92,7 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
                         listtype.add("sy2sh")
                         listtype.add("sy2sp")
                         for (type in listtype){
-                            val entity = EquipmentService.relationTypeProjectservice.select(SFilter.eq("projectId", projectId!!), SFilter.eq("relationType", type)).entity()
+                            val entity = EquipmentService.relationTypeProjectservice.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("relationType", type)).entity()
                             if (entity!=null){
                                 entity.computationalState = 2
                                 EquipmentService.relationTypeProjectservice.update(entity)
@@ -112,19 +101,14 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
                     } catch (e: Exception) {
                         e.printStackTrace()
                     }
-
                     val sBaseResponse = SBaseResponse(SResponseType.success)
                     sBaseResponse.message = rSyEq.toJson()
-
-                    val jsonObject = JSONObject()
-                    jsonObject.put("type", "12")
-                    jsonObject.put("projectId", projectId)
-                    jsonObject.put("id", rSyEq.sysId)
-                    jsonObject.put("obj_type", "SystemEquip")
-                    jsonObject.put("linkId",rSyEq.equipId)
-                    /** 发送消息 */
-//                    messageHandler.sendMessage(jsonObject.toString())
-//                    kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "SystemEquip", "12", IdUtils.uuidCreate(),  rSyEq.sysId!!, rSyEq.equipId!!),false)
+                    try {
+                        /** 发送消息 */
+                        rabbitMqService.sendRel(Opt.projectId!!, "SystemEquip","12",rSyEq.sysId!!,rSyEq.equipId!!)
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
                     sBaseResponse
                 } else {
                     SBaseResponse(SResponseType.failure)
@@ -133,7 +117,7 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
             e.printStackTrace()
             return SBaseResponse(SResponseType.failure, e.message!!)
         }
-    } // Function deletes()
+    }
 
     /**
      * 创建系统下设备关系
@@ -142,13 +126,12 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
      */
     fun createSy(rSyEqList: RSyEqList): SCreateResponse<RSyEq> {
         return try {
-            val projectId = SPageContext.getHeader("projectId")
             /** 成功集合 */
             val successList = ArrayList<Any>()
             /** 失败集合 */
             val failureList = ArrayList<Any>()
             try {
-                delete("sysID = '${rSyEqList.sysId}'")
+                delete("sysId = '${rSyEqList.sysId}'")
             } catch (e: Exception) {
                 e.printStackTrace()
             }
@@ -157,25 +140,22 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
                     val rSyEq = RSyEq()
                     rSyEq.equipId = eqId
                     rSyEq.sysId =  rSyEqList.sysId
-                    rSyEq.projectId = projectId
+                    rSyEq.projectId = Opt.projectId
                     val replace = replace(rSyEq)
                     if (replace){
-                        successList.add(rSyEq)
+                        successList.add(eqId)
                     }else{
                         failureList.add(rSyEq)
                     }
                 }
                 if (successList.size>0){
-                    val jsonObject = JSONObject()
-                    jsonObject.put("type", "13")
-                    jsonObject.put("projectId", projectId)
-                    jsonObject.put("id", rSyEqList.sysId)
-                    jsonObject.put("obj_type", "SystemEquip")
-                    jsonObject.put("linkId",successList.toJson())
-                    /** 发送消息 */
-//                    messageHandler.sendMessage(jsonObject.toString())
-//                    kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "SystemEquip", "13", IdUtils.uuidCreate(),  rSyEqList.sysId!!, null),false)
 
+                    try {
+                        /** 发送消息 */
+                        rabbitMqService.sendRel(Opt.projectId!!, "SystemEquip","13",rSyEqList.sysId!!,successList.toJson()!!)
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
                     val sCreateResponse = SCreateResponse<RSyEq>(SResponseType.success)
                     if (failureList.size>0){
                         sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -192,7 +172,7 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createSy()
+    }
 
     /**
     * 创建系统下设备关系
@@ -208,7 +188,7 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
             val failureList = ArrayList<Any>()
 
             try {
-                delete("EquipID = '${rSyEqList.equipId}'")
+                delete("equipId = '${rSyEqList.equipId}'")
             } catch (e: Exception) {
                 e.printStackTrace()
             }
@@ -221,23 +201,18 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
                     rSyEq.projectId = projectId
                     val replace = replace(rSyEq)
                     if (replace){
-                        successList.add(rSyEq)
+                        successList.add(eqId)
                     }else{
                         failureList.add(rSyEq)
                     }
                 }
                 if (successList.size>0){
-                    val jsonObject = JSONObject()
-                    jsonObject.put("type", "13")
-                    jsonObject.put("projectId", projectId)
-                    jsonObject.put("id", rSyEqList.equipId)
-                    jsonObject.put("obj_type", "SystemEquip")
-                    jsonObject.put("linkId",successList.toJson())
-                    /** 发送消息 */
-//                    messageHandler.sendMessage(jsonObject.toString())
-//                    kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "SystemEquip", "13", IdUtils.uuidCreate(),  rSyEqList.equipId!!, null),false)
-
-
+                    try {
+                        /** 发送消息 */
+                        rabbitMqService.sendRel(Opt.projectId!!, "SystemEquip","13",rSyEqList.equipId!!,successList.toJson()!!)
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
                     if (failureList.size>0){
                         val sCreateResponse = SCreateResponse<RSyEq>(SResponseType.success)
                         sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -252,13 +227,11 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
             }else{
                 SCreateResponse(SResponseType.success)
             }
-
-
         } catch (e: Exception) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createsEq()
+    }
 
     /**
      * 创建系统下设备关系
@@ -267,51 +240,31 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
      */
     fun createSyEq(rSyEqList: RSyEqList): SCreateResponse<RSyEq> {
         return try {
-            logger.debug("设备和系统00001=${rSyEqList.toJson()}")
-            val projectId = SPageContext.getHeader("projectId")
 
             /** 失败集合 */
             val failureList = ArrayList<RSyEq>()
             if (rSyEqList.equipIdList!=null&&rSyEqList.equipIdList!!.isNotEmpty()){
-
                 /** 成功集合 */
-                val successList = ArrayList<RSyEq>()
+                val successList = ArrayList<Any>()
                 for (eqId in rSyEqList.equipIdList!!){
                     val rSyEq = RSyEq()
-                    logger.debug("设备和系统11 =${eqId}")
                     rSyEq.equipId = eqId
                     rSyEq.sysId =  rSyEqList.sysId
-                    rSyEq.projectId = projectId
-                    logger.debug("设备和系统12 =${rSyEq.toJson()}")
+                    rSyEq.projectId = Opt.projectId
                     val replace = replace(rSyEq)
                     if (replace){
-                        val rSyEq = RSyEq()
-                        logger.debug("设备和系统11 =${eqId}")
-                        rSyEq.equipId = eqId
-                        rSyEq.sysId =  rSyEqList.sysId
-                        rSyEq.projectId = projectId
-                        successList.add(rSyEq)
+                        successList.add(eqId)
                     }else{
                         failureList.add(rSyEq)
                     }
                 }
-                logger.debug("设备和系统14 =${successList.toJson()}")
                 if (successList.size>0){
-//                    val listId = ArrayList<String>()
-//                    for (success   in successList){
-//                        val rSyEq = success as RSyEq
-//                        listId.add(rSyEq.equipId!!)
-//                    }
-                    logger.debug("设备和系统 =${successList.toJson()}")
-                    val jsonObject = JSONObject()
-                    jsonObject.put("type", "14")
-                    jsonObject.put("projectId", projectId)
-                    jsonObject.put("id", rSyEqList.sysId)
-                    jsonObject.put("obj_type", "SystemEquip")
-                    jsonObject.put("linkId",successList.toJson())
-                    /** 发送消息 */
-//                    messageHandler.sendMessage(jsonObject.toString())
-//                    kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "SystemEquip", "14", IdUtils.uuidCreate(),  rSyEqList.sysId!!, null),false)
+                    try {
+                        /** 发送消息 */
+                        rabbitMqService.sendRel(Opt.projectId!!, "SystemEquip","14",rSyEqList.sysId!!,successList.toJson()!!)
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
                     val sCreateResponse = SCreateResponse<RSyEq>(SResponseType.success)
                     if (failureList.size>0){
                         sCreateResponse.message ="失败对象:"+failureList.toJson()
@@ -325,7 +278,7 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
                         listtype.add("sy2sh")
                         listtype.add("sy2sp")
                         for (type in listtype){
-                            val entity = EquipmentService.relationTypeProjectservice.select(SFilter.eq("projectId", projectId!!), SFilter.eq("relationType", type)).entity()
+                            val entity = EquipmentService.relationTypeProjectservice.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("relationType", type)).entity()
                             if (entity!=null){
                                 entity.computationalState = 2
                                 EquipmentService.relationTypeProjectservice.update(entity)
@@ -347,7 +300,7 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
             e.printStackTrace()
             SCreateResponse(SResponseType.failure,e.message.toString())
         }
-    } // Function createSy()
+    }
 
     /**
      * 删除前的操作
@@ -359,47 +312,36 @@ object RSyEqService : RService<RSyEq>(SMybatisDao(RSyEq::class.java)) {
         }else{
             super.onDeleteBefore(entity)
         }
-    } // Function onDeleteBefore()
+    }
 
     /**
      * 创建关系
      */
     override fun onCreateSuccess(entityList: ArrayList<RSyEq>) {
         super.onCreateSuccess(entityList)
-        val projectId = SPageContext.getHeader("projectId")
-        for (rSyEq in entityList){
-            val jsonObject = JSONObject()
-            jsonObject.put("type", "11")
-            jsonObject.put("projectId", projectId)
-            jsonObject.put("id", rSyEq.sysId)
-            jsonObject.put("obj_type", "SystemEquip")
-            jsonObject.put("linkId",rSyEq.equipId)
-
-            /** 发送消息 */
-//            messageHandler.sendMessage(jsonObject.toString())
-//            kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "SystemEquip", "11", IdUtils.uuidCreate(),  rSyEq.sysId!!, rSyEq.equipId),false)
+        try {
+            for (rSyEq in entityList){
+                /** 发送消息 */
+                rabbitMqService.sendRel(Opt.projectId!!, "SystemEquip","11",rSyEq.sysId!!,rSyEq.equipId!!)
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
         }
-
-    } // Function onCreateSuccess()
+    }
 
     /**
      * 删除关系
      */
     override fun onDeleteSuccess(entityList: ArrayList<RSyEq>) {
         super.onDeleteSuccess(entityList)
-        val projectId = SPageContext.getHeader("projectId")
-        for (rSyEq in entityList){
-            val jsonObject = JSONObject()
-            jsonObject.put("type", "12")
-            jsonObject.put("projectId", projectId)
-            jsonObject.put("id", rSyEq.sysId)
-            jsonObject.put("obj_type", "SystemEquip")
-            jsonObject.put("linkId",rSyEq.equipId)
-            /** 发送消息 */
-//            messageHandler.sendMessage(jsonObject.toString())
-//            kafkaService.sendNotice("datacenterrel", RelationNotice(projectId!!, "SystemEquip", "12", IdUtils.uuidCreate(),  rSyEq.sysId!!, rSyEq.equipId),false)
+        try {
+            for (rSyEq in entityList){
+                /** 发送消息 */
+                rabbitMqService.sendRel(Opt.projectId!!, "SystemEquip","12",rSyEq.sysId!!,rSyEq.equipId!!)
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
         }
-    } // Function onDeleteSuccess()
-
+    }
 
-} // Object RSyEqService
+}

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

@@ -98,6 +98,62 @@ object Configure {
     }
 
     /**
+     * 关系列表
+     *
+     * @param graphCode     图类型编码
+     * @param relCode       边类型编码
+     * @param objFrom       主对象 id
+     * @param objTo         从对象 id
+     */
+    fun toJsonObjList(graphCode: String, relCode: String, objFrom: String, objTos: ArrayList<String>): JSONArray {
+        /** 列表 */
+        val jsonArray = JSONArray()
+        for (id in objTos){
+            /** 对象 */
+            val jsonObject = JSONObject()
+            /** 图类型编码 */
+            jsonObject["graphCode"] = graphCode
+            /** 边类型编码 */
+            jsonObject["relCode"] = relCode
+            /** 主对象 id */
+            jsonObject["objFrom"] = objFrom
+            /** 从对象 id */
+            jsonObject["objTo"] = id
+            /** 添加到列表 */
+            jsonArray.plus(jsonObject)
+        }
+        return jsonArray
+    }
+
+    /**
+     * 关系列表
+     *
+     * @param graphCode     图类型编码
+     * @param relCode       边类型编码
+     * @param objFroms      主对象列表 id
+     * @param objTo         从对象 id
+     */
+    fun toJsonObjFromList(graphCode: String, relCode: String, objFroms: ArrayList<String>, objTo: String): JSONArray {
+        /** 列表 */
+        val jsonArray = JSONArray()
+        for (id in objFroms){
+            /** 对象 */
+            val jsonObject = JSONObject()
+            /** 图类型编码 */
+            jsonObject["graphCode"] = graphCode
+            /** 边类型编码 */
+            jsonObject["relCode"] = relCode
+            /** 主对象 id */
+            jsonObject["objFrom"] = id
+            /** 从对象 id */
+            jsonObject["objTo"] = objTo
+            /** 添加到列表 */
+            jsonArray.plus(jsonObject)
+        }
+        return jsonArray
+    }
+
+    /**
      * 创建关系列表
      *
      * @param graphCode     图类型编码
@@ -125,4 +181,6 @@ object Configure {
         return jsonObject1
     }
 
+
+
 }

+ 20 - 6
datasyn/src/main/kotlin/com/persagy/server/syn/jms/DataCenterSync.kt

@@ -26,6 +26,9 @@
 
 package com.persagy.server.syn.jms
 
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.persagy.server.datacenter.models.entities.assistant.PointPosition
 import com.persagy.server.datacenter.models.jms.SynchronousMessage
 import com.persagy.server.datacenter.models.jms.SynchronousMessageRel
 import com.persagy.server.syn.Configure
@@ -122,6 +125,8 @@ class DataCenterSync {
      * 处理关系数据到数据中台
      */
     fun  dataSyncRel(messageList:ArrayList<SynchronousMessageRel>){
+        val type = object : TypeToken<ArrayList<String>>() {
+        }.type
         for (message in messageList){
             when(message.type){
                 "EquipinSpace" -> {
@@ -129,21 +134,30 @@ class DataCenterSync {
                     when(message.ops){
 
                         "11" -> { // 创建关系
-                            equipInSpaceSync.equipInSpaceCreate(message)
+                            equipInSpaceSync.equipInSpaceCreate(message,"MechInArch","Eq2Sp",null)
                         }
                         "12" -> { // 删除关系
-
+                            equipInSpaceSync.delRel(message,"MechInArch","Eq2Sp")
                         }
                         "13" -> { // 清除之前的关系,替换
 
+                            if (message.fromId!!.startsWith("Eq")){
+                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
+                                equipInSpaceSync.addRelSuperposition(message,ids,"MechInArch","Eq2Sp")
+
+                            } else if (message.fromId!!.startsWith("Sq")) {
+                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
+
+                                equipInSpaceSync.addRelSuperpositionFan(message,ids,"MechInArch","Eq2Sp")
+                            }
                         }
                         "14" -> {  // 添加不替换
-
+                            if (message.fromId!!.startsWith("Sq")) {
+                                var ids=  Gson().fromJson<ArrayList<String>>(message.toId,type)
+                                equipInSpaceSync.equipInSpaceCreate(message,"MechInArch","Eq2Sp",ids)
+                            }
                         }
-
                     }
-
-
                 }
                 "SystemEquip" -> {
                     /** 系统包含的的设备 */

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

@@ -1,5 +1,6 @@
 package com.persagy.server.syn.services.jms.rel
 
+import com.alibaba.fastjson.JSONArray
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.entities.dictnew.DictProject
@@ -21,16 +22,23 @@ class EquipinSpaceSync {
     private val dictProjectService = SObjectService(SMybatisDao(DictProject::class.java))
     /**
      * 创建关系
+     *
+     * @param synchronousMessageRel     关系对象
+     * @param graphCode                 图类型
+     * @param relCode                   关系类型
      */
-    fun equipInSpaceCreate(synchronousMessageRel: SynchronousMessageRel){
+    fun equipInSpaceCreate(synchronousMessageRel: SynchronousMessageRel,graphCode: String,relCode: String,fromIds:ArrayList<String>?){
         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 toJsonObjArray = if (!fromIds.isNullOrEmpty()){
+                    /** 关系列表 */
+                    Configure.toJsonObjFromList(graphCode, relCode, fromIds, synchronousMessageRel.toId!!)
+                } else {
+                    /** 关系列表 */
+                    Configure.toJsonObjArray(graphCode, relCode, synchronousMessageRel.fromId!!, synchronousMessageRel.toId!!)
+                }
                 val createRel = EquipApi.createRel(dictProject.groupCode!!, synchronousMessageRel.projectId!!, toJsonObjArray)
                 if (!createRel ){
                     synchronousMessageRel.sign = 2
@@ -45,6 +53,105 @@ class EquipinSpaceSync {
         }
     }
 
+    /**
+     * 删除关系
+     *
+     * @param synchronousMessageRel     关系对象
+     */
+    fun delRel(synchronousMessageRel: SynchronousMessageRel,graphCode: String,relCode: String){
+        try {
+            val dictProject = dictProjectService.select(SFilter.eq("id", synchronousMessageRel.projectId!!)).entity()
+            if (dictProject!=null) {
+                synchronousMessageRel.sign = 0
+                val toJsonObj = Configure.toJsonObj(graphCode, relCode, synchronousMessageRel.fromId!!, synchronousMessageRel.toId!!)
+                val delRel = EquipApi.delRel(dictProject.groupCode!!, synchronousMessageRel.projectId!!, toJsonObj)
+                if (!delRel){
+                    synchronousMessageRel.sign = 2
+                }
+            } else {
+                synchronousMessageRel.sign = 2
+            }
+            /** 更改标记 */
+            synchronousMessageRelService.update(synchronousMessageRel, arrayListOf("sign"))
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+    }
+
+    /**
+     * 累计叠加关系
+     */
+    fun addRelSuperposition(synchronousMessageRel: SynchronousMessageRel,toIds: ArrayList<String>,graphCode: String,relCode: String){
+
+        try {
+            val dictProject = dictProjectService.select(SFilter.eq("id", synchronousMessageRel.projectId!!)).entity()
+            if (dictProject!=null) {
+                synchronousMessageRel.sign = 0
+
+                val toJsonObj = Configure.toJsonObj(graphCode, relCode, synchronousMessageRel.fromId!!, null)
+                val delRel = EquipApi.delRel(dictProject.groupCode!!, synchronousMessageRel.projectId!!, toJsonObj)
+                if (delRel) {
+                    /** 关系列表 */
+                    val toJsonObjArray =
+                            Configure.toJsonObjList(graphCode, relCode, synchronousMessageRel.fromId!!, toIds)
+
+                    val createRel = EquipApi.createRel(dictProject.groupCode!!, synchronousMessageRel.projectId!!, toJsonObjArray)
+                    if (!createRel ){
+                        synchronousMessageRel.sign = 2
+                    }
+                } else {
+                    synchronousMessageRel.sign = 2
+                }
+                /** 更改标记 */
+                synchronousMessageRelService.update(synchronousMessageRel, arrayListOf("sign"))
+
+            } else {
+                synchronousMessageRel.sign = 2
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+    }
+
+    /**
+     * 主对象和从对象相反的替换函数
+     */
+    fun addRelSuperpositionFan(synchronousMessageRel: SynchronousMessageRel,fromIds: ArrayList<String>,graphCode: String,relCode: String){
+
+        try {
+            val dictProject = dictProjectService.select(SFilter.eq("id", synchronousMessageRel.projectId!!)).entity()
+            if (dictProject!=null) {
+                synchronousMessageRel.sign = 0
+                for (id in fromIds){
+                    val toJsonObj = Configure.toJsonObj(graphCode, relCode, id, null)
+                    val delRel = EquipApi.delRel(dictProject.groupCode!!, synchronousMessageRel.projectId!!, toJsonObj)
+                    if (!delRel) {
+                        synchronousMessageRel.sign = 2
+                        break
+                    }
+                }
+                if (synchronousMessageRel.sign == 0){
+                    /** 关系列表 */
+                    val toJsonObjArray =
+                            Configure.toJsonObjFromList(graphCode, relCode, fromIds, synchronousMessageRel.toId!!)
+
+                    val createRel = EquipApi.createRel(dictProject.groupCode!!, synchronousMessageRel.projectId!!, toJsonObjArray)
+                    if (!createRel ){
+                        synchronousMessageRel.sign = 2
+                    }
+                }
+
+                /** 更改标记 */
+                synchronousMessageRelService.update(synchronousMessageRel, arrayListOf("sign"))
+
+            } else {
+                synchronousMessageRel.sign = 2
+            }
+        } catch (e: Exception) {
+            e.printStackTrace()
+        }
+    }
+
 
 
 }

+ 6 - 10
equip-component/src/main/kotlin/com/persagy/server/service/objects/ZoneSpaceBaseService.kt

@@ -61,7 +61,10 @@ object ZoneSpaceBaseService : SObjectService<ZoneSpace>(SMybatisDao(ZoneSpace::c
     /** 空间建筑楼层 */
     val spInFlService = SObjectService(SMybatisDao(RSpinFl::class.java))
 
-
+    /** 自定义sql */
+    val customSqlService by lazy {
+        SSpringContextUtil.getBean(CustomSqlService::class.java) as CustomSqlService
+    }
 
     override fun onQueryBefore(queryBuilder: SQueryBuilder<ZoneSpace>) {
         val projectId = SPageContext.getHeader("projectId")
@@ -112,13 +115,6 @@ object ZoneSpaceBaseService : SObjectService<ZoneSpace>(SMybatisDao(ZoneSpace::c
 
     }
 
-
-    /** 自定义sql */
-    val customSqlService by lazy {
-        SSpringContextUtil.getBean(CustomSqlService::class.java) as CustomSqlService
-    }
-
-
     /**
      * 统计数量
      */
@@ -142,7 +138,7 @@ object ZoneSpaceBaseService : SObjectService<ZoneSpace>(SMybatisDao(ZoneSpace::c
             }
             if (!request.zoneTypes.isNullOrEmpty()&&!request.funcTypes.isNullOrEmpty()){
                 val spInFlList = spInFlService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.inList("objectType", request.zoneTypes!!),
-                        SFilter.eq("building", request.buildingId!!), SFilter.eq("floorId", request.floorId!!)).exec()
+                        SFilter.eq("buildingId", request.buildingId!!), SFilter.eq("floorId", request.floorId!!)).exec()
                 if (!spInFlList.isNullOrEmpty()) {
                     val setIds = HashSet<String>()
                     for (spInFl in spInFlList){
@@ -162,7 +158,7 @@ object ZoneSpaceBaseService : SObjectService<ZoneSpace>(SMybatisDao(ZoneSpace::c
 
             } else if (!request.zoneTypes.isNullOrEmpty()){
                 val spInFlList = spInFlService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.inList("objectType", request.zoneTypes!!),
-                    SFilter.eq("building", request.buildingId!!), SFilter.eq("floorId", request.floorId!!)).exec()
+                    SFilter.eq("buildingId", request.buildingId!!), SFilter.eq("floorId", request.floorId!!)).exec()
                 if (!spInFlList.isNullOrEmpty()) {
                     val setIds = HashSet<String>()
                     for (spInFl in spInFlList){