Przeglądaj źródła

********************WX************************
数据中心改版

zhangweixin 4 lat temu
rodzic
commit
b3eebec217

+ 16 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/objects/Shaft.kt

@@ -1,5 +1,6 @@
 package com.persagy.server.datacenter.models.entities.objects
 
+import com.persagy.server.datacenter.models.entities.assistant.PointPosition
 import com.persagy.server.datacenter.models.entities.base.BaseInfo
 import com.persagy.service.models.annotations.SCascade
 import io.swagger.annotations.ApiModel
@@ -63,11 +64,26 @@ class Shaft : BaseInfo() {
     @Column(name = "project_id")
     var projectId: String? = null
 
+    /** BIM模型中坐标 */
+    @ApiModelProperty(value = "BIM模型中坐标")
+    @Column(name = "bim_location")
+    var bimLocation: String? = null
+
+    /** 竖井顺序码 */
+    @ApiModelProperty(value = "竖井顺序码")
+    @Column(name = "shaft_sequenceId")
+    var shaftSequenceId: Int? = null
+
     /** 信息点 */
     @ApiModelProperty(value = "信息点")
     @Column(name = "infos")
     var infos: HashMap<String, Any?>? = null
 
+    /** BIM模型中轮廓坐标 */
+    @ApiModelProperty(value = "BIM模型中轮廓坐标")
+    @Column(name = "outline")
+    var outline: ArrayList<PointPosition>? = null
+
     /** 结构信息 */
     @ApiModelProperty(value = "结构信息")
     @Column(name = "structure_info")

+ 1 - 1
datacenter/build.gradle

@@ -51,7 +51,7 @@ dependencies {
     compile group: "org.springframework.boot", name: "spring-boot-starter-actuator", version: SPRING_BOOT_VERSION
     compile group: "org.springframework.boot", name: "spring-boot-starter-logging", version: SPRING_BOOT_VERSION
     //消息
-    compile group: "org.springframework.boot", name: "spring-boot-starter-activemq", version: SPRING_BOOT_VERSION
+//    compile group: "org.springframework.boot", name: "spring-boot-starter-activemq", version: SPRING_BOOT_VERSION
     providedCompile group: "org.springframework.boot", name:"spring-boot-starter-tomcat", version: SPRING_BOOT_VERSION
     // spring boot 缓存
     compile group:"org.springframework.boot", name:"spring-boot-starter-cache", version: SPRING_BOOT_VERSION

+ 6 - 3
datacenter/src/main/resources/application-prod.yml

@@ -28,12 +28,15 @@ server:
 
 spring:
   datasource:
-    url:                                jdbc:postgresql://data-center:5432/datacenter
+#    url:                                jdbc:postgresql://data-center:5432/datacenter
+#    username:                           postgres
+#    password:                           123qwe!@#
+    url:                                jdbc:postgresql://172.17.100.16:5432/datacenter
     username:                           postgres
-    password:                           123qwe!@#
+    password:                           persagy_2020qwe!@#
 
   activemq:
-    broker-url:                         tcp://activemq:61616
+#    broker-url:                         tcp://activemq:61616
 
   servlet:
     multipart:

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

@@ -1,20 +1,63 @@
 package com.persagy.server.syn.controllers.obj
 
+import com.persagy.database.SFilter
+import com.persagy.mybatis.SMybatisDao
+import com.persagy.server.datacenter.models.entities.objects.Building
+import com.persagy.server.syn.models.api.obj.BuildingApi
+import com.persagy.service.SObjectService
+import com.persagy.service.models.enums.SResponseType
+import com.persagy.service.models.responses.SBaseResponse
+import io.swagger.annotations.Api
+import io.swagger.annotations.ApiOperation
+import org.slf4j.LoggerFactory
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RestController
+
 /**
  * 数据中心 - 数据中台
  *
  * @author wx  <zhangweixin@sagacloud.com>
  * @date  2020/10/22 21:39
  */
+@Api(tags = ["0003、对象-数据中心到中台"])
+@RestController
+@RequestMapping("/sync")
 class ObjectToFromController {
+    companion object {
+        /** 日志 */
+        private val logger = LoggerFactory.getLogger(ObjectToFromController::class.java)
+    } // Companion object
+    /** 数据中心建筑服务 */
+    private val buildingService = SObjectService(SMybatisDao(Building::class.java))
 
     /**
      * 建筑同步
      *
      * @param projectId     项目 id
      */
-    fun buildingSyn(projectId: String) {
-
+    @ApiOperation(value="建筑-数据中心同步到数据中台", notes="")
+    @PostMapping("/building")
+    fun buildingSynCreate(projectId: String): SBaseResponse {
+        try {
+            val buildingList = buildingService.select(SFilter.eq("projectId", projectId)).exec()
+            if (buildingList.size>0){
+                for (building in buildingList){
+                    val createBuilding = BuildingApi.createBuilding(projectId, building)
+                    if (!createBuilding){
+                        logger.debug("建筑创建失败:${building}")
+                        val updateBuilding = BuildingApi.updateBuilding(projectId, building)
+                        if (!updateBuilding){
+                            logger.debug("建筑更新失败:${building}")
+                        }
+                    }
+                }
+            }
+            return SBaseResponse(SResponseType.success)
+        } catch (e: Exception) {
+            e.printStackTrace()
+            return SBaseResponse(SResponseType.failure,e.message!!)
+        }
     }
 
 

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

@@ -2,8 +2,10 @@ package com.persagy.server.syn.models.api.obj
 
 import com.alibaba.fastjson.JSONObject
 import com.persagy.base.utils.SHttpUtil
+import com.persagy.server.datacenter.models.entities.objects.Building
 import com.persagy.server.syn.Opts
 import com.persagy.server.syn.models.obj.MiddleGroundDataRespose
+import com.persagy.server.syn.models.tools.BuildingUtil
 import com.persagy.service.utils.SSpringContextUtil
 
 /**
@@ -23,6 +25,8 @@ object BuildingApi {
      * 获取建筑
      *
      * @param projectId     项目 id
+     * @param type          类型
+     * @return              返回结果
      */
     fun buildingSyn(projectId: String,type: String): ArrayList<HashMap<String, Any?>> {
         val url = "${opts.dataPlatform}/instance/object/query?projectId=${projectId}"
@@ -40,12 +44,74 @@ object BuildingApi {
 
     /**
      * 中台创建建筑
+     *
+     * @param projectId     项目 id
+     * @param building      建筑对象
+     * @return 是否成功
      */
-    fun  createBuilding(projectId: String) {
+    fun  createBuilding(projectId: String, building:Building): Boolean {
         val url = "${opts.dataPlatform}/instance/object/create?projectId=${projectId}&appId=datacenter"
+        val buildingTools = BuildingUtil.buildingTools(projectId, building)
+        val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, buildingTools)
+        if (postObject.result == "success") {
+            return true
+        }
+        return false
+    }
 
+    /**
+     * 中台更新建筑
+     *
+     * @param projectId     项目 id
+     * @param building      建筑对象
+     * @return 是否成功
+     */
+    fun  updateBuilding(projectId: String, building:Building): Boolean {
+        val url = "${opts.dataPlatform}/instance/object/update?projectId=${projectId}&appId=datacenter"
+        val buildingTools = BuildingUtil.buildingTools(projectId, building)
+        val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, buildingTools)
+        if (postObject.result == "success") {
+            return true
+        }
+        return false
+    }
 
+    /**
+     * 中台删除建筑
+     *
+     * @param projectId     项目 id
+     * @param building      建筑对象
+     * @return 是否成功
+     */
+    fun  delBuilding(projectId: String, buildingId: String): Boolean {
+        val url = "${opts.dataPlatform}/instance/object/delete?projectId=${projectId}&appId=datacenter"
+        val listId = ArrayList<String>()
+        listId.add(buildingId)
+        val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, listId)
+        if (postObject.result == "success") {
+            return true
+        }
+        return false
     }
 
+    /**
+     * 根据 id 查询对象
+     *
+     * @param projectId     项目 id
+     * @param id             对象 id
+     * @return 返回结果
+     */
+    fun queryBuilding(projectId: String,id: String): ArrayList<HashMap<String, Any?>> {
+        val url = "${opts.dataPlatform}/instance/object/query?projectId=${projectId}"
+        val jsonObject = JSONObject()
+        val jsonObject2 = JSONObject()
+        jsonObject2["id"] = id
+        jsonObject["criteria"] = jsonObject2
+        val postObject = SHttpUtil.postObject<MiddleGroundDataRespose>(url, jsonObject)
+        if (postObject.result == "success"&&!postObject.data.isNullOrEmpty()) {
+            return postObject.data!!
+        }
+        return ArrayList<HashMap<String, Any?>>()
+    }
 
 }

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

@@ -439,7 +439,42 @@ object BuildingUtil {
         return building
     }
 
+    /**
+     * 建筑工具
+     *
+     * @param projectId     项目 id
+     * @param building      建筑对象
+     * @return 返回对象
+     */
+    fun buildingTools(projectId: String,building: Building): ArrayList<HashMap<String,Any?>> {
+        var list = ArrayList<HashMap<String,Any?>>()
+        val hashMap = HashMap<String, Any?>()
+        hashMap["id"] = building.id
+        hashMap["name"] = building.name
+        hashMap["projectId"] = projectId
+        hashMap["objType"] = "building"
+        hashMap["classCode"] = "building"
+        if (!building.localName.isNullOrEmpty()){
+            hashMap["localName"] = building.localName
+        }
+        if (!building.localId.isNullOrEmpty()){
+            hashMap["localId"] = building.localId
+        }
+        if (!building.defaultQRCode.isNullOrEmpty()){
+            hashMap["defaultQRCode"] = building.defaultQRCode
+        }
+        if (!building.buildQRCode.isNullOrEmpty()){
+            hashMap["buildQRCode"] = building.buildQRCode
+        }
+       if (!building.infos.isNullOrEmpty()){
+           for (key in building.infos!!.keys){
+               hashMap[key] = building.infos!![key]
+           }
+       }
 
+        list.add(hashMap)
+        return list
+    }
 
 
 }

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

@@ -2457,4 +2457,69 @@ object EquipUtil {
 
         return equipment
     }
+
+    /**
+     * 设备工具
+     *
+     * @param projectId     项目 id
+     * @param equipment     设备对象
+     * @return 返回结果
+     */
+    fun equipTools(projectId: String,equipment: Equipment): ArrayList<HashMap<String,Any?>> {
+        var list = ArrayList<HashMap<String,Any?>>()
+        val hashMap = HashMap<String, Any?>()
+        hashMap["id"] = equipment.id
+        hashMap["name"] = equipment.name
+        hashMap["projectId"] = projectId
+        hashMap["objType"] = "equipment"
+        hashMap["classCode"] = equipment.classCode
+        if (!equipment.localName.isNullOrEmpty()){
+            hashMap["localName"] = equipment.localName
+        }
+        if (!equipment.localId.isNullOrEmpty()){
+            hashMap["localId"] = equipment.localId
+        }
+        if (!equipment.defaultQRCode.isNullOrEmpty()){
+            hashMap["defaultQRCode"] = equipment.defaultQRCode
+        }
+        if (!equipment.qRCodePic.isNullOrEmpty()){
+            hashMap["qRCodePic"] = equipment.qRCodePic
+        }
+        if (!equipment.	rfId.isNullOrEmpty()){
+            hashMap["rfId"] = equipment.rfId
+        }
+        if (!equipment.cadId.isNullOrEmpty()){
+            hashMap["cadId"] = equipment.cadId
+        }
+        if (!equipment.bimId.isNullOrEmpty()){
+            hashMap["bimId"] = equipment.bimId
+        }
+        if (!equipment.bimLocation.isNullOrEmpty()){
+            hashMap["bimLocation"] = equipment.bimLocation
+        }
+        if (!equipment.bimFamilyName.isNullOrEmpty()){
+            hashMap["bimFamilyName"] = equipment.bimFamilyName
+        }
+        if (!equipment.bimFamilySymbol.isNullOrEmpty()){
+            hashMap["bimFamilySymbol"] = equipment.bimFamilySymbol
+        }
+        if (!equipment.bimTypeId.isNullOrEmpty()){
+            hashMap["bimTypeId"] = equipment.bimTypeId
+        }
+        if (equipment.equipSerial!=null&&equipment.equipSerial!=0.0){
+            hashMap["equipSerial"] = equipment.equipSerial
+        }
+
+        if (!equipment.infos.isNullOrEmpty()){
+            for (key in equipment.infos!!.keys){
+                hashMap[key] = equipment.infos!![key]
+            }
+        }
+
+        list.add(hashMap)
+        return list
+    }
+
+
+
 }

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

@@ -267,4 +267,64 @@ object FloorUtil {
         return floor
     }
 
+    /**
+     * 楼层工具
+     *
+     * @param projectId     项目 id
+     * @param floor         楼层对象
+     * @return 返回结果
+     */
+    fun floorTools(projectId: String,floor: Floor): ArrayList<HashMap<String,Any?>> {
+        var list = ArrayList<HashMap<String,Any?>>()
+        val hashMap = HashMap<String, Any?>()
+        hashMap["id"] = floor.id
+        hashMap["name"] = floor.name
+        hashMap["projectId"] = projectId
+        hashMap["objType"] = "floor"
+        hashMap["classCode"] = "floor"
+        hashMap["floorSequenceId"] = floor.floorSequenceId
+        if (!floor.localName.isNullOrEmpty()){
+            hashMap["localName"] = floor.localName
+        }
+        if (!floor.localId.isNullOrEmpty()){
+            hashMap["localId"] = floor.localId
+        }
+        if (!floor.defaultQRCode.isNullOrEmpty()){
+            hashMap["defaultQRCode"] = floor.defaultQRCode
+        }
+        if (!floor.qRCodePic.isNullOrEmpty()){
+            hashMap["qRCodePic"] = floor.qRCodePic
+        }
+        if (!floor.bimIdPre.isNullOrEmpty()){
+            hashMap["bimIdPre"] = floor.bimIdPre
+        }
+        if (!floor.modelId.isNullOrEmpty()){
+            hashMap["modelId"] = floor.modelId
+        }
+        if (!floor.bimId.isNullOrEmpty()){
+            hashMap["bimId"] = floor.bimId
+        }
+        if (!floor.bimLocation.isNullOrEmpty()){
+            hashMap["bimLocation"] = floor.bimLocation
+        }
+        if (!floor.outline.isNullOrEmpty()){
+            hashMap["outline"] = floor.outline.toString()
+        }
+        if (floor.permanentPeopleNum!=null&&floor.permanentPeopleNum!=0){
+            hashMap["permanentPeopleNum"] = floor.permanentPeopleNum
+        }
+        if (!floor.floorIdentity.isNullOrEmpty()){
+            hashMap["floorIdentity"] = floor.floorIdentity
+        }
+        if (!floor.infos.isNullOrEmpty()){
+            for (key in floor.infos!!.keys){
+                hashMap[key] = floor.infos!![key]
+            }
+        }
+
+        list.add(hashMap)
+        return list
+    }
+
+
 }

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

