Explorar el Código

********************WX***********************
屏蔽不规范编码

zhangweixin hace 4 años
padre
commit
3fe831f035

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

@@ -100,7 +100,9 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
                 SFilter.eq("projectId", equip.projectId!!),
                 SFilter.endWith("code", equip.classCode!!)
             ).entity()
-                ?: return false
+               if (entity == null) {
+                  return false
+               }
         }
 
         /** 设备名字 */
@@ -119,10 +121,6 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
         return true
     } // Function onCreateBefore()
 
-    override fun onCountSuccess(count: Long) {
-        super.onCountSuccess(count)
-
-    }
 
 
     /**
@@ -153,29 +151,23 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
 
             if(entity.classCode!!.length<6){
                 val defClass = defClassService.select(
-                        SFilter.eq("projectId", entity.projectId!!),
+                        SFilter.eq("projectId", Opt.projectId!!),
                         SFilter.endWith("code", entity.classCode!!)
                 ).entity()
                 if (defClass!=null){
                     entity.classCode = defClass.code
                 } else {
-                    return false
+                    entity.classCode = null
                 }
             }
 
+            if (entity.projectId.isNullOrEmpty()){
+                entity.projectId = Opt.projectId
+            }
+
             if (entity.propertyId.isNullOrEmpty()) {
 
-//                val property = PropertyService.select(SFilter.eq("equipmentId", entity.id!!)).entity()
-//                logger.debug("设备初次关联*********************************")
-//                if (property!=null){
-//                    property.equipId = null
-//                    val list = ArrayList<Property>()
-//                    list.add(property)
-//                    val sUpdateRequest = SUpdateRequest<Property>()
-//                    sUpdateRequest.content = list
-//                    sUpdateRequest.projection = arrayListOf("EquipmentId")
-//                    PropertyService.updateList(sUpdateRequest)
-//                }
+
             } else {
                 val property = PropertyService.select(SFilter.eq("equipId", entity.id!!)).entity()
                 if (property != null) {
@@ -413,6 +405,7 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
 
     } // Function onUpdateSuccess()
 
+
     /**
      * @Description:删除成功之后
      */

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

