浏览代码

计量移除自动设置小数位

yangyj 1 年之前
父节点
当前提交
a95bc35e59

+ 8 - 1
blade-service/blade-manager/src/main/java/com/mixsmart/utils/FormulaUtils.java

@@ -925,7 +925,7 @@ public class FormulaUtils {
         return result;
         return result;
     }
     }
 
 
-
+    /*保留小数缺失的情况会自动识别小数位*/
     public static List<ElementData> setScale(Integer scale, List<ElementData> data){
     public static List<ElementData> setScale(Integer scale, List<ElementData> data){
         if(scale==null){
         if(scale==null){
             scale=StringUtils.getScale(data.stream().map(ElementData::getValue).filter(StringUtils::isDouble).collect(Collectors.toList()));
             scale=StringUtils.getScale(data.stream().map(ElementData::getValue).filter(StringUtils::isDouble).collect(Collectors.toList()));
@@ -934,6 +934,13 @@ public class FormulaUtils {
         return data.stream().peek(e->{if(StringUtils.isDouble(e.getValue())){e.setValue(StringUtils.number2StringZero(e.getValue(),finalScale));}}).collect(Collectors.toList());
         return data.stream().peek(e->{if(StringUtils.isDouble(e.getValue())){e.setValue(StringUtils.number2StringZero(e.getValue(),finalScale));}}).collect(Collectors.toList());
     }
     }
 
 
+    /*不会自动识别小数位*/
+    public static List<ElementData> setScaleMeter(Integer scale, List<ElementData> data){
+        if(scale!=null){
+            return data.stream().peek(e->{if(StringUtils.isDouble(e.getValue())){e.setValue(StringUtils.number2StringZero(e.getValue(),scale));}}).collect(Collectors.toList());
+        }
+       return data;
+    }
 
 
     /**
     /**
      * @Description  定位信息排序
      * @Description  定位信息排序

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorFormat.java

@@ -37,7 +37,7 @@ public class ExecutorFormat extends FormulaExecutor {
                 if(f!=null){
                 if(f!=null){
                     if(!fd.empty()&&fd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isNumber)) {
                     if(!fd.empty()&&fd.getValues().stream().map(ElementData::getValue).anyMatch(StringUtils::isNumber)) {
                         /*保留小数位*/
                         /*保留小数位*/
-                        fd.setValues(FormulaUtils.setScale(f.getScale(), fd.getValues()));
+                        fd.setValues(FormulaUtils.setScaleMeter(f.getScale(), fd.getValues()));
                     }
                     }
                     if(StringUtils.isNotEmpty(f.getRely())&&f.getRelyList().size()==1&&repeatKeys.contains(f.getRely())){
                     if(StringUtils.isNotEmpty(f.getRely())&&f.getRelyList().size()==1&&repeatKeys.contains(f.getRely())){
                         /*设置为repeat元素*/
                         /*设置为repeat元素*/