Browse Source

修复bug:1.excel读取数字类型小数位截断,2.excel读取数字类型整数补0,3.属性表上下code写入一样,4.点的高程和埋深未按属性模版精度截断

欧阳劲驰 1 month ago
parent
commit
3a9935416c

+ 2 - 1
src/main/java/com/shkpr/service/alambizplugin/commtools/ExcelUtils.java

@@ -15,6 +15,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.ArrayList;
@@ -383,7 +384,7 @@ public class ExcelUtils {
                     if (DateUtil.isCellDateFormatted(cell)) {
                         value = TimeTool.convertDateObj2DateStr(cell.getDateCellValue(), cell.getCellStyle().getDataFormatString());
                     } else if (String.valueOf(cell.getNumericCellValue()).contains(".")) {
-                        value = String.format("%f", cell.getNumericCellValue());
+                        value = BigDecimal.valueOf(cell.getNumericCellValue()).stripTrailingZeros().toPlainString();
                     } else
                         value = String.valueOf(cell.getNumericCellValue());
                 }

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

@@ -399,13 +399,6 @@ public class GisSurveyThirdImporter {
         //默认值
         layerApply.setApply(GisSurveyExcelDefine.DEFAULT_VALUE.APPLY);
         layerApply.setSource(GisSurveyExcelDefine.DEFAULT_VALUE.SOURCE);
-        //高程和埋深
-        String elevationStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.TEMPLATE.ELEVATION);
-        if (NumberUtils.isParsable(elevationStr))
-            layerApply.setElevation(Double.parseDouble(elevationStr));
-        String depthStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.TEMPLATE.DEPTH);
-        if (NumberUtils.isParsable(depthStr))
-            layerApply.setDepth(Double.parseDouble(depthStr));
         //点号(长度64截断)
         String noStr = ThirdImportTemplateUtils.getValue(point, layerTemplate, GisSurveyExcelDefine.TEMPLATE.NO);
         if (StringUtils.isNotBlank(noStr))
@@ -416,7 +409,15 @@ public class GisSurveyThirdImporter {
             //解析属性
             GisSurveyPropertyValueThirdCopy propertyValue = decodeDataToPropertyValue(point, layerApply
                     , propertyTemplate, params);
-            if (propertyValue != null) propertyValueList.add(propertyValue);
+            //不为空,填入数据
+            if (propertyValue != null) {
+                propertyValueList.add(propertyValue);
+                //高程和埋深
+                if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.ELEVATION))
+                    layerApply.setElevation(Double.valueOf(propertyValue.getValue()));
+                if (Objects.equals(propertyValue.getProperty(), GisSurveyExcelDefine.TEMPLATE.DEPTH))
+                    layerApply.setDepth(Double.valueOf(propertyValue.getValue()));
+            }
         }
         layerApply.setPropertyValues(propertyValueList);
 
@@ -483,7 +484,7 @@ public class GisSurveyThirdImporter {
                     , propertyTemplate.getKey(), layerApply.getUpNode());
         if (Objects.equals(GisSurveyExcelDefine.TEMPLATE.DOWN_NODE, propertyTemplate.getKey()))
             return new GisSurveyPropertyValueThirdCopy(params.getJobId(), layerApply.getCode()
-                    , propertyTemplate.getKey(), layerApply.getUpNode());
+                    , propertyTemplate.getKey(), layerApply.getDownNode());
 
         //获取表头
         String templateName = propertyTemplate.getName();