Browse Source

分项工程中期支付汇总保留小数位

huangtf 8 months ago
parent
commit
f3049b542e

+ 7 - 5
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/SubprojectInterimPaymentSummary.java

@@ -2,6 +2,7 @@ package org.springblade.manager.vo;
 
 import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;
+import org.apache.commons.lang.StringUtils;
 import org.springblade.core.tool.utils.StringPool;
 
 import javax.validation.constraints.NotNull;
@@ -82,17 +83,18 @@ public class SubprojectInterimPaymentSummary {
     public SubprojectInterimPaymentSummary() {
     }
 
-    public void count( @NotNull Consumer<String> setting ,@NotNull  List<SubprojectInterimPaymentSummary> data, @NotNull  Function<SubprojectInterimPaymentSummary,String> fc){
-        setting.accept(data.stream().map(e->new BigDecimal(fc.apply(e))).reduce(BigDecimal.ZERO,BigDecimal::add).setScale(1, RoundingMode.HALF_UP).toString());
+    public void count( @NotNull Consumer<String> setting ,@NotNull  List<SubprojectInterimPaymentSummary> data, @NotNull  Function<SubprojectInterimPaymentSummary,String> fc,@NotNull Integer scale){
+        setting.accept(data.stream().map(e->new BigDecimal(fc.apply(e))).reduce(BigDecimal.ZERO,BigDecimal::add).setScale(scale, RoundingMode.HALF_UP).toString());
     }
 
 
-    public void calculate(List<SubprojectInterimPaymentSummary> data){
+    public void calculate(List<SubprojectInterimPaymentSummary> data,Integer scale){
         if(data!=null&&data.size()>0){
+
             /*本次支付*/
-            count(this::setCurrentPeriodPay,data,SubprojectInterimPaymentSummary::getCurrentPeriodPay);
+            count(this::setCurrentPeriodPay,data,SubprojectInterimPaymentSummary::getCurrentPeriodPay,scale);
             /*本次累计支付*/
-            count(this::setCurrentPeriodEndPay,data,SubprojectInterimPaymentSummary::getCurrentPeriodEndPay);
+            count(this::setCurrentPeriodEndPay,data,SubprojectInterimPaymentSummary::getCurrentPeriodEndPay,scale);
         }
     }
 }

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

@@ -603,14 +603,14 @@ public class ExecutorMeter extends FormulaExecutor {
                     if(placeholderSize>0){
                         tmp.addAll(Collections.nCopies(placeholderSize,new SubprojectInterimPaymentSummary()));
                     }
-                    subtotal(new SubprojectInterimPaymentSummary("本页小计"),tmp,currentPageData);
+                    subtotal(new SubprojectInterimPaymentSummary("本页小计"),tmp,currentPageData,tec.getScale());
                     if(m>1) {
                         /*本章小结*/
-                        subtotal(new SubprojectInterimPaymentSummary("章合计"),tmp,v);
+                        subtotal(new SubprojectInterimPaymentSummary("章合计"),tmp,v,tec.getScale());
                     }
                     if(m>2){
                         /*所有章合计*/
-                        subtotal(new SubprojectInterimPaymentSummary("所有章合计"),tmp,totalList);
+                        subtotal(new SubprojectInterimPaymentSummary("所有章合计"),tmp,totalList,tec.getScale());
                     }
                     dataList.addAll(tmp);
                     tmp.clear();
@@ -621,8 +621,9 @@ public class ExecutorMeter extends FormulaExecutor {
         }
 
 
-        public void subtotal(SubprojectInterimPaymentSummary b,  List<SubprojectInterimPaymentSummary> result ,List<SubprojectInterimPaymentSummary> data){
-            b.calculate(data);
+        public void subtotal(SubprojectInterimPaymentSummary b,  List<SubprojectInterimPaymentSummary> result ,List<SubprojectInterimPaymentSummary> data,Integer scale){
+            b.calculate(data,scale);
+
             result.add(b);
         }