@@ -560,10 +560,10 @@ object ZoneSpaceBaseService : ServiceSpace<ZoneSpace>(SMybatisDao(ZoneSpace::cla
                 DataCenterLogsService.addLogs(
                     Opt.projectId!!,"create",zoneSpace.classCode!!,
                     zoneSpace.id!!,zoneSpace, Opt.account, Opt.coming)
+//                ObjInfoService.createInfo(zoneSpace,true,"Sp",zoneSpace.classCode!!)
             } catch (e: Exception) {
                 e.printStackTrace()
             }
-            ObjInfoService.createInfo(zoneSpace,true,"Sp",zoneSpace.classCode!!)
         }
         val projectId = SPageContext.getHeader("projectId")
         try {

+ 18 - 8
datacenter/src/main/resources/application-dev.yml

@@ -34,7 +34,7 @@ spring:
     type:                               com.alibaba.druid.pool.DruidDataSource
     driver-class-name:                  org.postgresql.Driver
 #    url:                                jdbc:postgresql://60.205.177.43:5432/datacenterlabsl
-    url:                                jdbc:postgresql://192.168.64.15:5432/datacenterwanda
+    url:                                jdbc:postgresql://192.168.64.15:5432/datacenter
 #    url:                                jdbc:postgresql://39.102.40.239:5432/datacenter
     username:                           postgres
 #    password:                           persagy_2020qwe!@#
@@ -46,13 +46,23 @@ spring:
       max-file-size:                   500MB        # 限制单个文件的最大值
 
     #配置rabbitMq 服务器
-  rabbitmq:
-    host: 192.168.64.15
-    port: 9936
-    username: admin
-    password: brzj123456
-    #虚拟host 可以不设置,使用 server 默认 host
-    virtual-host: /test
+#  rabbitmq:
+#    host: 192.168.64.15
+#    port: 9936
+#    username: admin
+#    password: brzj123456
+#    #虚拟host 可以不设置,使用 server 默认 host
+#    virtual-host: /test
+
+#  rabbitmq:
+#    host: 39.102.43.179
+#    port: 9936
+#    username: admin
+#    password: brzj123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /test
+
+
 
 mqtopid: # 消息
   exchange:                           exchange-dmp

+ 105 - 2
datasyn/src/main/kotlin/com/persagy/server/syn/controllers/obj/ObjectFromToControllers.kt

@@ -26,6 +26,7 @@
 
 package com.persagy.server.syn.controllers.obj
 
+import com.alibaba.fastjson.JSONObject
 import com.google.gson.Gson
 import com.google.gson.reflect.TypeToken
 import com.persagy.base.extensions.toJson
@@ -270,7 +271,7 @@ class ObjectFromToControllers {
             var num = page
             if (switch) {
                 val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", projectId)).entity()
-                val equipSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,projectId, page)
+                val equipSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,projectId, page,"equipment")
                 val equipDataList = equipSynApi.data
                 for (equipData in equipDataList!!){
                     val equipSyn = EquipUtil.equipSyns(projectId, dictProject!!.groupCode!!, equipData)
@@ -287,6 +288,7 @@ class ObjectFromToControllers {
                         /** 查询楼层 */
                         val equipInFloorList = EquipApi.equipInFloor(dictProject!!.groupCode!!,projectId, equipSyn.id!!)
                         if (equipInFloorList.size>0){
+
                             val hashMap = equipInFloorList[0]
                             if (hashMap.containsKey("objTo")){
                                 equipSyn.floorId = hashMap["objTo"].toString()
@@ -302,6 +304,7 @@ class ObjectFromToControllers {
                         }
                     }
                     BaseDataService.equipmentService.replace(equipSyn)
+
                 }
                 if (equipSynApi.data!!.size>= 1000){
                     num ++
@@ -311,7 +314,7 @@ class ObjectFromToControllers {
                 val projectList = BaseDataService.projectService.selectAll().exec()
                 for (project in projectList){
                     val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", project.id!!)).entity()
-                    val equipSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,project.id!!, page)
+                    val equipSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,project.id!!, page,"equipment")
                     val equipDataList = equipSynApi.data
                     for (equipData in equipDataList!!){
                         val equipSyn = EquipUtil.equipSyns(project.id!!, dictProject.groupCode!!, equipData)
@@ -445,8 +448,108 @@ class ObjectFromToControllers {
         }
     }
 
+    /**
+     * 部件
+     */
+    @Operation(summary = "部件信息-数据中台存储到数据中心 ", description = "switch true  根据输入的项目 id  同步楼层,false 同步所有项目的 楼层")
+    @PostMapping(value = ["/component-syn"])
+    fun componentSyn(@RequestParam projectId: String,@RequestParam switch: Boolean = true,@RequestParam isBuildingFloor: Boolean = true,@RequestParam page: Int = 1){
+
+        var num = page
+        if (switch) {
+            val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", projectId)).entity()
+            val componentSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,projectId, page,"component")
+            val equipDataList = componentSynApi.data
+            for (equipData in equipDataList!!){
+                val equipSyn = EquipUtil.equipSyns(projectId, dictProject!!.groupCode!!, equipData)
+                logger.debug("设备=${equipSyn.toJson()}")
+                if (isBuildingFloor){
+                    logger.debug("***************************************************")
+                    try {
+
+                        val jsonObject = JSONObject()
+                        /** 部件和设备的关系 */
+                        val jsonObject2 =  JSONObject()
+                        jsonObject2["graphCode"] = "MechSubset"
+                        jsonObject2["relCode"] = "Eq2Ec"
+                        jsonObject2["objTo"] = equipSyn.id
+                        jsonObject["criteria"] = jsonObject2
+                        logger.debug("3333333333333333333333333333333333333333333333")
+                        val queryRelationList =
+                            EquipApi.queryRelation(dictProject.groupCode!!, projectId!!, jsonObject)
+                        if (queryRelationList.size>0){
+                            logger.debug("44444444444444444444444444444444444444444444")
+                            val hashMap = queryRelationList[0]
+                            if (hashMap.containsKey("objFrom")){
+                                equipSyn.parentId = hashMap["objFrom"].toString()
 
+                                val entity = BaseDataService.equipmentService.select(
+                                    SFilter.eq("projectId", projectId),
+                                    SFilter.eq("id", equipSyn.parentId!!)
+                                ).entity()
+                                if (entity !=null ) {
+                                    equipSyn.buildingId = entity.buildingId
+                                    equipSyn.floorId = entity.floorId
+                                }
+                            }
+                        }
+                        logger.debug("222222222222222222222222222222222222222")
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
+                }
+                logger.debug("//////////////////////////////////////////////////")
+                BaseDataService.equipmentService.replace(equipSyn)
+            }
+            if (componentSynApi.data!!.size>= 1000){
+                num ++
+                componentSyn(projectId,switch,isBuildingFloor,num)
+            }
+        } else {
+            val projectList = BaseDataService.projectService.selectAll().exec()
+            for (project in projectList){
 
+                val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", project.id!!)).entity()
+                val componentSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,projectId, page,"component")
+                val equipDataList = componentSynApi.data
+                for (equipData in equipDataList!!){
+                    val equipSyn = EquipUtil.equipSyns(projectId, dictProject!!.groupCode!!, equipData)
+                    logger.debug("设备=${equipSyn.toJson()}")
+                    if (isBuildingFloor){
+                        /** 部件和设备的关系 */
+                        val jsonObject2 =  JSONObject()
+                        jsonObject2["graphCode"] = "MechSubset"
+                        jsonObject2["relCode"] = "Eq2Ec"
+                        jsonObject2["objTo"] = equipSyn.id
+                        val queryRelationList =
+                            EquipApi.queryRelation(dictProject.groupCode!!, projectId!!, jsonObject2)
+                        if (queryRelationList.size>0){
+                            val hashMap = queryRelationList[0]
+                            if (hashMap.containsKey("objFrom")){
+                                equipSyn.parentId = hashMap["objFrom"].toString()
+
+                                val entity = BaseDataService.equipmentService.select(
+                                    SFilter.eq("projectId", projectId),
+                                    SFilter.eq("id", equipSyn.parentId!!)
+                                ).entity()
+                                if (entity !=null ) {
+                                    equipSyn.buildingId = entity.buildingId
+                                    equipSyn.floorId = entity.floorId
+                                }
+                            }
+                        }
+                    }
+
+                    BaseDataService.equipmentService.replace(equipSyn)
+                }
+                if (componentSynApi.data!!.size>= 1000){
+                    num ++
+                    componentSyn(projectId,switch,isBuildingFloor,num)
+                }
+
+            }
+        }
+    }
 
 
     /**

+ 1 - 1
datasyn/src/main/kotlin/com/persagy/server/syn/controllers/obj/RelToFromController.kt

@@ -352,7 +352,7 @@ class RelToFromController {
                 for (equipment in equipmentList) {
                     if (!equipment.parentId.isNullOrEmpty()){
                         if (isDel) {
-                            val toJsonObj = Configure.toJsonObj(graphCode, type, equipment.parentId!!, null)
+                            val toJsonObj = Configure.toJsonObj(graphCode, type, equipment.parentId!!, equipment.id!!)
                             EquipApi.delRel(dictProject!!.groupCode!!, projectId,toJsonObj)
                         }
                         val toJsonObjArray =

+ 22 - 23
datasyn/src/main/kotlin/com/persagy/server/syn/jms/MessageReceiver.kt

@@ -30,7 +30,6 @@ import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.jms.MessageNotice
 import com.persagy.server.datacenter.models.jms.SynchronousMessage
 import com.persagy.server.datacenter.models.jms.SynchronousMessageRel
-import com.persagy.server.syn.Configure
 import com.persagy.server.syn.jms.bean.SyncRwdDatacenterMessage
 import com.persagy.service.SObjectService
 import com.persagy.service.utils.SJsonUtil
@@ -82,28 +81,28 @@ class MessageReceiver {
                 /** 不做处理 */
             }else if (messag != null) {
                 /** 消息类型 */
-                when(messag.type){
-                    Configure.RWDCREATE -> {
-                        /** 中台创建 */
-                        syncRwdMessageService.insert(messag)
-                    }
-                    Configure.RWDUPDATE -> {
-                        /** 中台修改 */
-                        syncRwdMessageService.insert(messag)
-                    }
-                    Configure.RWDDELETE -> {
-                        /** 中台删除 */
-                        syncRwdMessageService.insert(messag)
-                    }
-                    Configure.RELATIONCREATE -> {
-                        /** 中台关系创建 */
-                        syncRwdMessageService.insert(messag)
-                    }
-                    Configure.RELATIONDELETE -> {
-                        /** 中台关系删除 */
-                        syncRwdMessageService.insert(messag)
-                    }
-                }
+//                when(messag.type){
+//                    Configure.RWDCREATE -> {
+//                        /** 中台创建 */
+//                        syncRwdMessageService.insert(messag)
+//                    }
+//                    Configure.RWDUPDATE -> {
+//                        /** 中台修改 */
+//                        syncRwdMessageService.insert(messag)
+//                    }
+//                    Configure.RWDDELETE -> {
+//                        /** 中台删除 */
+//                        syncRwdMessageService.insert(messag)
+//                    }
+//                    Configure.RELATIONCREATE -> {
+//                        /** 中台关系创建 */
+//                        syncRwdMessageService.insert(messag)
+//                    }
+//                    Configure.RELATIONDELETE -> {
+//                        /** 中台关系删除 */
+//                        syncRwdMessageService.insert(messag)
+//                    }
+//                }
                 /** 处理消息 */
 //            messageProcessing.syncRwdData()
             }

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

@@ -60,10 +60,10 @@ object EquipApi {
      * @param page          页码
      * @return 返回值
      */
-    fun equipSynApi(groupCode: String,projectId: String,page: Int): MiddleGroundDataRespose{
+    fun equipSynApi(groupCode: String,projectId: String,page: Int,objType: String): MiddleGroundDataRespose{
         val jsonObject = JSONObject()
         val jsonObject2 = JSONObject()
-        jsonObject2["objType"] = "equipment"
+        jsonObject2["objType"] = objType
         jsonObject2["valid"] = 1
         jsonObject["criteria"] = jsonObject2
         jsonObject["page"] = page
@@ -193,19 +193,31 @@ object EquipApi {
      * @return 返回结果
      */
     fun queryRelation(groupCode: String,projectId: String,jsonObject: JSONObject): ArrayList<HashMap<String, Any?>> {
-        /** 直接 http 请求还是通过注册中心 */
-        if (!Configure.customProperties.eurekaorhttp) {
-            val url = "${opts.dataPlatform}/rwd/instance/relation/query?groupCode=$groupCode&projectId=${projectId}"
-            val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, jsonObject)
-            if (postObject.result == "success"&&!postObject.data.isNullOrEmpty()) {
-                return postObject.data!!
-            }
-        } else {
-            val url = "http://${Configure.serviceNameConfig.DMPRWD}/rwd/instance/relation/query?groupCode=$groupCode&projectId=${projectId}"
-            val postObject = Configure.restTemplate.postForObject(url, jsonObject, MiddleGroundDataRespose::class.java)
-            if (postObject.result == "success"&&!postObject.data.isNullOrEmpty()) {
-                return postObject.data!!
+        try {
+            logger.debug("999999999999999999999999999999999999999999")
+            /** 直接 http 请求还是通过注册中心 */
+            if (!Configure.customProperties.eurekaorhttp) {
+                logger.debug("999999999999999999999999999999999999999999")
+                val url = "${opts.dataPlatform}/rwd/instance/relation/query?groupCode=$groupCode&projectId=${projectId}"
+                logger.debug("url= ${url}")
+                logger.debug("boby=${jsonObject}")
+                val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, jsonObject)
+                logger.debug("结果= ${postObject.toJson()}")
+
+                if (postObject.result == "success"&&!postObject.data.isNullOrEmpty()) {
+                    return postObject.data!!
+                }
+            } else {
+                val url = "http://${Configure.serviceNameConfig.DMPRWD}/rwd/instance/relation/query?groupCode=$groupCode&projectId=${projectId}"
+                val postObject = Configure.restTemplate.postForObject(url, jsonObject, MiddleGroundDataRespose::class.java)
+                logger.debug("url= ${url}")
+                logger.debug("boby=${jsonObject}")
+                if (postObject.result == "success"&&!postObject.data.isNullOrEmpty()) {
+                    return postObject.data!!
+                }
             }
+        } catch (e: Exception) {
+            e.printStackTrace()
         }
         return ArrayList<HashMap<String, Any?>>()
     }
@@ -303,6 +315,8 @@ object EquipApi {
         /** 直接 http 请求还是通过注册中心 */
         if (!Configure.customProperties.eurekaorhttp) {
             val url = "${opts.dataPlatform}/rwd/instance/relation/create?groupCode=$groupCode&projectId=${projectId}&appId=datacenter"
+//            logger.debug("url=${url}")
+//            logger.debug("boby=${jsonArray.toJson()}")
             val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, jsonArray)
             if (postObject.result == "success") {
                 return true

+ 3 - 3
datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/DataCenterSpace.kt

@@ -102,7 +102,7 @@ class DataCenterSpace {
                             if (rSpinBdList.size>0){
                                 for (rSpinBd in rSpinBdList) {
                                     val toJsonObj =
-                                        toJsonObjArray("ArchSubset", "Bd2Sp", space.id!!, rSpinBd.buildingId!!)
+                                        toJsonObjArray("ArchSubset", "Bd2Sp",rSpinBd.buildingId!!, space.id!!)
                                     jsonArray.add(toJsonObj)
                                 }
                             }
@@ -110,11 +110,11 @@ class DataCenterSpace {
                             if (rSpinFlList.size>0){
                                 for (rSpinFl in rSpinFlList){
                                     val toJsonObj =
-                                        toJsonObjArray("ArchSubset", "Fl2Sp", space.id!!, rSpinFl.floorId!!)
+                                        toJsonObjArray("ArchSubset", "Fl2Sp", rSpinFl.floorId!!, space.id!!)
                                     jsonArray.add(toJsonObj)
                                 }
                             }
-                            if (listRel.size>0) {
+                            if (jsonArray.size>0) {
                                 val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, jsonArray)
                                 if (!createRel){
                                     message.sign = 2

+ 12 - 3
datasyn/src/main/kotlin/com/persagy/server/syn/services/jms/RwdComponent.kt

@@ -36,6 +36,7 @@ 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.EquipUtil
+import com.persagy.server.syn.services.BaseDataService
 import com.persagy.service.SBaseService
 import com.persagy.service.SObjectService
 import org.springframework.stereotype.Service
@@ -81,13 +82,21 @@ class RwdComponent {
                         jsonObject2["objTo"] = equipment.id
                         val queryRelationList =
                             EquipApi.queryRelation(dictProject.groupCode!!, message.projectId!!, jsonObject2)
-                        equipService.replace(equipment)
                         if (queryRelationList.size>0){
                             val hashMap = queryRelationList[0]
-                            if (hashMap.containsKey("objTo")){
-                                equipment.parentId = hashMap["objTo"].toString()
+                            if (hashMap.containsKey("objFrom")){
+                                equipment.parentId = hashMap["objFrom"].toString()
+                                val entity = BaseDataService.equipmentService.select(
+                                    SFilter.eq("projectId", message.projectId!!),
+                                    SFilter.eq("id", equipment.parentId!!)
+                                ).entity()
+                                if (entity !=null ) {
+                                    equipment.buildingId = entity.buildingId
+                                    equipment.floorId = entity.floorId
+                                }
                             }
                         }
+                        equipService.replace(equipment)
                         message.state = 0
                     } else {
                         message.state = 2

+ 3 - 3
datasyn/src/main/resources/application-dev.yml

@@ -6,8 +6,8 @@ spring:
     #    username:                           postgres
     #    password:                           123qwe!@#
     #    url:                                jdbc:postgresql://192.168.64.14:5432/datacenterlabsl
-#    url:                                jdbc:postgresql://192.168.64.15:5432/datacenter
-    url:                                jdbc:postgresql://39.102.40.239:5432/datacenter
+    url:                                jdbc:postgresql://192.168.64.15:5432/datacenter
+#    url:                                jdbc:postgresql://39.102.40.239:5432/datacenter
     username:                           postgres
     #    password:                           persagy_2020qwe!@#
     password:                           cGVyc2FneV8yMDIwcXdlIUAj
@@ -45,7 +45,7 @@ mqtopid:
 
 custom:
   #true 代表eureka  false  代表 http
-  eurekaorhttp:                       true
+  eurekaorhttp:                       false
 
 # 服务名
 servicename:

+ 4 - 2
equip-component/src/main/kotlin/com/persagy/server/service/objects/EquipmentService.kt

@@ -649,9 +649,11 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
                     if (equip == null){
                         continue
                     }
+                    if (equip!!.infos.isNullOrEmpty()) {
+                        equip!!.infos= HashMap()
+                    }
                     logger.debug("设备id= ${equip?.id}")
                     if (!equipUpDateEnclosure.pic.isNullOrEmpty()){
-                        if (!equip!!.infos.isNullOrEmpty()) {
                             val containsKey1 = equip!!.infos!!.containsKey(Opt.PIC)
                             if (containsKey1) {
                                 val any = equip!!.infos!![Opt.PIC] as JSONArray
@@ -660,7 +662,7 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
                             } else {
                                 equip!!.infos!![Opt.PIC] = equipUpDateEnclosure.pic!!
                             }
-                        }
+
                     }
                     if (!equipUpDateEnclosure.archive.isNullOrEmpty()){
                         val containsKey1 = equip!!.infos!!.containsKey(Opt.ARCHIVE)

+ 1 - 1
gradle.properties

@@ -26,7 +26,7 @@
 
 PERSAGY_URL = http://www.persagy.cn
 PERSAGY_KOTLIN_VERSION = 1.4.121
-PERSAGY_SERVICE_VERSION = 1.4.163
+PERSAGY_SERVICE_VERSION = 1.4.164
 
 #PERSAGY_KOTLIN_VERSION = 1.4.128
 #PERSAGY_SERVICE_VERSION = 1.4.165