|
@@ -30,9 +30,15 @@ import com.persagy.database.SFilter
|
|
|
import com.persagy.mybatis.SMybatisDao
|
|
|
import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
|
|
|
import com.persagy.server.datacenter.models.entities.graphtype.block.ConnectedBlock
|
|
|
+import com.persagy.server.datacenter.models.entities.objects.Equipment
|
|
|
import com.persagy.server.datacenter.models.entities.rel.REq2Eq
|
|
|
import com.persagy.server.mappers.ICalcSpecialMapper
|
|
|
+import com.persagy.server.models.entities.Connector
|
|
|
+import com.persagy.server.models.wrapperobj.ClassCodeEnum
|
|
|
import com.persagy.server.services.assistant.RUpDateEquipAndSapceService
|
|
|
+import com.persagy.server.services.objects.BuildingService
|
|
|
+import com.persagy.server.services.objects.EquipmentService
|
|
|
+import com.persagy.server.services.objects.FloorService
|
|
|
import com.persagy.server.utils.IdUtils
|
|
|
import com.persagy.service.SBaseService
|
|
|
import com.persagy.service.SObjectService
|
|
@@ -64,6 +70,7 @@ open class CalcSpecialService {
|
|
|
/** 关系总览服务 */
|
|
|
val relationTypeProjectservice = SBaseService(SMybatisDao(RelationTypeProject::class.java))
|
|
|
val rEq2EqService = SObjectService(SMybatisDao(REq2Eq::class.java))
|
|
|
+ val connectorService = SObjectService(SMybatisDao(Connector::class.java))
|
|
|
|
|
|
/**
|
|
|
* 管网系统设备分块
|
|
@@ -244,4 +251,232 @@ open class CalcSpecialService {
|
|
|
}
|
|
|
} // Fun
|
|
|
|
|
|
+ /**
|
|
|
+ * @Description: 管网计算
|
|
|
+ * @Param:
|
|
|
+ * @Return:
|
|
|
+ */
|
|
|
+ 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 = connectorService.select(SFilter.eq("modelId",floor.modelId!!), SFilter.ne("domain","DomainPiping")).exec()
|
|
|
+ val dcEquipments = EquipmentService.select(SFilter.eq("projectId",projectId), SFilter.eq("floorId",floor.id!!)).exec()
|
|
|
+ val dcEquipMap = HashMap<String, Equipment>(10000)
|
|
|
+ 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 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) {
|
|
|
+// 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)
|
|
|
+ }
|
|
|
+ }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>>()
|
|
|
+// 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 belongSet = belongMap[key]!!
|
|
|
+
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+// 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
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 = 1
|
|
|
+ connectedBlock.blockId = cBlockId.toString()
|
|
|
+ connectedBlock.typeCode1 = e1?.classCode
|
|
|
+ connectedBlock.typeCode2 = e2?.classCode
|
|
|
+ if (!connectedBlocks.contains(connectedBlock)) {
|
|
|
+ connectedBlocks.add(connectedBlock)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ connectedBlockService.delete(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId))
|
|
|
+ val request = SCreateRequest<ConnectedBlock>()
|
|
|
+ request.content = connectedBlocks
|
|
|
+ connectedBlockService.createList(request)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return SBaseResponse(SResponseType.success, "")
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ fun fullDist(list: HashSet<String>, belongMap: HashMap<String,HashSet<String>>): HashSet<String>{
|
|
|
+ val beforeList = HashSet<String>(list)
|
|
|
+ for (belong in beforeList) {
|
|
|
+ if(belongMap[belong] == null){
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ val belongs = HashSet<String>(belongMap[belong]!!)
|
|
|
+// if(typeMap[belong] != "Equipment"){
|
|
|
+// directList.addAll(belongs)
|
|
|
+// }
|
|
|
+ list.addAll(belongs)
|
|
|
+ }
|
|
|
+ if(beforeList.containsAll(list)){
|
|
|
+ return list
|
|
|
+ }else{
|
|
|
+ return fullDist(list,belongMap)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fun directDist(directList:HashSet<String>, belongMap: HashMap<String,HashSet<String>>,typeMap: HashMap<String,String>): HashSet<String>{
|
|
|
+ val beforeList = HashSet<String>(directList)
|
|
|
+ for (belong in beforeList) {
|
|
|
+ if(belongMap[belong] == null){
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ val belongs = HashSet<String>(belongMap[belong]!!)
|
|
|
+ if(typeMap[belong] != "Equipment"){
|
|
|
+ directList.addAll(belongs)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(beforeList.containsAll(directList)){
|
|
|
+ return directList
|
|
|
+ }else{
|
|
|
+ return directDist(directList,belongMap,typeMap)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
} // Class CalcSpecialService
|