瀏覽代碼

Merge remote-tracking branch 'origin/master' into master

yangyj 1 年之前
父節點
當前提交
1861d71657

+ 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);
         }
     }
 }

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

@@ -619,14 +619,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();
@@ -637,8 +637,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);
         }
 
@@ -726,6 +727,8 @@ public class ExecutorMeter extends FormulaExecutor {
                         /*每一章需要留一行做小计,其他要填充空白行*/
                         SubInterimMeterPaySummary summary=  new SubInterimMeterPaySummary("小计");
                         summary.setCurrentPeriodEndPay(tmp.stream().map(SubInterimMeterPaySummary::getCurrentPeriodEndPay).filter(BaseUtils::isNumber).map(BigDecimal::new).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
+                        summary.setCurrentPeriodEndPay(StringUtils.number2StringZero(summary.getCurrentPeriodEndPay(),tec.getScale()));
+
                         int over = size*capacity-1-tmp.size();
                         if(over>0){
                             /*填充空白行*/
@@ -854,7 +857,7 @@ public class ExecutorMeter extends FormulaExecutor {
             if(dataList.size()>0){
                 InterimMeterPaySummary summary = new InterimMeterPaySummary("合计");
                 double sum=dataList.stream().map(InterimMeterPaySummary::getMoney).filter(StringUtils::isNumber).mapToDouble(Double::parseDouble).sum();
-                summary.setMoney(StringUtils.number2StringZero(sum,2));
+                summary.setMoney(StringUtils.number2StringZero(sum,tec.getScale()));
                 dataList.add(summary);
             }
             putOut(InterimMeterPaySummary.class);