Quellcode durchsuchen

******************WX *********************
关系同步

zhangweixin vor 4 Jahren
Ursprung
Commit
38d60477f9

+ 42 - 5
datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/ManualRelationAddService.kt

@@ -29,6 +29,7 @@ package com.persagy.server.services.relation_calc
 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.dictnew.DefClass
 import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
 import com.persagy.server.datacenter.models.entities.graphtype.block.RelationAddRequest
@@ -39,6 +40,7 @@ import com.persagy.server.datacenter.models.entities.rel.archforarch.RSh2Bd
 import com.persagy.server.datacenter.models.entities.rel.archforarch.RSh2Sp
 import com.persagy.server.datacenter.models.response.ManualRelationCalcSCreateResponse
 import com.persagy.server.jms.RabbitMqService
+import com.persagy.server.services.base.RService
 import com.persagy.server.services.objects.*
 import com.persagy.server.services.rel.*
 import com.persagy.service.SObjectService
@@ -403,7 +405,12 @@ class ManualRelationAddService {
                 rEq2Sh.projectId = projectId
                 rEq2Sh.equipId = relProperty.id
                 rEq2Sh.sign = 1
-                REqForShService.replace(rEq2Sh)
+                val replace = REqForShService.replace(rEq2Sh)
+                if (replace) {
+                    /** 发送消息 */
+                   rabbitMqService.sendRel(Opt.projectId!!, "eq2sh_for","11",rEq2Sh.equipId!!,rEq2Sh.shaftId!!)
+                }
+
             }
             sCreateResponse.result = SResponseType.success
             sCreateResponse.message = "添加成功"
