Browse Source

查询当前模型文件下指定元空间内的设备sql转换

linhuili 3 years ago
parent
commit
eacc7f113a

+ 5 - 0
.idea/jarRepositories.xml

@@ -46,5 +46,10 @@
       <option name="name" value="maven4" />
       <option name="url" value="http://47.93.132.139:8081/nexus/content/groups/public/" />
     </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven7" />
+      <option name="name" value="maven7" />
+      <option name="url" value="https://repo.osgeo.org/repository/release/" />
+    </remote-repository>
   </component>
 </project>

+ 5 - 3
data-core/src/main/kotlin/com/persagy/server/datacenter/models/entities/objects/ZoneIspace.kt

@@ -30,7 +30,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
 import com.persagy.server.datacenter.models.entities.assistant.PointPosition
 import com.persagy.server.datacenter.models.entities.base.BaseInfo
 import io.swagger.v3.oas.annotations.media.Schema
-import java.util.*
 import javax.persistence.Column
 import javax.persistence.Id
 import javax.persistence.Table
@@ -155,8 +154,11 @@ open class ZoneIspace : BaseInfo() {
     @Column(name = "model_id")
     var modelId: String? = null
 
+   // @Schema(description = "轮廓线")
+   // @Column(name = "outline")
+    //var outline: ArrayList<ArrayList<PointPosition>>? = null
+
     @Schema(description = "轮廓线")
-    @Column(name = "outline")
-    var outline: ArrayList<ArrayList<PointPosition>>? = null
+    val outLine: List<LinkedHashMap<String, Any>>? = null
 
 }

+ 2 - 0
gradle.properties

@@ -28,6 +28,8 @@ MAVEN_REPO_PUBLIC_URL = http://dev.dp.sagacloud.cn:8082/repository/maven-public/
 MAVEN_REPO_RELEASE_URL = http://dev.dp.sagacloud.cn:8082/repository/maven-releases/
 MAVEN_REPO_SNAPSHOT_URL = http://dev.dp.sagacloud.cn:8082/repository/maven-snapshots/
 
+MAVEN_REPO_GEO_SNAPSHOT_URL = https://repo.osgeo.org/repository/release/
+
 NEXUS_USERNAME = admin
 NEXUS_PASSWORD = 123qwe!@#
 

+ 2 - 0
scanbuilding/build.gradle

