Browse Source

********************WX******************
删除建筑和楼层提示

zhangweixin 4 years ago
parent
commit
651cf4a57e

+ 12 - 0
datacenter/src/main/kotlin/com/persagy/server/controllers/objects/BuildingController.kt

@@ -87,6 +87,18 @@ open class BuildingController {
     } // Function delete()
 
     /**
+     * 根据id删除建筑 - 单条删除
+     *
+     * @param   idList      id数组
+     * @return              删除的结果信息
+     */
+    @Operation(summary = "根据id删除建筑信息 - 单条删除 ", description = "")
+    @PostMapping(value = ["/single/delete"])
+    fun deleteSingle(@RequestBody idList: ArrayList<Building>): SBaseResponse {
+        return BuildingService.deleteList(idList)
+    } // Function delete()
+
+    /**
      * 更新建筑信息
      *
      * @param   request     更新的内容对象

+ 12 - 1
datacenter/src/main/kotlin/com/persagy/server/controllers/objects/FloorController.kt

@@ -85,8 +85,19 @@ open class FloorController {
     }
 
     /**
-     * 更新楼层信息
+     * 根据id删除楼层 - 单条删除
      *
+     * @param idList  id 数组
+     * @return 删除的结果信息
+     */
+    @Operation(summary = "根据id删除楼层 - 单条删除 ", description = "")
+    @PostMapping(value = ["/single/delete"])
+    fun deleteSingle(@RequestBody idList: ArrayList<Floor>): SBaseResponse {
+        return FloorService.deleteList( idList)
+    }
+
+    /**
+     * 更新楼层信息
      *
      * @param request     更新的内容对象
      * @return 更新的结果

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

@@ -30,12 +30,15 @@ import com.persagy.database.SFilter
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.objects.Building
+import com.persagy.server.datacenter.models.entities.objects.Floor
 import com.persagy.server.services.assistant.ObjInfoService
 import com.persagy.server.services.base.Service
 import com.persagy.server.services.log.DataCenterLogsService
 import com.persagy.server.utils.IdUtils
 import com.persagy.server.utils.ShaftNameUtil
 import com.persagy.service.SPageContext
+import com.persagy.service.models.enums.SResponseType
+import com.persagy.service.models.responses.SBaseResponse
 import java.util.*
 
 /**
@@ -176,7 +179,7 @@ object BuildingService : Service<Building>(SMybatisDao(Building::class.java)) {
         try {
             val projectId = SPageContext.getHeader("projectId")
             for (building in entityList) {
-                ObjInfoService.delete(SFilter.eq("projectId",projectId!!), SFilter.eq("objId",building.id!!), SFilter.eq("objType","Bd"))
+//                ObjInfoService.delete(SFilter.eq("projectId",projectId!!), SFilter.eq("objId",building.id!!), SFilter.eq("objType","Bd"))
                 rabbitMqService.sendObjects(building.projectId!!, Opt.DELETE,building.id!!)
             }
         } catch (e: Exception) {
@@ -184,5 +187,47 @@ object BuildingService : Service<Building>(SMybatisDao(Building::class.java)) {
         }
     }
 
+    /**
+     * 删除楼层数据
+     */
+    fun deleteList(buildingList: ArrayList<Building>): SBaseResponse {
+        val sBaseResponse = SBaseResponse(SResponseType.success)
+        if (!buildingList.isNullOrEmpty()) {
+            for (building in buildingList) {
+
+                val floorList = FloorService.select(SFilter.eq("projectId", Opt.projectId!!),
+                    SFilter.eq("buildingId", building.id!!)).exec()
+                val equipList =
+                    EquipmentService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("buildingId", building.id!!))
+                        .exec()
+                val spaceList = ZoneSpaceBaseService.select(SFilter.eq("projectId", Opt.projectId!!),
+                    SFilter.eq("buildingId", building.id!!)).exec()
+                val ispaceList =
+                    SpaceService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("buildingId", building.id!!))
+                        .exec()
+                if (floorList.size>0||equipList.size>0||spaceList.size>0||ispaceList.size>0 ) {
+                    sBaseResponse.message = "建筑下包含其他对象实例,请解除关系后删除"
+                    sBaseResponse.result =  SResponseType.failure
+                    return sBaseResponse
+                }
+                val delete =
+                    BuildingService.delete(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("id", building.id!!))
+                if (delete) {
+                    try {
+                        rabbitMqService.sendObjects(building.projectId!!, Opt.DELETE,building.id!!)
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
+                    return sBaseResponse
+                }
+            }
+        }else {
+            sBaseResponse.result = SResponseType.failure
+            sBaseResponse.message = "列表不可以为空"
+        }
+        return sBaseResponse
+    }
+
+
 
 } // Object BuildingService

