Ver código fonte

重复点检查增加经纬度精度匹配

欧阳劲驰 3 meses atrás
pai
commit
4d5fe8c829

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

@@ -11,9 +11,11 @@ import com.shkpr.service.alambizplugin.constants.GisSurveyCheckStatusEnum;
 import com.shkpr.service.alambizplugin.constants.GisSurveyCheckTypeEnum;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
 import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.TypeDefineService;
 import com.shkpr.service.alambizplugin.dto.GisSurveyCheckResult;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyLine;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
+import com.shkpr.service.alambizplugin.dto.TypeDefine;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.AsyncResult;
 import org.springframework.stereotype.Component;
@@ -40,15 +42,17 @@ public class GisSurveySystemChecker {
     private final String mBizType;
 
     private final GisSurveyLayerApplyService gisSurveyLayerApplyService;
+    private final TypeDefineService typeDefineService;
     private final IsolatedPointsFinder isolatedPointsFinder;
     private final IsolatedLinesFinder isolatedLinesFinder;
     private final DuplicatePointsFinder duplicatePointsFinder;
     private final OverlapLinesFinder overlapLinesFinder;
 
-    public GisSurveySystemChecker(GisSurveyLayerApplyService gisSurveyLayerApplyService, IsolatedPointsFinder isolatedPointsFinder, IsolatedLinesFinder isolatedLinesFinder, DuplicatePointsFinder duplicatePointsFinder, OverlapLinesFinder overlapLinesFinder) {
+    public GisSurveySystemChecker(GisSurveyLayerApplyService gisSurveyLayerApplyService, TypeDefineService typeDefineService, IsolatedPointsFinder isolatedPointsFinder, IsolatedLinesFinder isolatedLinesFinder, DuplicatePointsFinder duplicatePointsFinder, OverlapLinesFinder overlapLinesFinder) {
         mStrClassName = "GisSurveySystemChecker";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
         this.gisSurveyLayerApplyService = gisSurveyLayerApplyService;
+        this.typeDefineService = typeDefineService;
         this.isolatedPointsFinder = isolatedPointsFinder;
         this.isolatedLinesFinder = isolatedLinesFinder;
         this.duplicatePointsFinder = duplicatePointsFinder;
@@ -103,6 +107,8 @@ public class GisSurveySystemChecker {
                 points = gisSurveyLayerApplyService.findAddPointByJobId(jobId);
                 lines = gisSurveyLayerApplyService.findAddLineByJobId(jobId);
             }
+            //查询经纬度类型定义
+            List<TypeDefine> typeDefines = typeDefineService.findLatLng();
 
             //孤立点检查
             if (points != null && lines != null) {
@@ -110,7 +116,7 @@ public class GisSurveySystemChecker {
             }
             //重复点检查
             if (points != null) {
-                duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, 6);
+                duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, typeDefines);
             }
             //孤立线和重叠线检查
             if (lines != null) {
@@ -146,6 +152,7 @@ public class GisSurveySystemChecker {
 
             //完成检查
             result.setCompleteTime(LocalDateTime.now());
+            result.setCheckStatus(GisSurveyCheckStatusEnum.SUCCESS.getCode());
             LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
                     , String.format(
                             "结束执行系统检查;检查类型: %d,项目ID:%s, 任务ID:,%s,用时(毫秒):%d",
@@ -159,7 +166,7 @@ public class GisSurveySystemChecker {
         } catch (InterruptedException | ExecutionException e) {
             LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
                     , String.format(
-                            "监测到中断或执行异常,开始清除子任务: %d,项目ID:%s, 任务ID:,%s,",
+                            "监测到中断或执行异常,开始清除子任务 检查类型:%d,项目ID:%s, 任务ID:,%s,",
                             checkType,
                             projId,
                             jobId

+ 52 - 6
src/main/java/com/shkpr/service/alambizplugin/components/checker/DuplicatePointsFinder.java

@@ -4,6 +4,8 @@ import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyPoint;
+import com.shkpr.service.alambizplugin.dto.TypeDefine;
+import org.apache.commons.lang3.StringUtils;
 import org.locationtech.jts.geom.Coordinate;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.AsyncResult;
@@ -22,6 +24,18 @@ import java.util.stream.Collectors;
 @Component
 public class DuplicatePointsFinder {
     /**
+     * 经纬度默认精度
+     */
+    private final static int DEFAULT_SCALE = 6;
+    /**
+     * 经度key
+     */
+    private final static String LNG_KEY = "lng";
+    /**
+     * 纬度key
+     */
+    private final static String LAT_KEY = "lat";
+    /**
      * log
      */
     private final String mStrClassName;
@@ -36,13 +50,18 @@ public class DuplicatePointsFinder {
      * 寻找重复点
      * <p>根据 <strong>精度</strong> 强匹配</p>
      *
-     * @param points 点集合
-     * @param scale  精度
+     * @param points      点集合
+     * @param typeDefines 类型定义
      * @return 重复点
      */
     @Async
-    public ListenableFuture<List<List<String>>> findDuplicatePoints(List<GisSurveyLayerApplyPoint> points, int scale) throws InterruptedException {
-        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, String.format("开始执行寻找重复点 精度:%s ======>", scale));
+    public ListenableFuture<List<List<String>>> findDuplicatePoints(List<GisSurveyLayerApplyPoint> points, List<TypeDefine> typeDefines) throws InterruptedException {
+        //经纬度精度
+        int lonScale = getScale(typeDefines, LNG_KEY);
+        int latScale = getScale(typeDefines, LAT_KEY);
+
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName,
+                String.format("开始执行寻找重复点 经度精度:%s 纬度精度:%s   ======>", lonScale, latScale));
         long begin = System.currentTimeMillis();
 
         //根据经纬度分组
@@ -50,8 +69,8 @@ public class DuplicatePointsFinder {
                 .collect(Collectors.groupingBy(point -> {
                     //抹去经纬度精度,并设置为分组条件
                     Coordinate coordinate = point.getGis().getCoordinate();
-                    BigDecimal bdLon = new BigDecimal(Double.toString(coordinate.getX())).setScale(scale, RoundingMode.DOWN);
-                    BigDecimal bdLat = new BigDecimal(Double.toString(coordinate.getY())).setScale(scale, RoundingMode.DOWN);
+                    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()));
         //响应中断
@@ -76,4 +95,31 @@ public class DuplicatePointsFinder {
         );
         return new AsyncResult<>(collect);
     }
+
+    /**
+     * 获取精度
+     *
+     * @param typeDefines 类型定义
+     * @param key         类型定义key
+     * @return 经度精度
+     */
+    private int getScale(List<TypeDefine> typeDefines, String key) {
+        //空返回默认值
+        if (typeDefines == null || typeDefines.isEmpty()) return DEFAULT_SCALE;
+        //过滤出纬度类型定义
+        TypeDefine typeDefine = typeDefines.stream()
+                .filter(td -> key.equals(td.getKey()))
+                .findFirst()
+                .orElse(null);
+        //解析参数而,转换成数字,大于等于0则使用字典
+        if (typeDefine != null && StringUtils.isNotBlank(typeDefine.getParam2())) {
+            try {
+                int lngScale = Integer.parseInt(typeDefine.getParam2());
+                return lngScale < 0 ? DEFAULT_SCALE : lngScale;
+            } catch (NumberFormatException e) {
+                return DEFAULT_SCALE;
+            }
+        }
+        return DEFAULT_SCALE;
+    }
 }

+ 22 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/TypeDefineMapper.java

@@ -0,0 +1,22 @@
+package com.shkpr.service.alambizplugin.dbdao.mapper;
+
+import com.shkpr.service.alambizplugin.dto.TypeDefine;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * 自定义类型集合表mapper
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Mapper
+public interface TypeDefineMapper {
+    /**
+     * 查询经纬度定义
+     *
+     * @return 经纬度定义
+     */
+    List<TypeDefine> findLatLng();
+}

+ 33 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/TypeDefineServiceImpl.java

@@ -0,0 +1,33 @@
+package com.shkpr.service.alambizplugin.dbdao.services;
+
+import com.shkpr.service.alambizplugin.dbdao.mapper.TypeDefineMapper;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.TypeDefineService;
+import com.shkpr.service.alambizplugin.dto.TypeDefine;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 自定义类型Service
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Service
+public class TypeDefineServiceImpl implements TypeDefineService {
+    final
+    TypeDefineMapper typeDefineMapper;
+
+    public TypeDefineServiceImpl(TypeDefineMapper typeDefineMapper) {
+        this.typeDefineMapper = typeDefineMapper;
+    }
+
+    /**
+     * 查询经纬度定义
+     *
+     * @return 经纬度定义
+     */
+    public List<TypeDefine> findLatLng() {
+        return typeDefineMapper.findLatLng();
+    }
+}

+ 20 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/TypeDefineService.java

@@ -0,0 +1,20 @@
+package com.shkpr.service.alambizplugin.dbdao.services.intef;
+
+import com.shkpr.service.alambizplugin.dto.TypeDefine;
+
+import java.util.List;
+
+/**
+ * 自定义类型Service
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public interface TypeDefineService {
+    /**
+     * 查询经纬度定义
+     *
+     * @return 经纬度定义
+     */
+    List<TypeDefine> findLatLng();
+}

+ 2 - 2
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCheckResult.java

@@ -53,11 +53,11 @@ public class GisSurveyCheckResult {
      */
     private List<List<String>> isolatedLines;
     /**
-     * 重复点集合
+     * 重复点code集合
      */
     private List<List<String>> duplicatePoints;
     /**
-     * 重叠线集合
+     * 重叠线code集合
      */
     private List<List<String>> overlapLines;
 

+ 67 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/TypeDefine.java

@@ -0,0 +1,67 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import lombok.Data;
+
+/**
+ * 自定义类型集合表
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Data
+public class TypeDefine {
+    /**
+     *
+     */
+    private Integer id;
+
+    /**
+     * 自定义类型中的唯一标识符
+     */
+    private String key;
+
+    /**
+     * 自定义类型所属种类;0 -- 设备标记字段;1 -- 分区主类型; 2 -- 分区子类型; 3 -- 用水类型;4 -- 站点类型
+     */
+    private Short kind;
+
+    /**
+     * 自定义类型名称
+     */
+    private String name;
+
+    /**
+     * 备注说明
+     */
+    private String remark;
+
+    /**
+     * 参数1
+     */
+    private String param1;
+
+    /**
+     * 参数2
+     */
+    private String param2;
+
+    /**
+     * 排列顺序
+     */
+    private Short ordering;
+
+    /**
+     *
+     */
+    private String alias;
+
+    /**
+     * 性质用途
+     */
+    private String nature;
+
+    /**
+     * 特性
+     */
+    private String feature;
+}

+ 1 - 1
src/main/java/com/shkpr/service/alambizplugin/globalmgr/ScheduleTaskMgr.java

@@ -53,7 +53,7 @@ public class ScheduleTaskMgr {
     @Scheduled(fixedRateString = "${system-check.ttl-check-interval}")
     public void sysCheckTasksTtl() {
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue(), mStrClassName
-                , String.format("开始执行系统检查超时任务 ttl:%s ======>", ttl));
+                , String.format("开始执行系统检查超时任务 ttl(毫秒):%s ======>", ttl));
         if (ttl != null) gisSurveyBizService.expireResult(ttl);
     }
 

+ 20 - 0
src/main/resources/mapper/TypeDefineMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.shkpr.service.alambizplugin.dbdao.mapper.TypeDefineMapper">
+    <select id="findLatLng" resultType="com.shkpr.service.alambizplugin.dto.TypeDefine">
+        select id,
+               key,
+               kind,
+               name,
+               remark,
+               param1,
+               param2,
+               ordering,
+               alias,
+               nature,
+               feature
+        from k2_type_define
+        where kind = 12
+          and (key = 'lat' or key = 'lng')
+    </select>
+</mapper>