@@ -228,4 +228,50 @@ object ShaftUtil {
         return shaft
     }
 
+    /**
+     * 竖井
+     */
+    fun shaftTools(projectId: String,shaft: Shaft): ArrayList<HashMap<String,Any?>> {
+        var list = ArrayList<HashMap<String,Any?>>()
+        val hashMap = HashMap<String, Any?>()
+        hashMap["id"] = shaft.id
+        hashMap["name"] = shaft.name
+        hashMap["projectId"] = projectId
+        hashMap["objType"] = "shaft"
+        hashMap["classCode"] = "shaft"
+        if (!shaft.localName.isNullOrEmpty()){
+            hashMap["localName"] = shaft.localName
+        }
+        if (!shaft.localId.isNullOrEmpty()){
+            hashMap["localId"] = shaft.localId
+        }
+        if (!shaft.defaultQRCode.isNullOrEmpty()){
+            hashMap["defaultQRCode"] = shaft.defaultQRCode
+        }
+        if (!shaft.qRCodePic.isNullOrEmpty()){
+            hashMap["qRCodePic"] = shaft.qRCodePic
+        }
+        if (!shaft.bimId.isNullOrEmpty()){
+            hashMap["bimId"] = shaft.bimId
+        }
+        if (!shaft.bimLocation.isNullOrEmpty()){
+            hashMap["bimLocation"] = shaft.bimLocation
+        }
+        if (!shaft.outline.isNullOrEmpty()){
+            hashMap["outline"] = shaft.outline.toString()
+        }
+        if (shaft.shaftSequenceId!=null&&shaft.shaftSequenceId!=0){
+            hashMap["shaftSequenceId"] = shaft.shaftSequenceId
+        }
+        if (!shaft.infos.isNullOrEmpty()){
+            for (key in shaft.infos!!.keys){
+                hashMap[key] = shaft.infos!![key]
+            }
+        }
+
+        list.add(hashMap)
+        return list
+    }
+
+
 }

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

