Browse Source

删除文件表头映射,完全依赖于模版

欧阳劲驰 2 months ago
parent
commit
db1eca9cc4

+ 121 - 0
src/main/java/com/shkpr/service/alambizplugin/commtools/ThirdImportTemplateUtils.java

@@ -0,0 +1,121 @@
+package com.shkpr.service.alambizplugin.commtools;
+
+import com.shkpr.service.alambizplugin.constants.GisMetadataDefine;
+import com.shkpr.service.alambizplugin.constants.GisSurveyImportDefine;
+import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate;
+import com.shkpr.service.alambizplugin.dto.GisMetadataPropertyTemplate;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * 第三方导入模版工具类
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+public class ThirdImportTemplateUtils {
+
+    /**
+     * 获取模版
+     *
+     * @param data           数据
+     * @param layerTemplates 图层模版集合
+     * @param kind           数据类型
+     * @param propertyKey    属性模版key
+     * @return 点号
+     */
+    public static GisMetadataPropertyTemplate getPropertyTemplate(Map<String, String> data
+            , List<GisMetadataLayerTemplate> layerTemplates
+            , String kind, String propertyKey) {
+        //提取图层模版
+        GisMetadataLayerTemplate layerTemplate = getLayerTemplate(data, layerTemplates, kind);
+        if (layerTemplate == null) return null;
+        //提取点号模版
+        return layerTemplate.getPropertyTemplates().stream()
+                .filter(template -> Objects.equals(propertyKey, template.getKey()))
+                .findFirst().orElse(null);
+
+    }
+
+    /**
+     * 获取值
+     *
+     * @param data             数据
+     * @param propertyTemplate 属性模版
+     * @return 点号
+     */
+    public static String getValue(Map<String, String> data, GisMetadataPropertyTemplate propertyTemplate) {
+        //排除空模版
+        if (propertyTemplate == null || StringUtils.isBlank(propertyTemplate.getName())) return null;
+        //获取点号
+        return data.get(propertyTemplate.getName());
+    }
+
+    /**
+     * 获取值
+     *
+     * @param data          数据
+     * @param layerTemplate 图层模版
+     * @param propertyKey   属性模版key
+     * @return 点号
+     */
+    public static String getValue(Map<String, String> data, GisMetadataLayerTemplate layerTemplate
+            , String propertyKey) {
+        //排除空模版
+        if (layerTemplate == null) return null;
+        //提取点号模版
+        GisMetadataPropertyTemplate propertyTemplate = layerTemplate.getPropertyTemplates().stream()
+                .filter(template -> Objects.equals(propertyKey, template.getKey()))
+                .findFirst().orElse(null);
+        if (propertyTemplate == null || StringUtils.isBlank(propertyTemplate.getName())) return null;
+        //获取点号
+        return data.get(propertyTemplate.getName());
+    }
+
+    /**
+     * 获取值
+     *
+     * @param data           数据
+     * @param layerTemplates 图层模版集合
+     * @param kind           数据类型
+     * @param propertyKey    属性模版key
+     * @return 点号
+     */
+    public static String getValue(Map<String, String> data, List<GisMetadataLayerTemplate> layerTemplates
+            , String kind, String propertyKey) {
+        //提取图层模版
+        GisMetadataLayerTemplate layerTemplate = getLayerTemplate(data, layerTemplates, kind);
+        return getValue(data, layerTemplate, propertyKey);
+    }
+
+    /**
+     * 获取图层模版
+     *
+     * @param data           数据
+     * @param layerTemplates 图层模版
+     * @param kind           数据类型
+     * @return 图层模版
+     */
+    public static GisMetadataLayerTemplate getLayerTemplate(Map<String, String> data
+            , List<GisMetadataLayerTemplate> layerTemplates, String kind) {
+        //图层文件key
+        String layKey = null;
+        if (Objects.equals(kind, GisMetadataDefine.TYPE_KINE.POINT))
+            layKey = GisSurveyImportDefine.FILE.POINT_LAYER;
+        if (Objects.equals(kind, GisMetadataDefine.TYPE_KINE.LINE))
+            layKey = GisSurveyImportDefine.FILE.LINE_LAYER;
+        if (layKey == null) return null;
+
+        //过滤对应模版
+        String finalLayKey = layKey;
+        return layerTemplates.stream()
+                .filter(template -> StringUtils.isNotBlank(template.getName())
+                        && Objects.equals(template.getName(), data.get(finalLayKey))
+                        && Objects.equals(template.getKind(), kind)
+                )
+                .findFirst().orElse(null);
+    }
+}

+ 38 - 40
src/main/java/com/shkpr/service/alambizplugin/components/GisSurveyThirdImporter.java

@@ -5,6 +5,7 @@ import com.global.base.log.LogPrintMgr;
 import com.shkpr.service.alambizplugin.apiparam.GisSurveyThirdImportParams;
 import com.shkpr.service.alambizplugin.commtools.ExcelUtils;
 import com.shkpr.service.alambizplugin.commtools.PointCodeUtil;