@@ -2546,7 +2553,12 @@ class ManualRelationAddService {
                         rSp2Sp.type = relationAddRequest.relType
                         rSp2Sp.sign = 1
                         rSp2Sp.zoneType = zoneSpaceList[0].classCode
-                        rSp2SpService.replace(rSp2Sp)
+                        val replace = rSp2SpService.replace(rSp2Sp)
+                        if (replace) {
+                            /** 发送消息 */
+                            rabbitMqService.sendRel(Opt.projectId!!, "sp2sp_ArchForArch","11",rSp2Sp.id1!!,rSp2Sp.id2!!)
+                        }
+
                     }
 
                 }else if (relationAddRequest.relType == "sp2bd_ArchForArch") {
@@ -2584,7 +2596,15 @@ class ManualRelationAddService {
                         rSp2Bd.type = relationAddRequest.relType
                         rSp2Bd.sign = 1
                         rSp2Bd.zoneType = zoneSpaceList[0].classCode
-                        rSp2BdService.replace(rSp2Bd)
+                        try {
+                            val replace = rSp2BdService.replace(rSp2Bd)
+                            if (replace) {
+                                /** 发送消息 */
+                                rabbitMqService.sendRel(Opt.projectId!!, "sp2bd_ArchForArch","11",rSp2Bd.id1!!,rSp2Bd.id2!!)
+                            }
+                        } catch (e: Exception) {
+                            e.printStackTrace()
+                        }
                     }
                 }else if (relationAddRequest.relType == "sp2fl_ArchForArch") {
                     for (fromContent in relationAddRequest.fromContent!!){
@@ -2621,7 +2641,16 @@ class ManualRelationAddService {
                         rSp2Fl.type = relationAddRequest.relType
                         rSp2Fl.sign = 1
                         rSp2Fl.zoneType = zoneSpaceList[0].classCode
-                        rSp2FlService.replace(rSp2Fl)
+                        try {
+                            val replace = rSp2FlService.replace(rSp2Fl)
+                            if (replace) {
+                                /** 发送消息 */
+                                rabbitMqService.sendRel(Opt.projectId!!, "sp2fl_ArchForArch","11",rSp2Fl.id1!!,rSp2Fl.id2!!)
+                            }
+                        } catch (e: Exception) {
+                            e.printStackTrace()
+                        }
+
                     }
                 }else if (relationAddRequest.relType == "sp2sh_ArchForArch") {
                     for (fromContent in relationAddRequest.fromContent!!){
@@ -2657,7 +2686,15 @@ class ManualRelationAddService {
                         rSp2Sh.type = relationAddRequest.relType
                         rSp2Sh.sign = 1
                         rSp2Sh.zoneType = zoneSpaceList[0].classCode
-                        rSp2ShService.replace(rSp2Sh)
+                        try {
+                            val replace = rSp2ShService.replace(rSp2Sh)
+                            if (replace) {
+                                /** 发送消息 */
+                                rabbitMqService.sendRel(Opt.projectId!!, "sp2sh_ArchForArch","11",rSp2Sh.id1!!,rSp2Sh.id2!!)
+                            }
+                        } catch (e: Exception) {
+                            e.printStackTrace()
+                        }
                     }
                 }
             }

+ 7 - 0
datacenter/src/main/kotlin/com/persagy/server/services/relation_calc/ManualRelationCalcService.kt

@@ -29,6 +29,7 @@ package com.persagy.server.services.relation_calc
 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.dictnew.DefClass
 import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
 import com.persagy.server.datacenter.models.entities.graphtype.rel.*
@@ -601,6 +602,12 @@ open class ManualRelationCalcService {
                 }
 
                 if (delete){
+                    /** 发送消息 */
+                    try {
+                        rabbitMqService.sendRel(Opt.projectId!!, manualRelationCalcDel.relType!!,"12",manualRelationCalcDel.fromId!!,manualRelationCalcDel.toId!!)
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
                     return SBaseResponse(SResponseType.success)
                 }else{
                     return  SBaseResponse(SResponseType.failure)

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

@@ -1322,7 +1322,81 @@ class DataCenterSync {
                         }
                     }
                 }
-
+                "eq2sh_for" -> {
+                    /** 设备服务于竖井 */
+                    when(message.ops) {
+                        "11" -> { // 创建关系
+                            equipInSpaceSync.equipInSpaceCreate(message, "MechForArch", "Eq2Sh", null)
+                        }
+                        "12" -> { // 删除关系
+                            equipInSpaceSync.delRel(message, "MechForArch", "Eq2Sh")
+                        }
+                        "20" -> {
+                            /** 关系计算-整体同步 */
+                            automaticCalculationSync.eq2ShFor(message)
+                        }
+                    }
+                }
+                "sp2sp_ArchForArch" -> {
+                    /** 空间服务于空间 */
+                    when(message.ops) {
+                        "11" -> { // 创建关系
+                            equipInSpaceSync.equipInSpaceCreate(message, "ArchForArch", "Sp2Sp", null)
+                        }
+                        "12" -> { // 删除关系
+                            equipInSpaceSync.delRel(message, "ArchForArch", "Sp2Sp")
+                        }
+                        "20" -> {
+                            /** 关系计算-整体同步 */
+                            automaticCalculationSync.sp2SpFor(message)
+                        }
+                    }
+                }
+                "sp2sh_ArchForArch" -> {
+                    /** 空间服务于竖井 */
+                    when(message.ops) {
+                        "11" -> { // 创建关系
+                            equipInSpaceSync.equipInSpaceCreate(message, "ArchForArch", "Sp2Sh", null)
+                        }
+                        "12" -> { // 删除关系
+                            equipInSpaceSync.delRel(message, "ArchForArch", "Sp2Sh")
+                        }
+                        "20" -> {
+                            /** 关系计算-整体同步 */
+                            automaticCalculationSync.sp2ShFor(message)
+                        }
+                    }
+                }
+                "sp2fl_ArchForArch" -> {
+                    /** 空间服务于楼层 */
+                    when(message.ops) {
+                        "11" -> { // 创建关系
+                            equipInSpaceSync.equipInSpaceCreate(message, "ArchForArch", "Sp2Fl", null)
+                        }
+                        "12" -> { // 删除关系
+                            equipInSpaceSync.delRel(message, "ArchForArch", "Sp2Fl")
+                        }
+                        "20" -> {
+                            /** 关系计算-整体同步 */
+                            automaticCalculationSync.sp2FlFor(message)
+                        }
+                    }
+                }
+                "sp2bd_ArchForArch" -> {
+                    /** 空间服务于建筑 */
+                    when(message.ops) {
+                        "11" -> { // 创建关系
+                            equipInSpaceSync.equipInSpaceCreate(message, "ArchForArch", "Sp2Bd", null)
+                        }
+                        "12" -> { // 删除关系
+                            equipInSpaceSync.delRel(message, "ArchForArch", "Sp2Bd")
+                        }
+                        "20" -> {
+                            /** 关系计算-整体同步 */
+                            automaticCalculationSync.sp2BdFor(message)
+                        }
+                    }
+                }
             }
         }
     }

+ 187 - 2
datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/rel/AutomaticCalculationSync.kt

@@ -30,6 +30,9 @@ import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.entities.dictnew.DictProject
 import com.persagy.server.datacenter.models.entities.rel.*
