|
@@ -34,6 +34,9 @@ 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.entities.Duct
|
|
|
+import com.persagy.server.models.entities.Pipe
|
|
|
+import com.persagy.server.models.service.BaseDataService
|
|
|
import com.persagy.server.models.wrapperobj.ClassCodeEnum
|
|
|
import com.persagy.server.services.assistant.RUpDateEquipAndSapceService
|
|
|
import com.persagy.server.services.objects.BuildingService
|
|
@@ -49,6 +52,9 @@ import com.persagy.service.models.responses.SBaseResponse
|
|
|
import org.json.JSONObject
|
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
|
import org.springframework.stereotype.Service
|
|
|
+import java.util.stream.Collectors
|
|
|
+import kotlin.math.pow
|
|
|
+import kotlin.math.sqrt
|
|
|
|
|
|
/**
|
|
|
* 关系计算-管网
|
|
@@ -71,6 +77,8 @@ open class CalcSpecialService {
|
|
|
val relationTypeProjectservice = SBaseService(SMybatisDao(RelationTypeProject::class.java))
|
|
|
val rEq2EqService = SObjectService(SMybatisDao(REq2Eq::class.java))
|
|
|
val connectorService = SObjectService(SMybatisDao(Connector::class.java))
|
|
|
+ val ductService = SObjectService(SMybatisDao(Duct::class.java))
|
|
|
+ val pipeService = SObjectService(SMybatisDao(Pipe::class.java))
|
|
|
|
|
|
/**
|
|
|
* 管网系统设备分块
|
|
@@ -258,176 +266,228 @@ open class CalcSpecialService {
|
|
|
*/
|
|
|
fun calcNetworks(projectId: String): SBaseResponse{
|
|
|
val buildings = BuildingService.select(SFilter.eq("projectId",projectId)).exec()
|
|
|
+ val fMap = HashMap<String,HashSet<String>>()
|
|
|
+ val dMap = HashMap<String,HashSet<String>>()
|
|
|
+ val modelIds = ArrayList<String>()
|
|
|
+
|
|
|
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
|
|
|
- }
|
|
|
+ modelIds.add(floor.modelId!!)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ val riserMap = riserConnect("DomainHvac","",modelIds)
|
|
|
+
|
|
|
|
|
|
+ val connectedBlocks = ArrayList<ConnectedBlock>()
|
|
|
+// for (floor in floors) {
|
|
|
+// if (!floor.modelId.isNullOrEmpty()) {
|
|
|
+// val connectors = mapper.connectorOrder(floor.modelId!!)
|
|
|
+ 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>(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>()
|
|
|
+ val eqBelongMap = HashMap<String, String>(10000)
|
|
|
+ for (connector in connectors) {
|
|
|
+ connectorMap[connector.id!!] = connector
|
|
|
+
|
|
|
+ val belong = connector.belong ?: continue
|
|
|
+ val belongType = connector.belongType
|
|
|
+ if (belongType != null) {
|
|
|
+ if(belongType != "Equipment"){
|
|
|
+ typeMap[belong] = belongType
|
|
|
+ }else if(equipIds.contains(belong)){
|
|
|
+ typeMap[belong] = belongType
|
|
|
}
|
|
|
|
|
|
- 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.belong
|
|
|
+
|
|
|
+ if(belong != null){
|
|
|
+ if(belongType == "Equipment"){
|
|
|
+ eqBelongMap[belong] = connector.belongBimId!!
|
|
|
}
|
|
|
- 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)){
|
|
|
+ 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!!]
|
|
|
+ //系统不同
|
|
|
+// if(connector.mepSystemType != currentConnector?.mepSystemType){
|
|
|
+// continue
|
|
|
// }
|
|
|
+ val cBelong = currentConnector?.belong
|
|
|
+ if (cBelong != null) {
|
|
|
+ val belongs = belongMap[belong]!!
|
|
|
+ belongs.add(cBelong)
|
|
|
+ belongMap[belong] = belongs
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(connector.riserState != null && connector.riserState!! > 0 && listOf("Duct","Pipe").contains(connector.belongType)){
|
|
|
+ for (key in riserMap.keys) {
|
|
|
+ if(key == belong){
|
|
|
+ belongMap[belong]!!.addAll(riserMap[key]!!)
|
|
|
|
|
|
- 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()
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- 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 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)
|
|
|
- }
|
|
|
+ val belongSet = belongMap[key]!!
|
|
|
+ dSet = directDist(HashSet(belongSet),belongMap,typeMap)
|
|
|
+ dBlockId ++
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- 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 = null
|
|
|
+ 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()
|
|
|
+ fMap[key] = fSet
|
|
|
+ dMap[key] = dSet
|
|
|
+
|
|
|
+
|
|
|
+ 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
|
|
|
+// }
|
|
|
|
|
|
- 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 = 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)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
connectedBlockService.delete(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId))
|
|
|
val request = SCreateRequest<ConnectedBlock>()
|
|
@@ -435,11 +495,37 @@ open class CalcSpecialService {
|
|
|
connectedBlockService.createList(request)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
return SBaseResponse(SResponseType.success, "")
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description:递归查找连接
|
|
|
+ * @Param:
|
|
|
+ * @Return:
|
|
|
+ */
|
|
|
+ fun searchConnector(connector: Connector, currentConnector: Connector, map: HashMap<String,ArrayList<Connector>>, connectorMap: HashMap<String, Connector>): Connector?{
|
|
|
+ val belong = currentConnector.belong ?: return null
|
|
|
+ if(currentConnector.belongType == "Equipment" && currentConnector != connector){
|
|
|
+ return currentConnector
|
|
|
+ }else{
|
|
|
+// println(currentConnector.belong)
|
|
|
+ val connectors = map[belong] ?: return null
|
|
|
+ for (connector in connectors) {
|
|
|
+ if(currentConnector.revitId != connector.revitId && connector.isConnected == true){
|
|
|
+ val revitId = connector.connectedIds!![0]!!
|
|
|
+ val ccConnector = connectorMap[revitId]!!
|
|
|
+ return searchConnector(connector,ccConnector,map,connectorMap)
|
|
|
+ }else{
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
fun fullDist(list: HashSet<String>, belongMap: HashMap<String,HashSet<String>>): HashSet<String>{
|
|
|
val beforeList = HashSet<String>(list)
|
|
|
for (belong in beforeList) {
|
|
@@ -477,6 +563,86 @@ open class CalcSpecialService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Description: 立管连接
|
|
|
+ * @Param:
|
|
|
+ * @Return:
|
|
|
+ */
|
|
|
+ fun riserConnect(domain: String,memSystemType: String,modelIds: List<String>): HashMap<String,ArrayList<String>>{
|
|
|
+ val itemMap = HashMap<String,ArrayList<String>>()
|
|
|
+ //风管立管连接
|
|
|
+ if(domain == "DomainHvac"){
|
|
|
+ val ducts = ArrayList<List<Duct>>()
|
|
|
+ val ductList = ductService.select(SFilter.inList("modelId",modelIds), SFilter.gt("riserState",0)).exec()
|
|
|
+ for (modelId in modelIds) {
|
|
|
+ ducts.add(ductList.stream().filter { duct -> duct.modelId == modelId }.collect(Collectors.toList()))
|
|
|
+ }
|
|
|
+ for (index in 0 until ducts.size -1) {
|
|
|
+ //低楼层管道
|
|
|
+ val lowerDucts = ducts[index].filter { d -> d.riserState == 2 || d.riserState == 3 }
|
|
|
+ //高楼层管道
|
|
|
+ val higherDucts = ducts[index+1].filter { d -> d.riserState == 1 || d.riserState == 3 }
|
|
|
+ for (lowerDuct in lowerDucts) {
|
|
|
+ val itemList = ArrayList<String>()
|
|
|
+ //允许的距离误差范围
|
|
|
+ val distance = if(lowerDuct.diameter!! > 0) lowerDuct.diameter!! /2 else (lowerDuct.width!!).coerceAtMost(lowerDuct.height!!) /2
|
|
|
+ val lpoint = lowerDuct.location?.points?.get(0) ?: continue
|
|
|
+ for (higherDuct in higherDucts) {
|
|
|
+ val hpoint = higherDuct.location?.points?.get(0)
|
|
|
+ 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){
|
|
|
+ itemList.add(higherDuct.id!!)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(itemList.size > 0){
|
|
|
+ itemMap[lowerDuct.id!!] = itemList
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //水管的立管连接
|
|
|
+ }else if(domain == "DomainPiping"){
|
|
|
+ val pipes = ArrayList<List<Pipe>>()
|
|
|
+ val pipeList = pipeService.select(SFilter.inList("modelId",modelIds), SFilter.gt("riserState",0)).exec()
|
|
|
+ for (modelId in modelIds) {
|
|
|
+ pipes.add(pipeList.stream().filter { pipe -> pipe.modelId == modelId }.collect(Collectors.toList()))
|
|
|
+ }
|
|
|
+ for (index in 0 until pipes.size -1) {
|
|
|
+ //低楼层管道
|
|
|
+ val lowerPipes = pipes[index].filter { d -> d.riserState == 2 || d.riserState == 3 }
|
|
|
+ //高楼层管道
|
|
|
+ val higherPipes = pipes[index+1].filter { d -> d.riserState == 1 || d.riserState == 3 }
|
|
|
+ for (lowerPipe in lowerPipes) {
|
|
|
+ val itemList = ArrayList<String>()
|
|
|
+ //允许的距离误差范围
|
|
|
+ val distance = lowerPipe.diameter!! /2
|
|
|
+ val lpoint = lowerPipe.location?.points?.get(0) ?: continue
|
|
|
+ for (higherPipe in higherPipes) {
|
|
|
+ val hpoint = higherPipe.location?.points?.get(0)
|
|
|
+ if(hpoint != null){
|
|
|
+ // 求两个点的距离 是否在允许的误差范围内
|
|
|
+ val connected = sqrt((lpoint.x - hpoint.x).pow(2.0) + (lpoint.y - hpoint.y).pow(2.0)) < distance
|
|
|
+ if(connected){
|
|
|
+ itemList.add(higherPipe.id!!)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(itemList.size > 0){
|
|
|
+ itemMap[lowerPipe.id!!] = itemList
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return itemMap
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
} // Class CalcSpecialService
|