+ 35 - 2
datacenter/src/main/kotlin/com/persagy/server/services/objects/FloorService.kt

@@ -28,6 +28,7 @@ package com.persagy.server.services.objects
 
 import com.persagy.base.extensions.toJson
 import com.persagy.database.SFilter
+import com.persagy.database.extensions.keyValue
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.objects.Floor
@@ -316,10 +317,42 @@ object FloorService : Service<Floor>(SMybatisDao(Floor::class.java)) {
 
 
     /**
-     *
+     * 删除楼层数据
      */
-    fun deleteList(idList: ArrayList<Floor>){
+    fun deleteList(floorList: ArrayList<Floor>): SBaseResponse {
+        val sBaseResponse = SBaseResponse(SResponseType.success)
+        if (!floorList.isNullOrEmpty()) {
+            for (floor in floorList) {
+
+                val equipList =
+                    EquipmentService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("floorId", floor.id!!))
+                        .exec()
+                val spaceList = ZoneSpaceBaseService.select(SFilter.eq("projectId", Opt.projectId!!),
+                    SFilter.eq("floorId", floor.id!!)).exec()
+                val ispaceList =
+                    SpaceService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("floorId", floor.id!!))
+                        .exec()
+                if (equipList.size>0||spaceList.size>0||ispaceList.size>0 ) {
+                    sBaseResponse.message = "楼层下包含其他对象实例,请解除关系后删除"
+                    sBaseResponse.result =  SResponseType.failure
+                    return sBaseResponse
+                }
 
+                val delete = delete(SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("floorId", floor.id!!))
+                if (delete) {
+                    try {
+                        rabbitMqService.sendObjects(Opt.projectId!!, Opt.DELETE, floor.id!!)
+                    } catch (e: Exception) {
+                        e.printStackTrace()
+                    }
+                    return sBaseResponse
+                }
+            }
+        }else {
+            sBaseResponse.result = SResponseType.failure
+            sBaseResponse.message = "列表不可以为空"
+        }
+        return sBaseResponse
     }
 
 

+ 14 - 14
datacenter/src/main/resources/application-test.yml

@@ -25,28 +25,28 @@ server:
 
 spring:
   datasource:
-    url:                                jdbc:postgresql://192.168.64.14:5432/datacenterlabsl
+#    url:                                jdbc:postgresql://192.168.64.14:5432/datacenterlabsl
 #    url:                                jdbc:postgresql://datacenter:5432/datacenterlabsl
-#    url:                                jdbc:postgresql://192.168.64.15:5432/datacenter
+    url:                                jdbc:postgresql://192.168.64.15:5432/datacenter
 #    url:                                jdbc:postgresql://datacenter:5432/datacenter
     username:                           postgres
     password:                           cGVyc2FneV8yMDIwcXdlIUAj
 
-  rabbitmq:
-    host: 192.168.100.108
-    port: 9936
-    username: pbsage
-    password: pbsage123
-    #虚拟host 可以不设置,使用server默认host
-    virtual-host: /adm
-#
 #  rabbitmq:
-#    host: 192.168.64.15
+#    host: 192.168.100.108
 #    port: 9936
-#    username: admin
-#    password: brzj123456
+#    username: pbsage
+#    password: pbsage123
 #    #虚拟host 可以不设置,使用server默认host
-#    virtual-host: /test
+#    virtual-host: /adm
+
+  rabbitmq:
+    host: 192.168.64.15
+    port: 9936
+    username: admin
+    password: brzj123456
+    #虚拟host 可以不设置,使用server默认host
+    virtual-host: /test
 
 
   servlet:

+ 10 - 10
equip-component/src/main/resources/application-test.yml

@@ -1,15 +1,15 @@
 
 # spring-cloud相关配置
-eureka:
-  client:                                   #客户端注册进eureka服务列表内
-    service-url:
-      defaultZone:                          http://eureka-service:8761/eureka
-
-  instance:
-    # 实例ID
-    # instance-id:                            ${spring.application.name}:${server.port}:${project.version}
-    # 优先使用IP地址方式进行注册服务
-    prefer-ip-address:                      true
+#eureka:
+#  client:                                   #客户端注册进eureka服务列表内
+#    service-url:
+#      defaultZone:                          http://eureka-service:8761/eureka
+#
+#  instance:
+#    # 实例ID
+#    # instance-id:                            ${spring.application.name}:${server.port}:${project.version}
+#    # 优先使用IP地址方式进行注册服务
+#    prefer-ip-address:                      true
 
 server:
   port: 8087