caiaf 4 tahun lalu
induk
melakukan
5674baf7b4

+ 20 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/obj/Equipment.kt

@@ -27,10 +27,13 @@
 package com.persagy.server.datacenter.wanda.obj
 
 import com.alibaba.fastjson.annotation.JSONField
+import com.persagy.server.datacenter.datacenter.models.entities.graphtype.rel.RelZoneSpace
 import com.persagy.server.datacenter.models.entities.assistant.BIMLocation
 import com.persagy.server.datacenter.models.entities.base.BaseInfo
 import com.persagy.server.datacenter.models.entities.task.SchemeUtils
 import com.persagy.server.datacenter.wanda.AttPic
+import com.persagy.server.datacenter.wanda.rel.RelZoneSpaceBd
+import com.persagy.service.models.annotations.SCascade
 import io.swagger.v3.oas.annotations.media.Schema
 import javax.persistence.Column
 import javax.persistence.Id
@@ -218,6 +221,12 @@ open class Equipment : BaseInfo() {
     @Column(name = "code_name")
     var codeName: String? = null
 
+    /** 构件分类名称 */
+    @Schema(description = "构件分类名称")
+    @Column(name = "bim_type_name")
+    var bimTypeName: String? = null
+
+
     /** 方案id */
     @Schema(description = "方案id")
 //    @Column(name = "scheme_id")
@@ -228,4 +237,15 @@ open class Equipment : BaseInfo() {
             }
             return null
         }
+
+
+    /** 级联-楼层   table  对应关系表   idColumn 对应 本类的id    childIdColumn 级联对象的关系id */
+    @Schema(description = "级联-楼层")
+    @SCascade(table="equipment", idColumn="id", childIdColumn="floor_id")
+    var floor: Floor? = null
+
+    /** 级联-设备所在空间 */
+    @Schema(description = "级联-设备所在空间")
+    @SCascade(table="relationship.r_eq2sp", idColumn="eq_id", childIdColumn="sp_id",filter ="type = 'Eq2Sp' and graph_code = 'MechInArch'" )
+    var objectInfo: ArrayList<RelZoneSpace>? = null
 }

+ 2 - 0
datacenter/src/main/kotlin/com/persagy/server/datacenter/models/service/BaseDataService.kt

@@ -3,9 +3,11 @@ package com.persagy.server.datacenter.models.service
 import cn.sagacloud.server.algorithm.models.entities.Door
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.datacenter.models.entities.Connector
+import com.persagy.server.datacenter.models.entities.Equipment
 import com.persagy.service.SObjectService
 
 object BaseDataService {
     val doorService = SObjectService(SMybatisDao(Door::class.java))
     val connectorService = SObjectService(SMybatisDao(Connector::class.java))
+    val equipmentService = SObjectService(SMybatisDao(Equipment::class.java))
 }

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

@@ -166,28 +166,28 @@ open class GraphicTypeMapperService {
                                 count = equipmentList.size
                             }else if (relationType == "Eq2Sp"){
                                 /** 设备所在的空间 */
-                                val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicType!!),
+                                val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicTypeCode!!),
                                         SFilter.eq("type", relationType!!), SFilter.eq("zoneType", relationTypeProject.zoneType!!)).exec()
                                 count = rEq2SpList.size
                             }
                         } else if (graphicTypeCode == "ArchForArch") {
                             /** 区域服务关系 */
                             if (relationType == "Sp2Sp") {
-                                val rSp2SpList = rSp2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicType!!),
+                                val rSp2SpList = rSp2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicTypeCode!!),
                                         SFilter.eq("type", relationType!!)).exec()
                                 count = rSp2SpList.size
                             }
                         }else if (graphicTypeCode == "MechSubset") {
                             /** 机电从属关系 */
                             if (relationType == "Sy2Eq") {
-                                val rEq2SyList = rEq2SyService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicType!!),
+                                val rEq2SyList = rEq2SyService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicTypeCode!!),
                                         SFilter.eq("type", relationType!!)).exec()
                                 count = rEq2SyList.size
                             }
                         }else if (graphicTypeCode == "MechForArch") {
                             /** 机电类服务区域关系 */
                             if (relationType == "Eq2Sp") {
-                                val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicType!!),
+                                val rEq2SpList = rEq2SpService.select(SFilter.eq("projectId", projectId), SFilter.eq("graphCode", graphicTypeCode!!),
                                         SFilter.eq("type", relationType!!), SFilter.eq("zoneType", relationTypeProject.zoneType!!)).exec()
                                 count = rEq2SpList.size
                             }

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

@@ -32,6 +32,7 @@ import com.persagy.database.SQueryBuilder
 import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.assistant.BuildingFloorInfo
+import com.persagy.server.datacenter.models.entities.dictnew.DefFuncIdProject
 import com.persagy.server.datacenter.wanda.obj.Equipment
 import com.persagy.server.datacenter.models.entities.rel.RSyEq
 import com.persagy.server.datacenter.models.entities.rel.RSyEqList
