瀏覽代碼

系统检查增加高程差异常检查

欧阳劲驰 1 月之前
父節點
當前提交
e0b07815eb

+ 6 - 0
src/main/java/com/shkpr/service/alambizplugin/apiparam/GisSurveyCheckParams.java

@@ -80,6 +80,12 @@ public class GisSurveyCheckParams {
     private Boolean overlapLinesStart = true;
 
     /**
+     * 高程差启动
+     */
+    private Boolean elevationDiffStart = true;
+
+
+    /**
      * 元素/属性的变化时间
      * <p>系统内部用</p>
      */

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

@@ -4,6 +4,7 @@ import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
 import com.shkpr.service.alambizplugin.apiparam.GisSurveyCheckParams;
 import com.shkpr.service.alambizplugin.components.checker.DuplicatePointsFinder;
+import com.shkpr.service.alambizplugin.components.checker.ElevationDiffFinder;
 import com.shkpr.service.alambizplugin.components.checker.IsolatedLinesFinder;
 import com.shkpr.service.alambizplugin.components.checker.IsolatedPointsFinder;
 import com.shkpr.service.alambizplugin.components.checker.OverlapLinesFinder;
@@ -52,8 +53,13 @@ public class GisSurveySystemChecker {
     private final IsolatedLinesFinder isolatedLinesFinder;
     private final DuplicatePointsFinder duplicatePointsFinder;
     private final OverlapLinesFinder overlapLinesFinder;
+    private final ElevationDiffFinder elevationDiffFinder;
 
-    public GisSurveySystemChecker(GisSurveySystemCheckResultManager systemCheckResultManager, GisSurveyLayerApplyService gisSurveyLayerApplyService, TypeDefineService typeDefineService, IsolatedPointsFinder isolatedPointsFinder, IsolatedLinesFinder isolatedLinesFinder, DuplicatePointsFinder duplicatePointsFinder, OverlapLinesFinder overlapLinesFinder) {
+    public GisSurveySystemChecker(GisSurveySystemCheckResultManager systemCheckResultManager
+            , GisSurveyLayerApplyService gisSurveyLayerApplyService, TypeDefineService typeDefineService
+            , IsolatedPointsFinder isolatedPointsFinder, IsolatedLinesFinder isolatedLinesFinder
+            , DuplicatePointsFinder duplicatePointsFinder, OverlapLinesFinder overlapLinesFinder
+            , ElevationDiffFinder elevationDiffFinder) {
         mStrClassName = "GisSurveySystemChecker";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
         this.systemCheckResultManager = systemCheckResultManager;
@@ -63,6 +69,7 @@ public class GisSurveySystemChecker {
         this.isolatedLinesFinder = isolatedLinesFinder;
         this.duplicatePointsFinder = duplicatePointsFinder;
         this.overlapLinesFinder = overlapLinesFinder;
+        this.elevationDiffFinder = elevationDiffFinder;
     }
 
     /**
@@ -92,6 +99,8 @@ public class GisSurveySystemChecker {
         ListenableFuture<GisSurveySystemCheckResultDetail> duplicatePointsFuture = null;
         //重叠线任务
         ListenableFuture<GisSurveySystemCheckResultDetail> overlapLinesFuture = null;
+        //高程差任务
+        ListenableFuture<GisSurveySystemCheckResultDetail> elevationDiffFuture = null;
         //点集合
         List<GisSurveyLayerApplyPoint> points = null;
         //线集合
@@ -128,17 +137,20 @@ public class GisSurveySystemChecker {
                 if (params.getDuplicatePointsStart())
                     duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines, systemCheckId);
             }
-            //孤立线和重叠线检查
+            //孤立线\重叠线\高程差异常检查
             if (lines != null) {
                 if (params.getIsolatedLinesStart())
                     isolatedLinesFuture = isolatedLinesFinder.findIsolatedLines(lines, systemCheckId);
                 if (params.getOverlapLinesStart())
                     overlapLinesFuture = overlapLinesFinder.findOverlapLines(lines, systemCheckId);
+                if (params.getElevationDiffStart())
+                    elevationDiffFuture = elevationDiffFinder.findElevationDiff(lines, systemCheckId);
             }
 
             //返回子任务
             onStartSubtask.accept(
-                    new GisSurveySystemCheckSubtask(isolatedPointsFuture, isolatedLinesFuture, duplicatePointsFuture, overlapLinesFuture)
+                    new GisSurveySystemCheckSubtask(isolatedPointsFuture, isolatedLinesFuture, duplicatePointsFuture
+                            , overlapLinesFuture,elevationDiffFuture)
             );
 
             //等待结果,并存入返回,优先监听点相关(执行速度快且只需要点集合,优先释放点集合内存)
@@ -166,6 +178,11 @@ public class GisSurveySystemChecker {
                 final GisSurveySystemCheckResultDetail overlapLinesResult = overlapLinesFuture.get();
                 result.setOverlapLinesResult(overlapLinesResult);
             }
+            if (elevationDiffFuture != null) {
+                //监听高程差异常
+                final GisSurveySystemCheckResultDetail elevationDiffResult = elevationDiffFuture.get();
+                result.setElevationDiffResult(elevationDiffResult);
+            }
 
             //完成检查
             result.setCheckStatus(CommAsyncStatusEnum.SUCCESS.getCode());
@@ -207,6 +224,7 @@ public class GisSurveySystemChecker {
             if (isolatedLinesFuture != null) isolatedLinesFuture.cancel(true);
             if (duplicatePointsFuture != null) duplicatePointsFuture.cancel(true);
             if (overlapLinesFuture != null) overlapLinesFuture.cancel(true);
+            if (elevationDiffFuture != null) elevationDiffFuture.cancel(true);
 
             //失败信息
             result.setCheckStatus(CommAsyncStatusEnum.FAIL.getCode());

+ 146 - 0
src/main/java/com/shkpr/service/alambizplugin/components/checker/ElevationDiffFinder.java

@@ -0,0 +1,146 @@
+package com.shkpr.service.alambizplugin.components.checker;
+
+import com.global.base.log.LogLevelFlag;
+import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.alambizplugin.commtools.BeanUtil;
+import com.shkpr.service.alambizplugin.components.GisSurveySystemCheckResultManager;
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultHead;
+import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultPath;
+import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
+import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
+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.exception.UncheckedInterruptedException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.AsyncResult;
+import org.springframework.stereotype.Component;
+import org.springframework.util.concurrent.ListenableFuture;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 高程差寻找器
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Component
+public class ElevationDiffFinder {
+    /**
+     * log
+     */
+    private final String mStrClassName;
+    private final String mBizType;
+    private final GisSurveySystemCheckResultManager systemCheckResultManager;
+
+
+    public ElevationDiffFinder(GisSurveySystemCheckResultManager systemCheckResultManager) {
+        mStrClassName = "ElevationDiffFinder";
+        mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
+        this.systemCheckResultManager = systemCheckResultManager;
+    }
+
+    /**
+     * 寻找高程差异常
+     * <p>根据高程差和勘测长度判断,不涉及拓扑点</p><p>异常规则:高程差大于勘测长度</p>
+     *
+     * @param lines         线集合
+     * @param systemCheckId 系统检查id
+     * @return 高程差异常集合
+     */
+    @Async
+    public ListenableFuture<GisSurveySystemCheckResultDetail> findElevationDiff(List<GisSurveyLayerApplyLine> lines
+            , GisSurveySystemCheckId systemCheckId) throws InterruptedException {
+        try {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找高程差异常========>");
+            long begin = System.currentTimeMillis();
+
+            //并行流寻找高度差异常
+            List<GisSurveySystemCheckElement> elements = lines.parallelStream()
+                    //响应中断
+                    .peek(line -> {
+                        if (Thread.currentThread().isInterrupted())
+                            throw new UncheckedInterruptedException(new InterruptedException());
+                    })
+                    .filter(line -> {
+                        //勘测长度字符串判断
+                        if (StringUtils.isBlank(line.getSurveyLength()) && NumberUtils.isParsable(line.getSurveyLength()))
+                            return false;
+                        try {
+                            //判断高程差是否大于勘测长度
+                            return line.getElevationDiff() > Double.parseDouble(line.getSurveyLength());
+                        } catch (NumberFormatException numberFormatException) {
+                            return false;
+                        }
+                    })
+                    .map(line -> BeanUtil.copy(line, GisSurveySystemCheckElement.class))
+                    .collect(Collectors.toList());
+
+            return new AsyncResult<>(createResult(elements, systemCheckId, begin));
+        } catch (UncheckedInterruptedException e) {
+            throw e.getCause();
+        }
+    }
+
+    /**
+     * 创建结果
+     *
+     * @param data          数据
+     * @param systemCheckId 系统检查id
+     * @param begin         开始时间
+     * @return 结果
+     */
+    private GisSurveySystemCheckResultDetail createResult(List<GisSurveySystemCheckElement> data
+            , GisSurveySystemCheckId systemCheckId, long begin) {
+        //数据大小
+        final int size = data.size();
+        //结果路径
+        String resultPath = GisSurveySystemCheckResultPath.ELEVATION_DIFF;
+        //excel路径
+        String excelPath = GisSurveySystemCheckResultPath.ELEVATION_DIFF_EXCEL;
+        //写入结果
+        systemCheckResultManager.writeResult(data, systemCheckId, resultPath);
+        //写入excel
+        systemCheckResultManager.writeExcel(GisSurveySystemCheckResultHead.ELEVATION_DIFF,
+                buildExcel(data), systemCheckId, excelPath);
+
+        long end = System.currentTimeMillis();
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "结束执行寻找孤立点,用时(毫秒):%d"
+                        , (end - begin)
+                )
+        );
+
+        //构建结果
+        return new GisSurveySystemCheckResultDetail(true
+                , GisSurveySystemCheckResultPath.relativePath(systemCheckId, resultPath)
+                , GisSurveySystemCheckResultPath.relativePath(systemCheckId, excelPath)
+                , size);
+    }
+
+    /**
+     * 构建excel数据
+     *
+     * @param data 数据
+     * @return excel数据
+     */
+    private List<Map<String, Object>> buildExcel(List<GisSurveySystemCheckElement> data) {
+        return data.stream().map(element -> {
+            Map<String, Object> map = new HashMap<>();
+            map.put(GisSurveySystemCheckResultHead.KEYS.UP_NO, element.getUpNo());
+            map.put(GisSurveySystemCheckResultHead.KEYS.DOWN_NO, element.getDownNo());
+            map.put(GisSurveySystemCheckResultHead.KEYS.CODE, element.getCode());
+            map.put(GisSurveySystemCheckResultHead.KEYS.UP_NODE, element.getUpNode());
+            map.put(GisSurveySystemCheckResultHead.KEYS.DOWN_NODE, element.getDownNode());
+            map.put(GisSurveySystemCheckResultHead.KEYS.NAME, element.getName());
+            return map;
+        }).collect(Collectors.toList());
+    }
+}

+ 11 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveySystemCheckResultHead.java

@@ -51,6 +51,17 @@ public class GisSurveySystemCheckResultHead {
         put(KEYS.DOWN_NODE, "终点编码");
         put(KEYS.NAME, "类型");
     }};