+import com.shkpr.service.alambizplugin.commtools.ThirdImportTemplateUtils;
 import com.shkpr.service.alambizplugin.components.checker.DuplicatePointsFinder;
 import com.shkpr.service.alambizplugin.components.checker.InvalidLinesFinder;
 import com.shkpr.service.alambizplugin.components.checker.InvalidPropertiesFinder;
@@ -118,8 +119,8 @@ public class GisSurveyThirdImporter {
             parseExcel(inputStreams, points, lines);
 
             //提取图层名
-            List<String> pointLayerNames = getLayerNames(points, GisSurveyImportDefine.POINT.LAYER);
-            List<String> lineLayerNames = getLayerNames(lines, GisSurveyImportDefine.LINE.LAYER);
+            List<String> pointLayerNames = getLayerNames(points, GisSurveyImportDefine.FILE.POINT_LAYER);
+            List<String> lineLayerNames = getLayerNames(lines, GisSurveyImportDefine.FILE.LINE_LAYER);
             //图层模版
             List<GisMetadataLayerTemplate> pointLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), pointLayerNames);
             List<GisMetadataLayerTemplate> lineLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), lineLayerNames);
@@ -127,9 +128,9 @@ public class GisSurveyThirdImporter {
             //无效属性检查
             invalidPropertiesFuture = invalidPropertiesFinder.findInvalidProperties(points, lines, pointLayerTemplates, lineLayerTemplates);
             //重复点检查
-            duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points);
+            duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, pointLayerTemplates);
             //无效线检查