@@ -42,6 +43,7 @@ import com.persagy.server.datacenter.wanda.obj.Shaft
 import com.persagy.server.datacenter.wanda.obj.ZoneSpace
 import com.persagy.server.services.assistant.ObjInfoService
 import com.persagy.server.services.base.Service
+import com.persagy.server.services.dict.dictnew.DictDefClassService
 import com.persagy.server.services.log.DataCenterLogsService
 import com.persagy.server.services.rel.RSyInBdService
 import com.persagy.server.services.rel.RSyInFlService
@@ -52,8 +54,22 @@ import com.persagy.service.SPageContext
 import com.persagy.service.models.enums.SResponseType
 import com.persagy.service.models.requests.SCreateRequest
 import com.persagy.service.models.requests.SQueryRequest
+import com.persagy.service.models.requests.SUpdateRequest
+import com.persagy.service.models.responses.SBaseResponse
 import com.persagy.service.models.responses.SCreateResponse
 import com.persagy.service.models.responses.SQueryResponse
+import org.apache.poi.ss.usermodel.CellType
+import org.apache.poi.xssf.usermodel.XSSFCell
+import org.apache.poi.xssf.usermodel.XSSFRow
+import org.apache.poi.xssf.usermodel.XSSFSheet
+import org.apache.poi.xssf.usermodel.XSSFWorkbook
+import org.springframework.web.multipart.MultipartFile
+import java.io.IOException
+import java.io.InputStream
+import java.io.OutputStream
+import java.util.HashMap
+import java.util.LinkedHashMap
+import javax.servlet.http.HttpServletResponse
 
 /**
  * 系统信息服务
@@ -62,7 +78,8 @@ import com.persagy.service.models.responses.SQueryResponse
  */
 object GeneralSystemService : Service<GeneralSystem>(SMybatisDao(GeneralSystem::class.java)) {
 
-
+    /** 项目定制化服务 */
+    private val defFuncIdProjectService = SObjectService(SMybatisDao(DefFuncIdProject::class.java))
 
     /**
      * 创建之前的操作
@@ -552,4 +569,218 @@ object GeneralSystemService : Service<GeneralSystem>(SMybatisDao(GeneralSystem::
     }
 
 
+
+    fun exportExcel(response: HttpServletResponse, projectId: String, classCode: String) {
+        response.contentType = "application/octet-stream"
+        response.setHeader("Content-disposition", "attachment;filename=equip-$classCode.xlsx")
+        response.flushBuffer()
+        val defFuncIds = defFuncIdProjectService.select(SFilter.eq("projectId",projectId), SFilter.eq("classCode",classCode)).exec()
+
+        val equipments = EquipmentService.select(SFilter.eq("projectId", projectId), SFilter.eq("classCode", classCode)).exec()
+        val list = java.util.ArrayList<List<Any>>()
+        val firstList = java.util.ArrayList<String>()
+        val codeList = java.util.ArrayList<String>()
+        codeList.add("id")
+        codeList.add("bimTypeId")
+        codeList.add("systemCategory")
+        codeList.add("codeName")
+        codeList.add("localId")
+        firstList.add("设备ID-id")
+        firstList.add("BIM构件编码-bimTypeId")
+        firstList.add("系统分类-systemCategory")
+        firstList.add("设备类型名称-codeName")
+        firstList.add("本地编码-localId")
+        for (defFuncId in defFuncIds) {
+            codeList.add(defFuncId.code!!)
+            firstList.add("${defFuncId.name}-${defFuncId.code}")
+        }
+
+
+        list.add(firstList)
+        for (equipment in equipments) {
+            val itemList = java.util.ArrayList<Any>()
+            val infos = equipment.infos
+            for (s in codeList) {
+                if(s == "id"){
+                    itemList.add(equipment.id?:"")
+                } else if(s == "bimTypeId"){
+                    itemList.add(equipment.bimTypeId?:"")
+                }else if(s == "systemCategory"){
+                    itemList.add(equipment.systemCategory?:"")
+                }else if(s == "codeName"){
+                    itemList.add(equipment.codeName?:"")
+                }else if(s == "localId"){
+                    itemList.add(equipment.localId?:"")
+                }else{
+                    if(infos != null && infos[s] != null){
+                        itemList.add(infos[s]!!)
+                    }else{
+                        itemList.add("")
+                    }
+                }
+
+
+            }
+            list.add(itemList)
+
+        }
+        writeExcel(list,response.outputStream)
+
+
+    } // Fun exportExcel
+
+
+    /**
+     * 把内容写入Excel
+     * @param list 传入要写的内容,此处以一个List内容为例,先把要写的内容放到一个list中
+     * @param outputStream 把输出流怼到要写入的Excel上,准备往里面写数据
+     */
+    fun writeExcel(list: List<List<*>>, outputStream: OutputStream){
+        //创建工作簿
+        var xssfWorkbook = XSSFWorkbook()
+
+        //创建工作表
+        val xssfSheet: XSSFSheet
+        xssfSheet = xssfWorkbook.createSheet("系统绑点")
+
+        //创建行
+        var xssfRow: XSSFRow
+
+        //创建列,即单元格Cell
+        var xssfCell: XSSFCell
+
+        //把List里面的数据写到excel中
+        for (i in list.indices) {
+            //从第一行开始写入
+            xssfRow = xssfSheet.createRow(i)
+            //创建每个单元格Cell,即列的数据
+            val sub_list = list[i]
+            for (j in sub_list.indices) {
+                xssfCell = xssfRow.createCell(j) //创建单元格
+                xssfCell.setCellValue(sub_list[j] as String?) //设置单元格内容
+            }
+        }
+
+        //用输出流写到excel
+        try {
+            xssfWorkbook.write(outputStream)
+            outputStream.flush()
+            outputStream.close()
+        } catch (e: IOException) {
+            e.printStackTrace()
+        }
+    }
+
+    fun importExcel(file: MultipartFile, projectId: String, classCode: String) : SBaseResponse {
+        try {
+
+            val equipments = EquipmentService.select(SFilter.eq("projectId", projectId), SFilter.eq("classCode", classCode)).exec()
+            val equipMap = HashMap<String,Equipment>()
+            for (equipment in equipments) {
+                equipMap[equipment.id!!] = equipment
+            }
+            val content = java.util.ArrayList<Equipment>()
+            val list = readExcel(file.inputStream,"")
+            for (map in list) {
+                val infos = HashMap<String,Any?>()
+                var equipId : String? = null
+                for (key in map.keys) {
+                    val code = key.substring(key.lastIndexOf("-"),key.length)
+                    if(code == "id"){
+                        equipId = map[key]!!
+                    } else if(code == "bimTypeId"){
+
+                    }else if(code == "systemCategory"){
+
+                    }else if(code == "codeName"){
+
+                    }else if(code == "localId"){
+
+                    }else{
+                        if(!map[key].isNullOrEmpty()){
+                            infos[key] = map[key]
+                        }
+                    }
+                }
+
+                val equipment = equipMap[equipId]
+                if(equipment != null){
+                    content.add(equipment)
+                }
+            }
+            val request = SUpdateRequest<Equipment>()
+            request.content = content
+            EquipmentService.updateList(request)
+
+
+        }catch (e : Exception){
+            return SBaseResponse(SResponseType.failure,"error:" + e.message)
+        }
+        return SBaseResponse(SResponseType.success, "")
+    }
+
+    /**
+     * 读取Excel文件的内容
+     * @param inputStream excel文件,以InputStream的形式传入
+     * @param sheetName sheet名字
+     * @return 以List返回excel中内容
+     */
+    fun readExcel(inputStream: InputStream?, sheetName: String): List<Map<String, String>> {
+
+        //定义工作簿
+        var xssfWorkbook: XSSFWorkbook? = null
+        try {
+            xssfWorkbook = XSSFWorkbook(inputStream)
+        } catch (e: Exception) {
+            println("Excel data file cannot be found!")
+        }
+
+        //定义工作表
+        val xssfSheet: XSSFSheet
+        xssfSheet = if (sheetName == "") {
+            // 默认取第一个子表
+            xssfWorkbook!!.getSheetAt(0)
+        } else {
+            xssfWorkbook!!.getSheet(sheetName)
+        }
+        val list = java.util.ArrayList<LinkedHashMap<String, String>>()
+
+        //定义行
+        //默认第一行为标题行,index = 0
+        val titleRow = xssfSheet.getRow(0)
+
+        //循环取每行的数据
+        for (rowIndex in 1 until xssfSheet.physicalNumberOfRows) {
+            val xssfRow = xssfSheet.getRow(rowIndex) ?: continue
+            val map = LinkedHashMap<String, String>()
+            //循环取每个单元格(cell)的数据
+            for (cellIndex in 0 until xssfRow.physicalNumberOfCells) {
+                val titleCell = titleRow.getCell(cellIndex)
+                val xssfCell = xssfRow.getCell(cellIndex)
+                map[getString(titleCell)] = getString(xssfCell)
+            }
+            list.add(map)
+        }
+        return list
+    }
+
+    /**
+     * 把单元格的内容转为字符串
+     * @param xssfCell 单元格
+     * @return 字符串
+     */
+    fun getString(xssfCell: XSSFCell?): String {
+        if (xssfCell == null) {
+            return ""
+        }
+        return if (xssfCell.cellType == CellType.NUMERIC) {
+            xssfCell.numericCellValue.toString()
+        } else if (xssfCell.cellType == CellType.BOOLEAN) {
+            xssfCell.booleanCellValue.toString()
+        } else {
+            xssfCell.stringCellValue
+        }
+    }
+
+
 } // Object GeneralSystemService

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