+    /**
+     * 高程差异常
+     */
+    public final static Map<String, String> ELEVATION_DIFF = new LinkedHashMap<String, String>() {{
+        put(KEYS.UP_NO, "起点号");
+        put(KEYS.DOWN_NO, "终点号");
+        put(KEYS.CODE, "编码");
+        put(KEYS.UP_NODE, "起点编码");
+        put(KEYS.DOWN_NODE, "终点编码");
+        put(KEYS.NAME, "类型");
+    }};
 
     /**
      * 键

+ 8 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveySystemCheckResultPath.java

@@ -45,6 +45,14 @@ public class GisSurveySystemCheckResultPath {
      * 重叠线excel
      */
     public final static String OVERLAP_LINES_EXCEL = "overlapLines.xlsx";
+    /**
+     * 高程差异常
+     */
+    public final static String ELEVATION_DIFF = "elevationDiff.json";
+    /**
+     * 高程差异常excel
+     */
+    public final static String ELEVATION_DIFF_EXCEL = "elevationDiff.xlsx";
 
     /**
      * 获取相对路径

+ 8 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyLayerApplyLine.java

@@ -59,4 +59,12 @@ public class GisSurveyLayerApplyLine {
      * 终点号
      */
     private String downNo;
+    /**
+     * 高程差
+     */
+    private Double elevationDiff;
+    /**
+     * 勘测长度
+     */
+    private String surveyLength;
 }

