Quellcode durchsuchen

第三方导入excel结果增加原因

欧阳劲驰 vor 1 Monat
Ursprung
Commit
ddcebc15e1

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

@@ -116,7 +116,12 @@ public class DuplicatePointsFinder {
                     })
                     //过滤组内大于1
                     .filter(group -> StringUtils.isNotBlank(group.getKey()) && group.getValue().size() > 1)
-                    .map(entry -> new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.POINT, entry.getKey(), null, null))
+                    .map(entry ->
+                            new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.POINT, entry.getKey(),
+                                    null, null,
+                                    GisSurveyExcelDefine.MESSAGE.DUPLICATE_POINTS
+                            )
+                    )
                     .collect(Collectors.toList());
 
             long end = System.currentTimeMillis();
@@ -397,6 +402,7 @@ public class DuplicatePointsFinder {
             Map<String, Object> map = new HashMap<>();
             map.put(GisSurveyThirdImportResultHead.KEYS.KIND, element.getKind());
             map.put(GisSurveyThirdImportResultHead.KEYS.NO, element.getNo());
+            map.put(GisSurveyThirdImportResultHead.KEYS.MESSAGE, element.getMessage());
             return map;
         }).collect(Collectors.toList());
     }

+ 10 - 4
src/main/java/com/shkpr/service/alambizplugin/components/checker/InvalidLinesFinder.java

@@ -107,7 +107,9 @@ public class InvalidLinesFinder {
                                 return new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.LINE,
                                         ThirdImportTemplateUtils.getValue(line, upNoTemplate),
                                         ThirdImportTemplateUtils.getValue(line, downNoTemplate),
-                                        line.get(GisSurveyExcelDefine.FILE.LINE_LAYER), String.join(",", propertyNames));
+                                        line.get(GisSurveyExcelDefine.FILE.LINE_LAYER), String.join(",", propertyNames),
+                                        GisSurveyExcelDefine.MESSAGE.INVALID_LINES_ALL
+                                );
                             })
                             .collect(Collectors.toList()),
                     jobId, begin
@@ -148,7 +150,7 @@ public class InvalidLinesFinder {
             String upNo = ThirdImportTemplateUtils.getValue(line, upNoTemplate);
             boolean notContainsUp = StringUtils.isBlank(upNo) || !nos.contains(upNo);
             String downNo = ThirdImportTemplateUtils.getValue(line, downNoTemplate);
-            boolean notContainsDown = StringUtils.isBlank(upNo) || !nos.contains(downNo);
+            boolean notContainsDown = StringUtils.isBlank(downNo) || !nos.contains(downNo);
             //不包含上节点或下节点,则收集
             if (notContainsUp || notContainsDown) {
                 //根据条件构造表头
@@ -161,7 +163,10 @@ public class InvalidLinesFinder {
                 }
                 //存入结果
                 results.add(new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.LINE, upNo, downNo,
-                        line.get(GisSurveyExcelDefine.FILE.LINE_LAYER), String.join(",", propertyNames)));
+                        line.get(GisSurveyExcelDefine.FILE.LINE_LAYER), String.join(",", propertyNames),
+                        StringUtils.isBlank(upNo) || StringUtils.isBlank(downNo) ?
+                                GisSurveyExcelDefine.MESSAGE.INVALID_LINES_NULL : GisSurveyExcelDefine.MESSAGE.INVALID_LINES
+                ));
             }
         }
 