-            invalidLinesFuture = invalidLinesFinder.finderInvalidLines(points, lines);
+            invalidLinesFuture = invalidLinesFinder.finderInvalidLines(points, lines, pointLayerTemplates, lineLayerTemplates);
 
             //返回子任务
             onStartSubtask.accept(
@@ -261,7 +262,7 @@ public class GisSurveyThirdImporter {
      * 获取图层名称
      *
      * @param datas    数据
-     * @param layerKey 图层的key
+     * @param layerKey 文件图层的key
      * @return 图层名称集合
      */
     private List<String> getLayerNames(List<Map<String, String>> datas, String layerKey) {
@@ -343,7 +344,7 @@ public class GisSurveyThirdImporter {
         //格式化点
         for (Map<String, String> point : points) {
             //获取模版
-            GisMetadataLayerTemplate layerTemplate = poineTemplateMap.get(point.get(GisSurveyImportDefine.POINT.LAYER));
+            GisMetadataLayerTemplate layerTemplate = poineTemplateMap.get(point.get(GisSurveyImportDefine.FILE.POINT_LAYER));
             //解码点对象
             GisSurveyLayerApplyThirdCopy layerApply = decodePointToLayerApply(point, layerTemplate, params);
             //存入点号
@@ -354,7 +355,7 @@ public class GisSurveyThirdImporter {
         //格式化线
         for (Map<String, String> line : lines) {
             //获取模版
-            GisMetadataLayerTemplate layerTemplate = lineTemplateMap.get(line.get(GisSurveyImportDefine.LINE.LAYER));
+            GisMetadataLayerTemplate layerTemplate = lineTemplateMap.get(line.get(GisSurveyImportDefine.FILE.LINE_LAYER));
             //解码对象
             GisSurveyLayerApplyThirdCopy layerApply = decodeLineToLayerApply(line, layerTemplate, params, pointNoMapping);
 
@@ -387,29 +388,32 @@ public class GisSurveyThirdImporter {
         layerApply.setLayer(layerTemplate.getKey());
         layerApply.setKind(GisMetadataDefine.TYPE_KINE.POINT);
         //解析坐标
-        Point geometry = geometryFactory.createPoint(new Coordinate(
-                Double.parseDouble(point.get(GisSurveyImportDefine.POINT.LNG))
-                , Double.parseDouble(point.get(GisSurveyImportDefine.POINT.LAT))
-        ));
-        layerApply.setGis(geometry);
+        String lngStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyImportDefine.TEMPLATE.LNG);
+        String latStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyImportDefine.TEMPLATE.LAT);
+        if (NumberUtils.isParsable(lngStr) && NumberUtils.isParsable(latStr)) {
+            Point geometry = geometryFactory.createPoint(new Coordinate(Double.parseDouble(lngStr), Double.parseDouble(latStr)));
+            layerApply.setGis(geometry);
+        }
         //默认值
         layerApply.setApply(GisSurveyImportDefine.DEFAULT_VALUE.APPLY);
         layerApply.setSource(GisSurveyImportDefine.DEFAULT_VALUE.SOURCE);
         //高程和埋深
-        String elevationStr = point.get(GisSurveyImportDefine.POINT.ELEVATION);
+        String elevationStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyImportDefine.TEMPLATE.ELEVATION);
         if (NumberUtils.isParsable(elevationStr))
             layerApply.setElevation(Double.parseDouble(elevationStr));
-        String depthStr = point.get(GisSurveyImportDefine.POINT.DEPTH);
+        String depthStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyImportDefine.TEMPLATE.DEPTH);
         if (NumberUtils.isParsable(depthStr))
             layerApply.setDepth(Double.parseDouble(depthStr));
         //点号(长度64截断)
-        layerApply.setNo(StringUtils.substring(point.get(GisSurveyImportDefine.POINT.NO), 0, 64));
+        String noStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyImportDefine.TEMPLATE.NO);
+        if (StringUtils.isNotBlank(noStr))
+            layerApply.setNo(StringUtils.substring(noStr, 0, 64));
         //遍历属性模版
         List<GisSurveyPropertyValueThirdCopy> propertyValueList = new ArrayList<>();
         for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) {
             //解析属性
             GisSurveyPropertyValueThirdCopy propertyValue = decodeDataToPropertyValue(point, layerApply
-                    , propertyTemplate, params, GisSurveyImportDefine.LayerType.POINT);
+                    , propertyTemplate, params);
             if (propertyValue != null) propertyValueList.add(propertyValue);
         }
         layerApply.setPropertyValues(propertyValueList);
@@ -437,13 +441,19 @@ public class GisSurveyThirdImporter {
         layerApply.setApply(GisSurveyImportDefine.DEFAULT_VALUE.APPLY);
         layerApply.setSource(GisSurveyImportDefine.DEFAULT_VALUE.SOURCE);
         //上下游节点
-        layerApply.setUpNode(pointNoMapping.get(line.get(GisSurveyImportDefine.LINE.UP_NO)));
-        layerApply.setDownNode(pointNoMapping.get(line.get(GisSurveyImportDefine.LINE.DOWN_NO)));
+        String upNoStr = ThirdImportTemplateUtils.getValue(line, layerTemplate, GisSurveyImportDefine.TEMPLATE.UP_NO);
+        if (StringUtils.isNotBlank(upNoStr)) {
+            layerApply.setUpNode(pointNoMapping.get(upNoStr));
+        }
+        String downNoStr = ThirdImportTemplateUtils.getValue(line, layerTemplate, GisSurveyImportDefine.TEMPLATE.DOWN_NO);
+        if (StringUtils.isNotBlank(downNoStr)) {
+            layerApply.setDownNode(pointNoMapping.get(downNoStr));
+        }
         //遍历属性模版
         List<GisSurveyPropertyValueThirdCopy> propertyValueList = new ArrayList<>();
         for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) {
             //解析属性
-            GisSurveyPropertyValueThirdCopy propertyValue = decodeDataToPropertyValue(line, layerApply, propertyTemplate, params, GisSurveyImportDefine.LayerType.LINE);
+            GisSurveyPropertyValueThirdCopy propertyValue = decodeDataToPropertyValue(line, layerApply, propertyTemplate, params);
             if (propertyValue != null) propertyValueList.add(propertyValue);
         }
         layerApply.setPropertyValues(propertyValueList);
@@ -458,35 +468,23 @@ public class GisSurveyThirdImporter {
      * @param layerApply       采集元素
      * @param propertyTemplate 属性模版
      * @param params           导出参数
-     * @param layerType        图层类型
      * @return 属性值对象
      */
     private GisSurveyPropertyValueThirdCopy decodeDataToPropertyValue(Map<String, String> data, GisSurveyLayerApplyThirdCopy layerApply
-            , GisMetadataPropertyTemplate propertyTemplate, GisSurveyThirdImportParams params, GisSurveyImportDefine.LayerType layerType) {
+            , GisMetadataPropertyTemplate propertyTemplate, GisSurveyThirdImportParams params) {
         //点号直接返回点号属性
         if (Objects.equals(GisSurveyImportDefine.TEMPLATE.CODE, propertyTemplate.getKey()))
             return new GisSurveyPropertyValueThirdCopy(params.getJobId(), layerApply.getCode()
                     , propertyTemplate.getKey(), layerApply.getCode());
-        //根据图层类型和模版映射,获取表头
+        if (Objects.equals(GisSurveyImportDefine.TEMPLATE.UP_NODE, propertyTemplate.getKey()))
+            return new GisSurveyPropertyValueThirdCopy(params.getJobId(), layerApply.getUpNode()
+                    , propertyTemplate.getKey(), layerApply.getCode());
+        if (Objects.equals(GisSurveyImportDefine.TEMPLATE.DOWN_NODE, propertyTemplate.getKey()))
+            return new GisSurveyPropertyValueThirdCopy(params.getJobId(), layerApply.getDownNode()
+                    , propertyTemplate.getKey(), layerApply.getCode());
+
+        //获取表头
         String templateName = propertyTemplate.getName();
-        if (layerType == GisSurveyImportDefine.LayerType.POINT)
-            switch (propertyTemplate.getKey()) {
-                case GisSurveyImportDefine.TEMPLATE.LNG:
-                    templateName = GisSurveyImportDefine.POINT.LNG;
-                    break;
-                case GisSurveyImportDefine.TEMPLATE.LAT:
-                    templateName = GisSurveyImportDefine.POINT.LAT;
-                    break;
-            }
-        if (layerType == GisSurveyImportDefine.LayerType.LINE)
-            switch (propertyTemplate.getKey()) {
-                case GisSurveyImportDefine.TEMPLATE.UP_NODE:
-                    templateName = GisSurveyImportDefine.LINE.UP_NO;
-                    break;
-                case GisSurveyImportDefine.TEMPLATE.DOWN_NODE:
-                    templateName = GisSurveyImportDefine.LINE.DOWN_NO;
-                    break;
-            }
         //获取值
         String value = data.get(templateName);
         //构建dto,并将值长度64截断

+ 16 - 8
src/main/java/com/shkpr/service/alambizplugin/components/checker/DuplicatePointsFinder.java

@@ -3,11 +3,13 @@ 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.commtools.ThirdImportTemplateUtils;
 import com.shkpr.service.alambizplugin.components.GisSurveySystemCheckResultManager;
 import com.shkpr.service.alambizplugin.constants.GisMetadataDefine;
 import com.shkpr.service.alambizplugin.constants.GisSurveyImportDefine;
 import com.shkpr.service.alambizplugin.constants.GisSurveySystemCheckResultPath;
 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;
@@ -65,21 +67,27 @@ public class DuplicatePointsFinder {
      * 寻找重复点
      * <p>根据 <strong>code</strong> 匹配</p>
      *
-     * @param points 点集合
+     * @param points              点集合
+     * @param pointLayerTemplates 点图层模版
      * @return 重复点
      */
     @Async
-    public ListenableFuture<GisSurveyThirdImportResultDetail<List<GisSurveyThirdImportElement>>> findDuplicatePoints(List<Map<String, String>> points) throws InterruptedException {
+    public ListenableFuture<GisSurveyThirdImportResultDetail<List<GisSurveyThirdImportElement>>> findDuplicatePoints(
+            List<Map<String, String>> points, List<GisMetadataLayerTemplate> pointLayerTemplates) throws InterruptedException {
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找重复点   ======>");
         long begin = System.currentTimeMillis();
 
         //根据code度分组
         Map<String, List<Map<String, String>>> keyToPoints = points.parallelStream()
-                //过滤类型为字符串
-                .filter(point ->
-                        point.get(GisSurveyImportDefine.POINT.NO) != null)
                 .collect(Collectors.groupingBy(point ->
-                                point.get(GisSurveyImportDefine.POINT.NO),
+                                StringUtils.defaultIfBlank(
+                                        ThirdImportTemplateUtils.getValue(
+                                                point, pointLayerTemplates,
+                                                GisMetadataDefine.TYPE_KINE.POINT,
+                                                GisSurveyImportDefine.TEMPLATE.NO
+                                        ),
+                                        ""
+                                ),
                         Collectors.toList())
                 );
         //响应中断
@@ -87,8 +95,8 @@ public class DuplicatePointsFinder {
         //并行流寻找重复点号
         List<GisSurveyThirdImportElement> groupElements = keyToPoints.entrySet().parallelStream()
                 //过滤组内大于1
-                .filter(group -> group.getValue().size() > 1)
-                .map(entry -> new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.POINT, entry.getKey()))
+                .filter(group -> StringUtils.isNotBlank(group.getKey()) && group.getValue().size() > 1)
+                .map(entry -> new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.POINT, entry.getKey(), null, null))
                 .collect(Collectors.toList());
 
         long end = System.currentTimeMillis();

+ 62 - 16
src/main/java/com/shkpr/service/alambizplugin/components/checker/InvalidLinesFinder.java

@@ -3,10 +3,15 @@ package com.shkpr.service.alambizplugin.components.checker;
 import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
 import com.google.common.collect.Lists;
+import com.shkpr.service.alambizplugin.commtools.ThirdImportTemplateUtils;
+import com.shkpr.service.alambizplugin.constants.GisMetadataDefine;
 import com.shkpr.service.alambizplugin.constants.GisSurveyImportDefine;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
+import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate;
+import com.shkpr.service.alambizplugin.dto.GisMetadataPropertyTemplate;
 import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportElement;
 import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResultDetail;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.AsyncResult;
 import org.springframework.stereotype.Component;
@@ -19,9 +24,6 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import static com.shkpr.service.alambizplugin.constants.GisSurveyImportDefine.LINE.DOWN_NO;
-import static com.shkpr.service.alambizplugin.constants.GisSurveyImportDefine.LINE.UP_NO;
-
 /**
  * 无效线查找器
  *
@@ -44,13 +46,16 @@ public class InvalidLinesFinder {
     /**
      * 寻找无效线
      *
-     * @param points 点集合
-     * @param lines  线集合
+     * @param points              点集合
+     * @param lines               线集合
+     * @param pointLayerTemplates 点图层模版
+     * @param lineLayerTemplates  线图层模版
      * @return 线分组
      */
     @Async
-    public ListenableFuture<GisSurveyThirdImportResultDetail<List<GisSurveyThirdImportElement>>> finderInvalidLines(List<Map<String, String>> points
-            , List<Map<String, String>> lines) throws InterruptedException {
+    public ListenableFuture<GisSurveyThirdImportResultDetail<List<GisSurveyThirdImportElement>>> finderInvalidLines(
+            List<Map<String, String>> points, List<Map<String, String>> lines,
+            List<GisMetadataLayerTemplate> pointLayerTemplates, List<GisMetadataLayerTemplate> lineLayerTemplates) throws InterruptedException {
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找无效线   ======>");
         long begin = System.currentTimeMillis();
 
@@ -65,8 +70,26 @@ public class InvalidLinesFinder {
             );
             return new AsyncResult<>(new GisSurveyThirdImportResultDetail<>(true,
                     lines.stream()
-                            //转code字符串
-                            .map(line -> GisSurveyThirdImportElement.create(line, GisSurveyImportDefine.LayerType.LINE))
+                            //转结果
+                            .map(line -> {
+                                //获取模版
+                                GisMetadataPropertyTemplate upNoTemplate = ThirdImportTemplateUtils.getPropertyTemplate(line, pointLayerTemplates,
+                                        GisMetadataDefine.TYPE_KINE.LINE, GisSurveyImportDefine.TEMPLATE.UP_NO);
+                                GisMetadataPropertyTemplate downNoTemplate = ThirdImportTemplateUtils.getPropertyTemplate(line, pointLayerTemplates,
+                                        GisMetadataDefine.TYPE_KINE.LINE, GisSurveyImportDefine.TEMPLATE.DOWN_NO);
+                                //构造表头
+                                List<String> propertyNames = new ArrayList<>();
+                                if (upNoTemplate != null) {
+                                    propertyNames.add(upNoTemplate.getName());
+                                }
+                                if (downNoTemplate != null) {
+                                    propertyNames.add(downNoTemplate.getName());
+                                }
+                                return new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.LINE,
+                                        ThirdImportTemplateUtils.getValue(line, upNoTemplate),
+                                        ThirdImportTemplateUtils.getValue(line, downNoTemplate),
+                                        line.get(GisSurveyImportDefine.FILE.LINE_LAYER), String.join(",", propertyNames));
+                            })
                             .collect(Collectors.toList())
             ));
         }
@@ -86,7 +109,11 @@ public class InvalidLinesFinder {
 
         //点号集合
         Set<String> nos = points.parallelStream()
-                .map(it -> it.get(GisSurveyImportDefine.POINT.NO))
+                .map(point -> ThirdImportTemplateUtils.getValue(
+                        point, pointLayerTemplates,
+                        GisMetadataDefine.TYPE_KINE.POINT,
+                        GisSurveyImportDefine.TEMPLATE.NO)
+                )
                 .filter(Objects::nonNull)
                 .collect(Collectors.toSet());
         //收集无效线
@@ -94,17 +121,36 @@ public class InvalidLinesFinder {
         for (Map<String, String> line : lines) {
             //响应中断
             if (Thread.interrupted()) throw new InterruptedException();
+            //上下节点模版
+            GisMetadataPropertyTemplate upNoTemplate = ThirdImportTemplateUtils.getPropertyTemplate(line, lineLayerTemplates,
+                    GisMetadataDefine.TYPE_KINE.LINE, GisSurveyImportDefine.TEMPLATE.UP_NO);
+            GisMetadataPropertyTemplate downNoTemplate = ThirdImportTemplateUtils.getPropertyTemplate(line, lineLayerTemplates,
+                    GisMetadataDefine.TYPE_KINE.LINE, GisSurveyImportDefine.TEMPLATE.DOWN_NO);
+            //判断是否包含上下节点
+            boolean notContainsUp = false;
+            boolean notContainsDown = false;
+            String upNo = null;
+            String downNo = null;
+            if (upNoTemplate != null) {
+                upNo = ThirdImportTemplateUtils.getValue(line, upNoTemplate);
+                notContainsUp = StringUtils.isBlank(upNo) || !nos.contains(upNo);
+
+            }
+            if (downNoTemplate != null) {
+                downNo = ThirdImportTemplateUtils.getValue(line, downNoTemplate);
+                notContainsDown = StringUtils.isBlank(upNo) || !nos.contains(downNo);
+            }
             //不包含上节点或下节点,则收集
-            boolean notContainsUp = !nos.contains(line.get(UP_NO));
-            boolean notContainsDown = !nos.contains(line.get(DOWN_NO));
             if (notContainsUp || notContainsDown) {
                 //根据条件构造表头
                 String propertyName;
-                if (notContainsUp && notContainsDown) propertyName = UP_NO + "," + DOWN_NO;
-                else if (notContainsUp) propertyName = UP_NO;
-                else propertyName = DOWN_NO;
+                if (notContainsUp && notContainsDown)
+                    propertyName = upNoTemplate.getName() + "," + downNoTemplate.getName();
+                else if (notContainsUp) propertyName = upNoTemplate.getName();
+                else propertyName = downNoTemplate.getName();
                 //存入结果
-                results.add(GisSurveyThirdImportElement.create(line, propertyName, GisSurveyImportDefine.LayerType.LINE));
+                results.add(new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.LINE, upNo, downNo,
+                        line.get(GisSurveyImportDefine.FILE.LINE_LAYER), propertyName));
             }
         }
 

+ 45 - 81
src/main/java/com/shkpr/service/alambizplugin/components/checker/InvalidPropertiesFinder.java

@@ -3,6 +3,8 @@ 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.GeomUtil;
+import com.shkpr.service.alambizplugin.commtools.ThirdImportTemplateUtils;
+import com.shkpr.service.alambizplugin.constants.GisMetadataDefine;
 import com.shkpr.service.alambizplugin.constants.GisSurveyImportDefine;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
 import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate;
@@ -20,7 +22,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 
 /**
  * 无效属性查找器
@@ -76,65 +77,50 @@ public class InvalidPropertiesFinder {
         for (Map<String, String> point : points) {
             //响应中断
             if (Thread.interrupted()) throw new InterruptedException();
-            //点号
-            String no = point.get(GisSurveyImportDefine.POINT.NO);
-            //如点号缺失直接返回必填不存在
-            if (StringUtils.isBlank(no)) {
-                missingRequirementsResult.add(GisSurveyThirdImportElement.create(point
-                        , GisSurveyImportDefine.POINT.NO
-                        , GisSurveyImportDefine.LayerType.POINT
-                ));
-                continue;
-            }
-            //过滤图层
-            GisMetadataLayerTemplate layerTemplate = pointLayerTemplates.stream()
-                    .filter(template ->
-                            StringUtils.isNotBlank(template.getName()) &&
-                                    Objects.equals(point.get(GisSurveyImportDefine.POINT.LAYER), template.getName())
-                    )
-                    .findFirst().orElse(null);
+            //获取图层
+            GisMetadataLayerTemplate layerTemplate = ThirdImportTemplateUtils
+                    .getLayerTemplate(point, pointLayerTemplates, GisMetadataDefine.TYPE_KINE.POINT);
             //图层不存在则加入无效图层结果
             if (layerTemplate == null)
-                invalidLayersResult.add(GisSurveyThirdImportElement.create(point, GisSurveyImportDefine.LayerType.POINT));
+                invalidLayersResult.add(new GisSurveyThirdImportElement(
+                        GisMetadataDefine.TYPE_KINE.POINT,
+                        null,
+                        point.get(GisSurveyImportDefine.FILE.POINT_LAYER),
+                        null
+                ));
             else
                 //图层存在则检查图层
-                checkLayer(point, layerTemplate, missingRequirementsResult, invalidTypesResult, GisSurveyImportDefine.LayerType.POINT);
+                checkLayer(point, layerTemplate, missingRequirementsResult, invalidTypesResult);
             //检查坐标超出范围
-            if (checkOutRanges(point))
-                outRangesResult.add(GisSurveyThirdImportElement.create(point, GisSurveyImportDefine.LayerType.POINT));
+            if (checkOutRanges(point, layerTemplate))
+                outRangesResult.add(
+                        new GisSurveyThirdImportElement(
+                                GisMetadataDefine.TYPE_KINE.POINT,
+                                ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyImportDefine.TEMPLATE.NO),
+                                layerTemplate != null ? layerTemplate.getName() : null,
+                                null
+                        )
+                );
         }
         //检查线属性
         for (Map<String, String> line : lines) {
             //响应中断
             if (Thread.interrupted()) throw new InterruptedException();
-            //上下游点号
-            String upNo = line.get(GisSurveyImportDefine.LINE.UP_NO);
-            String downNo = line.get(GisSurveyImportDefine.LINE.DOWN_NO);
-            //如点号缺失直接返回必填不存在
-            if (StringUtils.isBlank(upNo)) {
-                missingRequirementsResult.add(GisSurveyThirdImportElement.create(line
-                        , GisSurveyImportDefine.LINE.UP_NO
-                        , GisSurveyImportDefine.LayerType.LINE
-                ));
-                continue;
-            }
-            if (StringUtils.isBlank(downNo)) {
-                missingRequirementsResult.add(GisSurveyThirdImportElement.create(line
-                        , GisSurveyImportDefine.LINE.DOWN_NO
-                        , GisSurveyImportDefine.LayerType.LINE
-                ));
-                continue;
-            }
             //过滤图层
-            GisMetadataLayerTemplate layerTemplate = lineLayerTemplates.stream()
-                    .filter(template -> Objects.equals(template.getName(), line.get(GisSurveyImportDefine.LINE.LAYER)))
-                    .findFirst().orElse(null);
+            GisMetadataLayerTemplate layerTemplate = ThirdImportTemplateUtils
+                    .getLayerTemplate(line, lineLayerTemplates, GisMetadataDefine.TYPE_KINE.LINE);
             //图层不存在则加入无效图层结果
             if (layerTemplate == null)
-                invalidLayersResult.add(GisSurveyThirdImportElement.create(line, GisSurveyImportDefine.LayerType.LINE));
+                invalidLayersResult.add(new GisSurveyThirdImportElement(
+                        GisMetadataDefine.TYPE_KINE.LINE,
+                        null,
+                        null,
+                        line.get(GisSurveyImportDefine.FILE.LINE_LAYER),
+                        null
+                ));
             else
                 //图层存在则检查图层
-                checkLayer(line, layerTemplate, missingRequirementsResult, invalidTypesResult, GisSurveyImportDefine.LayerType.LINE);
+                checkLayer(line, layerTemplate, missingRequirementsResult, invalidTypesResult);
         }
 
         long end = System.currentTimeMillis();
@@ -160,12 +146,12 @@ public class InvalidPropertiesFinder {
      * @param point 点
      * @return 超出范围昨状态
      */
-    public Boolean checkOutRanges(Map<String, String> point) {
+    public Boolean checkOutRanges(Map<String, String> point, GisMetadataLayerTemplate layerTemplate) {
         //获取经纬度字段
-        String latStr = point.get(GisSurveyImportDefine.POINT.LAT);
-        String lngStr = point.get(GisSurveyImportDefine.POINT.LNG);
+        String latStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyImportDefine.TEMPLATE.LAT);
+        String lngStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyImportDefine.TEMPLATE.LNG);
         //检查是否字符串
-        if (latStr == null || lngStr == null) return true;
+        if (StringUtils.isBlank(latStr) || StringUtils.isBlank(lngStr)) return true;
         //检查是否可解析
         if (!NumberUtils.isParsable(latStr) || !NumberUtils.isParsable(lngStr)) return true;
         //解析
@@ -182,53 +168,31 @@ public class InvalidPropertiesFinder {
      * @param layerTemplate             图层模版
      * @param missingRequirementsResult 缺少必填结果
      * @param invalidTypesResult        无效类型结果
-     * @param layerType                 图层类型
      */
     public void checkLayer(Map<String, String> data, GisMetadataLayerTemplate layerTemplate
             , List<GisSurveyThirdImportElement> missingRequirementsResult
-            , List<GisSurveyThirdImportElement> invalidTypesResult, GisSurveyImportDefine.LayerType layerType) {
+            , List<GisSurveyThirdImportElement> invalidTypesResult) {
         //遍历图层属性模版
         for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) {
             //排除非必填
             if (propertyTemplate.getRequired() != 1)
                 continue;
-            //排除code
-            if (Objects.equals(GisSurveyImportDefine.TEMPLATE.CODE, propertyTemplate.getKey()))
-                continue;
             //模版名称
             String templateName = propertyTemplate.getName();
-            //点类型模版表头映射
-            if (layerType == GisSurveyImportDefine.LayerType.POINT)
-                switch (propertyTemplate.getKey()) {
-                    case GisSurveyImportDefine.TEMPLATE.LNG:
-                        templateName = GisSurveyImportDefine.POINT.LNG;
-                        break;
-                    case GisSurveyImportDefine.TEMPLATE.LAT:
-                        templateName = GisSurveyImportDefine.POINT.LAT;
-                        break;
-                }
-            if (layerType == GisSurveyImportDefine.LayerType.LINE)
-                switch (propertyTemplate.getKey()) {
-                    case GisSurveyImportDefine.TEMPLATE.UP_NODE:
-                        templateName = GisSurveyImportDefine.LINE.UP_NO;
-                        break;
-                    case GisSurveyImportDefine.TEMPLATE.DOWN_NODE:
-                        templateName = GisSurveyImportDefine.LINE.DOWN_NO;
-                        break;
-                }
             //必填不存在则存入缺少必填
-            if (data.get(templateName) == null || StringUtils.isBlank(data.get(templateName)))
-                missingRequirementsResult.add(GisSurveyThirdImportElement.create(data,
-                        templateName,
-                        layerType
-                ));
-            else if ((GisSurveyImportDefine.DATA_TYPE.INT.equals(propertyTemplate.getType()) ||
+            if (data.get(templateName) == null || StringUtils.isBlank(data.get(templateName))) {
+                GisSurveyThirdImportElement gisSurveyThirdImportElement = GisSurveyThirdImportElement.create(data,
+                        layerTemplate,
+                        propertyTemplate.getName()
+                );
+                missingRequirementsResult.add(gisSurveyThirdImportElement);
+            } else if ((GisSurveyImportDefine.DATA_TYPE.INT.equals(propertyTemplate.getType()) ||
                     GisSurveyImportDefine.DATA_TYPE.FLOAT.equals(propertyTemplate.getType()))
                     && !NumberUtils.isParsable(data.get(templateName)))
                 //存在且类型为数字,则判断数字类型
                 invalidTypesResult.add(GisSurveyThirdImportElement.create(data,
-                        data.get(templateName),
-                        layerType
+                        layerTemplate,
+                        propertyTemplate.getName()
                 ));
         }
     }

+ 9 - 25
src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveyImportDefine.java

@@ -8,32 +8,11 @@ package com.shkpr.service.alambizplugin.constants;
  */
 public interface GisSurveyImportDefine {
     /**
-     * 图层 枚举
+     * 文件映射
      */
-    enum LayerType {
-        POINT,
-        LINE
-    }
-
-    /**
-     * 点文件映射
-     */
-    interface POINT {
-        String NO = "点号";
-        String LAYER = "点类型";
-        String LNG = "X坐标/经度";
-        String LAT = "Y坐标/纬度";
-        String ELEVATION = "地面高程";
-        String DEPTH = "埋深";
-    }
-
-    /**
-     * 线文件映射
-     */
-    interface LINE {
-        String UP_NO = "起点号";
-        String DOWN_NO = "终点号";
-        String LAYER = "线类型";
+    interface FILE {
+        String POINT_LAYER = "点类型";
+        String LINE_LAYER = "线类型";
     }
 
     /**
@@ -41,10 +20,15 @@ public interface GisSurveyImportDefine {
      */
     interface TEMPLATE {
         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";
     }
 
     /**

+ 17 - 22
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyThirdImportElement.java

@@ -1,10 +1,12 @@
 package com.shkpr.service.alambizplugin.dto;
 
+import com.shkpr.service.alambizplugin.commtools.ThirdImportTemplateUtils;
 import com.shkpr.service.alambizplugin.constants.GisMetadataDefine;
 import com.shkpr.service.alambizplugin.constants.GisSurveyImportDefine;
 import lombok.Data;
 
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * 第三方导入元素dto
@@ -39,11 +41,6 @@ public class GisSurveyThirdImportElement {
      */
     private String propertyName;
 
-    public GisSurveyThirdImportElement(String kind, String no) {
-        this.kind = kind;
-        this.no = no;
-    }
-
     public GisSurveyThirdImportElement(String kind, String no, String layerName, String propertyName) {
         this.kind = kind;
         this.no = no;
@@ -59,23 +56,21 @@ public class GisSurveyThirdImportElement {
         this.propertyName = propertyName;
     }
 
-    public static GisSurveyThirdImportElement create(Map<String, String> data, GisSurveyImportDefine.LayerType layerType) {
-        return create(data, null, layerType);
-    }
-
-    public static GisSurveyThirdImportElement create(Map<String, String> data, String propertyName
-            , GisSurveyImportDefine.LayerType layerType) {
-        //点号
-        String no = data.get(GisSurveyImportDefine.POINT.NO);
-        String upNo = data.get(GisSurveyImportDefine.LINE.UP_NO);
-        String Down = data.get(GisSurveyImportDefine.LINE.DOWN_NO);
-        //根据类型创建
-        if (layerType == GisSurveyImportDefine.LayerType.POINT) {
-            return new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.POINT, no
-                    , data.get(GisSurveyImportDefine.POINT.LAYER), propertyName);
-        } else if (layerType == GisSurveyImportDefine.LayerType.LINE) {
-            return new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.LINE, upNo, Down
-                    , data.get(GisSurveyImportDefine.LINE.LAYER), propertyName);
+    public static GisSurveyThirdImportElement create(Map<String, String> data, GisMetadataLayerTemplate layerTemplate, String propertyName) {
+        if (Objects.equals(GisMetadataDefine.TYPE_KINE.POINT, layerTemplate.getKind())) {
+            return new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.POINT,
+                    ThirdImportTemplateUtils.getValue(data, layerTemplate, GisSurveyImportDefine.TEMPLATE.NO),
+                    layerTemplate.getName(),
+                    propertyName
+            );
+        }
+        if (Objects.equals(GisMetadataDefine.TYPE_KINE.LINE, layerTemplate.getKind())) {
+            return new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.LINE,
+                    ThirdImportTemplateUtils.getValue(data, layerTemplate, GisSurveyImportDefine.TEMPLATE.UP_NO),
+                    ThirdImportTemplateUtils.getValue(data, layerTemplate, GisSurveyImportDefine.TEMPLATE.DOWN_NO),
+                    layerTemplate.getName(),
+                    propertyName
+            );
         }
         return null;
     }

+ 0 - 5
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyThirdImportResult.java

@@ -75,11 +75,6 @@ public class GisSurveyThirdImportResult {
     private GisSurveyThirdImportResultDetail<List<GisSurveyThirdImportElement>> invalidLinesResult = new GisSurveyThirdImportResultDetail<>();
 
     /**
-     * 预览数据
-     */
-    private List<GisSurveyLayerApplyThirdCopy> previewData;
-
-    /**
      * 进行中
      */
     public static GisSurveyThirdImportResult inProgress(GisSurveyThirdImportParams params, GisSurveyThirdImportSubtask subtask, LocalDateTime requestTime) {