Browse Source

根据模型空间id查询设备信息bug修复

linhuili 3 years ago
parent
commit
3303d48c77

+ 0 - 6
scanbuilding/src/main/kotlin/com/persagy/server/services/task/ModelScanTaskService.kt

@@ -60,7 +60,6 @@ import com.persagy.service.models.responses.SQueryResponse
 import com.persagy.service.utils.SSpringContextUtil
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.util.StringUtils
 import org.springframework.web.bind.annotation.RequestBody
 import java.util.*
 import java.util.stream.Collectors
@@ -746,9 +745,7 @@ object ModelScanTaskService : RService<ModelScanTask>(SMybatisDao(ModelScanTask:
         //查询设备信息
         var equipRequest = SQueryRequest()
         val filters = StringBuilder()
-       // filters.append("bimLocation  is not null and ")
         filters.append("modelId = '$modelId' ")
-       // filters.append("taskState is null or taskState = 0 or taskState =-1 ")
         equipRequest.filters = filters.toString();
         equipRequest.orders = "createTime desc , id desc"
         val equipmentList = admBaseService?.queryEquip(equipRequest)
@@ -783,7 +780,6 @@ object ModelScanTaskService : RService<ModelScanTask>(SMybatisDao(ModelScanTask:
                 if(taskState != null && (taskState != 0 || taskState != -1)){
                     continue
                 }
-
                 val bimLocalJson = equip.locationJson
                 val node = JsonNodeFactory.instance.objectNode()
                 if (bimLocalJson != null) {
@@ -815,10 +811,8 @@ object ModelScanTaskService : RService<ModelScanTask>(SMybatisDao(ModelScanTask:
         //查询设备信息
         var equipRequest = SQueryRequest()
         val filters = StringBuilder()
-        // filters.append("bimLocation  is not null and ")
         filters.append("classCode = '$category' and ")
         filters.append("modelId = '$modelId' ")
-        // filters.append("taskState is null or taskState = 0 or taskState =-1 ")
         equipRequest.filters = filters.toString();
         equipRequest.orders = "createTime desc , id desc"
         val equipmentList = admBaseService?.queryEquip(equipRequest)

+ 53 - 113
scanbuilding/src/main/kotlin/com/persagy/server/util/GeoToolsUtil.kt

@@ -1,15 +1,14 @@
-package com.persagy.server.util;
-
-import cn.hutool.core.collection.CollUtil;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.persagy.server.datacenter.models.entities.assistant.PointPosition;
-import org.geotools.geometry.jts.JTSFactoryFinder;
-import org.locationtech.jts.geom.*;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
+package com.persagy.server.util
 
+import org.geotools.geometry.jts.JTSFactoryFinder
+import org.locationtech.jts.geom.LinearRing
+import cn.hutool.core.collection.CollUtil
+import com.fasterxml.jackson.databind.node.ObjectNode
+import com.persagy.server.datacenter.models.entities.assistant.PointPosition
+import org.locationtech.jts.geom.Coordinate
+import org.locationtech.jts.geom.Point
+import org.locationtech.jts.geom.Polygon
+import kotlin.collections.ArrayList
 
 /**
  * @ClassName GeoToolsUtil
@@ -17,74 +16,59 @@ import java.util.List;
  * @Author linhuili
  * @Date 2021/9/3 20:31
  * @Version V1.0
- **/
-public class GeoToolsUtil {
+ */
+object 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();
+    private fun createPoint(pointLocal: ObjectNode): Point {
+        var x = 0.0
+        var y = 0.0
+        val z = 0.0
+        if (pointLocal["X"] != null) {
+            x = pointLocal["X"].doubleValue()
         }
-        if(pointLocal.get("Y") != null){
-            y = pointLocal.get("Y").doubleValue();
+        if (pointLocal["Y"] != null) {
+            y = pointLocal["Y"].doubleValue()
         }
-        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
-        Coordinate coord = new Coordinate(x, y,z);
-        Point point = geometryFactory.createPoint(coord);
-        return point;
+        val geometryFactory = JTSFactoryFinder.getGeometryFactory()
+        val coord = Coordinate(x, y, z)
+        return geometryFactory.createPoint(coord)
     }
 
     /**
      * 创建面
      * @param outLines
      */
-    private static Polygon createPolygon(ArrayList<ArrayList<PointPosition>> outLines){
-        ArrayList<PointPosition> pointPositions = outLines.get(0);
-        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
-        List<Coordinate> objects = new ArrayList<>();
-        for (PointPosition outLine : pointPositions) {
-            double x = outLine.getX();
-            double y = outLine.getY();
-            double z = outLine.getZ();
-            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);
+    private fun createPolygon(outLines: ArrayList<ArrayList<PointPosition>>?): Polygon {
+        val pointPositions = outLines?.get(0)
+        val geometryFactory = JTSFactoryFinder.getGeometryFactory()
+        val objects: MutableList<Coordinate> = ArrayList()
+        for (outLine in pointPositions!!) {
+            var x = 0.0
+            if(outLine.x != null){
+                x = outLine.x!!
+            }
+            var y = 0.0
+            if(outLine.y != null){
+                y = outLine.y!!
+            }
 
-        return polygon;
-    }
+            var z = 0.0
+            if(outLine.z!= null){
+                z = outLine.z!!
+            }
+            val coordinate = Coordinate(x, y, z)
+            objects.add(coordinate)
 
 
-    /**
-     * 创建面
-     * @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;
+        val coordinates = objects.toTypedArray()
+        val ring = geometryFactory.createLinearRing(coordinates)
+        val holes: Array<LinearRing>? = null
+        return geometryFactory.createPolygon(ring, holes)
     }
 
     /**
@@ -94,60 +78,16 @@ public class GeoToolsUtil {
      * @param outLines 轮廓线
      * @return
      */
-    public static Boolean isPointInPoly(ObjectNode pointLocal, List<LinkedHashMap<String,Object>> outLines) {
-        if (null==pointLocal || CollUtil.isEmpty(outLines)){
-            return false;
+    fun isPointInPoly(pointLocal: ObjectNode?, outLines: ArrayList<ArrayList<PointPosition>>?): Boolean {
+        if (null == pointLocal || CollUtil.isEmpty(outLines)) {
+            return false
         }
         //创建点
-        Point point = createPoint(pointLocal);
+        val point = createPoint(pointLocal)
         //创建面
-        Polygon polygon = createPolygon(outLines);
+        val polygon = createPolygon(outLines)
         //判断点面包含关系
-        return polygon.contains(point);
+        return polygon.contains(point)
     }
 
-
-    /**
-     * 点面包含关系判断
-     * 用途:判断一个面是否包含一个点,即一个点是否在一个面内
-     * @param pointLocal 坐标点
-     * @param outLines 轮廓线
-     * @return
-     */
-    public static Boolean isPointInPoly(ObjectNode pointLocal, ArrayList<ArrayList<PointPosition>> 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);
-    }
-}
+}

+ 3 - 3
scheduler/src/main/resources-dev/application.yml

@@ -71,10 +71,10 @@ spring:
     #password: admin
     #non-blocking-redelivery: true
 
-  jms:
-    pub-sub-domain: true
+    #jms:
+  #  pub-sub-domain: true
 
-topic:                                 datacenter.broadcast
+#topic:                                 datacenter.broadcast
 
 mybatis:
   typeAliasesPackage:                   cn.sagacloud.server.datacenter.entities