@@ -364,6 +364,7 @@ object SpaceUtil {
 
         val zoneSpace = ZoneSpace()
         zoneSpace.projectId = projectId
+        zoneSpace.classCode = mapObj["classCode"].toString()
         for (key in mapObj.keys) {
             val containsKey = mapEx.containsKey(key)
             if (containsKey){
@@ -514,4 +515,57 @@ object SpaceUtil {
 
         return zoneSpace
     }
+
+//    fun spaceTools(projectId: String,zoneSpace: ZoneSpace): ArrayList<HashMap<String,Any?>> {
+//        var list = ArrayList<HashMap<String,Any?>>()
+//        val hashMap = HashMap<String, Any?>()
+//        hashMap["id"] = zoneSpace.id
+//        hashMap["name"] = zoneSpace.name
+//        hashMap["projectId"] = projectId
+//        hashMap["objType"] = "space"
+//        hashMap["classCode"] = zoneSpace.classCode
+//        hashMap["zoneSpaceSequenceId"] = zoneSpace.zoneSpaceSequenceId
+//        if (!zoneSpace.localName.isNullOrEmpty()){
+//            hashMap["localName"] = zoneSpace.localName
+//        }
+//        if (!zoneSpace.localId.isNullOrEmpty()){
+//            hashMap["localId"] = zoneSpace.localId
+//        }
+//        if (!zoneSpace.defaultQRCode.isNullOrEmpty()){
+//            hashMap["defaultQRCode"] = zoneSpace.defaultQRCode
+//        }
+//        if (!zoneSpace.qRCodePic.isNullOrEmpty()){
+//            hashMap["qRCodePic"] = zoneSpace.qRCodePic
+//        }
+//        if (zoneSpace.roomSerial!=null&&zoneSpace.roomSerial!=0.0){
+//            hashMap["roomSerial"] = zoneSpace.roomSerial
+//        }
+//        if (!zoneSpace.roomFuncType.isNullOrEmpty()){
+//            hashMap["roomFuncType"] = zoneSpace.roomFuncType
+//        }
+//        if (!zoneSpace.bimId.isNullOrEmpty()){
+//            hashMap["bimId"] = zoneSpace.bimId
+//        }
+//        if (!zoneSpace.bimLocation.isNullOrEmpty()){
+//            hashMap["bimLocation"] = zoneSpace.bimLocation
+//        }
+//        if (!zoneSpace.outline.isNullOrEmpty()){
+//            hashMap["outline"] = zoneSpace.outline.toString()
+//        }
+//        if (zoneSpace.permanentPeopleNum!=null&&zoneSpace.permanentPeopleNum!=0){
+//            hashMap["permanentPeopleNum"] = zoneSpace.permanentPeopleNum
+//        }
+//        if (!zoneSpace.zoneSpaceIdentity.isNullOrEmpty()){
+//            hashMap["zoneSpaceIdentity"] = zoneSpace.zoneSpaceIdentity
+//        }
+//        if (!zoneSpace.infos.isNullOrEmpty()){
+//            for (key in zoneSpace.infos!!.keys){
+//                hashMap[key] = zoneSpace.infos!![key]
+//            }
+//        }
+//
+//        list.add(hashMap)
+//        return list
+//    }
+
 }

+ 4 - 4
equip-componnet/src/main/resources/application-prod.yml

@@ -23,7 +23,7 @@ spring:
     username:                           postgres
     password:                           persagy_2020qwe!@#
 
-  activemq:
-    user:                               admin
-    password:                           admin
-    broker-url:                         tcp://activemq:61616
+#  activemq:
+#    user:                               admin
+#    password:                           admin
+#    broker-url:                         tcp://activemq:61616

+ 1 - 1
labsl/build.gradle

@@ -59,7 +59,7 @@ dependencies {
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // spring cloud 依赖
-    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka', version: SPRING_CLOUD_VERSION
+//    compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-eureka', version: SPRING_CLOUD_VERSION
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // MySQL

+ 1 - 0
labsl/src/main/kotlin/com/persagy/server/labsl/services/GraphService.kt

@@ -95,6 +95,7 @@ object GraphService : SObjectService<Graph>(SMybatisDao(Graph::class.java)) {
             val num = listVersion[2].toInt() + 1
             graph.version = listVersion[0] + "." + listVersion[1] + "." + num
         }
+        graph.state = 1
         val insertGraph = insert(graph)
         if (!insertGraph) {
             // 事务回滚