Parcourir la source

2-7百分比 两位小数

yangyj il y a 2 mois
Parent
commit
584b4a9b78

+ 5 - 1
blade-common/src/main/java/org/springblade/common/utils/BaseUtils.java

@@ -103,7 +103,7 @@ public class BaseUtils {
         }
     }
 
-    /*最小分割片*/
+    /**最小分割片*/
     public static int sliceNumber(Integer len,Integer capacity){
         return (int)Math.ceil(len/(double)capacity);
     }
@@ -159,6 +159,10 @@ public class BaseUtils {
         }
     }
 
+    public static String bigDecimalScale(Object s,int scale){
+             return str2BigDecimal(s).setScale(scale,RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
+    }
+
     /*默认返回零*/
     public static Double obj2DoubleZero(Object obj) {
         if(obj instanceof  Double){

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

@@ -1653,7 +1653,7 @@ public class ExecutorMeter extends FormulaExecutor {
                     sis.setCompleted(end.getCompleted().toPlainString());
                     sis.setCurrentPeriodEndPay(end.getMoney().toPlainString());
                     BigDecimal percent= BaseUtils.str2BigDecimal(ratioFc.apply(sis.getCurrentPeriodEndPay(), sis.getChangeMoney()));
-                    if(BigDecimal.ZERO.compareTo(percent)>0) {
+                    if(BigDecimal.ZERO.compareTo(percent)<0) {
                         /*百分比大于零才显示*/
                         sis.setPayRatio(percent.setScale(2,RoundingMode.HALF_UP).stripTrailingZeros().toPlainString()+"%");
                     }