@@ -251,7 +256,7 @@ public class InvalidLinesFinder {
 
         //构建结果
         return new GisSurveyThirdImportResultDetail<>(true
-                ,data, FLAG + "/" + excelPath.getFileName());
+                , data, FLAG + "/" + excelPath.getFileName());
     }
 
     /**
@@ -301,6 +306,7 @@ public class InvalidLinesFinder {
             map.put(GisSurveyThirdImportResultHead.KEYS.UP_NO, element.getUpNO());
             map.put(GisSurveyThirdImportResultHead.KEYS.DOWN_NO, element.getDownNO());
             map.put(GisSurveyThirdImportResultHead.KEYS.PROPERTY_NAME, element.getPropertyName());
+            map.put(GisSurveyThirdImportResultHead.KEYS.MESSAGE, element.getMessage());
             return map;
         }).collect(Collectors.toList());
     }

+ 23 - 11
src/main/java/com/shkpr/service/alambizplugin/components/checker/InvalidPropertiesFinder.java

@@ -106,19 +106,22 @@ public class InvalidPropertiesFinder {
                         GisMetadataDefine.TYPE_KINE.POINT,
                         null,
                         point.get(GisSurveyExcelDefine.FILE.POINT_LAYER),
-                        null
+                        null,
+                        GisSurveyExcelDefine.MESSAGE.INVALID_LAYERS
                 ));
             else
                 //图层存在则检查图层
                 checkLayer(point, layerTemplate, checkConstraint, projectConstraints, missingRequirementsResult, invalidTypesResult, outConstraintResult);
             //检查坐标超出范围
-            if (checkOutRanges(point, layerTemplate))
+            Boolean outRanged = checkOutRanges(point, layerTemplate);
+            if (outRanged == null || outRanged)
                 outRangesResult.add(
                         new GisSurveyThirdImportElement(
                                 GisMetadataDefine.TYPE_KINE.POINT,
                                 ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.TEMPLATE.NO),
                                 point.get(GisSurveyExcelDefine.FILE.POINT_LAYER),
-                                null
+                                null,
+                                outRanged == null ? GisSurveyExcelDefine.MESSAGE.OUT_RANGES_NULL : GisSurveyExcelDefine.MESSAGE.OUT_RANGES
                         )
                 );
         }
@@ -136,7 +139,8 @@ public class InvalidPropertiesFinder {
                         null,
                         null,
                         line.get(GisSurveyExcelDefine.FILE.LINE_LAYER),
-                        null
+                        null,
+                        GisSurveyExcelDefine.MESSAGE.INVALID_LAYERS
                 ));
             else
                 //图层存在则检查图层
@@ -166,9 +170,9 @@ public class InvalidPropertiesFinder {
         String latStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.TEMPLATE.LAT);
         String lngStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.TEMPLATE.LNG);
         //检查是否字符串
-        if (StringUtils.isBlank(latStr) || StringUtils.isBlank(lngStr)) return true;
+        if (StringUtils.isBlank(latStr) || StringUtils.isBlank(lngStr)) return null;
         //检查是否可解析
-        if (!NumberUtils.isParsable(latStr) || !NumberUtils.isParsable(lngStr)) return true;
+        if (!NumberUtils.isParsable(latStr) || !NumberUtils.isParsable(lngStr)) return null;
         //解析
         double lat = Double.parseDouble(latStr);
         double lng = Double.parseDouble(lngStr);
@@ -209,7 +213,8 @@ public class InvalidPropertiesFinder {
                 if (StringUtils.isBlank(value)) {
                     GisSurveyThirdImportElement gisSurveyThirdImportElement = GisSurveyThirdImportElement.create(data,
                             layerTemplate,
-                            propertyTemplate.getName()
+                            propertyTemplate.getName(),
+                            GisSurveyExcelDefine.MESSAGE.MISSING_REQUIREMENTS
                     );
                     missingRequirementsResult.add(gisSurveyThirdImportElement);
                     //值存在
@@ -225,7 +230,8 @@ public class InvalidPropertiesFinder {
                             && !NumberUtils.isParsable(value)) {
                         invalidTypesResult.add(GisSurveyThirdImportElement.create(data,
                                 layerTemplate,
-                                propertyTemplate.getName()
+                                propertyTemplate.getName(),
+                                GisSurveyExcelDefine.MESSAGE.INVALID_TYPES
                         ));
                     }
                 }
@@ -278,7 +284,8 @@ public class InvalidPropertiesFinder {
             //如列表不包含值,则超出约束
             if (!ranges.contains(value)) {
                 outConstraintResult.add(GisSurveyThirdImportElement.create(data, layerTemplate,
-                        propertyTemplate.getName(), value, constraint
+                        propertyTemplate.getName(), value, constraint,
+                        GisSurveyExcelDefine.MESSAGE.OUT_CONSTRAINT
                 ));
             }
         }
@@ -291,7 +298,9 @@ public class InvalidPropertiesFinder {
                 double min = Double.parseDouble(minStr);
                 if (!NumberUtils.isParsable(value) || Double.parseDouble(value) < min) {
                     outConstraintResult.add(GisSurveyThirdImportElement.create(data, layerTemplate,
-                            propertyTemplate.getName(), value, constraint));
+                            propertyTemplate.getName(), value, constraint,
+                            GisSurveyExcelDefine.MESSAGE.OUT_CONSTRAINT
+                    ));
                 }
             }
             //最大值判断
@@ -300,7 +309,9 @@ public class InvalidPropertiesFinder {
                 double max = Double.parseDouble(maxStr);
                 if (!NumberUtils.isParsable(value) || Double.parseDouble(value) > max) {
                     outConstraintResult.add(GisSurveyThirdImportElement.create(data, layerTemplate,
-                            propertyTemplate.getName(), value, constraint));
+                            propertyTemplate.getName(), value, constraint,
+                            GisSurveyExcelDefine.MESSAGE.OUT_CONSTRAINT
+                    ));
                 }
             }
         }
@@ -396,6 +407,7 @@ public class InvalidPropertiesFinder {
             map.put(GisSurveyThirdImportResultHead.KEYS.VALUE, element.getValue());
             if (element.getCondition() != null)
                 map.put(GisSurveyThirdImportResultHead.KEYS.CONDITION, element.getCondition().getRanges());
+            map.put(GisSurveyThirdImportResultHead.KEYS.MESSAGE, element.getMessage());
             return map;
         }).collect(Collectors.toList());
     }

+ 46 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveyExcelDefine.java

@@ -61,4 +61,50 @@ public interface GisSurveyExcelDefine {
         Short ACTION = (short) 1;
         Short STATUS = (short) 4;
     }
+
+    /**
+     * 原因
+     */
+    interface MESSAGE {
+        /**
+         * 无效图层
+         */
+        String INVALID_LAYERS = "未找到该图层,请检查点/线类型是否在模版配置中";
+        /**
+         * 缺失必填
+         */
+        String MISSING_REQUIREMENTS = "必填项缺失,请填写必填项";
+        /**
+         * 无效类型
+         */
+        String INVALID_TYPES = "值类型无效,无法解析为十进制数字";
+        /**
+         * 超出范围
+         */
+        String OUT_RANGES = "坐标点超出范围,请检查坐标值";
+        /**
+         * 超出范围(空值)
+         */
+        String OUT_RANGES_NULL = "坐标点解析失败,请检查坐点值或坐标模版配置";
+        /**
+         * 超出约束
+         */
+        String OUT_CONSTRAINT = "值超出约束,请对照范围填写";
+        /**
+         * 重复点号
+         */
+        String DUPLICATE_POINTS = "点号重复,请去除重复数据";
+        /**
+         * 无效线
+         */
+        String INVALID_LINES = "线无效,请检查该线上下节点是否存在与点表中";
+        /**
+         * 无效线(空值)
+         */
+        String INVALID_LINES_NULL = "线上下节点解析失败,请检查上下节点值或上下节点模版配置";
+        /**
+         * 无效线(全为无效线)
+         */
+        String INVALID_LINES_ALL = "点表为空,请完善线上下节点对应的点信息";
+    }
 }

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