@@ -44,6 +44,7 @@ compileTestKotlin {
 repositories {
     maven{url MAVEN_REPO_NEXUS_PUBLIC_URL}
     maven{url MAVEN_REPO_NEXUS_RELEASE_URL}
+    maven{url MAVEN_REPO_GEO_SNAPSHOT_URL}
     mavenCentral()
     jcenter()
 }
@@ -110,6 +111,7 @@ dependencies {
     // Log 工具
     compile group: "org.projectlombok", name: "lombok", version: LOMBOK_VERSION
 
+    compile group: "org.geotools", name: "gt-main", version: 25.2
 //    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //    // 二维码与条形码
 //    // https://mvnrepository.com/artifact/com.google.zxing/core

+ 10 - 0
scanbuilding/src/main/kotlin/com/persagy/server/client/AdmMiddlewareClient.kt

@@ -86,4 +86,14 @@ interface AdmMiddlewareClient{
     @PostMapping(AdmMiddlewareUrlConstant.PROPERTY_UPDATE)
     fun updateProperty(@RequestHeader(defaultValue = "0" ) groupCode: String?, @RequestHeader(defaultValue = "0" ) projectId: String?, @RequestBody criteria: SUpdateRequest<Property>): SUpdateRequest<Property>?
 
+
+    /**
+     * @description: 查询元空间列表
+     * @param: objectUrlParam 对象请求url通用参数
+     * @param: criteria post请求参数
+     * @return: com.persagy.dmp.common.DmpResult
+     */
+    @PostMapping(AdmMiddlewareUrlConstant.ISPACE_QUERY)
+    fun queryIspace(@RequestHeader(defaultValue = "0" ) groupCode: String?, @RequestHeader(defaultValue = "0" ) projectId: String?,@RequestBody criteria: SQueryRequest?): SQueryResponse<JSONObject>?
+
 }

+ 5 - 0
scanbuilding/src/main/kotlin/com/persagy/server/constant/AdmMiddlewareUrlConstant.java

@@ -39,4 +39,9 @@ public class AdmMiddlewareUrlConstant {
      * 资产更新
      */
     public final static String PROPERTY_UPDATE = "/object/property/update";
+
+    /**
+     * 元空间查询
+     */
+    public final static String ISPACE_QUERY = "/object/ispace/query";
 }

File diff suppressed because it is too large
+ 4 - 4
scanbuilding/src/main/kotlin/com/persagy/server/mappers/StatisticsCountMapper.kt


+ 18 - 4
scanbuilding/src/main/kotlin/com/persagy/server/services/AdmBaseService.kt

@@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSON
 import com.alibaba.fastjson.JSONObject
 import com.persagy.server.Opts
 import com.persagy.server.client.AdmMiddlewareClient
-import com.persagy.server.datacenter.models.entities.objects.Building
-import com.persagy.server.datacenter.models.entities.objects.Component
-import com.persagy.server.datacenter.models.entities.objects.Equipment
-import com.persagy.server.datacenter.models.entities.objects.Property
+import com.persagy.server.datacenter.models.entities.objects.*
 
 import com.persagy.service.models.SCascadeQuery
 import com.persagy.service.models.requests.SQueryRequest
@@ -101,6 +98,23 @@ class AdmBaseService {
 
 
     /**
+     * 查询元空间信息
+     */
+    fun queryIspace(criteria: SQueryRequest?): List<ZoneIspace>? {
+        //查询对象信息
+        val result = admMiddlewareClient!!.queryIspace(Opts.groupCode,Opts.projectId,criteria) ?: return ArrayList()
+        if(CollUtil.isEmpty(result.content)){
+            return ArrayList<ZoneIspace>()
+        }
+        val content = ArrayList<ZoneIspace>()
+        for(obj in result.content!!){
+            val ispace = JSON.toJavaObject(obj, ZoneIspace::class.java)
+            content.add(ispace)
+        }
+        return content
+    }
+
+    /**
      * 实体属性转换
      */
     fun entityAttributeConvert(objects:List<JSONObject>): List<Equipment>? {

File diff suppressed because it is too large
+ 24 - 5
scanbuilding/src/main/kotlin/com/persagy/server/services/StatisticsCountService.kt


+ 1 - 1
scanbuilding/src/main/kotlin/com/persagy/server/services/task/EquipScanTaskQueryService.kt

@@ -189,7 +189,7 @@ object EquipScanTaskQueryService : SObjectService<EquipScanTaskQuery>(SMybatisDa
         }
         val equipIds = equipScanTaskList?.stream()?.map(EquipScanTaskQuery::equipId)?.collect(Collectors.toList<String>())
         var equipRequest = SQueryRequest()
-        equipRequest.filters = "id in "+"(\'" + java.lang.String.join("\',\'", equipIds) + "\'"
+        equipRequest.filters = "id in "+"(\'" + java.lang.String.join("\',\'", equipIds) + "\')"
 
         val requestCascade = request.cascade
         //查询级联关系

File diff suppressed because it is too large
+ 134 - 12
scanbuilding/src/main/kotlin/com/persagy/server/services/task/ModelScanTaskService.kt


+ 1 - 1
scanbuilding/src/main/kotlin/com/persagy/server/services/task/PropertyScanTaskService.kt

@@ -168,7 +168,7 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
         }
         val equipIds = equipScanTaskList?.stream()?.map(PropertyScanTask::equipId)?.collect(Collectors.toList<String>())
         var equipRequest = SQueryRequest()
-        equipRequest.filters = "id in "+"(\'" + java.lang.String.join("\',\'", equipIds) + "\'"
+        equipRequest.filters = "id in "+"(\'" + java.lang.String.join("\',\'", equipIds) + "\')"
 
         val requestCascade = request.cascade
         //查询级联关系

+ 2 - 2
scanbuilding/src/main/kotlin/com/persagy/server/services/task/ScanTaskBaseService.kt

@@ -182,13 +182,13 @@ object ScanTaskBaseService : RService<ScanTaskBase>(SMybatisDao(ScanTaskBase::cl
                 var buildingRequest = SQueryRequest()
 
                // buildingRequest.filters = "id in (" +builds!!.joinToString(",", ",", "'").substring(1) + ")"
-                buildingRequest.filters = "id in "+"(\'" + java.lang.String.join("\',\'", builds) + "\'"
+                buildingRequest.filters = "id in "+"(\'" + java.lang.String.join("\',\'", builds) + "\')"
                 buildingRequest.pageSize = 1000
                 buildingRequest.pageNumber = 1
                 var cascade = SCascadeQuery()
                 cascade.name = "floor"
                 //cascade.filters = "id in (" +floors!!.joinToString(",", ",", "'").substring(1) + ")"
-                cascade.filters = "id in "+"(\'" + java.lang.String.join("\',\'", floors) + "\'"
+                cascade.filters = "id in "+"(\'" + java.lang.String.join("\',\'", floors) + "\')"
                 buildingRequest.cascade = arrayListOf(cascade)
                 //调用adm-middleware建筑查询接口
                 val buildingList = admBaseService?.queryBuilding(buildingRequest) as ArrayList<Building>?

+ 104 - 0
scanbuilding/src/main/kotlin/com/persagy/server/util/GeoToolsUtil.java

@@ -0,0 +1,104 @@
+package com.persagy.server.util;
+
+import cn.hutool.core.collection.CollUtil;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.geotools.geometry.jts.JTSFactoryFinder;
+import org.locationtech.jts.geom.*;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+
+/**
+ * @ClassName GeoToolsUtil
+ * @Description: 点面包含关系分析
+ * @Author linhuili
+ * @Date 2021/9/3 20:31
+ * @Version V1.0
+ **/
+public class GeoToolsUtil {
+    /**
+     * 创建点
+     * @param pointLocal
+     */
+    private static Point createPoint(ObjectNode pointLocal){
+        double x =0L;
+        double y =0L;
+        double z =0L;
+        if(pointLocal.get("X") != null){
+            x =pointLocal.get("X").doubleValue();
+        }
+        if(pointLocal.get("Y") != null){
+            y = pointLocal.get("Y").doubleValue();
+        }
+        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
+        Coordinate coord = new Coordinate(x, y,z);
+        Point point = geometryFactory.createPoint(coord);
+        return point;
+    }
+
+    /**
+     * 创建面
+     * @param outLines
+     */
+    private static Polygon createPolygon(List<LinkedHashMap<String,Object>> outLines){
+        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
+        List<Coordinate> objects = new ArrayList<>();
+        for (LinkedHashMap<String,Object> outLine : outLines) {
+            double x = Double.parseDouble(outLine.getOrDefault("X",0.0D).toString());
+            double y = Double.parseDouble(outLine.getOrDefault("Y",0.0D).toString());
+            double z = 0L;
+            Coordinate coordinate = new Coordinate(x, y, z);
+            objects.add(coordinate);
+        }
+        //注意数据的闭合
+        Coordinate[] coordinates = objects.toArray(new Coordinate[0]);
+        LinearRing ring = geometryFactory.createLinearRing(coordinates);
+        LinearRing holes[] = null;
+        Polygon polygon = geometryFactory.createPolygon(ring, holes);
+
+        return polygon;
+    }
+
+    /**
+     * 点面包含关系判断
+     * 用途:判断一个面是否包含一个点,即一个点是否在一个面内
+     * @param pointLocal 坐标点
+     * @param outLines 轮廓线
+     * @return
+     */
+    public static Boolean isPointInPoly(ObjectNode pointLocal, List<LinkedHashMap<String,Object>> outLines) {
+        if (null==pointLocal || CollUtil.isEmpty(outLines)){
+            return false;
+        }
+        //创建点
+        Point point = createPoint(pointLocal);
+        //创建面
+        Polygon polygon = createPolygon(outLines);
+        //判断点面包含关系
+        return polygon.contains(point);
+    }
+    /**
+     * 点面包含关系判断
+     * 用途:判断一个面是否包含一个点,即一个点是否在一个面内
+     * @param fromOutLines: 轮廓坐标
+     * @param toOutLines: 轮廓坐标
+     * @return
+     */
+    public static Boolean isPolyInPoly(List<LinkedHashMap<String,Object>> fromOutLines,
+                                       List<LinkedHashMap<String,Object>> toOutLines) {
+        if (CollUtil.isEmpty(fromOutLines) || CollUtil.isEmpty(toOutLines)){
+            return false;
+        }
+        //创建点
+        Polygon fromPolygon = createPolygon(fromOutLines);
+        //创建面
+        Polygon toPolygon = createPolygon(toOutLines);
+        //判断面-面包含关系
+        return fromPolygon.contains(toPolygon)
+                || fromPolygon.equalsTopo(toPolygon)
+                || fromPolygon.overlaps(toPolygon)
+                || toPolygon.contains(fromPolygon);
+    }
+}