Jelajahi Sumber

重做重叠点检查算法,改为street索引+并查集的方式,用于快速检索出按浮动值分组的重复点

欧阳劲驰 3 minggu lalu
induk
melakukan
552e3ede4a

+ 10 - 6
src/main/java/com/shkpr/service/alambizplugin/bizservice/GisSurveySystemCheckBizService.java

@@ -15,6 +15,7 @@ import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyProjectInfo
 import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveySystemCheckDefineService;
 import com.shkpr.service.alambizplugin.dto.CommAsyncCache;
 import com.shkpr.service.alambizplugin.dto.CommAsyncResult;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckDefine;
 import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
 import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResultDetail;
 import org.apache.commons.collections4.CollectionUtils;
@@ -114,7 +115,8 @@ public class GisSurveySystemCheckBizService {
         //回填元素更新时间
         params.setRefreshTime(refreshTime);
         //获取支持检查项
-        List<String> supportedKeys = systemCheckDefineService.findKeys();
+        List<GisSurveySystemCheckDefine> systemCheckDefines = systemCheckDefineService.findAll();
+        List<String> supportedKeys = systemCheckDefines.stream().map(GisSurveySystemCheckDefine::getKey).collect(Collectors.toList());
         //对入参取交集
         params.getSubitemKeys().retainAll(supportedKeys);
         //设置启动项
@@ -141,7 +143,7 @@ public class GisSurveySystemCheckBizService {
 
         //启动检查任务
         if (Boolean.TRUE.equals(params.getCheckStart()) && CollectionUtils.isNotEmpty(params.getStartSubitemKeys())) {
-            startTask(systemCheckId, params);
+            startTask(systemCheckId, params, systemCheckDefines);
             //如需要返回上次结果,则直接返回结果
             if (Boolean.TRUE.equals(params.getReturnLastResult())) return fileResult;
             //返回进行中
@@ -269,17 +271,19 @@ public class GisSurveySystemCheckBizService {
     /**
      * 启动任务
      *
-     * @param systemCheckId 系统检查id
-     * @param params        检查参数
+     * @param systemCheckId      系统检查id
+     * @param params             检查参数
+     * @param systemCheckDefines 系统检查定义
      */
-    private void startTask(GisSurveySystemCheckId systemCheckId, GisSurveyCheckParams params) {
+    private void startTask(GisSurveySystemCheckId systemCheckId, GisSurveyCheckParams params, List<GisSurveySystemCheckDefine> systemCheckDefines) {
         //获取已存在的任务
         ListenableFuture<CommAsyncResult<Map<String, GisSurveySystemCheckResultDetail>>> previousFuture = TASK_CACHE.get(systemCheckId);
         //已结束判断,删除缓存
         if (previousFuture != null && (previousFuture.isDone() || previousFuture.isCancelled()))
             removeCache(systemCheckId);
         //异步执行系统检查任务
-        ListenableFuture<CommAsyncResult<Map<String, GisSurveySystemCheckResultDetail>>> future = systemChecker.systemCheckTask(params,
+        ListenableFuture<CommAsyncResult<Map<String, GisSurveySystemCheckResultDetail>>> future = systemChecker.systemCheckTask(
+                params, systemCheckDefines,
                 //缓存子任务句柄
                 subtask -> SUBTASK_CACHE.put(systemCheckId, subtask),
                 //删除子任务句柄

+ 10 - 3
src/main/java/com/shkpr/service/alambizplugin/components/GisSurveySystemChecker.java

@@ -20,6 +20,7 @@ import com.shkpr.service.alambizplugin.dbdao.services.intef.TypeDefineService;
 import com.shkpr.service.alambizplugin.dto.CommAsyncResult;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckDefine;
 import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
 import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResultDetail;
 import com.shkpr.service.alambizplugin.dto.TypeDefine;
@@ -36,6 +37,7 @@ import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ExecutionException;
 import java.util.function.Consumer;
 
@@ -89,13 +91,14 @@ public class GisSurveySystemChecker {
      * 系统检查任务
      *
      * @param params              系统检查参数
+     * @param systemCheckDefines  系统检查定义
      * @param onStartSubtask      启动子任务
      * @param onDeprecatedSubtask 弃用子任务(完成数据收集/取消)
      * @return 系统检查返回
      */
     @Async
     public ListenableFuture<CommAsyncResult<Map<String, GisSurveySystemCheckResultDetail>>> systemCheckTask(
-            GisSurveyCheckParams params
+            GisSurveyCheckParams params, List<GisSurveySystemCheckDefine> systemCheckDefines
             , Consumer<Map<String, ListenableFuture<GisSurveySystemCheckResultDetail>>> onStartSubtask
             , Consumer<GisSurveySystemCheckId> onDeprecatedSubtask) {
         //系统检查id
@@ -145,9 +148,13 @@ public class GisSurveySystemChecker {
                 points = gisSurveyLayerApplyService.findAddPointByJobId(systemCheckId.getCode());
                 lines = gisSurveyLayerApplyService.findAddLineByJobId(systemCheckId.getCode());
             }
+
             //查询经纬度类型定义
             List<TypeDefine> typeDefines = typeDefineService.findLatLng();
-
+            //重复点定义
+            GisSurveySystemCheckDefine duplicatePointsDefine = systemCheckDefines.stream().
+                    filter(it -> Objects.equals(GisSurveySystemCheckKeys.DUPLICATE_POINTS, it.getKey()))
+                    .findFirst().orElse(null);
 
             //结果flag
             final String FLAG = systemCheckId.getFlag();
@@ -175,7 +182,7 @@ public class GisSurveySystemChecker {
             //重复点检查
             if (points != null) {
                 if (params.getStartSubitemKeys().contains(GisSurveySystemCheckKeys.DUPLICATE_POINTS)) {
-                    duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines, systemCheckId);
+                    duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines, duplicatePointsDefine, systemCheckId);
                     subtask.put(GisSurveySystemCheckKeys.DUPLICATE_POINTS, duplicatePointsFuture);
                 }
             }

+ 217 - 37
src/main/java/com/shkpr/service/alambizplugin/components/checker/DuplicatePointsFinder.java

@@ -9,18 +9,15 @@ import com.shkpr.service.alambizplugin.constants.GisMetadataDefine;
 import com.shkpr.service.alambizplugin.constants.GisSurveyExcelDefine;
 import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckKeys;
 import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultHead;
+import com.shkpr.service.alambizplugin.constants.GisSurveyTemplateDefine;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
-import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate;
-import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
-import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckElement;
-import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckId;
-import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResultDetail;
-import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportElement;
-import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResultDetail;
-import com.shkpr.service.alambizplugin.dto.TypeDefine;
+import com.shkpr.service.alambizplugin.dto.*;
 import com.shkpr.service.alambizplugin.exception.UncheckedInterruptedException;
 import org.apache.commons.lang3.StringUtils;
 import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.index.strtree.STRtree;
+import org.locationtech.jts.util.NumberUtil;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.AsyncResult;
 import org.springframework.stereotype.Component;
@@ -29,9 +26,12 @@ import org.springframework.util.concurrent.ListenableFuture;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
@@ -134,53 +134,106 @@ public class DuplicatePointsFinder {
      *
      * @param points      点集合
      * @param typeDefines 类型定义
+     * @param define      系统检查定义
      * @return 重复点
      */
     @Async
     public ListenableFuture<GisSurveySystemCheckResultDetail> findDuplicatePoints(List<GisSurveyLayerApplyPoint> points
-            , List<TypeDefine> typeDefines, GisSurveySystemCheckId systemCheckId) throws InterruptedException {
+            , List<TypeDefine> typeDefines, GisSurveySystemCheckDefine define, GisSurveySystemCheckId systemCheckId) throws InterruptedException {
         //经纬度精度
-        int lonScale = getScale(typeDefines, LNG_KEY);
+        int lngScale = getScale(typeDefines, LNG_KEY);
         int latScale = getScale(typeDefines, LAT_KEY);
+        //偏差集合
+        List<GisSurveySystemCheckDeviation> deviations = define != null ? define.getDeviation() : Collections.emptyList();
+        //经纬度公差
+        double lngTolerance = deviations.stream()
+                .filter(deviation -> Objects.equals(GisSurveyTemplateDefine.LNG, deviation.getProperty()))
+                .map(GisSurveySystemCheckDeviation::getTolerance)
+                .findFirst().orElse(0d);
+        double latTolerance = deviations.stream()
+                .filter(deviation -> Objects.equals(GisSurveyTemplateDefine.LAT, deviation.getProperty()))
+                .map(GisSurveySystemCheckDeviation::getTolerance)
+                .findFirst().orElse(0d);
+        //高程公差
+        double elevationTolerance = deviations.stream()
+                .filter(deviation -> Objects.equals(GisSurveyTemplateDefine.ELEVATION, deviation.getProperty()))
+                .map(GisSurveySystemCheckDeviation::getTolerance)
+                .findFirst().orElse(0d);
 
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName,
-                String.format("开始执行寻找重复点 经度精度:%s 纬度精度:%s   ======>", lonScale, latScale));
+                String.format("开始执行寻找重复点 经度精度:%s 纬度精度:%s 经度公差:%s 纬度公差:%s 高程公差:%s  ======>",
+                        lngScale, latScale, lngTolerance, latTolerance, elevationTolerance));
         long begin = System.currentTimeMillis();
 
-        try {
-            //根据经纬度分组
-            Map<String, List<GisSurveyLayerApplyPoint>> keyToPoints = points.parallelStream()
-                    //响应中断
-                    .peek(it -> {
-                        if (Thread.currentThread().isInterrupted())
-                            throw new UncheckedInterruptedException(new InterruptedException());
-                    })
-                    .collect(Collectors.groupingBy(point -> {
-                        //抹去经纬度精度,并设置为分组条件
-                        Coordinate coordinate = point.getGis().getCoordinate();
-                        BigDecimal bdLon = new BigDecimal(Double.toString(coordinate.getX())).setScale(lonScale, RoundingMode.DOWN);
-                        BigDecimal bdLat = new BigDecimal(Double.toString(coordinate.getY())).setScale(latScale, RoundingMode.DOWN);
-                        return String.format("%s%s%s", bdLon.toPlainString(), bdLat.toPlainString(), point.getElevation());
-                    }, Collectors.toList()));
+        //创建空间索引
+        STRtree tree = new STRtree();
+        //元素存入索引
+        for (GisSurveyLayerApplyPoint point : points) {
+            if (point.getGis() == null) continue;
+            tree.insert(
+                    calcEnvelope(point.getGis().getCoordinate(), lngScale, latScale, lngTolerance, latTolerance),
+                    point
+            );
+        }
+        tree.build();
+
+        //创建并查集
+        UnionFind uf = new UnionFind(points);
+
+        //遍历点元素,并合并并查集
+        for (GisSurveyLayerApplyPoint point1 : points) {
+            if (point1.getGis() == null) continue;
             //响应中断
             if (Thread.interrupted()) throw new InterruptedException();
-            //并行流寻找重复点
-            List<List<GisSurveySystemCheckElement>> groupElements = keyToPoints.values().parallelStream()
+
+            //查询索引内元素
+            List<?> candidates = tree.query(calcEnvelope(
+                    point1.getGis().getCoordinate(),
+                    lngScale, latScale,
+                    lngTolerance, latTolerance));
+            for (Object candidate : candidates) {
+                GisSurveyLayerApplyPoint point2 = (GisSurveyLayerApplyPoint) candidate;
+                //排除code相同的元素
+                if (Objects.equals(point1.getCode(), point2.getCode()) || point2.getGis() == null) continue;
+                //响应中断
+                if (Thread.interrupted()) throw new InterruptedException();
+                //判断是否完全重叠
+                if (calcFullOverlap(point1, point2, lngScale, latScale, lngTolerance, latTolerance, elevationTolerance)) {
+                    //合并重叠点
+                    uf.union(point1.getCode(), point2.getCode());
+                }
+            }
+        }
+
+        //按并查集结果分组
+        Map<Integer, List<GisSurveySystemCheckElement>> groupMap = new HashMap<>();
+        for (GisSurveyLayerApplyPoint point : points) {
+            if (point.getGis() == null) continue;
+            //响应中断
+            if (Thread.interrupted()) throw new InterruptedException();
+            //获取并查集的索引
+            Integer index = uf.getIndex(point.getCode());
+            if (index == null) continue;
+            //获取父节点的索引
+            int root = uf.find(index);
+            //获取当前父节点组
+            List<GisSurveySystemCheckElement> group = groupMap
+                    .computeIfAbsent(root, k -> new ArrayList<>());
+            //填入当前元素
+            group.add(BeanUtil.copy(point, GisSurveySystemCheckElement.class));
+        }
+
+        try {
+            //并行流过滤大于2的元素
+            List<List<GisSurveySystemCheckElement>> collect = groupMap.values().parallelStream()
                     //响应中断
                     .peek(it -> {
                         if (Thread.currentThread().isInterrupted())
                             throw new UncheckedInterruptedException(new InterruptedException());
                     })
-                    //过滤组内大于1
-                    .filter(group -> group.size() > 1)
-                    //转为返回元素
-                    .map(group -> group.stream()
-                            .map(point -> BeanUtil.copy(point, GisSurveySystemCheckElement.class))
-                            .collect(Collectors.toList())
-                    )
+                    .filter(it -> it.size() > 1)
                     .collect(Collectors.toList());
-
-            return new AsyncResult<>(createResult(groupElements, systemCheckId, begin));
+            return new AsyncResult<>(createResult(collect, systemCheckId, begin));
         } catch (UncheckedInterruptedException e) {
             throw e.getCause();
         }
@@ -214,6 +267,59 @@ public class DuplicatePointsFinder {
     }
 
     /**
+     * 计算边界
+     *
+     * @param coordinate   坐标
+     * @param lngScale     经度精度
+     * @param latScale     经度精度
+     * @param lngTolerance 经度公差
+     * @param latTolerance 纬度公差
+     * @return 边界
+     */
+    private Envelope calcEnvelope(Coordinate coordinate, int lngScale, int latScale, double lngTolerance, double latTolerance) {
+        //抹去经纬度精度
+        BigDecimal bdLng = new BigDecimal(Double.toString(coordinate.getX())).setScale(lngScale, RoundingMode.DOWN);
+        BigDecimal bdLat = new BigDecimal(Double.toString(coordinate.getY())).setScale(latScale, RoundingMode.DOWN);
+
+        //计算公差边界
+        double minX = bdLng.subtract(BigDecimal.valueOf(lngTolerance)).doubleValue();
+        double maxX = bdLng.add(BigDecimal.valueOf(lngTolerance)).doubleValue();
+        double minY = bdLat.subtract(BigDecimal.valueOf(latTolerance)).doubleValue();
+        double maxY = bdLat.add(BigDecimal.valueOf(latTolerance)).doubleValue();
+
+        return new Envelope(minX, maxX, minY, maxY);
+    }
+
+    /**
+     * 计算完全重叠
+     *
+     * @param point1             点1
+     * @param point2             点2
+     * @param lngScale           经度精度
+     * @param latScale           经度精度
+     * @param lngTolerance       经度公差
+     * @param latTolerance       纬度公差
+     * @param elevationTolerance 高程公差
+     * @return 重叠状态
+     */
+    private boolean calcFullOverlap(GisSurveyLayerApplyPoint point1, GisSurveyLayerApplyPoint point2
+            , int lngScale, int latScale
+            , double lngTolerance, double latTolerance, double elevationTolerance) {
+        //获取点1xyz
+        double x1 = BigDecimal.valueOf(point1.getGis().getX()).setScale(lngScale, RoundingMode.DOWN).doubleValue();
+        double y1 = BigDecimal.valueOf(point1.getGis().getY()).setScale(latScale, RoundingMode.DOWN).doubleValue();
+        double z1 = point1.getElevation();
+        //获取点2xyz
+        double x2 = BigDecimal.valueOf(point2.getGis().getX()).setScale(lngScale, RoundingMode.DOWN).doubleValue();
+        double y2 = BigDecimal.valueOf(point2.getGis().getY()).setScale(latScale, RoundingMode.DOWN).doubleValue();
+        double z2 = point2.getElevation();
+        //比较xyz
+        if (!NumberUtil.equalsWithTolerance(x1, x2, lngTolerance)) return false;
+        if (!NumberUtil.equalsWithTolerance(y1, y2, latTolerance)) return false;
+        return NumberUtil.equalsWithTolerance(z1, z2, elevationTolerance);
+    }
+
+    /**
      * 创建结果
      *
      * @param data          数据
@@ -265,4 +371,78 @@ public class DuplicatePointsFinder {
                     return map;
                 })).collect(Collectors.toList());
     }
+
+    /**
+     * 并查集最
+     * <p>简单的实现</p>
+     */
+    private static class UnionFind {
+        // 点标识符(code)到索引的映射
+        private final Map<String, Integer> indexMapping = new HashMap<>();
+        //父节点信息
+        private final int[] parent;
+        //树高度
+        private final short[] rank;
+
+        public UnionFind(List<GisSurveyLayerApplyPoint> points) {
+            //过滤有效点
+            List<GisSurveyLayerApplyPoint> validPoints = points.stream()
+                    .filter(p -> p.getGis() != null)
+                    .collect(Collectors.toList());
+            //初始化关系和树高度
+            parent = new int[validPoints.size()];
+            rank = new short[validPoints.size()];
+            //初始化,每个节点的父节点是自己
+            for (int i = 0; i < validPoints.size(); i++) {
+                parent[i] = i;
+                rank[i] = 0;
+                indexMapping.put(validPoints.get(i).getCode(), i);
+            }
+        }
+
+        /**
+         * 查找根节点
+         *
+         * @param i 当前节点索引
+         * @return 根结点
+         */
+        public int find(int i) {
+            //路径压缩
+            if (parent[i] != i) parent[i] = find(parent[i]);
+            return parent[i];
+        }
+
+        /**
+         * 获取索引
+         *
+         * @param code 节点code
+         * @return 并查集索引
+         */
+        public Integer getIndex(String code) {
+            return indexMapping.get(code);
+        }
+
+        /**
+         * 合并两个节点关系
+         *
+         * @param code1 节点1的code
+         * @param code2 节点2的code
+         */
+        public void union(String code1, String code2) {
+            //获取索引
+            int i1 = indexMapping.get(code1);
+            int i2 = indexMapping.get(code2);
+            //获取根节点
+            int root1 = find(i1);
+            int root2 = find(i2);
+            // 已在同一根节点
+            if (root1 == root2) return;
+            //按秩合并,如 当前根秩 大于 目标根秩,则 目标根 为 当前根 的下游线
+            if (rank[root1] > rank[root2]) parent[root2] = root1;
+            else {
+                parent[root1] = root2;
+                if (rank[root1] == rank[root2]) rank[root2]++;
+            }
+        }
+    }
 }

+ 1 - 1
src/main/java/com/shkpr/service/alambizplugin/components/checker/IsolatedLinesFinder.java

@@ -182,7 +182,7 @@ public class IsolatedLinesFinder {
         }
 
         /**
-         * 更新节点对应的根线映射
+         * 更新节点对应的根线映射
          *
          * @param node        节点
          * @param currentRoot 当前节点的根线

+ 21 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveyTemplateDefine.java

@@ -0,0 +1,21 @@
+package com.shkpr.service.alambizplugin.constants;
+
+/**
+ * 模版定义
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public interface GisSurveyTemplateDefine {
+    String LAYER = "layer";
+    String CODE = "code";
+    String NO = "no";
+    String UP_NO = "up_no";
+    String DOWN_NO = "down_no";
+    String LNG = "lng";
+    String LAT = "lat";
+    String UP_NODE = "up_node";
+    String DOWN_NODE = "down_node";
+    String ELEVATION = "elevation";
+    String DEPTH = "depth";
+}

+ 1 - 1
src/main/java/com/shkpr/service/alambizplugin/controllerserializer/GeometryDeserializer.java

@@ -25,7 +25,7 @@ public class GeometryDeserializer extends JsonDeserializer<Geometry> {
     public Geometry deserialize(JsonParser p, DeserializationContext ctx) throws IOException {
         try {
             //读取GeoJson并转换为Geom
-            return new GeoJsonReader().read(p.getValueAsString());
+            return new GeoJsonReader().read(p.readValueAsTree().toString());
         } catch (ParseException e) {
             log.error("反序列化geom异常:{}", e.getMessage());
             return null;

+ 4 - 3
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveySystemCheckDefineMapper.java

@@ -1,5 +1,6 @@
 package com.shkpr.service.alambizplugin.dbdao.mapper;
 
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckDefine;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -13,9 +14,9 @@ import java.util.List;
 @Mapper
 public interface GisSurveySystemCheckDefineMapper {
     /**
-     * 获取key集合
+     * 获取全部
      *
-     * @return key集合
+     * @return 系统检查定义集合
      */
-    List<String> findKeys();
+    List<GisSurveySystemCheckDefine> findAll();
 }

+ 5 - 4
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveySystemCheckDefineServiceImpl.java

@@ -2,6 +2,7 @@ package com.shkpr.service.alambizplugin.dbdao.services;
 
 import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveySystemCheckDefineMapper;
 import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveySystemCheckDefineService;
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckDefine;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -22,12 +23,12 @@ public class GisSurveySystemCheckDefineServiceImpl implements GisSurveySystemChe
     }
 
     /**
-     * 获取key集合
+     * 获取全部
      *
-     * @return key集合
+     * @return 系统检查定义集合
      */
     @Override
-    public List<String> findKeys() {
-        return systemCheckDefineMapper.findKeys();
+    public List<GisSurveySystemCheckDefine> findAll() {
+        return systemCheckDefineMapper.findAll();
     }
 }

+ 5 - 3
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveySystemCheckDefineService.java

@@ -1,5 +1,7 @@
 package com.shkpr.service.alambizplugin.dbdao.services.intef;
 
+import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckDefine;
+
 import java.util.List;
 
 /**
@@ -10,9 +12,9 @@ import java.util.List;
  */
 public interface GisSurveySystemCheckDefineService {
     /**
-     * 获取key集合
+     * 获取全部
      *
-     * @return key集合
+     * @return 系统检查定义集合
      */
-    List<String> findKeys();
+    List<GisSurveySystemCheckDefine> findAll();
 }

+ 19 - 12
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckDefine.java

@@ -2,38 +2,45 @@ package com.shkpr.service.alambizplugin.dto;
 
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * 系统检查项定义
  */
 @Data
 public class GisSurveySystemCheckDefine {
     /**
-    * 检查项key
-    */
+     * 检查项key
+     */
     private String key;
 
     /**
-    * 检查项名称
-    */
+     * 检查项名称
+     */
     private String name;
 
     /**
-    * 相关函数(预留备用)
-    */
+     * 相关函数(预留备用)
+     */
     private String functions;
 
     /**
-    * 相关参数(预留备用)
-    */
+     * 相关参数(预留备用)
+     */
     private String params;
 
     /**
-    * 详细描述
-    */
+     * 详细描述
+     */
     private String remarks;
 
     /**
-    * 显示顺序
-    */
+     * 显示顺序
+     */
     private Short ordering;
+
+    /**
+     * 有关偏差浮动值
+     */
+    private List<GisSurveySystemCheckDeviation> deviation;
 }

+ 25 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckDeviation.java

@@ -0,0 +1,25 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 系统检查浮动值
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class GisSurveySystemCheckDeviation {
+    /**
+     * 属性
+     */
+    private String property;
+    /**
+     * 公差
+     */
+    private Double tolerance;
+}

+ 15 - 3
src/main/resources/mapper/GisSurveySystemCheckDefineMapper.xml

@@ -9,10 +9,22 @@
         <result column="params" jdbcType="VARCHAR" property="params"/>
         <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
         <result column="ordering" jdbcType="SMALLINT" property="ordering"/>
+        <collection property="deviation" ofType="com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckDeviation">
+            <result column="deviation_property" jdbcType="VARCHAR" property="property"/>
+            <result column="deviation_tolerance" jdbcType="SMALLINT" property="tolerance"/>
+        </collection>
     </resultMap>
 
-    <select id="findKeys" resultType="java.lang.String">
-        select key
-        from k3_gis_survey_system_check_define
+    <select id="findAll" resultMap="BaseResultMap">
+        select key,
+               name,
+               functions,
+               params,
+               remarks,
+               ordering,
+               d ->> 'property'  as deviation_property,
+               d ->> 'tolerance' as deviation_tolerance
+        from k3_gis_survey_system_check_define scd
+                 left join jsonb_array_elements((coalesce(nullif(scd.deviation, '')::jsonb, '[]'::jsonb))) as d on true
     </select>
 </mapper>