@@ -16,6 +16,7 @@ public class GisSurveyThirdImportResultHead {
     public final static Map<String, String> INVALID_LAYERS = new LinkedHashMap<String, String>() {{
         put(KEYS.KIND, "元素分类");
         put(KEYS.LAYER_NAME, "图层名称");
+        put(KEYS.MESSAGE, "原因");
     }};
 
     /**
@@ -28,6 +29,7 @@ public class GisSurveyThirdImportResultHead {
         put(KEYS.UP_NO, "起点号");
         put(KEYS.DOWN_NO, "终点号");
         put(KEYS.PROPERTY_NAME, "属性名称");
+        put(KEYS.MESSAGE, "原因");
     }};
 
     /**
@@ -40,6 +42,7 @@ public class GisSurveyThirdImportResultHead {
         put(KEYS.UP_NO, "起点号");
         put(KEYS.DOWN_NO, "终点号");
         put(KEYS.PROPERTY_NAME, "属性名称");
+        put(KEYS.MESSAGE, "原因");
     }};
 
     /**
@@ -49,6 +52,7 @@ public class GisSurveyThirdImportResultHead {
         put(KEYS.KIND, "元素分类");
         put(KEYS.LAYER_NAME, "图层名称");
         put(KEYS.NO, "点号");
+        put(KEYS.MESSAGE, "原因");
     }};
 
     /**
@@ -63,6 +67,7 @@ public class GisSurveyThirdImportResultHead {
         put(KEYS.PROPERTY_NAME, "属性名称");
         put(KEYS.VALUE, "值");
         put(KEYS.CONDITION, "范围");
+        put(KEYS.MESSAGE, "原因");
     }};
 
     /**
@@ -71,6 +76,7 @@ public class GisSurveyThirdImportResultHead {
     public final static Map<String, String> DUPLICATE_POINTS = new LinkedHashMap<String, String>() {{
         put(KEYS.KIND, "元素分类");
         put(KEYS.NO, "点号");
+        put(KEYS.MESSAGE, "原因");
     }};
 
     /**
@@ -81,6 +87,7 @@ public class GisSurveyThirdImportResultHead {
         put(KEYS.UP_NO, "起点号");
         put(KEYS.DOWN_NO, "终点号");
         put(KEYS.PROPERTY_NAME, "属性名称");
+        put(KEYS.MESSAGE, "原因");
     }};
 
     /**
@@ -119,5 +126,9 @@ public class GisSurveyThirdImportResultHead {
          * 约束条件
          */
         String CONDITION = "condition";
+        /**
+         * 原因
+         */
+        String MESSAGE = "message";
     }
 }

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