+ 6 - 1
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckResult.java

@@ -71,7 +71,10 @@ public class GisSurveySystemCheckResult {
      * 重叠线结果
      */
     private GisSurveySystemCheckResultDetail overlapLinesResult = new GisSurveySystemCheckResultDetail();
-
+    /**
+     * 高程差异常结果
+     */
+    private GisSurveySystemCheckResultDetail elevationDiffResult = new GisSurveySystemCheckResultDetail();
     /**
      * 进行中
      */
@@ -89,6 +92,8 @@ public class GisSurveySystemCheckResult {
                 result.getDuplicatePointsResult().setDone(subtask.getDuplicatePointsFuture().isDone());
             if (subtask.getOverlapLinesFuture() != null)
                 result.getOverlapLinesResult().setDone(subtask.getOverlapLinesFuture().isDone());
+            if (subtask.getElevationDiffFuture() != null)
+                result.getElevationDiffResult().setDone(subtask.getElevationDiffFuture().isDone());
         }
 
         result.setCheckStatus(CommAsyncStatusEnum.IN_PROGRESS.getCode());

+ 4 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveySystemCheckSubtask.java

@@ -31,4 +31,8 @@ public class GisSurveySystemCheckSubtask {
      * 重叠线任务
      */
     private ListenableFuture<GisSurveySystemCheckResultDetail> overlapLinesFuture;
+    /**
+     * 高程差异常任务
+     */
+    private ListenableFuture<GisSurveySystemCheckResultDetail> elevationDiffFuture;
 }

+ 39 - 0
src/main/java/com/shkpr/service/alambizplugin/exception/UncheckedInterruptedException.java

@@ -0,0 +1,39 @@
+package com.shkpr.service.alambizplugin.exception;
+
+import java.util.Objects;
+
+/**
+ * 包裹一个{@link InterruptedException},用于未检查的异常
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public class UncheckedInterruptedException extends RuntimeException {
+
+    /**
+     * 构建
+     *
+     * @param message 详情消息
+     * @param cause   此{@link InterruptedException}
+     */
+    public UncheckedInterruptedException(String message, InterruptedException cause) {
+        super(message, Objects.requireNonNull(cause));
+    }
+
+    /**
+     * 构建
+     *
+     * @param cause 此{@link InterruptedException}
+     */
+    public UncheckedInterruptedException(InterruptedException cause) {
+        super(Objects.requireNonNull(cause));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public InterruptedException getCause() {
+        return (InterruptedException) super.getCause();
+    }
+}

+ 11 - 1
src/main/resources/mapper/GisSurveyLayerApplyMapper.xml

@@ -39,7 +39,7 @@
         <result column="apply" jdbcType="VARCHAR" property="apply"/>
         <result column="source" jdbcType="SMALLINT" property="source"/>
         <result column="elevation" jdbcType="DOUBLE" property="elevation"/>
-        <result column="no" jdbcType="DOUBLE" property="no"/>
+        <result column="no" jdbcType="VARCHAR" property="no"/>
     </resultMap>
 
     <resultMap id="Line" type="com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine">
@@ -57,6 +57,8 @@
         <result column="down_node" jdbcType="VARCHAR" property="downNode"/>
         <result column="up_no" jdbcType="VARCHAR" property="upNo"/>
         <result column="down_no" jdbcType="VARCHAR" property="downNo"/>
+        <result column="elevation_diff" jdbcType="DOUBLE" property="elevationDiff"/>
+        <result column="survey_length" jdbcType="VARCHAR" property="surveyLength"/>
     </resultMap>
 
     <select id="findAddPointByProjId" fetchSize="3000" resultMap="Point">
@@ -78,6 +80,8 @@
         un.no as up_no, dn.no as down_no,
         case when un.code is not null and dn.code is not null then concat('[', un.gis, ',', dn.gis, ']') else la.gis end
         as gis,
+        abs(coalesce(un.elevation, 0)::numeric - coalesce(dn.elevation, 0)::numeric) as elevation_diff,
+        sl.value as survey_length,
         case when lt.name is null then
         (select td.name from k2_type_define td where td.key = la.layer and td.kind = 7)
         else lt.name end as name
@@ -88,6 +92,8 @@
         on la.up_node = un.code and un.kind = 'point' and la.job_id = un.job_id
         left join k3_gis_survey_layer_apply as dn
         on la.down_node = dn.code and dn.kind = 'point' and la.job_id = dn.job_id
+        left join k3_gis_survey_property_value sl on la.code = sl.code and la.job_id = sl.job_id and property =
+        'survey_length'
         left join k3_gis_metadata_layer_template lt on pit.nature = lt.nature and la.layer = lt.key
         where pit.uid = #{projId,jdbcType=VARCHAR}
         and jo.disused = 0
@@ -112,6 +118,8 @@
         un.no as up_no, dn.no as down_no,
         case when un.code is not null and dn.code is not null then concat('[', un.gis, ',', dn.gis, ']') else la.gis end
         as gis,
+        abs(coalesce(un.elevation, 0)::numeric - coalesce(dn.elevation, 0)::numeric) as elevation_diff,
+        sl.value as survey_length,
         case when lt.name is null then
         (select td.name from k2_type_define td where td.key = la.layer and td.kind = 7)
         else lt.name end as name
@@ -122,6 +130,8 @@
         on la.up_node = un.code and un.kind = 'point' and la.job_id = un.job_id
         left join k3_gis_survey_layer_apply as dn
         on la.down_node = dn.code and dn.kind = 'point' and la.job_id = dn.job_id
+        left join k3_gis_survey_property_value sl on la.code = sl.code and la.job_id = sl.job_id and property =
+        'survey_length'
         left join k3_gis_metadata_layer_template lt on pit.nature = lt.nature and la.layer = lt.key
         where jo.uid = #{jobId,jdbcType=VARCHAR}
         and la.apply = 'add' and la.kind = 'line';