@@ -80,6 +80,9 @@ object SpaceService : Service<ZoneIspace>(SMybatisDao(ZoneIspace::class.java)) {
         super.onCreateSuccess(entityList)
         val zoneSpaces = ArrayList<ZoneSpace>()
         for (zoneIspace in entityList) {
+            if(select(SFilter.eq("id",zoneIspace.id!!)).entity() == null){
+                continue
+            }
             val zoneSpace = ZoneSpace()
             zoneSpace.name = zoneIspace.name
             zoneSpace.bimLocation = zoneIspace.bimLocation
@@ -131,7 +134,6 @@ object SpaceService : Service<ZoneIspace>(SMybatisDao(ZoneIspace::class.java)) {
         return super.onDeleteBefore(entity)
     }
 
-
     /**
      * 查询元空间
      */

+ 109 - 96
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/CalcSpecialService.kt

@@ -36,6 +36,7 @@ import com.persagy.server.mappers.ICalcSpecialMapper
 import com.persagy.server.datacenter.models.entities.Connector
 import com.persagy.server.datacenter.models.entities.Duct
 import com.persagy.server.datacenter.models.entities.Pipe
+import com.persagy.server.datacenter.models.service.BaseDataService
 import com.persagy.server.datacenter.models.wrapperobj.ClassCodeEnum
 import com.persagy.server.datacenter.services.objects.BuildingService
 import com.persagy.server.datacenter.services.objects.EquipmentService
@@ -274,7 +275,7 @@ open class CalcSpecialService {
 
         for (building in buildings) {
             val buildingId = building.id!!
-            val floors = FloorService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId)).exec()
+            val floors = FloorService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId), SFilter.eq("id","Fl44030700030232b37b40f84312932da8cb6046698a")).exec()
             for (floor in floors) {
                 if (!floor.modelId.isNullOrEmpty()) {
                     modelIds.add(floor.modelId!!)
@@ -288,34 +289,37 @@ open class CalcSpecialService {
 //            for (floor in floors) {
 //                if (!floor.modelId.isNullOrEmpty()) {
 //                    val connectors = mapper.connectorOrder(floor.modelId!!)
-                    val connectors = connectorService.select(SFilter.inList("modelId",modelIds)).exec()
+                    val connectors = connectorService.select(SFilter.inList("modelId",modelIds), SFilter.ne("domain","DomainPiping")).exec()
 
 //                    val dcEquipments = EquipmentService.select(SFilter.eq("projectId",projectId), SFilter.eq("floorId",floor.id!!)).exec()
                     val dcEquipments = EquipmentService.select(SFilter.eq("projectId",projectId),SFilter.eq("buildingId",building.id!!)).exec()
-                    val dcEquipMap = HashMap<String, Equipment>(4096)
+                    val dcEquipMap = HashMap<String, Equipment>(10000)
                     for (equipment in dcEquipments) {
                         if(!equipment.bimId.isNullOrEmpty()){
                             dcEquipMap[equipment.bimId!!] = equipment
                         }
 
                     }
-
+                    val equipments = BaseDataService.equipmentService.select(SFilter.inList("modelId",modelIds)).projection("id").exec()
+                    val equipIds = equipments.map { e -> e.id!! }
                     val connectorMap = HashMap<String, Connector>(100000)
-                    val typeMap = HashMap<String, String>(20000)
-                    val eqBelongMap = HashMap<String, String>(20000)
+                    val typeMap = HashMap<String, String>()
+                    val eqBelongMap = HashMap<String, String>(10000)
                     for (connector in connectors) {
                         connectorMap[connector.id!!] = connector
 
-                        val belong = connector.belongBimId ?: continue
+                        val belong = connector.belong ?: continue
                         val belongType = connector.belongType
-                        val id = connector.id!!
                         if (belongType != null) {
-                            typeMap[id] = belongType
-                        }
-                        if(belongType == "Equipment"){
-                            eqBelongMap[id] = belong
+                            if(belongType != "Equipment"){
+                                typeMap[belong] = belongType
+                            }else if(equipIds.contains(belong)){
+                                typeMap[belong] = belongType
+                            }
+
                         }
 
+
                     }
 
                     val belongMap = HashMap<String, HashSet<String>>()
@@ -325,32 +329,37 @@ open class CalcSpecialService {
                         //拿到所属类
                         val belongType = connector.belongType
                         //拿到所属id
-                        val belong = connector.id
+                        val belong = connector.belong
+                        if(belong == "6570cc5d8dff11eba822e9f08377214a"){
+                            print("111")
+                        }
                         if(belong != null){
-                            belongMap[belong] = HashSet()
+                            if(belongType == "Equipment"){
+                                eqBelongMap[belong] = connector.belongBimId!!
+                            }
+                            if(!belongMap.containsKey(belong)){
+                                belongMap[belong] = HashSet()
+                            }
+//                            if(connector.belongType == "Equipment"){
+//                                eqBelongSet.add(belong)
+//                            }
+
                             eqBelongSet.add(belong)
+
                             //如果连接件有连接
                             if (connector.connectIdJson!!.size > 0) {
                                 val connectorId = connector!!.connectIdJson?.get(0)
                                 var currentConnector = connectorMap[connectorId!!]
-                                val cBelong = currentConnector?.id
-                                if (cBelong != null) {
-//                                if(belongType == "Equipment"){
-//                                    eqBelongSet.add(belong)
+                                //系统不同
+//                                if(connector.mepSystemType != currentConnector?.mepSystemType){
+//                                    continue
 //                                }
-
-                                    if (belongMap.containsKey(belong)) {
-                                        val belongs = belongMap[belong]!!
-                                        belongs.add(cBelong)
-                                        belongMap[belong] = belongs
-                                    } else {
-                                        belongMap[belong] = hashSetOf(cBelong)
-                                    }
-                                }else{
-                                    belongMap[belong] = HashSet()
+                                val cBelong = currentConnector?.belong
+                                if (cBelong != null) {
+                                    val belongs = belongMap[belong]!!
+                                    belongs.add(cBelong)
+                                    belongMap[belong] = belongs
                                 }
-                            }else {
-                                belongMap[belong] = HashSet()
                             }
                             if(connector.riserState != null && connector.riserState!! > 0 && listOf("Duct","Pipe").contains(connector.belongType)){
                                 for (key in riserMap.keys) {
@@ -373,48 +382,14 @@ open class CalcSpecialService {
                     var dSet: HashSet<String>
                     println(eqBelongSet.size)
                     for (key in eqBelongSet) {
-                        val e1 = dcEquipMap[eqBelongMap[key]]
-                        if(e1 == null || !enumList.contains(e1.classCode)){
-                            continue
-                        }
 
-                        val belongSet = belongMap[key]!!
 
+                        val belongSet = belongMap[key]!!
                         dSet = directDist(HashSet(belongSet),belongMap,typeMap)
                         dBlockId ++
 
-                        for (s in dSet!!) {
-                            if(typeMap[s] == "Equipment" && key != s){
-                                val e2 = dcEquipMap[eqBelongMap[key]]
-                                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 = connectorMap[key]!!.modelId
-                                connectedBlock.modelId2 = connectorMap[s]!!.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)
-                                }
-
-                            }
-                        }
 
+                        fSet = null
                         for (block in fBlockMap.keys) {
                             val set = fBlockMap[block]!!
                             if(set.contains(key)){
@@ -428,9 +403,6 @@ open class CalcSpecialService {
                             fBlockId ++
                             cBlockId = fBlockId
                             fBlockMap[cBlockId] = HashSet(fSet)
-                            if(cBlockId == 1){
-                                println(fBlockMap[cBlockId]!!.toJson())
-                            }
                         }
 //                    fSet = fullDist(HashSet(belongSet),belongMap)
 //                    println(fSet.contains(key))
@@ -438,40 +410,81 @@ open class CalcSpecialService {
 
                         fMap[key] = fSet
                         dMap[key] = dSet
-                        for (s in fSet!!) {
-                            if(typeMap[s] == "Equipment" && key != s){
-                                val e2 = dcEquipMap[eqBelongMap[key]]
-                                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 = connectorMap[key]!!.modelId
-                                connectedBlock.modelId2 = connectorMap[s]!!.modelId
+                        if(typeMap[key] == "Equipment"){
+                            val e1 = dcEquipMap[eqBelongMap[key]]
+                            if(e1 == null || !enumList.contains(e1.classCode)){
+                                continue
+                            }
+                            for (s in dSet!!) {
+                                if(typeMap[s] == "Equipment" && key != s){
+                                    val e2 = dcEquipMap[eqBelongMap[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 = connectorMap[key]!!.modelId
+//                                connectedBlock.modelId2 = connectorMap[s]!!.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 = 0
+                                    connectedBlock.blockId = dBlockId.toString()
+                                    connectedBlock.typeCode1 = e1?.classCode
+                                    connectedBlock.typeCode2 = e2?.classCode
+                                    if (!connectedBlocks.contains(connectedBlock)) {
+                                        connectedBlocks.add(connectedBlock)
+                                    }
+
                                 }
+                            }
+                            for (s in fSet!!) {
+                                if(typeMap[s] == "Equipment" && key != s){
+                                    val e2 = dcEquipMap[eqBelongMap[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 = connectorMap[key]!!.modelId
+//                                connectedBlock.modelId2 = connectorMap[s]!!.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)
+                                    }
 
+                                }
                             }
                         }
 
 
+
+
 //                    }
 //                }
 
@@ -569,7 +582,7 @@ open class CalcSpecialService {
             for (modelId in modelIds) {
                 ducts.add(ductList.stream().filter { duct -> duct.modelId == modelId }.collect(Collectors.toList()))
             }
-            for (index in ducts.indices-1) {
+            for (index in 0 until ducts.size -1) {
                 //低楼层管道
                 val lowerDucts = ducts[index].filter { d -> d.riserState == 2 || d.riserState == 3 }
                 //高楼层管道
@@ -581,7 +594,7 @@ open class CalcSpecialService {
                     val lpoint = lowerDuct.location?.points?.get(0) ?: continue
                     for (higherDuct in higherDucts) {
                         val hpoint = higherDuct.location?.points?.get(0)
-                        if(hpoint != null){
+                        if(lowerDuct.mepSystemType == higherDuct.mepSystemType && hpoint != null){
                             // 求两个点的距离 是否在允许的误差范围内
                             val connected = sqrt((lpoint.x - hpoint.x).pow(2.0) + (lpoint.y - hpoint.y).pow(2.0)) < distance
                             if(connected){
@@ -602,7 +615,7 @@ open class CalcSpecialService {
             for (modelId in modelIds) {
                 pipes.add(pipeList.stream().filter { pipe -> pipe.modelId == modelId }.collect(Collectors.toList()))
             }
-            for (index in pipes.indices-1) {
+            for (index in 0 until pipes.size -1) {
                 //低楼层管道
                 val lowerPipes = pipes[index].filter { d -> d.riserState == 2 || d.riserState == 3 }
                 //高楼层管道

+ 32 - 48
datacenter/src/main/kotlin/com/persagy/server/datacenter/services/relation_calc/RelationCalcService.kt

@@ -1109,56 +1109,38 @@ open class RelationCalcService {
      *  @param  sign        是否要删除自动维护的关系(不填默认为false), boolean型, 值为true或false (true表示删除自动和手动维护的关系, false表示只删除手动计算的的关系)
      */
     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()
 
         try {
 
-            try {
-//                upDateBiaoji(projectId, "eq2fl", 3)
-//                upDateBiaoji(projectId, "fl2sp", 3)
+            calcSpecialService.calcNetworks(projectId)
+            val codeList= ClassCodeEnum.toSourceList(1)
 
-                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)
-                }
-            } catch (e: Exception) {
-                e.printStackTrace()
+            val connectedBlocks = connectedBlockService.select(SFilter.eq("projectId",projectId), SFilter.or(SFilter.inList("typeCode1",codeList), SFilter.inList("typeCode2",codeList))).exec()
+
+            var sqlBuilder = arrayListOf(SFilter.eq("projectId", projectId), SFilter.eq("relationType", relType
+            ), SFilter.eq("graphicType",graphCode))
+
+            if(tables != null){
+                sqlBuilder.add(SFilter.eq("zoneType", tables!!))
+            }
+            val entity = relationTypeProjectservice.select(sqlBuilder).entity()
+            if (entity != null) {
+                entity.computationalState = 3
+                relationTypeProjectservice.update(entity)
             }
             /** 启动计算   ******************************/
-//            val result = mapper.calcEq2Sp(projectId)
-            var result = 0
+            val result = mapper.calcEq2Sp(projectId)
             logger.debug("计算结果= ${result}")
 
             /*************************上面添加数据**********************************/
 
-
-
-//            REq2SpService.delete(SFilter.eq("projectId", projectId),
-//                     SFilter.eq("type", "eq2sp_for"))
-//            val r2 = mapper.insertsp(projectId)
-//                logger.debug("设备关联业务空间计算结果= ${r1}+${r2}")
-
-
-
             if (result != null && result == 0) {
-                try {
 
-//                    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()
-                        relationTypeProjectservice.update(entity)
-                    }
-                } catch (e: Exception) {
-                    e.printStackTrace()
+                if (entity != null) {
+                    entity.computationalState = 1
+                    entity.computingTime = IdUtils.time()
+                    relationTypeProjectservice.update(entity)
                 }
 
                 val sourceList = ClassCodeEnum.toSourceList(0)
@@ -1173,9 +1155,15 @@ open class RelationCalcService {
                         listId.add(equipment.id!!)
                         typeMap[equipment.id!!] = equipment.classCode!!
                     }
-                    val rEq2SpList = REq2SpService.select(SFilter.eq("projectId", projectId),
-                            SFilter.inList("id1", listId)
-                            , SFilter.eq("graphCode", "MechInArch"), SFilter.eq("type",relType), SFilter.eq("zoneType",tables!!)).exec()
+                    val rbuilder = arrayListOf(SFilter.eq("projectId", projectId),
+                    SFilter.inList("id1", listId)
+                    , SFilter.eq("graphCode", "MechInArch"), SFilter.eq("type",relType))
+
+                    if(tables != null){
+                        rbuilder.add( SFilter.eq("zoneType",tables!!))
+                    }
+
+                    val rEq2SpList = REq2SpService.select(rbuilder).exec()
                     val rEq2Sps = ArrayList<REq2Sp>()
                     if (rEq2SpList.size > 0) {
                         for (rEq2Sp in rEq2SpList) {
@@ -1190,24 +1178,24 @@ open class RelationCalcService {
                                 for (connectedBlock in connectedBlocks) {
                                     val typeCode1 = connectedBlock.typeCode1
                                     val typeCode2 = connectedBlock.typeCode2
-                                    if(sourceList.contains(typeCode1)){
+                                    if(sourceList.contains(typeCode1) && connectedBlock.id1 == rEq2Sp.id1){
                                         val fullREq2Sp = REq2Sp()
                                         fullREq2Sp.type = relType
                                         fullREq2Sp.graphCode = graphCode
                                         fullREq2Sp.projectId = projectId
                                         fullREq2Sp.id1 = connectedBlock.id2
                                         fullREq2Sp.id2 = rEq2Sp.id2
-                                        fullREq2Sp.zoneType = tables
+                                        fullREq2Sp.zoneType = rEq2Sp.zoneType
                                         fullREq2Sp.sign =2
                                         rEq2Sps.add(fullREq2Sp)
-                                    }else if(sourceList.contains(typeCode2)){
+                                    }else if(sourceList.contains(typeCode2)  && connectedBlock.id2 == rEq2Sp.id1){
                                         val fullREq2Sp = REq2Sp()
                                         fullREq2Sp.type = relType
                                         fullREq2Sp.graphCode = graphCode
                                         fullREq2Sp.projectId = projectId
                                         fullREq2Sp.id1 = connectedBlock.id1
                                         fullREq2Sp.id2 = rEq2Sp.id2
-                                        fullREq2Sp.zoneType = tables
+                                        fullREq2Sp.zoneType = rEq2Sp.zoneType
                                         fullREq2Sp.sign =2
                                         rEq2Sps.add(fullREq2Sp)
                                     }
@@ -1225,10 +1213,6 @@ open class RelationCalcService {
                 rabbitMqService.sendRel(Opt.projectId!!, "fengkou_for", "20", "123", "456")
                 return SBaseResponse(SResponseType.success)
             } else {
-                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()

+ 23 - 0
datacenter/src/main/kotlin/com/persagy/server/datacenter/wanda/controllers/obj/GeneralSystemController.kt

@@ -28,6 +28,7 @@ package com.persagy.server.datacenter.wanda.controllers.obj
 
 import com.persagy.database.SFilter
 import com.persagy.server.Opt
+import com.persagy.server.datacenter.services.objects.EquipmentService
 import com.persagy.server.datacenter.services.objects.GeneralSystemService
 import com.persagy.server.datacenter.wanda.obj.GeneralSystem
 import com.persagy.service.models.requests.SCountRequest
@@ -41,7 +42,10 @@ import com.persagy.service.models.responses.SQueryResponse
 import io.swagger.v3.oas.annotations.Operation
 import io.swagger.v3.oas.annotations.tags.Tag
 import org.slf4j.LoggerFactory
+import org.springframework.http.MediaType
 import org.springframework.web.bind.annotation.*
+import org.springframework.web.multipart.MultipartFile
+import javax.servlet.http.HttpServletResponse
 
 /**
  * 系统接口
@@ -195,5 +199,24 @@ open class GeneralSystemController {
 //        return GeneralSystemService.createLinkEquip(rSyEqList)
 //    } // Function create()
 
+    /**
+     * 导出系统
+     */
+    @Operation(summary="导出系统*", description="")
+    @GetMapping(value = ["/export"])
+    fun exportExcel(response: HttpServletResponse, @RequestParam projectId: String, @RequestParam classCode: String) {
+        GeneralSystemService.exportExcel(response, projectId,classCode)
+    } // Fun exportExcel
 
+    /**
+     * 导入excel
+     *
+     * @param   file            导入的excel文件
+     * @return  导入状态
+     */
+    @Operation(summary = "导入excel", description = "")
+    @PostMapping("/import",consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
+    fun importExcel(@RequestPart("file") file: MultipartFile, @RequestParam projectId: String, @RequestParam classCode: String) : SBaseResponse {
+        return GeneralSystemService.importExcel(file,projectId,classCode)
+    } // Fun importExcel()
 }

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

@@ -321,7 +321,7 @@ class RelationCalcController {
      */
     @Operation(summary = "设备服务空间关系", description = "空调风口(ATIO)、通风风口(VTIO)")
     @PostMapping(value = ["/eq2sp_for"])
-    fun eqForSp(@RequestParam objectTypes: String?,@RequestParam graphCode:String, @RequestParam relType:String): SBaseResponse {
+    fun eqForSp(@RequestParam(required = false) objectTypes: String?,@RequestParam graphCode:String, @RequestParam relType:String): SBaseResponse {
         val projectId = SPageContext.getHeader("projectId").toString()
         logger.debug("calcEq2Sp --------------  $projectId")
         return service.calcEqForSp(objectTypes,projectId,graphCode,relType)

+ 10 - 10
datacenter/src/main/resources/application-prod.yml

@@ -31,20 +31,20 @@ spring:
 #    url:                                jdbc:postgresql://data-center:5432/datacenter
 #    username:                           postgres
 #    password:                           123qwe!@#
-#    url:                                jdbc:postgresql://localhost:5432/datacenter
-    url:                                jdbc:postgresql://172.17.11.228:5432/datacenterlabsl
+    url:                                jdbc:postgresql://192.168.0.72:5432/datacenter
+#    url:                                jdbc:postgresql://172.17.11.228:5432/datacenterlabsl
 #    url:                                jdbc:postgresql://192.168.64.14:5432/datacenterlabsl
     username:                           postgres
 #    password:                           persagy_2020qwe!@#
-    password:                           123456
+    password:                           cGVyc2FneV8yMDIwcXdlIUAj
 
-  rabbitmq:
-    host: 39.102.43.179
-    port: 9936
-    username: admin
-    password: brzj123456
-    #虚拟host 可以不设置,使用server默认host
-    virtual-host: /test
+#  rabbitmq:
+#    host: 39.102.43.179
+#    port: 9936
+#    username: admin
+#    password: brzj123456
+#    #虚拟host 可以不设置,使用server默认host
+#    virtual-host: /test
 
   servlet:
     multipart:

+ 2 - 1
equip-component/src/main/kotlin/com/persagy/server/controllers/dict/DictCustomController.kt

@@ -27,6 +27,7 @@
 package com.persagy.server.controllers.dict
 
 import com.persagy.server.datacenter.datacenter.models.entities.dictnew.DefClass
+import com.persagy.server.datacenter.datacenter.models.entities.dictnew.DictMajor
 import com.persagy.server.datacenter.wanda.response.DictInfoResponse
 import com.persagy.server.service.dict.DefFuncIdService
 import com.persagy.service.models.responses.SQueryResponse
@@ -67,7 +68,7 @@ class DictCustomController {
      */
     @Operation(summary = "统计项目已有的设备类型", description = "系统-设备树形结构")
     @GetMapping(value = ["/project/equip/type"])
-    fun projectEquipType(): SQueryResponse<DefClass>{
+    fun projectEquipType(): SQueryResponse<DictMajor>{
        return  DefFuncIdService.dictProjectTypeEquipQuery()
     }
 

+ 21 - 4
equip-component/src/main/kotlin/com/persagy/server/service/dict/DictDefClassService.kt

@@ -199,9 +199,9 @@ object DefFuncIdService: SObjectService<DefFuncId>(SMybatisDao(DefFuncId::class.
     /**
      * 项目下已有的设备类型
      */
-    fun dictProjectTypeEquipQuery(): SQueryResponse<DefClass>{
+    fun dictProjectTypeEquipQuery(): SQueryResponse<DictMajor>{
         return try {
-            val sQueryResponse = SQueryResponse<DefClass>(SResponseType.success)
+            val sQueryResponse = SQueryResponse<DictMajor>(SResponseType.success)
             val equipTypeProjectList = personnalisationSql.equipTypeProject(Opt.projectId!!)
             if (equipTypeProjectList.size>0) {
                 val equipTypeList = ArrayList<String>()
@@ -228,12 +228,17 @@ object DefFuncIdService: SObjectService<DefFuncId>(SMybatisDao(DefFuncId::class.
                 }
                if (defClassList.size>0){
                    val typeset = HashSet<String>()
+                   val majorSet = HashSet<String>()
                    for (defClass in defClassList) {
                        typeset.add(defClass.systemCode!!)
+                       majorSet.add(defClass.majorCode!!)
                    }
 
                    var systemDefClassList = defClassService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.inList("code", typeset.toList())).order("code").exec()
+                   val defMajors = dictMajorService.select(SFilter.inList("code",majorSet.toList())).order("id").exec()
+
                    if (systemDefClassList.size>0) {
+
                        for (systemDefClass in systemDefClassList) {
                            for (defClass in defClassList) {
                                if (defClass.systemCode == systemDefClass.code) {
@@ -243,10 +248,22 @@ object DefFuncIdService: SObjectService<DefFuncId>(SMybatisDao(DefFuncId::class.
                                    systemDefClass.children!!.add(defClass)
                                }
                            }
+
+                       }
+
+                       for (defMajor in defMajors) {
+                           for (systemDefClass in systemDefClassList) {
+                               if(defMajor.code == systemDefClass.majorCode){
+                                   if (defMajor.children.isNullOrEmpty()) {
+                                       defMajor.children = ArrayList<DefClass>()
+                                   }
+                                   defMajor.children!!.add(systemDefClass)
+                               }
+                           }
                        }
                    }
-                   sQueryResponse.content = systemDefClassList
-                   sQueryResponse.total = systemDefClassList.size.toLong()
+                   sQueryResponse.content = defMajors
+                   sQueryResponse.total = defMajors.size.toLong()
                    sQueryResponse
                }
                 sQueryResponse

+ 3 - 3
equip-component/src/main/resources/application-prod.yml

@@ -12,18 +12,18 @@ eureka:
     prefer-ip-address:                      true
 
 server:
-  port: 8080
+  port: 8081
 
 spring:
   datasource:
 #    url:                                jdbc:postgresql://data-center:5432/datacenter
 #    username:                           postgres
 #    password:                           123qwe!@#
-    url:                                jdbc:postgresql://localhost:5432/datacenter
+    url:                                jdbc:postgresql://192.168.0.72:5432/datacenter
 #    url:                                jdbc:postgresql://172.17.11.228:5432/datacenterlabsl
 #    url:                                jdbc:postgresql://192.168.64.14:5432/datacenterlabsl
     username:                           postgres
 #    password:                           persagy_2020qwe!@#
-    password:                           123456
+    password:                           cGVyc2FneV8yMDIwcXdlIUAj