瀏覽代碼

Merge remote-tracking branch 'origin/master'

zhangweixin 4 年之前
父節點
當前提交
d8e09a3778
共有 20 個文件被更改,包括 349 次插入228 次删除
  1. 14 0
      data-core/src/main/kotlin/com/persagy/server/datacenter/datacenter/models/entities/graphtype/RelationType.kt
  2. 15 0
      data-core/src/main/kotlin/com/persagy/server/datacenter/datacenter/models/entities/graphtype/RelationTypeProject.kt
  3. 1 1
      data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/rel/RelEq2FlEquip.kt
  4. 1 1
      data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/rel/RelSy2EqSystem.kt
  5. 2 2
      datacenter/src/main/kotlin/com/persagy/server/datacenter/mappers/IRelationCalcMapper.kt
  6. 32 8
      datacenter/src/main/kotlin/com/persagy/server/datacenter/mappers/IRelationExcelImportMapper.kt
  7. 9 9
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/graphtype/GraphicTypeMapperService.kt
  8. 4 1
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/graphtype/GraphicTypeService.kt
  9. 26 24
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/graphtype/RelationTypeProjectService.kt
  10. 7 0
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/objects/EquipmentService.kt
  11. 1 1
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/objects/SpaceService.kt
  12. 18 3
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/rel/RelStatisticService.kt
  13. 7 7
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/rel/RelationType.kt
  14. 143 136
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/CalcSpecialService.kt
  15. 16 2
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/ManualRelationCalcService.kt
  16. 34 24
      datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/RelationCalcService.kt
  17. 2 2
      datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/CalcSpecialController.kt
  18. 11 2
      datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/GraphicTypeController.kt
  19. 2 1
      datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/ManualRelationCalcController.kt
  20. 4 4
      datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/RelationCalcController.kt

+ 14 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/datacenter/models/entities/graphtype/RelationType.kt

@@ -162,4 +162,18 @@ open class RelationType : RBaseInfo() {
     @Column(name = "mep_system_type")
     var mepSystemType: ArrayList<String>? = null
 
+    /** 关系相关类型主从 0 None 1主 2从 3主从 */
+    @Schema(description = "关系相关类型主从 0 None 1主 2从 3主从")
+    @Column(name = "rel_type_status")
+    var relTypeStatus: Int? = null
+
+    /** 是否可以计算,1,可以,0不可以 */
+    @Schema(description = "否可以计算,1,可以,0不可以")
+    @Column(name = "enable_calc")
+    var enableCalc: Int? = null
+
+    /** 请求路径 */
+    @Schema(description = "请求路径")
+    @Column(name = "request_url")
+    var requestUrl: String? = null
 }

+ 15 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/datacenter/models/entities/graphtype/RelationTypeProject.kt

@@ -185,4 +185,19 @@ open class RelationTypeProject : RBaseInfo() {
     @Column(name = "mep_system_type")
     var mepSystemType: ArrayList<String>? = null
 
+
+    /** 关系相关类型主从 0 None 1主 2从 3主从 */
+    @Schema(description = "关系相关类型主从 0 None 1主 2从 3主从")
+    @Column(name = "rel_type_status")
+    var relTypeStatus: Int? = null
+
+    /** 是否可以计算,1,可以,0不可以 */
+    @Schema(description = "否可以计算,1,可以,0不可以")
+    @Column(name = "enable_calc")
+    var enableCalc: Int? = null
+
+    /** 请求路径 */
+    @Schema(description = "请求路径")
+    @Column(name = "request_url")
+    var requestUrl: String? = null
 }

+ 1 - 1
data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/rel/RelEq2FlEquip.kt

@@ -18,6 +18,6 @@ class RelEq2FlEquip: EquipmentBase() {
     /** 级联-设备服务的建筑 */
     @Schema(description = "级联-设备服务的建筑")
     @SCascade(table="public.equipment", idColumn="id", childIdColumn="floor_id")
-    var objectInfo: ArrayList<RelBuilding>? = null
+    var objectInfo: ArrayList<RelFloor>? = null
 
 }

+ 1 - 1
data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/rel/RelSy2EqSystem.kt

