Browse Source

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

zhangweixin 4 năm trước cách đây
mục cha
commit
577c085c9d

+ 3 - 2
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/task/EquipScanTaskQuery.kt

@@ -31,6 +31,7 @@ import com.persagy.server.datacenter.models.entities.assistant.TaskPic
 import com.persagy.server.datacenter.models.entities.base.RBaseInfo
 import com.persagy.server.datacenter.models.entities.dict.EquipCategory
 import com.persagy.server.datacenter.models.entities.dict.EquipFamily
+import com.persagy.server.datacenter.models.entities.dictnew.DefClass
 import com.persagy.server.datacenter.models.entities.objects.Building
 import com.persagy.server.datacenter.models.entities.objects.Floor
 import com.persagy.server.datacenter.models.entities.objects.Project
@@ -306,8 +307,8 @@ class EquipScanTaskQuery :  RBaseInfo()  {
 
     /** 级联-设备分类 */
     @Schema(description = "级联-设备分类")
-    @SCascade(table="scantask.equip_scan_task", idColumn="id", childIdColumn="category")
-    var equipCategory: EquipCategory? = null
+//    @SCascade(table="scantask.equip_scan_task", idColumn="id", childIdColumn="category")
+    var equipCategory: DefClass? = null
 
     /** 级联-设备族 */
     @Schema(description = "级联-设备族")

+ 3 - 3
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/task/ModelScanTaskQuery.kt

@@ -29,7 +29,7 @@ package com.persagy.server.datacenter.models.entities.task
 import com.persagy.server.datacenter.models.entities.assistant.BIMLocation
 import com.persagy.server.datacenter.models.entities.assistant.TaskPic
 import com.persagy.server.datacenter.models.entities.base.RBaseInfo
-import com.persagy.server.datacenter.models.entities.dict.EquipCategory
+import com.persagy.server.datacenter.models.entities.dictnew.DefClass
 import com.persagy.server.datacenter.models.entities.objects.Building
 import com.persagy.server.datacenter.models.entities.objects.Floor
 import com.persagy.server.datacenter.models.entities.objects.Project
@@ -325,7 +325,7 @@ class ModelScanTaskQuery : RBaseInfo() {
 
     /** 级联-设备分类 */
     @Schema(description = "级联-设备分类")
-    @SCascade(table="scantask.model_scan_task", idColumn="id", childIdColumn="category")
-    var equipCategory: EquipCategory? = null
+//    @SCascade(table="scantask.model_scan_task", idColumn="id", childIdColumn="category")
+    var equipCategory: DefClass? = null
 
 }

+ 1 - 1
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/task/PropertyScanTask.kt

@@ -77,7 +77,7 @@ open class PropertyScanTask : ScanTaskBase() {
 
     /** 级联-资产设备族 */
     @Schema(description = "级联-资产设备族")
-    @SCascade(table="scantask.property_scan_task", idColumn="id", childIdColumn="category")
+//    @SCascade(table="scantask.property_scan_task", idColumn="id", childIdColumn="code")
     var equipFamily: EquipFamilyCategory? = null
 
 } // Class PropertyScanTask

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

@@ -49,6 +49,10 @@ object Configure {
     const val RWDUPDATE = "instanceObjectUpdate"
     /** 数据中台消息之删除 */
     const val RWDDELETE = "instanceObjectDelete"
+    /** 数据中台创建关系 */
+    const val RELATIONCREATE = "instanceRelationCreate"
+    /** 数据中台删除关系 */
+    const val RELATIONDELETE = "instanceRelationDelete"
 
     /** 对象类型 - 项目 */
     const val PROJECT = "project"

+ 12 - 2
datasyn/src/main/kotlin/com/persagy/server/syn/jms/MessageReceiver.kt

@@ -35,6 +35,8 @@ import com.persagy.server.syn.jms.bean.SyncRwdDatacenterMessage
 import com.persagy.service.SObjectService
 import com.persagy.service.utils.SJsonUtil
 import org.slf4j.LoggerFactory
+import org.springframework.amqp.rabbit.annotation.RabbitHandler
+import org.springframework.amqp.rabbit.annotation.RabbitListener
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Component
 import org.springframework.stereotype.Service
@@ -70,8 +72,8 @@ class MessageReceiver {
     /**
      * 接收中台消息
      */
-//    @RabbitListener(queues = ["queue-center-syn"])
-//    @RabbitHandler
+    @RabbitListener(queues = ["queue-center-syn"])
+    @RabbitHandler
     fun process(mess: String) {
         logger.debug("接收中台消息:${mess}")
         /** 解析消息 */
@@ -95,6 +97,14 @@ class MessageReceiver {
                         /** 中台删除 */
                         syncRwdMessageService.insert(messag)
                     }
+                    Configure.RELATIONCREATE -> {
+                        /** 中台关系创建 */
+                        syncRwdMessageService.insert(messag)
+                    }
+                    Configure.RELATIONDELETE -> {
+                        /** 中台关系删除 */
+                        syncRwdMessageService.insert(messag)
+                    }
                 }
                 /** 处理消息 */
 //            messageProcessing.syncRwdData()

+ 46 - 31
datasyn/src/main/kotlin/com/persagy/server/syn/jms/RwdSync.kt

@@ -69,41 +69,56 @@ class RwdSync {
      */
     fun dataSync(messageList: ArrayList<SyncRwdDatacenterMessage>){
         for (message in messageList){
-            when(message.str1){
-                Configure.PROJECT -> {
-                    /** 项目信息 */
-                    rwdProject.projectType(message)
-                }
-                Configure.BUILDING -> {
+            if (message.type=="instanceObjectCreate"||message.type=="instanceObjectUpdate"||message.type=="instanceObjectDelete"){
+                when(message.str1){
+                    Configure.PROJECT -> {
+                        /** 项目信息 */
+                        rwdProject.projectType(message)
+                    }
+                    Configure.BUILDING -> {
 
-                    /** 建筑 */
-                    rwdBuilding.buildingType(message)
-                }
-                Configure.FLOOR -> {
-                    /** 楼层 */
-                    rwdFloor.floorType(message)
-                }
-                Configure.EQUIPMENT -> {
-                    /** 设备 */
-                    rwdEquip.equipType(message)
-                }
-                Configure.COMPONENT -> {
-                    /** 部件 */
-                    rwdComponent.componentType(message)
-                }
-                Configure.SHAFT -> {
-                    /** 竖井 */
-                    rwdShaft.shaftType(message)
+                        /** 建筑 */
+                        rwdBuilding.buildingType(message)
+                    }
+                    Configure.FLOOR -> {
+                        /** 楼层 */
+                        rwdFloor.floorType(message)
+                    }
+                    Configure.EQUIPMENT -> {
+                        /** 设备 */
+                        rwdEquip.equipType(message)
+                    }
+                    Configure.COMPONENT -> {
+                        /** 部件 */
+                        rwdComponent.componentType(message)
+                    }
+                    Configure.SHAFT -> {
+                        /** 竖井 */
+                        rwdShaft.shaftType(message)
+                    }
+                    Configure.SYSTEM -> {
+                        /** 系统 */
+                        rwdSystem.equipType(message)
+                    }
+                    Configure.SPACE -> {
+                        /** 空间 */
+                        rwdSpace.spaceType(message)
+                    }
                 }
-                Configure.SYSTEM -> {
-                    /** 系统 */
-                    rwdSystem.equipType(message)
-                }
-                Configure.SPACE -> {
-                    /** 空间 */
-                    rwdSpace.spaceType(message)
+            } else if (message.type=="instanceRelationCreate"||message.type=="instanceRelationDelete") {
+                when(message.type){
+                    Configure.RELATIONDELETE -> {
+                        /** 删除关系 */
+
+                    }
+                    Configure.RELATIONCREATE -> {
+                        /** 创建关系 */
+
+                    }
                 }
+
             }
+
         }
 
     }

+ 1 - 1
datasyn/src/main/kotlin/com/persagy/server/syn/jms/bean/SyncRwdDatacenterMessage.kt

@@ -79,7 +79,7 @@ class SyncRwdDatacenterMessage : Serializable {
 
     /** 描述 */
     @Column(name = "exts")
-    var exts: String? = null
+    var exts: HashMap<String,Any?>? = null
 
     /** 未定义 */
     @Column(name = "int1")

+ 2 - 2
datasyn/src/main/kotlin/com/persagy/server/syn/models/api/obj/EquipApi.kt

@@ -152,8 +152,8 @@ object EquipApi {
      */
     fun queryRelation(groupCode: String,projectId: String,jsonObject: JSONObject): ArrayList<HashMap<String, Any?>> {
         val url = "${opts.dataPlatform}/rwd/instance/relation/query?groupCode=$groupCode&projectId=${projectId}"
-        val jsonObject = JSONObject()
-        jsonObject["criteria"] = jsonObject
+//        val jsonObject = JSONObject()
+//        jsonObject["criteria"] = jsonObject
         val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, jsonObject)
         if (postObject.result == "success"&&!postObject.data.isNullOrEmpty()) {
             return postObject.data!!

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

@@ -526,18 +526,18 @@ object SpaceUtil {
 //                                val replace1 = mapObj[key].toString().replace("X", "x")
 //                                val replace2 = replace1.replace("Y", "y")
 //                                val replace3 = replace2.replace("Z", "z")
+                                logger.debug("**********************************************************************************")
                                 val type = object : TypeToken<ArrayList<ArrayList<ArrayList<PointPosition>>>>() {
                                 }.type
                                 var outline=  Gson().fromJson<ArrayList<ArrayList<ArrayList<PointPosition>>>>(mapObj[key].toString(),type)
                                 zoneSpace.outline = outline
+                                logger.debug("/////////////////////////////////////////////////////////////////////")
                             } catch (e: Exception) {
                                 e.printStackTrace()
                             }
-
                         }
                     }
                 }
-
             } else {
 //                if (zoneSpace.infos.isNullOrEmpty()){
 //                    zoneSpace.infos = HashMap<String,Any?>()

+ 7 - 2
datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/RwdSpace.kt

@@ -26,6 +26,7 @@
 
 package com.persagy.server.syn.services.jms
 
+import com.persagy.base.extensions.toJson
 import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.entities.dictnew.DictProject
@@ -33,12 +34,14 @@ import com.persagy.server.datacenter.models.entities.objects.ZoneSpace
 import com.persagy.server.datacenter.models.entities.rel.RSpinBd
 import com.persagy.server.datacenter.models.entities.rel.RSpinFl
 import com.persagy.server.syn.Configure
+import com.persagy.server.syn.controllers.obj.ObjectFromToControllers
 import com.persagy.server.syn.jms.bean.SyncRwdDatacenterMessage
 import com.persagy.server.syn.models.api.obj.BuildingApi
 import com.persagy.server.syn.models.api.obj.EquipApi
 import com.persagy.server.syn.models.tools.SpaceUtil
 import com.persagy.service.SBaseService
 import com.persagy.service.SObjectService
+import org.slf4j.LoggerFactory
 import org.springframework.stereotype.Service
 
 /**
@@ -49,6 +52,8 @@ import org.springframework.stereotype.Service
  */
 @Service
 class RwdSpace {
+    /** 日志 */
+    private val logger = LoggerFactory.getLogger(ObjectFromToControllers::class.java)
     /** 建筑服务 */
     private val spaceService = SBaseService(SMybatisDao(ZoneSpace::class.java))
     /** 缓存对象数据 - 数据中台到数据中心 */
@@ -65,7 +70,7 @@ class RwdSpace {
      * @param message   消息
      */
     fun spaceType(message: SyncRwdDatacenterMessage) {
-
+        logger.debug("任务= ${message.toJson()}")
         when(message.type){
             Configure.RWDCREATE -> {
                 /** 创建 */
@@ -78,7 +83,6 @@ class RwdSpace {
                             dictProject!!.groupCode!!,
                             queryIdList[0]
                         )
-
                         val toJsonObj = Configure.toJsonObj("ArchSubset", "Bd2Sp", null, message.targetId)
                         /** 空间的建筑 */
                         val equipInBuildingList =
@@ -89,6 +93,7 @@ class RwdSpace {
                                 space.buildingId = hashMap["objFrom"].toString()
                             }
                         }
+
                         val toJsonObj02 = Configure.toJsonObj("ArchSubset", "Fl2Sp", null, message.targetId)
                         /** 查询空间和楼层关系 */
                         val equipInFloorList = EquipApi.queryRelation(dictProject.groupCode!!, message.projectId!!, toJsonObj02)

+ 1 - 2
datasyn/src/main/kotlin/com/persagy/server/syn/task/SchedulerTaskTwo.kt

@@ -29,7 +29,6 @@ package com.persagy.server.syn.task
 import com.persagy.server.syn.jms.MessageProcessing
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.scheduling.annotation.Scheduled
 import org.springframework.stereotype.Service
 
 /**
@@ -52,7 +51,7 @@ class SchedulerTaskTwo {
     //cron表达式:每隔5秒执行一次
 //    @Scheduled(cron = "0 */3 * * * ?")
 //    @Scheduled(cron = "0 */1 * * * ?")
-    @Scheduled(cron="0/5 * *  * * ? ")   //每5秒执行一次
+//    @Scheduled(cron="0/5 * *  * * ? ")   //每5秒执行一次
     fun scheduled() {
         try {
             logger.info("同步中台任务开始} *****************************************************************")

+ 1 - 1
scanbuilding/src/main/kotlin/com/persagy/server/controller/task/ModelScanTaskController.kt

@@ -79,7 +79,7 @@ open class ModelScanTaskController {
         val equipScanTaskQueryService = SObjectService(SMybatisDao(ModelScanTaskQuery::class.java))
         val withFilterList = ArrayList<SFilter>()
         withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("projectId").toString()))
-        withFilterList.add(SFilter.lt(SLength("classCode"), 6))
+        withFilterList.add(SFilter.lt(SLength("classCode"), 7))
         return ModelScanTaskQueryService.pageQuerys(request);
     } // Function pageQuery()
 

+ 11 - 2
scanbuilding/src/main/kotlin/com/persagy/server/services/task/EquipScanTaskQueryService.kt

@@ -29,7 +29,9 @@ package com.persagy.server.services.task
 import com.persagy.database.SFilter
 import com.persagy.database.functions.SLength
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.datacenter.models.entities.dictnew.DefClass
 import com.persagy.server.datacenter.models.entities.task.EquipScanTaskQuery
+import com.persagy.service.SBaseService
 import com.persagy.service.SObjectService
 import com.persagy.service.SPageContext
 import com.persagy.service.models.requests.SQueryRequest
@@ -43,15 +45,17 @@ import org.slf4j.LoggerFactory
  */
 object EquipScanTaskQueryService : SObjectService<EquipScanTaskQuery>(SMybatisDao(EquipScanTaskQuery::class.java))  {
 
+    /** 字典平台对象类型 */
+    private val defClassService = SBaseService(SMybatisDao(DefClass::class.java))
     // 日志
     private val logger = LoggerFactory.getLogger(EquipScanTaskQueryService::class.java)
 
 
     fun pageQuerys(request: SQueryRequest): SQueryResponse<EquipScanTaskQuery> {
-
+        val projectId = SPageContext.getHeader("projectId").toString()
         val withFilterList = ArrayList<SFilter>()
         withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("projectId").toString()))
-        withFilterList.add(SFilter.lt(SLength("category"), 6))
+        withFilterList.add(SFilter.lt(SLength("classCode"), 7))
         val pageQuery = pageQuery(request, withFilterList)
         if (!pageQuery.content.isNullOrEmpty()&&pageQuery.content!!.size>0){
             for (content in pageQuery.content!!){
@@ -59,6 +63,11 @@ object EquipScanTaskQueryService : SObjectService<EquipScanTaskQuery>(SMybatisDa
                 if (exec.size>0){
                     content.component = exec
                 }
+                val defClass =
+                    defClassService.select(SFilter.eq("projectId", projectId), SFilter.eq("code", content.classCode!!)).entity()
+                if (defClass!=null) {
+                    content.equipCategory = defClass
+                }
             }
         }
         return pageQuery

+ 11 - 0
scanbuilding/src/main/kotlin/com/persagy/server/services/task/ModelScanTaskQueryService.kt

@@ -29,8 +29,10 @@ package com.persagy.server.services.task
 import com.persagy.database.SFilter
 import com.persagy.database.functions.SLength
 import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.datacenter.models.entities.dictnew.DefClass
 import com.persagy.server.datacenter.models.entities.task.ModelScanTaskQuery
 import com.persagy.server.services.base.RService
+import com.persagy.service.SBaseService
 import com.persagy.service.SPageContext
 import com.persagy.service.models.requests.SQueryRequest
 import com.persagy.service.models.responses.SQueryResponse
@@ -43,7 +45,11 @@ import com.persagy.service.models.responses.SQueryResponse
  */
 object ModelScanTaskQueryService : RService<ModelScanTaskQuery>(SMybatisDao(ModelScanTaskQuery::class.java))  {
 
+    /** 字典平台对象类型 */
+    private val defClassService = SBaseService(SMybatisDao(DefClass::class.java))
+
     fun pageQuerys(request: SQueryRequest): SQueryResponse<ModelScanTaskQuery> {
+        val projectId = SPageContext.getHeader("projectId").toString()
         val withFilterList = ArrayList<SFilter>()
         withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("projectId").toString()))
         withFilterList.add(SFilter.lt(SLength("classCode"), 6))
@@ -54,6 +60,11 @@ object ModelScanTaskQueryService : RService<ModelScanTaskQuery>(SMybatisDao(Mode
                 if (exec.size>0){
                     content.component = exec
                 }
+                val defClass =
+                    defClassService.select(SFilter.eq("projectId", projectId), SFilter.eq("code", content.classCode!!)).entity()
+                if (defClass!=null) {
+                    content.equipCategory = defClass
+                }
             }
         }
         return pageQuery

+ 19 - 1
scanbuilding/src/main/kotlin/com/persagy/server/services/task/PropertyScanTaskService.kt

@@ -32,9 +32,11 @@ import com.google.gson.Gson
 import com.google.gson.reflect.TypeToken
 import com.persagy.base.extensions.toJson
 import com.persagy.database.SFilter
+import com.persagy.database.SPageQueryInfo
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.Opts
 import com.persagy.server.datacenter.models.entities.assistant.TaskPic
+import com.persagy.server.datacenter.models.entities.dict.EquipFamilyCategory
 import com.persagy.server.datacenter.models.entities.objects.Property
 import com.persagy.server.datacenter.models.entities.task.PropertyScanTask
 import com.persagy.server.datacenter.models.entities.task.SchemeUtils
@@ -64,7 +66,8 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
     var userLogService = SObjectService(SMybatisDao(UserLog::class.java))
     /** 用户 */
     var userService = SObjectService(SMybatisDao(User::class.java))
-
+    /** 用户 */
+    var equipFamilyCategoryService = SObjectService(SMybatisDao(EquipFamilyCategory::class.java))
     /**
      * 插入之前先过滤已经存在未验证任务的对象,返回新列表
      */
@@ -300,4 +303,19 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
 
     } // Fun onUpdateSuccess
 
+    override fun onQuerySuccess(pageInfo: SPageQueryInfo<PropertyScanTask>) {
+        if (!pageInfo.content.isNullOrEmpty()){
+            for (content in pageInfo.content!!){
+                val entity = equipFamilyCategoryService.select(SFilter.eq("family", content.classCode!!)).entity()
+                if (entity!=null) {
+                    content.equipFamily = entity
+                }
+            }
+        }
+        super.onQuerySuccess(pageInfo)
+
+    }
+
+
+
 } // Class PropertyScanTaskService