@@ -51,27 +51,36 @@ public class GisSurveyThirdImportElement {
      */
     private String value;
 
-    public GisSurveyThirdImportElement(String kind, String no, String layerName, String propertyName) {
+    /**
+     * 原因
+     */
+    private String message;
+
+    public GisSurveyThirdImportElement(String kind, String no, String layerName, String propertyName, String message) {
         this.kind = kind;
         this.no = no;
         this.layerName = layerName;
         this.propertyName = propertyName;
+        this.message = message;
     }
 
-    public GisSurveyThirdImportElement(String kind, String upNO, String downNO, String layerName, String propertyName) {
+    public GisSurveyThirdImportElement(String kind, String upNO, String downNO, String layerName, String propertyName, String message) {
         this.kind = kind;
         this.upNO = upNO;
         this.downNO = downNO;
         this.layerName = layerName;
         this.propertyName = propertyName;
+        this.message = message;
     }
 
-    public static GisSurveyThirdImportElement create(Map<String, String> data, GisMetadataLayerTemplate layerTemplate, String propertyName) {
+    public static GisSurveyThirdImportElement create(Map<String, String> data, GisMetadataLayerTemplate layerTemplate
+            , String propertyName, String message) {
         if (Objects.equals(GisMetadataDefine.TYPE_KINE.POINT, layerTemplate.getKind())) {
             return new GisSurveyThirdImportElement(GisMetadataDefine.TYPE_KINE.POINT,
                     ThirdImportTemplateUtils.getValue(data, layerTemplate, GisSurveyExcelDefine.TEMPLATE.NO),
                     layerTemplate.getName(),
-                    propertyName
+                    propertyName,
+                    message
             );
         }
         if (Objects.equals(GisMetadataDefine.TYPE_KINE.LINE, layerTemplate.getKind())) {
@@ -79,15 +88,16 @@ public class GisSurveyThirdImportElement {
                     ThirdImportTemplateUtils.getValue(data, layerTemplate, GisSurveyExcelDefine.TEMPLATE.UP_NO),
                     ThirdImportTemplateUtils.getValue(data, layerTemplate, GisSurveyExcelDefine.TEMPLATE.DOWN_NO),
                     layerTemplate.getName(),
-                    propertyName
+                    propertyName,
+                    message
             );
         }
         return null;
     }
 
     public static GisSurveyThirdImportElement create(Map<String, String> data, GisMetadataLayerTemplate layerTemplate
-            , String propertyName, String value, GisSurveyCondition condition) {
-        GisSurveyThirdImportElement element = create(data, layerTemplate, propertyName);
+            , String propertyName, String value, GisSurveyCondition condition, String message) {
+        GisSurveyThirdImportElement element = create(data, layerTemplate, propertyName, message);
         if (element == null) return null;
         element.setValue(value);
         element.setCondition(condition);