+import com.persagy.server.datacenter.models.entities.rel.archforarch.RSp2Bd
+import com.persagy.server.datacenter.models.entities.rel.archforarch.RSp2Fl
+import com.persagy.server.datacenter.models.entities.rel.archforarch.RSp2Sh
 import com.persagy.server.datacenter.models.jms.SynchronousMessageRel
 import com.persagy.server.syn.Configure
 import com.persagy.server.syn.models.api.obj.EquipApi
@@ -69,6 +72,16 @@ class AutomaticCalculationSync {
     val rSp2SpService = SObjectService(SMybatisDao(RSp2Sp::class.java))
     /** 设备和设备关系 */
     val rEq2EqService = SObjectService(SMybatisDao(REq2Eq::class.java))
+    /** 设备服务于竖井 */
+    val rEqForShService = SObjectService(SMybatisDao(REqForSh::class.java))
+    /** 空间和竖井 */
+    private val rSp2ShService = SObjectService(SMybatisDao(RSp2Sh::class.java))
+    /** 空间和楼层 */
+    private val rSp2FlService = SObjectService(SMybatisDao(RSp2Fl::class.java))
+    /** 区域服务-空间和建筑 */
+    private val rSp2BdService = SObjectService(SMybatisDao(RSp2Bd::class.java))
+
+
 
     /** 缓存对象数据服务 - 数据中心到数据中台  */
     var synchronousMessageRelService = SObjectService(SMybatisDao(SynchronousMessageRel::class.java))
@@ -685,12 +698,184 @@ class AutomaticCalculationSync {
                         val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
                         if (!createRel){
                             message.sign = 2
-                            message.count +1
+                            message.count = message.count +1
                         }
                     } catch (e: Exception) {
                         e.printStackTrace()
                         message.sign = 2
-                        message.count +1
+                        message.count = message.count +1
+                    }
+                }
+            }
+            /** 更改标记 */
+            synchronousMessageRelService.update(message)
+        }
+    }
+
+    /**
+     * 设备服务于竖井
+     */
+    fun eq2ShFor(message: SynchronousMessageRel) {
+        val dictProject = dictProjectService.select(SFilter.eq("id", message.projectId!!)).entity()
+        if (dictProject!=null) {
+            val rEq2SpList = rEqForShService.select(SFilter.eq("projectId", message.projectId!!)).exec()
+            message.sign = 0
+            if (rEq2SpList.size>0) {
+                for (rEq2Sp in rEq2SpList) {
+                    try {
+                        /** 先执行删除 */
+                        val toJsonObj = Configure.toJsonObj("MechForArch", "Eq2Sh", rEq2Sp.equipId!!, rEq2Sp.shaftId!!)
+                        val delRel = EquipApi.delRel(dictProject.groupCode!!, message.projectId!!, toJsonObj)
+                        /** 关系列表 */
+                        val toJsonObjArray =
+                            Configure.toJsonObjArray("MechForArch", "Eq2Sh", rEq2Sp.equipId!!, rEq2Sp.shaftId!!)
+                        val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
+                        if (!createRel){
+                            message.sign = 2
+                            message.count = message.count +1
+                        }
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                        message.sign = 2
+                        message.count = message.count +1
+                    }
+                }
+            }
+            /** 更改标记 */
+            synchronousMessageRelService.update(message)
+        }
+    }
+
+    /**
+     * 空间服务于空间
+     */
+    fun sp2SpFor(message: SynchronousMessageRel) {
+        val dictProject = dictProjectService.select(SFilter.eq("id", message.projectId!!)).entity()
+        if (dictProject!=null) {
+            val rEq2SpList = rSp2SpService.select(SFilter.eq("projectId", message.projectId!!),SFilter.eq("type", "sp2sp_ArchForArch")).exec()
+            message.sign = 0
+            if (rEq2SpList.size>0) {
+                for (rEq2Sp in rEq2SpList) {
+                    try {
+                        /** 先执行删除 */
+                        val toJsonObj = Configure.toJsonObj("ArchForArch", "Sp2Sp", rEq2Sp.id1!!, rEq2Sp.id1!!)
+                        val delRel = EquipApi.delRel(dictProject.groupCode!!, message.projectId!!, toJsonObj)
+                        /** 关系列表 */
+                        val toJsonObjArray =
+                            Configure.toJsonObjArray("ArchForArch", "Sp2Sp", rEq2Sp.id1!!, rEq2Sp.id1!!)
+                        val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
+                        if (!createRel){
+                            message.sign = 2
+                            message.count = message.count +1
+                        }
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                        message.sign = 2
+                        message.count = message.count +1
+                    }
+                }
+            }
+            /** 更改标记 */
+            synchronousMessageRelService.update(message)
+        }
+    }
+
+    /**
+     * 空间服务于竖井
+     */
+    fun sp2ShFor(message: SynchronousMessageRel) {
+        val dictProject = dictProjectService.select(SFilter.eq("id", message.projectId!!)).entity()
+        if (dictProject!=null) {
+            val rEq2SpList = rSp2ShService.select(SFilter.eq("projectId", message.projectId!!),SFilter.eq("type", "sp2sh_ArchForArch")).exec()
+            message.sign = 0
+            if (rEq2SpList.size>0) {
+                for (rEq2Sp in rEq2SpList) {
+                    try {
+                        /** 先执行删除 */
+                        val toJsonObj = Configure.toJsonObj("ArchForArch", "Sp2Sh", rEq2Sp.id1!!, rEq2Sp.id1!!)
+                        val delRel = EquipApi.delRel(dictProject.groupCode!!, message.projectId!!, toJsonObj)
+                        /** 关系列表 */
+                        val toJsonObjArray =
+                            Configure.toJsonObjArray("ArchForArch", "Sp2Sh", rEq2Sp.id1!!, rEq2Sp.id1!!)
+                        val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
+                        if (!createRel){
+                            message.sign = 2
+                            message.count = message.count +1
+                        }
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                        message.sign = 2
+                        message.count = message.count +1
+                    }
+                }
+            }
+            /** 更改标记 */
+            synchronousMessageRelService.update(message)
+        }
+    }
+
+    /**
+     * 空间服务于楼层
+     */
+    fun sp2FlFor(message: SynchronousMessageRel) {
+        val dictProject = dictProjectService.select(SFilter.eq("id", message.projectId!!)).entity()
+        if (dictProject!=null) {
+            val rEq2SpList = rSp2FlService.select(SFilter.eq("projectId", message.projectId!!),SFilter.eq("type", "sp2fl_ArchForArch")).exec()
+            message.sign = 0
+            if (rEq2SpList.size>0) {
+                for (rEq2Sp in rEq2SpList) {
+                    try {
+                        /** 先执行删除 */
+                        val toJsonObj = Configure.toJsonObj("ArchForArch", "Sp2Fl", rEq2Sp.id1!!, rEq2Sp.id1!!)
+                        val delRel = EquipApi.delRel(dictProject.groupCode!!, message.projectId!!, toJsonObj)
+                        /** 关系列表 */
+                        val toJsonObjArray =
+                            Configure.toJsonObjArray("ArchForArch", "Sp2Fl", rEq2Sp.id1!!, rEq2Sp.id1!!)
+                        val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
+                        if (!createRel){
+                            message.sign = 2
+                            message.count = message.count +1
+                        }else {
+                            message.sign = 0
+                        }
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                        message.sign = 2
+                        message.count = message.count +1
+                    }
+                }
+            }
+            /** 更改标记 */
+            synchronousMessageRelService.update(message)
+        }
+    }
+
+    /**
+     * 空间服务于建筑
+     */
+    fun sp2BdFor(message: SynchronousMessageRel) {
+        val dictProject = dictProjectService.select(SFilter.eq("id", message.projectId!!)).entity()
+        if (dictProject!=null) {
+            val rEq2SpList = rSp2BdService.select(SFilter.eq("projectId", message.projectId!!),SFilter.eq("type", "sp2bd_ArchForArch")).exec()
+            message.sign = 0
+            if (rEq2SpList.size>0) {
+                for (rEq2Sp in rEq2SpList) {
+                    try {
+                        /** 先执行删除 */
+                        val toJsonObj = Configure.toJsonObj("ArchForArch", "Sp2Bd", rEq2Sp.id1!!, rEq2Sp.id1!!)
+                        val delRel = EquipApi.delRel(dictProject.groupCode!!, message.projectId!!, toJsonObj)
+                        /** 关系列表 */
+                        val toJsonObjArray =
+                            Configure.toJsonObjArray("ArchForArch", "Sp2Bd", rEq2Sp.id1!!, rEq2Sp.id1!!)
+                        val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
+                        if (!createRel){
+                            message.sign = 2
+                            message.count = message.count +1
+                        }
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                        message.sign = 2
+                        message.count = message.count +1
                     }
                 }
             }