@@ -16,7 +16,7 @@ class RelSy2EqSystem : RelGeneralSystem() {
 
     /** 级联-设备服务的建筑 */
     @Schema(description = "级联-设备服务的建筑")
-    @SCascade(table="relationship.r_sy_eq", idColumn="sy_id", childIdColumn="eq_id")
+    @SCascade(table="relationship.r_sy2eq", idColumn="sy_id", childIdColumn="eq_id")
     var objectInfo: ArrayList<EquipmentBase>? = null
 
 

+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/datacenter/mappers/IRelationCalcMapper.kt

@@ -77,8 +77,8 @@ interface IRelationCalcMapper {
      *@param projectId 项目id
      */
     // @Select(" SELECT * from public.f_rel_eq2sp(#{tables},#{outTables},#{projectId},#{sign1},#{sign2}) ")
-    @Select("select public.f_rel_calc('rel_eq2sp', #{projectId}, 'zone_space_base','relationship.r_eq2sp', 2, 2,#{graphCode})")
-    fun calcEq2Sp( projectId: String,graphCode: String): Int?
+    @Select("select public.f_rel_calc('rel_eq2sp', #{projectId}, 'zone_space_base','relationship.r_eq2sp', 2, 2)")
+    fun calcEq2Sp( projectId: String): Int?
 
 //    /**
 //     * 删除关联业务空间

+ 32 - 8
datacenter/src/main/kotlin/com/persagy/server/datacenter/mappers/IRelationExcelImportMapper.kt

@@ -65,7 +65,7 @@ interface IRelationExcelImportMapper {
      * @return  excel需要的记录
      */
     @Update("UPDATE public.equipment SET building_id = #{id1} WHERE project_id = #{projectId} AND id = #{id2}")
-    fun eq2bdIn(projectId: String, type: String, id1: String, id2: String)
+    fun Eq2BdIn(projectId: String, type: String, id1: String, id2: String)
 
     /**
      * 设备与设备关系
@@ -89,7 +89,31 @@ interface IRelationExcelImportMapper {
      * @return  excel需要的记录
      */
     @Update("UPDATE public.equipment SET floor_id = #{id1} WHERE project_id = #{projectId} AND id = #{id2}")
-    fun eq2flIn(projectId: String, type: String, id1: String, id2: String)
+    fun Eq2FlIn(projectId: String, type: String, id1: String, id2: String)
+
+    /**
+     * 建筑下空间
+     *
+     * @param   projectId       项目ID
+     * @param   type            关系类型
+     * @param   id1             建筑ID
+     * @param   id2             空间ID
+     * @return  excel需要的记录
+     */
+    @Update("UPDATE public.zone_space_base SET building_id = #{id1} WHERE project_id = #{projectId} AND id = #{id2}")
+    fun Bd2Sp(projectId: String, type: String, id1: String, id2: String)
+
+    /**
+     * 楼层下空间
+     *
+     * @param   projectId       项目ID
+     * @param   type            关系类型
+     * @param   id1             楼层ID
+     * @param   id2             空间ID
+     * @return  excel需要的记录
+     */
+    @Update("UPDATE public.equipment SET floor_id = #{id1} WHERE project_id = #{projectId} AND id = #{id2}")
+    fun Fl2Sp(projectId: String, type: String, id1: String, id2: String)
 
     /**
      * 楼层与设备关系
@@ -124,8 +148,8 @@ interface IRelationExcelImportMapper {
      * @param   id2             空间ID
      * @return  excel需要的记录
      */
-    @Insert("INSERT INTO relationship.r_eq2sp(project_id, eq_id, sp_id, type, sign) VALUES(#{projectId}, #{id1}, #{id2}, #{type}, 1)")
-    fun eq2sp(projectId: String, type: String, id1: String, id2: String)
+    @Insert("INSERT INTO relationship.r_eq2sp(project_id, eq_id, sp_id, type, sign, graph_code,zone_type) VALUES(#{projectId}, #{id1}, #{id2}, #{type}, 1, #{graphCode},#{zoneType})")
+    fun Eq2Sp(projectId: String, type: String, id1: String, id2: String, graphCode: String,zoneType: String)
 
     /**
      * 设备与空间关系
@@ -136,8 +160,8 @@ interface IRelationExcelImportMapper {
      * @param   id2             系统ID
      * @return  excel需要的记录
      */
-    @Insert("INSERT INTO relationship.r_eq2sy(project_id, eq_id, sy_id, type, sign) VALUES(#{projectId}, #{id1}, #{id2}, #{type}, 1)")
-    fun eq2sy(projectId: String, type: String, id1: String, id2: String)
+    @Insert("INSERT INTO relationship.r_sy2eq(project_id, sy_id, eq_id, type, sign, graph_code) VALUES(#{projectId}, #{id1}, #{id2}, #{type}, 1, #{graphCode})")
+    fun Sy2Eq(projectId: String, type: String, id1: String, id2: String, graphCode: String)
 
     /**
      * 楼层与楼层关系
@@ -304,8 +328,8 @@ interface IRelationExcelImportMapper {
      * @param   id2             空间ID
      * @return  excel需要的记录
      */
-    @Insert("INSERT INTO relationship.r_sp2sp(project_id, id1, id2, type, sign) VALUES(#{projectId}, #{id1}, #{id2}, #{type}, 1)")
-    fun sp2sp(projectId: String, type: String, id1: String, id2: String)
+    @Insert("INSERT INTO relationship.r_sp2sp(project_id, id1, id2, type, sign, graph_code,zone_type) VALUES(#{projectId}, #{id1}, #{id2}, #{type}, 1, #{graphCode}, #{zoneType})")
+    fun Sp2Sp(projectId: String, type: String, id1: String, id2: String,graphCode: String,zoneType: String)
 
     /**
      * 建筑与竖井关系

+ 9 - 9
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/graphtype/GraphicTypeMapperService.kt

@@ -130,11 +130,11 @@ open class GraphicTypeMapperService {
                         var count = 0
                         if (relationTypeProject.graphicType == "ArchSubset") {
                             /** 建筑从属关系 */
-                            if (relationTypeProject.relManualType == "Bd2Sp"){
+                            if (relationTypeProject.relationType == "Bd2Sp"){
                                 /** 空间所在建筑 */
                                 val zoneSpaceList = ZoneSpaceBaseService.select(SFilter.eq("projectId", projectId), SFilter.not(SFilter.isNull("buildingId"))).exec()
                                 count = zoneSpaceList.size
-                            } else if(relationTypeProject.relManualType == "Fl2Sp") {
+                            } else if(relationTypeProject.relationType == "Fl2Sp") {
                                 /** 空间所在楼层 */
                                 val zoneSpaceList = ZoneSpaceBaseService.select(SFilter.eq("projectId", projectId), SFilter.not(SFilter.isNull("floorId"))).exec()
                                 count = zoneSpaceList.size
@@ -142,15 +142,15 @@ open class GraphicTypeMapperService {
 
                         }else if (relationTypeProject.graphicType == "MechInArch") {
                             /** 机电类所在区域关系 */
-                            if (relationTypeProject.relManualType == "Eq2Bd"){
+                            if (relationTypeProject.relationType == "Eq2Bd"){
                                 /** 建筑下的设备  */
                                 val equipmentList = EquipmentService.select(SFilter.eq("projectId", projectId), SFilter.not(SFilter.isNull("buildingId"))).exec()
                                 count = equipmentList.size
-                            } else if (relationTypeProject.relManualType == "Eq2Fl"){
+                            } else if (relationTypeProject.relationType == "Eq2Fl"){
                                 /** 楼层下的设备 */
                                 val equipmentList = EquipmentService.select(SFilter.eq("projectId", projectId), SFilter.not(SFilter.isNull("floorId"))).exec()
                                 count = equipmentList.size
-                            }else if (relationTypeProject.relManualType == "Eq2Sp"){
+                            }else if (relationTypeProject.relationType == "Eq2Sp"){
                                 /** 设备所在的空间 */
                                 val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", relationTypeProject.graphicType!!),
                                         SFilter.eq("type", relationTypeProject.relationType!!), SFilter.eq("zoneType", relationTypeProject.zoneType!!)).exec()
@@ -158,21 +158,21 @@ open class GraphicTypeMapperService {
                             }
                         } else if (relationTypeProject.graphicType == "ArchForArch") {
                             /** 区域服务关系 */
-                            if (relationTypeProject.relManualType == "Sp2Sp") {
+                            if (relationTypeProject.relationType == "Sp2Sp") {
                                 val rSp2SpList = rSp2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", relationTypeProject.graphicType!!),
-                                        SFilter.eq("type", relationTypeProject.relationType!!), SFilter.eq("zoneType", relationTypeProject.zoneType!!)).exec()
+                                        SFilter.eq("type", relationTypeProject.relationType!!)).exec()
                                 count = rSp2SpList.size
                             }
                         }else if (relationTypeProject.graphicType == "MechSubset") {
                             /** 机电从属关系 */
-                            if (relationTypeProject.relManualType == "Sy2Eq") {
+                            if (relationTypeProject.relationType == "Sy2Eq") {
                                 val rEq2SyList = rEq2SyService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", relationTypeProject.graphicType!!),
                                         SFilter.eq("type", relationTypeProject.relationType!!)).exec()
                                 count = rEq2SyList.size
                             }
                         }else if (relationTypeProject.graphicType == "MechForArch") {
                             /** 机电类服务区域关系 */
-                            if (relationTypeProject.relManualType == "Eq2Sp") {
+                            if (relationTypeProject.relationType == "Eq2Sp") {
                                 val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", relationTypeProject.graphicType!!),
                                         SFilter.eq("type", relationTypeProject.relationType!!), SFilter.eq("zoneType", relationTypeProject.zoneType!!)).exec()
                                 count = rEq2SpList.size

+ 4 - 1
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/graphtype/GraphicTypeService.kt

@@ -85,7 +85,7 @@ object GraphicTypeService : RService<GraphicType>(SMybatisDao(GraphicType::class
                     if (!content.childGraphicTypeList.isNullOrEmpty()){
                         val childGraphicTypeList = content.childGraphicTypeList
                         for (childGraphicType in childGraphicTypeList!!){
-                            val relationTypeProjectList = service.select(SFilter.eq("projectId", projectId), SFilter.eq("graphicId", childGraphicType.graphTypeId!!)).order("relationTypeCode").exec()
+                            val relationTypeProjectList = service.select(SFilter.eq("projectId", projectId), SFilter.eq("graphicId", childGraphicType.graphTypeId!!)).order("graphicType asc,relationType asc,zoneType asc").exec()
                             if (relationTypeProjectList.size>0){
                                 childGraphicType.relationTypeProjectList = relationTypeProjectList
                             }
@@ -144,6 +144,9 @@ object GraphicTypeService : RService<GraphicType>(SMybatisDao(GraphicType::class
                     relationTypeProject.fromObject = relationType.fromObject
                     relationTypeProject.mepSystemType = relationType.mepSystemType
                     relationTypeProject.graphicType = relationType.graphicType
+                    relationTypeProject.relTypeStatus = relationType.relTypeStatus
+                    relationTypeProject.enableCalc = relationType.enableCalc
+                    relationTypeProject.requestUrl = relationType.requestUrl
                     relationTypeProjectService.insert(relationTypeProject)
 
 

+ 26 - 24
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/graphtype/RelationTypeProjectService.kt

@@ -33,6 +33,7 @@ import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProje
 import com.persagy.server.mappers.IRelationExcelExportMapper
 import com.persagy.server.mappers.IRelationExcelImportMapper
 import com.persagy.server.datacenter.services.base.RService
+import com.persagy.server.datacenter.services.rel.RelationType
 import com.persagy.server.utils.IdUtils
 import com.persagy.service.SObjectService
 import com.persagy.service.SPageContext
@@ -85,15 +86,15 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
 
     private val codeTableMap by lazy {
         val map = HashMap<String, String>()
-        map["bd"] = "building"
-        map["eq"] = "equipment"
-        map["fl"] = "floor"
-        map["pe"] = "property"
-        map["pj"] = "project"
-        map["sh"] = "shaft"
-        map["sp"] = "zone_space_base"
-        map["sy"] = "general_system"
-        map["tn"] = "tenant"
+        map["Bd"] = "building"
+        map["Eq"] = "equipment"
+        map["Fl"] = "floor"
+        map["Pe"] = "property"
+        map["Pj"] = "project"
+        map["Sh"] = "shaft"
+        map["Sp"] = "zone_space_base"
+        map["Sy"] = "general_system"
+        map["Tn"] = "tenant"
         map
     }
 
@@ -264,7 +265,7 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
      * @param   zoneType        业务空间类型
      * @return  应答体
      */
-    fun importExcel(file: MultipartFile, relType: String, zoneType: String? = null,type: String,graphCode: String): SBaseResponse {
+    fun importExcel(file: MultipartFile, relType: String, zoneType: String? = null, graphCode: String): SBaseResponse {
         try {
             if (file.isEmpty) {
                 throw Exception("未选择文件")
@@ -296,7 +297,7 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
             logger.debug("识别编码:${code}  ******************************************")
             preExcelRelation(sheet, projectId!!, relType, code, zoneType)
 
-            readExcelRelation(sheet, projectId, relType, zoneType)
+            readExcelRelation(sheet, projectId, relType, zoneType,graphCode)
 
             val outFile = File("/tmp/relation-$projectId-${relType}${zone}.xlsx")
             workbook.write(outFile.outputStream())
@@ -384,14 +385,14 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
      * @param   relType         关系类型
      * @param   zoneType        业务空间类型
      */
-    private fun readExcelRelation(sheet: XSSFSheet, projectId: String, relType: String, zoneType: String? = null) {
+    private fun readExcelRelation(sheet: XSSFSheet, projectId: String, relType: String, zoneType: String? = null, graphCode: String) {
         try {
-            val len = relType.indexOf("_")
-            val cmd = if (len > 0) {
-                relType.substring(0, len)
-            } else {
-                relType
-            }
+//            val len = relType.indexOf("_")
+//            val cmd = if (len > 0) {
+//                relType.substring(0, len)
+//            } else {
+//                relType
+//            }
 //        val type = if (len > 0) {
 //            relType.substring(len + 1)
 //        } else {
@@ -400,15 +401,16 @@ object RelationTypeProjectService : RService<RelationTypeProject>(SMybatisDao(Re
 
             val type = relType
 
-            val importMethod = if (relType == "eq2bd" || relType == "pe2bd") {
-                excelImport.javaClass.getDeclaredMethod("${relType}In", String::class.java, String::class.java, String::class.java, String::class.java)
-            } else if (relType == "eq2fl" || relType == "pe2fl") {
+            val importMethod = if (relType == RelationType.Eq2Bd || relType == RelationType.Eq2Fl) {
                 excelImport.javaClass.getDeclaredMethod("${relType}In", String::class.java, String::class.java, String::class.java, String::class.java)
-            } else {
+            }else if(relType == RelationType.Bd2Sp || relType == RelationType.Fl2Sp){
+                excelImport.javaClass.getDeclaredMethod(relType, String::class.java, String::class.java, String::class.java, String::class.java)
+            }
+            else {
                 if(zoneType.isNullOrEmpty()) {
-                    excelImport.javaClass.getDeclaredMethod(cmd, String::class.java, String::class.java, String::class.java, String::class.java)
+                    excelImport.javaClass.getDeclaredMethod(relType, String::class.java, String::class.java, String::class.java, String::class.java)
                 } else {
-                    excelImport.javaClass.getDeclaredMethod(cmd, String::class.java, String::class.java, String::class.java, String::class.java, String::class.java)
+                    excelImport.javaClass.getDeclaredMethod(relType, String::class.java, String::class.java, String::class.java, String::class.java, String::class.java)
                 }
             }
 

+ 7 - 0
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/objects/EquipmentService.kt

@@ -27,16 +27,20 @@
 package com.persagy.server.datacenter.services.objects
 
 import com.persagy.database.SFilter
+import com.persagy.database.SQueryBuilder
+import com.persagy.database.enums.SOps
 import com.persagy.database.extensions.keyValue
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
 import com.persagy.server.datacenter.wanda.obj.Equipment
+import com.persagy.server.datacenter.wanda.rel.REq2Sy
 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.SBaseService
+import com.persagy.service.SObjectService
 
 import org.slf4j.LoggerFactory
 
@@ -52,6 +56,9 @@ object EquipmentService : Service<Equipment>(SMybatisDao(Equipment::class.java))
     /** 关系总览服务 */
     val relationTypeProjectservice = SBaseService(SMybatisDao(RelationTypeProject::class.java))
 
+    /** 设备和系统关系 */
+    private val rEq2SyService = SObjectService(SMybatisDao(REq2Sy::class.java))
+
     /**
      * 创建前赋值操作
      *

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

@@ -90,7 +90,7 @@ object SpaceService : Service<ZoneIspace>(SMybatisDao(ZoneIspace::class.java)) {
             zoneSpace.buildingId = zoneIspace.buildingId
             zoneSpace.floorId = zoneIspace.floorId
             zoneSpace.bimId = zoneIspace.bimId
-            zoneSpace.classCode = "GeneralZone"
+            zoneSpace.classCode = "FunctionZone"
             zoneSpace.infos = zoneIspace.infos
             if(zoneIspace.outline != null){
                 zoneSpace.outline = arrayListOf(zoneIspace.outline!!)

+ 18 - 3
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/rel/RelStatisticService.kt

@@ -27,14 +27,17 @@
 package com.persagy.server.datacenter.services.rel
 
 import com.persagy.database.SFilter
+import com.persagy.server.datacenter.services.graphtype.RelationTypeProjectService
 import com.persagy.server.datacenter.services.objects.EquipmentService
 import com.persagy.server.datacenter.wanda.obj.Equipment
 import com.persagy.server.mappers.ICalcSpaceMapper
 import com.persagy.service.SPageContext
 import com.persagy.service.models.enums.SResponseType
+import com.persagy.service.models.responses.SBaseResponse
 import com.persagy.service.models.responses.SQueryResponse
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Service
+import org.springframework.web.bind.annotation.RequestParam
 import java.util.stream.Collectors
 
 /**
@@ -94,7 +97,7 @@ open class RelStatisticService {
                 val rEq2Sps = CommonObjectService.rEq2SpService.select(SFilter.eq("projectId",projectId),SFilter.eq("type",type), SFilter.eq("graphCode",graphCode), SFilter.eq("zoneType",zoneType!!)).exec()
                 val equipIds = rEq2Sps.stream().map { r -> r.id1!! }.collect(Collectors.toList())
                 if(equipIds.size > 0){
-                    val equipments = EquipmentService.select(SFilter.eq("projectId",projectId), SFilter.inList("id",equipIds)).exec()
+                    val equipments = EquipmentService.select(SFilter.eq("projectId",projectId), SFilter.inList("id",equipIds)).projection(listOf("classCode")).distinct().exec()
                     for (equipment in equipments) {
                         val classCode = equipment.classCode!!
                         val item = HashMap<String,String?>()
@@ -129,7 +132,7 @@ open class RelStatisticService {
 
 
             }
-            RelationType.Sp2Bd -> {
+            RelationType.Bd2Sp -> {
                 val bdZoneSpaces = CommonObjectService.zoneSpaceService.select(SFilter.eq("projectId",projectId), SFilter.not(SFilter.isNull("buildingId"))).projection(listOf("classCode")).distinct().exec()
                 for (bdZoneSpace in bdZoneSpaces) {
                     val classCode = bdZoneSpace.classCode!!
@@ -139,7 +142,7 @@ open class RelStatisticService {
                     results.add(item)
                 }
             }
-            RelationType.Sp2Fl -> {
+            RelationType.Fl2Sp -> {
                 val flZoneSpaces = CommonObjectService.zoneSpaceService.select(SFilter.eq("projectId",projectId), SFilter.not(SFilter.isNull("floorId"))).projection(listOf("classCode")).distinct().exec()
                 for(flZoneSpace in flZoneSpaces){
                     val classCode = flZoneSpace.classCode!!
@@ -168,5 +171,17 @@ open class RelStatisticService {
         
     }
 
+    fun updateCalcTime(graphCode: String,relType: String, computingTime: String): SBaseResponse {
+        val projectId = SPageContext.getHeader("ProjectId") ?: return SBaseResponse(SResponseType.failure,"项目ID不能为空")
+        val relationTypeProject = RelationTypeProjectService.select(SFilter.eq("projectId",projectId), SFilter.eq("relationType",relType), SFilter.eq("graphicType",graphCode)).entity()
+        if(relationTypeProject != null){
+            relationTypeProject.computingTime = computingTime
+            RelationTypeProjectService.update(relationTypeProject)
+            return SBaseResponse(SResponseType.success,"")
+        }
+        return SBaseResponse(SResponseType.failure,"关系不存在")
+
+    }
+
 
 } // Class CalcSpaceService

+ 7 - 7
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/rel/RelationType.kt

@@ -8,13 +8,13 @@ package com.persagy.server.datacenter.services.rel
 interface RelationType {
 
     companion object {
-        const val Eq2Bd: String = "eq2bd"
-        const val Eq2Fl: String = "eq2fl"
-        const val Eq2Sp: String = "eq2sp"
-        const val Sy2Eq: String = "sy2eq"
-        const val Sp2Bd: String = "sp2bd"
-        const val Sp2Fl: String = "sp2fl"
-        const val Sp2Sp: String = "sp2sp"
+        const val Eq2Bd: String = "Eq2Bd"
+        const val Eq2Fl: String = "Eq2Fl"
+        const val Eq2Sp: String = "Eq2Sp"
+        const val Sy2Eq: String = "Sy2Eq"
+        const val Bd2Sp: String = "Bd2Sp"
+        const val Fl2Sp: String = "Fl2Sp"
+        const val Sp2Sp: String = "Sp2Sp"
 
     }
 }

+ 143 - 136
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/CalcSpecialService.kt

@@ -35,6 +35,7 @@ import com.persagy.server.datacenter.wanda.rel.REq2Eq
 import com.persagy.server.mappers.ICalcSpecialMapper
 import com.persagy.server.datacenter.models.entities.Connector
 import com.persagy.server.datacenter.models.wrapperobj.ClassCodeEnum
+import com.persagy.server.datacenter.services.objects.BuildingService
 import com.persagy.server.datacenter.services.objects.EquipmentService
 import com.persagy.server.datacenter.wanda.obj.Equipment
 import com.persagy.server.services.assistant.RUpDateEquipAndSapceService
@@ -255,119 +256,122 @@ open class CalcSpecialService {
      * @Param:
      * @Return:
      */
-    fun calcNetworks(projectId: String,buildingId: String): SBaseResponse{
-        val floors = FloorService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId),SFilter.eq("id","Fl440307000355ee6382da6d42cf87f19551cc4b4e60")).exec()
-        val connectedBlocks = ArrayList<ConnectedBlock>()
-        for (floor in floors) {
-            if (!floor.modelId.isNullOrEmpty()) {
-                val connectors = mapper.connectorOrder(floor.modelId!!)
-                val dcEquipments = EquipmentService.select(SFilter.eq("projectId",projectId), SFilter.eq("floorId",floor.id!!)).exec()
-                val dcEquipMap = HashMap<String, Equipment>(1024)
-                for (equipment in dcEquipments) {
-                    if(!equipment.bimId.isNullOrEmpty()){
-                        dcEquipMap[equipment.bimId!!] = equipment
+    fun calcNetworks(projectId: String): SBaseResponse{
+        val buildings = BuildingService.select(SFilter.eq("projectId",projectId)).exec()
+        for (building in buildings) {
+            val buildingId = building.id!!
+            val floors = FloorService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId)).exec()
+            val connectedBlocks = ArrayList<ConnectedBlock>()
+            for (floor in floors) {
+                if (!floor.modelId.isNullOrEmpty()) {
+                    val connectors = mapper.connectorOrder(floor.modelId!!)
+                    val dcEquipments = EquipmentService.select(SFilter.eq("projectId",projectId), SFilter.eq("floorId",floor.id!!)).exec()
+                    val dcEquipMap = HashMap<String, Equipment>(1024)
+                    for (equipment in dcEquipments) {
+                        if(!equipment.bimId.isNullOrEmpty()){
+                            dcEquipMap[equipment.bimId!!] = equipment
+                        }
+
                     }
 
-                }
+                    val connectorMap = HashMap<String, Connector>(100000)
+                    val typeMap = HashMap<String, String>(20000)
+                    for (connector in connectors) {
+                        connectorMap[connector.revitId!!] = connector
 
-                val connectorMap = HashMap<String, Connector>(100000)
-                val typeMap = HashMap<String, String>(20000)
-                for (connector in connectors) {
-                    connectorMap[connector.revitId!!] = connector
+                        val belong = connector.belongBimId ?: continue
+                        val belongType = connector.belongType
+                        if (belongType != null) {
+                            typeMap[belong] = belongType
+                        }
 
-                    val belong = connector.belongBimId ?: continue
-                    val belongType = connector.belongType
-                    if (belongType != null) {
-                        typeMap[belong] = belongType
                     }
-
-                }
-                val belongMap = HashMap<String, HashSet<String>>()
-                val eqBelongSet = HashSet<String>()
-                //遍历连接件
-                for (connector in connectors) {
-                    //拿到所属类
-                    val belongType = connector.belongType
-                    //拿到所属id
-                    val belong = connector.belongBimId
-                    if(belong != null){
-                        eqBelongSet.add(belong)
-                        //如果连接件有连接
-                        if (connector.connectedIds!!.size > 0) {
-                            val revitId = connector!!.connectedIds?.get(0)
-                            var currentConnector = connectorMap[revitId!!]
-                            val cBelong = currentConnector?.belongBimId
-                            if (cBelong != null) {
+                    val belongMap = HashMap<String, HashSet<String>>()
+                    val eqBelongSet = HashSet<String>()
+                    //遍历连接件
+                    for (connector in connectors) {
+                        //拿到所属类
+                        val belongType = connector.belongType
+                        //拿到所属id
+                        val belong = connector.belongBimId
+                        if(belong != null){
+                            eqBelongSet.add(belong)
+                            //如果连接件有连接
+                            if (connector.connectedIds!!.size > 0) {
+                                val revitId = connector!!.connectedIds?.get(0)
+                                var currentConnector = connectorMap[revitId!!]
+                                val cBelong = currentConnector?.belongBimId
+                                if (cBelong != null) {
 //                                if(belongType == "Equipment"){
 //                                    eqBelongSet.add(belong)
 //                                }
 
-                                if (belongMap.containsKey(belong)) {
-                                    val belongs = belongMap[belong]!!
-                                    belongs.add(cBelong)
-                                    belongMap[belong] = belongs
-                                } else {
-                                    belongMap[belong] = hashSetOf(cBelong)
+                                    if (belongMap.containsKey(belong)) {
+                                        val belongs = belongMap[belong]!!
+                                        belongs.add(cBelong)
+                                        belongMap[belong] = belongs
+                                    } else {
+                                        belongMap[belong] = hashSetOf(cBelong)
+                                    }
+                                }else{
+                                    belongMap[belong] = HashSet()
                                 }
-                            }else{
+                            }else {
                                 belongMap[belong] = HashSet()
                             }
-                        }else {
-                            belongMap[belong] = HashSet()
                         }
                     }
-                }
-                var fBlockId: Int =0
-                var dBlockId: Int =0
-                var cBlockId = 0
-                val fBlockMap = HashMap<Int,HashSet<String>>()
+                    var fBlockId: Int =0
+                    var dBlockId: Int =0
+                    var cBlockId = 0
+                    val fBlockMap = HashMap<Int,HashSet<String>>()
 //                val dBlockMap = HashMap<Int,HashSet<String>>()
-                val enumList = ClassCodeEnum.toSourceList(null)
-                var fSet: HashSet<String>? = null
-                var dSet: HashSet<String>
-                println(eqBelongSet.size)
-                for (key in eqBelongSet) {
-                    val e1 = dcEquipMap[key]
-                    if(e1 == null || !enumList.contains(e1.classCode)){
-                        continue
-                    }
+                    val enumList = ClassCodeEnum.toSourceList(null)
+                    var fSet: HashSet<String>? = null
+                    var dSet: HashSet<String>
+                    println(eqBelongSet.size)
+                    for (key in eqBelongSet) {
+                        val e1 = dcEquipMap[key]
+                        if(e1 == null || !enumList.contains(e1.classCode)){
+                            continue
+                        }
 
-                    val belongSet = belongMap[key]!!
+                        val belongSet = belongMap[key]!!
 
-                    dSet = directDist(HashSet(belongSet),belongMap,typeMap)
-                    dBlockId ++
+                        dSet = directDist(HashSet(belongSet),belongMap,typeMap)
+                        dBlockId ++
 
-                    for (s in dSet!!) {
-                        if(typeMap[s] == "Equipment" && key != s){
-                            val e2 = dcEquipMap[s]
-                            if(e2 == null || !enumList.contains(e2.classCode)){
-                                continue
-                            }
-                            if(e1.classCode == e2.classCode){
-                                continue
-                            }
+                        for (s in dSet!!) {
+                            if(typeMap[s] == "Equipment" && key != s){
+                                val e2 = dcEquipMap[s]
+                                if(e2 == null || !enumList.contains(e2.classCode)){
+                                    continue
+                                }
+                                if(e1.classCode == e2.classCode){
+                                    continue
+                                }
 
-                            val connectedBlock = ConnectedBlock()
-                            connectedBlock.id1 = e1.id!!
-                            connectedBlock.id2 = e2.id!!
-                            connectedBlock.type1 = "Equipment"
-                            connectedBlock.type2 = "Equipment"
-                            connectedBlock.modelId1 = floor.modelId
-                            connectedBlock.modelId2 = floor.modelId
+                                val connectedBlock = ConnectedBlock()
+                                connectedBlock.id1 = e1.id!!
+                                connectedBlock.id2 = e2.id!!
+                                connectedBlock.type1 = "Equipment"
+                                connectedBlock.type2 = "Equipment"
+                                connectedBlock.modelId1 = floor.modelId
+                                connectedBlock.modelId2 = floor.modelId
 //                                connectedBlock.domain = connector.domain
 //                                connectedBlock.mepSystemType = connector.mepSystemType
-                            connectedBlock.projectId = projectId
-                            connectedBlock.buildingId = buildingId
-                            connectedBlock.depth = 0
-                            connectedBlock.blockId = dBlockId.toString()
-                            connectedBlock.typeCode1 = e1?.classCode
-                            connectedBlock.typeCode2 = e2?.classCode
-                            if (!connectedBlocks.contains(connectedBlock)) {
-                                connectedBlocks.add(connectedBlock)
-                            }
+                                connectedBlock.projectId = projectId
+                                connectedBlock.buildingId = buildingId
+                                connectedBlock.depth = 0
+                                connectedBlock.blockId = dBlockId.toString()
+                                connectedBlock.typeCode1 = e1?.classCode
+                                connectedBlock.typeCode2 = e2?.classCode
+                                if (!connectedBlocks.contains(connectedBlock)) {
+                                    connectedBlocks.add(connectedBlock)
+                                }
 
+                            }
                         }
-                    }
 //                    if(listOf("Eq4403070003129ce8d657c94c648d2d164ccfc6802c",
 //                                    "Eq4403070003db010203b5e54a0e8e4de56234cb6ac9",
 //                                    "Eq4403070003666459bd6a7e434f8c091392bada823a",
@@ -375,58 +379,58 @@ open class CalcSpecialService {
 //                        fSet = fullDist(HashSet(belongSet),belongMap)
 //                    }
 
-                    for (block in fBlockMap.keys) {
-                        val set = fBlockMap[block]!!
-                        if(set.contains(key)){
-                            fSet = set
-                            cBlockId = block
-                            break
+                        for (block in fBlockMap.keys) {
+                            val set = fBlockMap[block]!!
+                            if(set.contains(key)){
+                                fSet = set
+                                cBlockId = block
+                                break
+                            }
                         }
-                    }
-                    if(fSet == null){
-                        fSet = fullDist(HashSet(belongSet),belongMap)
-                        fBlockId ++
-                        cBlockId = fBlockId
-                        fBlockMap[cBlockId] = HashSet(fSet)
-                        if(cBlockId == 1){
-                            println(fBlockMap[cBlockId]!!.toJson())
+                        if(fSet == null){
+                            fSet = fullDist(HashSet(belongSet),belongMap)
+                            fBlockId ++
+                            cBlockId = fBlockId
+                            fBlockMap[cBlockId] = HashSet(fSet)
+                            if(cBlockId == 1){
+                                println(fBlockMap[cBlockId]!!.toJson())
+                            }
                         }
-                    }
 //                    fSet = fullDist(HashSet(belongSet),belongMap)
 //                    println(fSet.contains(key))
 //                    println(fSet.size)
-                    for (s in fSet!!) {
-                        if(typeMap[s] == "Equipment" && key != s){
-                            val e2 = dcEquipMap[s]
-                            if(e2 == null || !enumList.contains(e2.classCode)){
-                                continue
-                            }
-                            if(e1.classCode == e2.classCode){
-                                continue
-                            }
+                        for (s in fSet!!) {
+                            if(typeMap[s] == "Equipment" && key != s){
+                                val e2 = dcEquipMap[s]
+                                if(e2 == null || !enumList.contains(e2.classCode)){
+                                    continue
+                                }
+                                if(e1.classCode == e2.classCode){
+                                    continue
+                                }
 
-                            val connectedBlock = ConnectedBlock()
+                                val connectedBlock = ConnectedBlock()
 
-                            connectedBlock.id1 = e1.id!!
-                            connectedBlock.id2 = e2.id!!
-                            connectedBlock.type1 = "Equipment"
-                            connectedBlock.type2 = "Equipment"
-                            connectedBlock.modelId1 = floor.modelId
-                            connectedBlock.modelId2 = floor.modelId
+                                connectedBlock.id1 = e1.id!!
+                                connectedBlock.id2 = e2.id!!
+                                connectedBlock.type1 = "Equipment"
+                                connectedBlock.type2 = "Equipment"
+                                connectedBlock.modelId1 = floor.modelId
+                                connectedBlock.modelId2 = floor.modelId
 //                                connectedBlock.domain = connector.domain
 //                                connectedBlock.mepSystemType = connector.mepSystemType
-                            connectedBlock.projectId = projectId
-                            connectedBlock.buildingId = buildingId
-                            connectedBlock.depth = 1
-                            connectedBlock.blockId = cBlockId.toString()
-                            connectedBlock.typeCode1 = e1?.classCode
-                            connectedBlock.typeCode2 = e2?.classCode
-                            if (!connectedBlocks.contains(connectedBlock)) {
-                                connectedBlocks.add(connectedBlock)
-                            }
+                                connectedBlock.projectId = projectId
+                                connectedBlock.buildingId = buildingId
+                                connectedBlock.depth = 1
+                                connectedBlock.blockId = cBlockId.toString()
+                                connectedBlock.typeCode1 = e1?.classCode
+                                connectedBlock.typeCode2 = e2?.classCode
+                                if (!connectedBlocks.contains(connectedBlock)) {
+                                    connectedBlocks.add(connectedBlock)
+                                }
 
+                            }
                         }
-                    }
 //                    for (block in dBlockMap.keys) {
 //                        val set = dBlockMap[block]!!
 //                        if(set.contains(key)){
@@ -453,15 +457,18 @@ open class CalcSpecialService {
 //
 //                    }
 
+                    }
                 }
-            }
 
 
+            }
+            connectedBlockService.delete(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId))
+            val request = SCreateRequest<ConnectedBlock>()
+            request.content = connectedBlocks
+            connectedBlockService.createList(request)
         }
-        connectedBlockService.delete(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId))
-        val request = SCreateRequest<ConnectedBlock>()
-        request.content = connectedBlocks
-        connectedBlockService.createList(request)
+
+
         return SBaseResponse(SResponseType.success, "")
 
     }

+ 16 - 2
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/ManualRelationCalcService.kt

@@ -547,7 +547,12 @@ open class ManualRelationCalcService {
                 for (spbuilding in spbuildingIdVagueToZoneType) {
                     listBuildingId.add(spbuilding.id!!)
                 }
-                val rBd2SpBuilidingList = rBd2SpBuilidingService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.inList("id", listBuildingId)).exec()
+                var rBd2SpBuilidingList: ArrayList<RBd2SpBuiliding>
+                if(spbuildingIdVagueToZoneType.size > 0){
+                    rBd2SpBuilidingList = rBd2SpBuilidingService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.inList("id", listBuildingId)).exec()
+                }else{
+                    rBd2SpBuilidingList = rBd2SpBuilidingService.select(SFilter.eq("projectId", Opt.projectId!!)).exec()
+                }
                 for (spbuilding in rBd2SpBuilidingList) {
                     for (spaceBase in spaceBaseList) {
                         if (spaceBase.buildingId == spbuilding.id) {
@@ -962,6 +967,11 @@ open class ManualRelationCalcService {
         list.add(SFilter.eq("projectId",Opt.projectId!!))
 
         val rEq2SyList = rEq2SyService.select(SFilter.eq("projectId", Opt.projectId!!)).exec()
+        val syIds = LinkedHashSet<String>()
+        for (rEq2Sy in rEq2SyList) {
+            syIds.add(rEq2Sy.id1!!)
+        }
+
         if (rEq2SyList.size>0) {
             if (manualRelationCalcRequest.objectType == "1") {
                 if (!manualRelationCalcRequest.vagueFrom.isNullOrEmpty()) {
@@ -970,8 +980,12 @@ open class ManualRelationCalcService {
                 if (!manualRelationCalcRequest.categoryFrom.isNullOrEmpty()) {
                     list.add(SFilter.eq("classCode",manualRelationCalcRequest.categoryFrom!!))
                 }
+                if(syIds.size > 0){
+                    list.add(SFilter.inList("id",ArrayList(syIds)))
+                }
+//                list.add(SFilter.not(SFilter.isNull("objectInfo")))
                 val pageQuery = relSy2EqSystemService.pageQuery(sQueryRequest, list)
-                manualRelationCalcResponse.content = pageQuery.content
+                manualRelationCalcResponse.content = pageQuery.content!!.filter { r -> r.objectInfo != null }
                 manualRelationCalcResponse.message = pageQuery.message
                 manualRelationCalcResponse.pageNumber = pageQuery.pageNumber
                 manualRelationCalcResponse.pageSize = pageQuery.pageSize

+ 34 - 24
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/RelationCalcService.kt

@@ -68,6 +68,9 @@ open class RelationCalcService {
     @Autowired
     lateinit var mapper: IRelationCalcMapper
 
+    @Autowired
+    lateinit var calcSpecialService: CalcSpecialService
+
     /** RabbitMQ消息对象 */
     val rabbitMqService by lazy {
         SSpringContextUtil.getBean(RabbitMqService::class.java) as RabbitMqService
@@ -261,7 +264,7 @@ open class RelationCalcService {
      *  @param  projectId   项目id
      *  @param  sign        是否要删除自动维护的关系(不填默认为false), boolean型, 值为true或false (true表示删除自动和手动维护的关系, false表示只删除手动计算的的关系)
      */
-    fun calcEq2Sp(tables: String?, projectId: String, sign: Boolean,graphCode: String): SBaseResponse {
+    fun calcEq2Sp(tables: String?, projectId: String, sign: Boolean,graphCode: String,relType: String): SBaseResponse {
         try {
             var tablesName = ""
             var outTablesName = ""
@@ -360,10 +363,11 @@ open class RelationCalcService {
             }
 
             try {
-                upDateBiaoji(projectId, "eq2fl", 3)
-                upDateBiaoji(projectId, "fl2sp", 3)
+//                upDateBiaoji(projectId, "eq2fl", 3)
+//                upDateBiaoji(projectId, "fl2sp", 3)
 
-                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", "eq2sp_in"), SFilter.eq("zoneType", tables!!)).entity()
+                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", relType
+                ), SFilter.eq("zoneType", tables!!), SFilter.eq("graphicType",graphCode)).entity()
                 if (entity != null) {
                     entity.computationalState = 3
                     entity.computingTime = IdUtils.time()
@@ -372,14 +376,15 @@ open class RelationCalcService {
             } catch (e: Exception) {
                 e.printStackTrace()
             }
-            val result = mapper.calcEq2Sp(projectId,graphCode)
+            val result = mapper.calcEq2Sp(projectId)
             if (result != null && result == 0) {
                 try {
                     /** 发送消息 */
                     rabbitMqService.sendRel(Opt.projectId!!, "Eq2Sp_in", "20", tables!!, "456")
                     upDate(projectId, "fl2sp")
                     upDate(projectId, "eq2fl")
-                    val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", "eq2sp_in"), SFilter.eq("zoneType", tables!!)).entity()
+                    val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", relType
+                    ), SFilter.eq("zoneType", tables!!), SFilter.eq("graphicType",graphCode)).entity()
                     if (entity != null) {
                         entity.computationalState = 1
                         entity.computingTime = IdUtils.time()
@@ -390,9 +395,10 @@ open class RelationCalcService {
                 }
                 return SBaseResponse(SResponseType.success)
             } else {
-                upDateBiaoji(projectId, "eq2fl", 5)
-                upDateBiaoji(projectId, "fl2sp", 5)
-                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", "eq2sp_in"), SFilter.eq("zoneType", tables!!)).entity()
+//                upDateBiaoji(projectId, "eq2fl", 5)
+//                upDateBiaoji(projectId, "fl2sp", 5)
+                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", relType
+                ), SFilter.eq("zoneType", tables!!), SFilter.eq("graphicType",graphCode)).entity()
                 if (entity != null) {
                     entity.computationalState = 5
                     entity.computingTime = IdUtils.time()
@@ -1036,7 +1042,7 @@ open class RelationCalcService {
                 e.printStackTrace()
             }
             /** 启动计算 */
-            val result = mapper.calcEq2Sp(projectId!!,graphCode)
+            val result = mapper.calcEq2Sp(projectId!!)
             if (result != null && result == 0) {
                 try {
                     /** 发送消息 */
@@ -1102,7 +1108,8 @@ open class RelationCalcService {
      *  @param  projectId   项目id
      *  @param  sign        是否要删除自动维护的关系(不填默认为false), boolean型, 值为true或false (true表示删除自动和手动维护的关系, false表示只删除手动计算的的关系)
      */
-    fun calcEqForSp(tables: String?, projectId: String,graphCode: String): SBaseResponse {
+    fun calcEqForSp(tables: String?, projectId: String,graphCode: String,relType: String): SBaseResponse {
+        calcSpecialService.calcNetworks(projectId)
         val codeList= ClassCodeEnum.toSourceList(1)
 
         val connectedBlocks = connectedBlockService.select(SFilter.eq("projectId",projectId), SFilter.or(SFilter.inList("typeCode1",codeList), SFilter.inList("typeCode2",codeList))).exec()
@@ -1110,10 +1117,11 @@ open class RelationCalcService {
         try {
 
             try {
-                upDateBiaoji(projectId, "eq2fl", 3)
-                upDateBiaoji(projectId, "fl2sp", 3)
+//                upDateBiaoji(projectId, "eq2fl", 3)
+//                upDateBiaoji(projectId, "fl2sp", 3)
 
-                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", "eq2sp_for"), SFilter.eq("zoneType", tables!!)).entity()
+                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", relType
+                ), SFilter.eq("zoneType", tables!!), SFilter.eq("graphicType",graphCode)).entity()
                 if (entity != null) {
                     entity.computationalState = 3
                     relationTypeProjectservice.update(entity)
@@ -1122,8 +1130,8 @@ open class RelationCalcService {
                 e.printStackTrace()
             }
             /** 启动计算   ******************************/
-            val result = mapper.calcEq2Sp(projectId,graphCode)
-//            var result = 0
+//            val result = mapper.calcEq2Sp(projectId)
+            var result = 0
             logger.debug("计算结果= ${result}")
 
             /*************************上面添加数据**********************************/
@@ -1140,9 +1148,10 @@ open class RelationCalcService {
             if (result != null && result == 0) {
                 try {
 
-                    upDate(projectId, "fl2sp")
-                    upDate(projectId, "eq2fl")
-                    val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", "eq2sp_for"), SFilter.eq("zoneType", tables!!)).entity()
+//                    upDate(projectId, "fl2sp")
+//                    upDate(projectId, "eq2fl")
+                    val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", relType
+                    ), SFilter.eq("zoneType", tables!!), SFilter.eq("graphicType",graphCode)).entity()
                     if (entity != null) {
                         entity.computationalState = 1
                         entity.computingTime = IdUtils.time()
@@ -1166,11 +1175,11 @@ open class RelationCalcService {
                     }
                     val rEq2SpList = REq2SpService.select(SFilter.eq("projectId", projectId),
                             SFilter.inList("id1", listId)
-                            , SFilter.eq("graphCode", graphCode)).exec()
+                            , SFilter.eq("graphCode", "MechInArch"), SFilter.eq("type",relType), SFilter.eq("zoneType",tables!!)).exec()
                     val rEq2Sps = ArrayList<REq2Sp>()
                     if (rEq2SpList.size > 0) {
                         for (rEq2Sp in rEq2SpList) {
-                            rEq2Sp.type = "Eq2Sp"
+                            rEq2Sp.type = relType
                             rEq2Sp.graphCode = graphCode
                             rEq2Sps.add(rEq2Sp)
 //                            REq2SpService.replace(rEq2Sp)
@@ -1183,7 +1192,7 @@ open class RelationCalcService {
                                     val typeCode2 = connectedBlock.typeCode2
                                     if(sourceList.contains(typeCode1)){
                                         val fullREq2Sp = REq2Sp()
-                                        fullREq2Sp.type = "Eq2Sp"
+                                        fullREq2Sp.type = relType
                                         fullREq2Sp.graphCode = graphCode
                                         fullREq2Sp.projectId = projectId
                                         fullREq2Sp.id1 = connectedBlock.id2
@@ -1193,7 +1202,7 @@ open class RelationCalcService {
                                         rEq2Sps.add(fullREq2Sp)
                                     }else if(sourceList.contains(typeCode2)){
                                         val fullREq2Sp = REq2Sp()
-                                        fullREq2Sp.type = "Eq2Sp"
+                                        fullREq2Sp.type = relType
                                         fullREq2Sp.graphCode = graphCode
                                         fullREq2Sp.projectId = projectId
                                         fullREq2Sp.id1 = connectedBlock.id1
@@ -1218,7 +1227,8 @@ open class RelationCalcService {
             } else {
                 upDateBiaoji(projectId, "eq2fl", 5)
                 upDateBiaoji(projectId, "fl2sp", 5)
-                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", "eq2sp_for"), SFilter.eq("zoneType", tables!!)).entity()
+                val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId), SFilter.eq("relationType", relType
+                ), SFilter.eq("zoneType", tables!!), SFilter.eq("graphicType",graphCode)).entity()
                 if (entity != null) {
                     entity.computationalState = 5
                     entity.computingTime = IdUtils.time()

+ 2 - 2
datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/CalcSpecialController.kt

@@ -89,9 +89,9 @@ open class CalcSpecialController {
      */
     @Operation(summary = "管网计算", description = "管网计算")
     @PostMapping(value = ["/calcNetworks"])
-    fun calcNetworks(@RequestParam buildingId: String): SBaseResponse{
+    fun calcNetworks(): SBaseResponse{
         val projectId = SPageContext.getHeader("projectId").toString()
-        return service.calcNetworks(projectId,buildingId)
+        return service.calcNetworks(projectId)
     } // Function sysBolck()
 
 } // Class CalcSpecialController

+ 11 - 2
datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/GraphicTypeController.kt

@@ -112,9 +112,9 @@ open class GraphicTypeController {
      */
     @Operation(summary = "导入excel", description = "")
     @PostMapping("/import",consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
-    fun importExcel(@RequestPart("file") file: MultipartFile, @RequestParam relType: String, @RequestParam zoneType: String? = null,@RequestParam type: String,@RequestParam graphCode: String) : SBaseResponse {
+    fun importExcel(@RequestPart("file") file: MultipartFile, @RequestParam relType: String, @RequestParam zoneType: String? = null,@RequestParam graphCode: String) : SBaseResponse {
         try {
-            RelationTypeProjectService.importExcel(file, relType, zoneType,type,graphCode)
+            RelationTypeProjectService.importExcel(file, relType, zoneType,graphCode)
         }catch (e : Exception){
             return SBaseResponse(SResponseType.failure,"error:" + e.message)
         }
@@ -168,5 +168,14 @@ open class GraphicTypeController {
         return relStatisticService.relToType(zoneType,graphCode,type,relType,status)
     }
 
+    /**
+     * 更新计算时间
+     */
+    @Operation(summary="更新计算时间", description="")
+    @GetMapping(value = ["/updateCalcTime"])
+    fun updateCalcTime(@RequestParam graphCode: String,@RequestParam relType: String,@RequestParam computingTime: String): SBaseResponse{
+        return relStatisticService.updateCalcTime(graphCode,relType,computingTime)
+    }
+
 
 } // Class EquipScanTaskController

+ 2 - 1
datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/ManualRelationCalcController.kt

@@ -41,6 +41,7 @@ import org.springframework.web.bind.annotation.PostMapping
 import org.springframework.web.bind.annotation.RequestBody
 import org.springframework.web.bind.annotation.RequestMapping
 import org.springframework.web.bind.annotation.RestController
+import javax.validation.Valid
 
 /**
  * 手动计算
@@ -67,7 +68,7 @@ class ManualRelationCalcController {
      */
     @Operation(summary = "查询关系数据", description = "")
     @PostMapping(value = ["/query"])
-    fun query(@RequestBody manualRelationCalcRequest: ManualRelationCalcRequest): ManualRelationCalcResponse {
+    fun query(@RequestBody @Valid manualRelationCalcRequest: ManualRelationCalcRequest): ManualRelationCalcResponse {
         return service.queryRel(manualRelationCalcRequest)
     }
 

+ 4 - 4
datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/relation/RelationCalcController.kt

@@ -110,10 +110,10 @@ class RelationCalcController {
             "FunctionZone,FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone\n " +
             "sign 是否要删除手动维护的关系(不填默认为false), boolean型, 值为true或false (true表示删除自动和手动维护的关系, false表示只删除自动计算的的关系)")
     @PostMapping(value = ["/eq2sp_in"])
-    fun calcEq2Sp(@RequestParam objectTypes: String?): SBaseResponse {
+    fun calcEq2Sp(@RequestParam objectTypes: String?,@RequestParam graphCode:String, @RequestParam relType:String): SBaseResponse {
         val projectId = SPageContext.getHeader("projectId").toString()
         logger.debug("calcEq2Sp --------------  $projectId")
-        return service.calcEq2Sp(objectTypes,projectId, false,"MechInArch")
+        return service.calcEq2Sp(objectTypes,projectId, false,graphCode,relType)
     } // Function calcEq2Sp()
 
     /**
@@ -321,10 +321,10 @@ class RelationCalcController {
      */
     @Operation(summary = "设备服务空间关系", description = "空调风口(ATIO)、通风风口(VTIO)")
     @PostMapping(value = ["/eq2sp_for"])
-    fun eqForSp(@RequestParam objectTypes: String?): SBaseResponse {
+    fun eqForSp(@RequestParam objectTypes: String?,@RequestParam graphCode:String, @RequestParam relType:String): SBaseResponse {
         val projectId = SPageContext.getHeader("projectId").toString()
         logger.debug("calcEq2Sp --------------  $projectId")
-        return service.calcEqForSp(objectTypes,projectId,"MechForArch")
+        return service.calcEqForSp(objectTypes,projectId,graphCode,relType)
     }
 
     /**