Переглянути джерело

修复经纬度没有截断的问题

欧阳劲驰 1 місяць тому
батько
коміт
c0525cdb11

+ 20 - 9
src/main/java/com/shkpr/service/alambizplugin/components/GisSurveyThirdImporter.java

@@ -389,13 +389,6 @@ public class GisSurveyThirdImporter {
         layerApply.setCode(PointCodeUtil.generateCode());
         layerApply.setLayer(layerTemplate.getKey());
         layerApply.setKind(GisMetadataDefine.TYPE_KINE.POINT);
-        //解析坐标
-        String lngStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.TEMPLATE.LNG);
-        String latStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.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(GisSurveyExcelDefine.DEFAULT_VALUE.APPLY);
         layerApply.setSource(GisSurveyExcelDefine.DEFAULT_VALUE.SOURCE);
@@ -403,6 +396,9 @@ public class GisSurveyThirdImporter {
         String noStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.TEMPLATE.NO);
         if (StringUtils.isNotBlank(noStr))
             layerApply.setNo(StringUtils.substring(noStr, 0, 64));
+        //经纬度
+        Double lng = null;
+        Double lat = null;
         //遍历属性模版
         List<GisSurveyPropertyValueThirdCopy> propertyValueList = new ArrayList<>();
         for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) {
@@ -412,15 +408,30 @@ public class GisSurveyThirdImporter {
             //不为空,填入数据
             if (propertyValue != null) {
                 propertyValueList.add(propertyValue);
+                //经纬度属性
+                if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.LNG)
+                        && NumberUtils.isParsable(propertyValue.getValue()))
+                    lng = Double.valueOf(propertyValue.getValue());
+                if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.LAT)
+                        && NumberUtils.isParsable(propertyValue.getValue()))
+                    lat = Double.valueOf(propertyValue.getValue());
                 //高程和埋深
-                if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.ELEVATION))
+                if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.ELEVATION)
+                        && NumberUtils.isParsable(propertyValue.getValue()))
                     layerApply.setElevation(Double.valueOf(propertyValue.getValue()));
-                if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.DEPTH))
+                if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.DEPTH)
+                        && NumberUtils.isParsable(propertyValue.getValue()))
                     layerApply.setDepth(Double.valueOf(propertyValue.getValue()));
             }
         }
         layerApply.setPropertyValues(propertyValueList);
 
+        //填入经纬度
+        if (lng != null && lat != null) {
+            Point geometry = geometryFactory.createPoint(new Coordinate(lng, lat));
+            layerApply.setGis(geometry);
+        }
+
         return layerApply;
     }