|
@@ -29,12 +29,18 @@ package com.persagy.server.services.relation_calc
|
|
|
import com.persagy.database.SFilter
|
|
|
import com.persagy.mybatis.SMybatisDao
|
|
|
import com.persagy.server.Opt
|
|
|
+import com.persagy.server.datacenter.models.entities.graphtype.MPoint
|
|
|
import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
|
|
|
import com.persagy.server.datacenter.models.entities.rel.REq2Sp
|
|
|
+import com.persagy.server.datacenter.models.entities.rel.RSp2Sp
|
|
|
import com.persagy.server.jms.RabbitMqService
|
|
|
import com.persagy.server.mappers.IRelationCalcMapper
|
|
|
+import com.persagy.server.models.`object`.TwicePoint
|
|
|
+import com.persagy.server.models.service.BaseDataService
|
|
|
import com.persagy.server.services.assistant.RUpDateEquipAndSapceService
|
|
|
+import com.persagy.server.services.base.RService
|
|
|
import com.persagy.server.services.objects.EquipmentService
|
|
|
+import com.persagy.server.services.objects.FloorService
|
|
|
import com.persagy.server.services.objects.ZoneSpaceBaseService
|
|
|
import com.persagy.server.services.rel.REq2SpService
|
|
|
import com.persagy.server.utils.IdUtils
|
|
@@ -1181,4 +1187,139 @@ open class RelationCalcService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Description: 空间交通关系
|
|
|
+ * @Param:
|
|
|
+ * @Return:
|
|
|
+ */
|
|
|
+ fun calcSp2Sp(projectId: String,buildingId: String,objectType: String,type: String):SBaseResponse{
|
|
|
+ val distance = 100.00
|
|
|
+ val floors = FloorService.select(SFilter.eq("projectId",projectId), SFilter.eq("buildingId",buildingId)).exec()
|
|
|
+ val rSp2Sps = ArrayList<RSp2Sp>()
|
|
|
+ for (floor in floors) {
|
|
|
+ if(!floor.modelId.isNullOrEmpty()){
|
|
|
+ val zoneSpaces = ZoneSpaceBaseService.select(SFilter.eq("projectId",projectId), SFilter.eq("floorId",floor.id!!), SFilter.eq("classCode",objectType)).exec()
|
|
|
+ val doors = BaseDataService.doorService.select(SFilter.eq("modelId",floor.modelId!!)).exec()
|
|
|
+ val pointList = ArrayList<TwicePoint>()
|
|
|
+
|
|
|
+ for (door in doors) {
|
|
|
+ val outline = door.outline
|
|
|
+ val point = door!!.location!!.points?.get(0)!!
|
|
|
+ if(!outline.isNullOrEmpty()){
|
|
|
+ val point1 = outline[0]!![0]
|
|
|
+ val point2 = outline[0]!![1]
|
|
|
+ val k = get_points(point1.x,point1.y,point2.x,point2.y)
|
|
|
+ var twicePoint: TwicePoint
|
|
|
+ if(k== null){
|
|
|
+ twicePoint = TwicePoint(point.x,point.y+distance,point.x,point.y-distance)
|
|
|
+ }else{
|
|
|
+// val distance = get_segment_distance(point1.x,point1.y,point2.x,point2.y)
|
|
|
+ twicePoint = get_point_by_distance(point.x,point.y,k,distance*2)
|
|
|
+ }
|
|
|
+ pointList.add(twicePoint)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ val map = HashMap<Int,ArrayList<String>>()
|
|
|
+ for (index in 0 until pointList.size) {
|
|
|
+ val mPoint1= MPoint(pointList[index].x1!!,pointList[index].y1!!,0.00)
|
|
|
+ val mPoint2= MPoint(pointList[index].x2!!,pointList[index].y2!!,0.00)
|
|
|
+ var isLocal1: Boolean
|
|
|
+ var isLocal2: Boolean
|
|
|
+
|
|
|
+ for (zoneSpace in zoneSpaces) {
|
|
|
+ val zoneOutline = zoneSpace.outline
|
|
|
+ if(zoneOutline.isNullOrEmpty()){
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ isLocal1 = CommonService.isPointInPolygonCheckWithJdkGeneralPath(mPoint1, zoneOutline?.get(0)?.get(0)!!)
|
|
|
+ isLocal2 = CommonService.isPointInPolygonCheckWithJdkGeneralPath(mPoint2, zoneOutline?.get(0)?.get(0)!!)
|
|
|
+ val spaceId = zoneSpace.id!!
|
|
|
+ if(isLocal1 || isLocal2)
|
|
|
+ if(map.containsKey(index)){
|
|
|
+ val list = map[index]!!
|
|
|
+ list.add(spaceId)
|
|
|
+ map[index] = list
|
|
|
+ }else{
|
|
|
+ map[index] = arrayListOf(spaceId)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //map遍历
|
|
|
+ for (v in map.values) {
|
|
|
+
|
|
|
+ val key = v[0] !!
|
|
|
+ if(v.size > 1){
|
|
|
+ for (index in 1 until v.size) {
|
|
|
+ val rSp2SP = RSp2Sp()
|
|
|
+ rSp2SP.id1 = key
|
|
|
+ rSp2SP.id2 = v[index]
|
|
|
+ rSp2SP.projectId = projectId
|
|
|
+ rSp2SP.sign = 1
|
|
|
+ rSp2SP.type = type
|
|
|
+ rSp2SP.zoneType = objectType
|
|
|
+ if(!rSp2Sps.contains(rSp2SP)){
|
|
|
+ rSp2Sps.add(rSp2SP)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val rSp2SpService = RService(SMybatisDao(RSp2Sp::class.java))
|
|
|
+ for (rSp2Sp in rSp2Sps) {
|
|
|
+ rSp2SpService.replace(rSp2Sp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return SBaseResponse(SResponseType.success,"")
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ fun get_points(x1: Double, y1: Double , x2: Double, y2: Double): Double?{
|
|
|
+ if (x1 == y1 && x2 == y2){
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ var k:Double? = null
|
|
|
+ // 计算当前线段的 k
|
|
|
+ if (x1 == x2){
|
|
|
+
|
|
|
+ }else{
|
|
|
+ k = (y2 - y1) / (x2 - x1)
|
|
|
+ }
|
|
|
+ var k2:Double?
|
|
|
+ //计算垂直方向的k
|
|
|
+ if (k == null){
|
|
|
+ k2 = 0.00
|
|
|
+ }else if(k == 0.00){
|
|
|
+ k2 = null
|
|
|
+ }else{
|
|
|
+ k2 = 1/k
|
|
|
+ }
|
|
|
+ return k2
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取两点之间的距离
|
|
|
+ fun get_segment_distance(x1: Double, y1: Double , x2: Double, y2: Double): Double{
|
|
|
+ val x_diff = x2 - x1
|
|
|
+ val y_diff = y2 - y1
|
|
|
+ return Math.sqrt(x_diff * x_diff + y_diff * y_diff)
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取坐标
|
|
|
+ fun get_point_by_distance(base_x: Double, base_y: Double, k: Double, distance: Double): TwicePoint {
|
|
|
+ if(k == null){
|
|
|
+ return TwicePoint(base_x, base_y + distance, base_x, base_y - distance)
|
|
|
+ }
|
|
|
+ val vector_x1 = Math.sqrt(distance * distance / (1 + k * k))
|
|
|
+ val vector_x2 = -vector_x1
|
|
|
+ val vector_y1 = k * vector_x1
|
|
|
+ val vector_y2 = k * vector_x2
|
|
|
+ return TwicePoint(base_x + vector_x1,base_y + vector_y1,base_x + vector_x2,base_y + vector_y2)
|
|
|
+ }
|
|
|
+
|
|
|
} // Class RelationCalcService
|