Browse Source

往期累计,本期支付,累计支付

yangyj 1 year ago
parent
commit
6e5034a1ed

+ 0 - 2
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/InterimPaymentCertificate.java

@@ -57,8 +57,6 @@ public class InterimPaymentCertificate implements  DataModel{
     private String constructionTotal;
     private String constructionTotal;
     /**是否是汇总小结数据,输出的时候显示,计算的时候不参与*/
     /**是否是汇总小结数据,输出的时候显示,计算的时候不参与*/
     private Boolean isSummary=false;
     private Boolean isSummary=false;
-
-
     /**本期末支付金额*/
     /**本期末支付金额*/
     @JSONField(name = "key_12",label="本期末变更金额",ordinal = 10)
     @JSONField(name = "key_12",label="本期末变更金额",ordinal = 10)
     private String currentPeriodEndChangeMoney;
     private String currentPeriodEndChangeMoney;

+ 2 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MeterInfo.java

@@ -46,7 +46,8 @@ public class MeterInfo {
     /**合同段所有支付项信息*/
     /**合同段所有支付项信息*/
     List<MidPayItem> midPayItemList;
     List<MidPayItem> midPayItemList;
     /**支付信息*/
     /**支付信息*/
-    List<Payment> paymentList;
+    /*List<Payment> paymentList;*/
+    LinkedHashMap<Integer,List<Payment>> paymentListMap;
     /**需要延后生成FormData(元素对象)*/
     /**需要延后生成FormData(元素对象)*/
     List<DataModel> delay =new LinkedList<>();
     List<DataModel> delay =new LinkedList<>();
     /**合同工程清单*/
     /**合同工程清单*/

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

@@ -91,7 +91,9 @@ public class ExecutorInit extends FormulaExecutor {
             changeToken();
             changeToken();
             /*材料调差*/
             /*材料调差*/
             materialAdjust();
             materialAdjust();
-            tec.meterInfo.setPaymentList(paymentListFc.apply(tec.getContractId()));
+            /*支付信息*/
+            payment();
+            /*tec.meterInfo.setPaymentList(paymentListFc.apply(tec.getContractId()));*/
             /*合同工程清单*/
             /*合同工程清单*/
             tec.meterInfo.setInventoryForms(CompletableFuture.supplyAsync(() ->  inventoryFormFc.apply(tec.getContractId())));
             tec.meterInfo.setInventoryForms(CompletableFuture.supplyAsync(() ->  inventoryFormFc.apply(tec.getContractId())));
 
 
@@ -188,6 +190,24 @@ public class ExecutorInit extends FormulaExecutor {
         }
         }
     }
     }
 
 
+
+    BiFunction< LinkedHashMap<Integer,List<Payment>>, Predicate<Map.Entry<Integer,List<Payment>>>, List<Payment>>
+            paymentListPick = (a,b)-> a.entrySet().stream().filter(b).flatMap(kv->kv.getValue().stream()).collect(Collectors.toList());
+
+    private void payment(){
+        List<Payment> paymentList = paymentListFc.apply(tec.getContractId());
+        if(paymentList.size()>0){
+            LinkedHashMap<Integer,List<Payment>> tmp = paymentList.stream().collect(Collectors.groupingBy(Payment::getSort,LinkedHashMap::new,Collectors.toList()));
+            int sort = tec.periodInfo.getSort();
+            LinkedHashMap<Integer,List<Payment>>paymentListMap = new LinkedHashMap<>();
+            paymentListMap.put(MeterInfo.PRE,paymentListPick.apply(tmp,kv->kv.getKey()<sort));
+            paymentListMap.put(MeterInfo.CUR,paymentListPick.apply(tmp,kv->kv.getKey()==sort));
+            paymentListMap.put(MeterInfo.END,paymentListPick.apply(tmp,kv->kv.getKey()<=sort));
+            tec.meterInfo.setPaymentListMap(paymentListMap);
+        }
+
+    }
+
     /**
     /**
      * type=0 返回本期
      * type=0 返回本期
      *  periodInfo.startDate   <  changeApprovalDate <= periodInfo.endDate  的changeTokenList
      *  periodInfo.startDate   <  changeApprovalDate <= periodInfo.endDate  的changeTokenList

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

@@ -22,10 +22,7 @@ import java.time.LocalDate;
 import java.util.*;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.BiFunction;
-import java.util.function.BinaryOperator;
-import java.util.function.Consumer;
-import java.util.function.Function;
+import java.util.function.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
 import java.util.stream.Stream;
@@ -425,16 +422,14 @@ public class ExecutorMeter extends FormulaExecutor {
             List<ChangeToken> changeTokenList2 =changeTokenListMap.get(MeterInfo.END);
             List<ChangeToken> changeTokenList2 =changeTokenListMap.get(MeterInfo.END);
 
 
             Map<String,InterimPaymentCertificate> paymentCertificateMap = new LinkedHashMap<>();
             Map<String,InterimPaymentCertificate> paymentCertificateMap = new LinkedHashMap<>();
-            List<Payment> paymentList=tec.meterInfo.getPaymentList();
-             if(Func.isNotEmpty(paymentList)){
+             if(Func.isNotEmpty(tec.meterInfo.getPaymentListMap())){
+                 LinkedHashMap<Integer,List<Payment>>paymentListMap = tec.meterInfo.getPaymentListMap();
                  /*之前的计量期数据*/
                  /*之前的计量期数据*/
-                 previous = paymentList.stream().filter(e->e.getSort()<tec.periodInfo.getSort()).collect(Collectors.toList());
+                 previous = paymentListMap.get(MeterInfo.PRE);
                  /*当前计量期数据*/
                  /*当前计量期数据*/
-                 current = paymentList.stream().filter(e-> e.getSort().equals(tec.periodInfo.getSort())).collect(Collectors.toList());
+                 current =paymentListMap.get(MeterInfo.CUR);
                  /*累计到本期末*/
                  /*累计到本期末*/
-                 paymentsPeriodEnd=paymentList.stream().filter(e->e.getSort()<=tec.periodInfo.getSort()).collect(Collectors.toList());
-                 /*往期累计,本期支付,累计支付*/
-                 periodCount();
+                 paymentsPeriodEnd=paymentListMap.get(MeterInfo.END);
                  /*往期每章节的实际花费*/
                  /*往期每章节的实际花费*/
                  Map<String,BigDecimal> previousMoney= this.moneySum.apply(previous);
                  Map<String,BigDecimal> previousMoney= this.moneySum.apply(previous);
                  /*当前计量期每章节的实际花费*/
                  /*当前计量期每章节的实际花费*/
@@ -480,6 +475,7 @@ public class ExecutorMeter extends FormulaExecutor {
                  List<InterimPaymentCertificate> payItemZj=new ArrayList<>();
                  List<InterimPaymentCertificate> payItemZj=new ArrayList<>();
                  if(MeterInfo.MB_ZJ.equals(tec.meterInfo.getConfig())){
                  if(MeterInfo.MB_ZJ.equals(tec.meterInfo.getConfig())){
                      InterimPaymentCertificate xj=new InterimPaymentCertificate("小计");
                      InterimPaymentCertificate xj=new InterimPaymentCertificate("小计");
+                     xj.setIsSummary(true);
                      addGetSetConfig(xj,summaryConfigMap,InterimPaymentCertificate::getContractAmount,xj::setContractAmount);
                      addGetSetConfig(xj,summaryConfigMap,InterimPaymentCertificate::getContractAmount,xj::setContractAmount);
                      addGetSetConfig(xj,summaryConfigMap,InterimPaymentCertificate::getRevisedTotal,xj::setRevisedTotal);
                      addGetSetConfig(xj,summaryConfigMap,InterimPaymentCertificate::getRevisedTotal,xj::setRevisedTotal);
                      addGetSetConfig(xj,summaryConfigMap,InterimPaymentCertificate::getRevisedAmount,xj::setRevisedAmount);
                      addGetSetConfig(xj,summaryConfigMap,InterimPaymentCertificate::getRevisedAmount,xj::setRevisedAmount);
@@ -501,6 +497,7 @@ public class ExecutorMeter extends FormulaExecutor {
                      }
                      }
                      payItemZj.add(jgtz);
                      payItemZj.add(jgtz);
                      InterimPaymentCertificate hj = new InterimPaymentCertificate("合计");
                      InterimPaymentCertificate hj = new InterimPaymentCertificate("合计");
+                     hj.setIsSummary(true);
                      addGetSetConfig(hj,summaryConfigMap,InterimPaymentCertificate::getCurrentPeriodEndPay,hj::setCurrentPeriodEndPay);
                      addGetSetConfig(hj,summaryConfigMap,InterimPaymentCertificate::getCurrentPeriodEndPay,hj::setCurrentPeriodEndPay);
                      addGetSetConfig(hj,summaryConfigMap,InterimPaymentCertificate::getPreviousPeriodEndPay,hj::setPreviousPeriodEndPay);
                      addGetSetConfig(hj,summaryConfigMap,InterimPaymentCertificate::getPreviousPeriodEndPay,hj::setPreviousPeriodEndPay);
                      addGetSetConfig(hj,summaryConfigMap,InterimPaymentCertificate::getCurrentPeriodPay,hj::setCurrentPeriodPay);
                      addGetSetConfig(hj,summaryConfigMap,InterimPaymentCertificate::getCurrentPeriodPay,hj::setCurrentPeriodPay);
@@ -542,12 +539,14 @@ public class ExecutorMeter extends FormulaExecutor {
                      });
                      });
                      dataList.addAll(payItemZj);
                      dataList.addAll(payItemZj);
                      /*分行合计列*/
                      /*分行合计列*/
-                     fieldGetSet(summaryConfigMap);
+                     fieldGetSet(summaryConfigMap,x->!x.getIsSummary());
                      /*计算合计值*/
                      /*计算合计值*/
                  }
                  }
              }
              }
             /*数据获取end*/
             /*数据获取end*/
              double total=dataList.stream().map(InterimPaymentCertificate::getCurrentPeriodPay).mapToDouble(BaseUtils::obj2DoubleZero).sum();
              double total=dataList.stream().map(InterimPaymentCertificate::getCurrentPeriodPay).mapToDouble(BaseUtils::obj2DoubleZero).sum();
+            /*往期累计,本期支付,累计支付*/
+            periodCount(dataList.get(dataList.size()-1));
              if(total>0){
              if(total>0){
                  FormData ft =tec.formDataMap.get(InterimPaymentCertificate.TBN+ StringPool.COLON+"key_9");
                  FormData ft =tec.formDataMap.get(InterimPaymentCertificate.TBN+ StringPool.COLON+"key_9");
                  put2FormData(ft,total);
                  put2FormData(ft,total);
@@ -561,8 +560,11 @@ public class ExecutorMeter extends FormulaExecutor {
             putOut();
             putOut();
         }
         }
 
 
-        public void periodCount(){
-            if(paymentsPeriodEnd.size()>0){
+        public void periodCount(InterimPaymentCertificate last){
+            tec.periodInfo.setPreTotal(last.getPreviousPeriodEndPay());
+            tec.periodInfo.setCurTotal(last.getCurrentPeriodPay());
+            tec.periodInfo.setTotal(last.getCurrentPeriodEndPay());
+         /*   if(paymentsPeriodEnd.size()>0){
                 FormData fd=tec.formDataMap.get(MeterPeriodInfo.TBN+":key_7");
                 FormData fd=tec.formDataMap.get(MeterPeriodInfo.TBN+":key_7");
                 if(fd!=null) {
                 if(fd!=null) {
                     elementWriter.write(fd, paymentsPeriodEnd.stream().mapToDouble(p -> Double.parseDouble(p.getMoney())).sum());
                     elementWriter.write(fd, paymentsPeriodEnd.stream().mapToDouble(p -> Double.parseDouble(p.getMoney())).sum());
@@ -579,7 +581,7 @@ public class ExecutorMeter extends FormulaExecutor {
                 if(fd!=null) {
                 if(fd!=null) {
                     elementWriter.write(fd, previous.stream().mapToDouble(p -> Double.parseDouble(p.getMoney())).sum());
                     elementWriter.write(fd, previous.stream().mapToDouble(p -> Double.parseDouble(p.getMoney())).sum());
                 }
                 }
-            }
+            }*/
         }
         }
 
 
         /**
         /**
@@ -1342,11 +1344,11 @@ public class ExecutorMeter extends FormulaExecutor {
             FormulaUtils.put2FormData(fdm, fieldDataFcMap,dataList);
             FormulaUtils.put2FormData(fdm, fieldDataFcMap,dataList);
         };
         };
         /*批量计算列表中之前的字段和,并赋值到当前字段*/
         /*批量计算列表中之前的字段和,并赋值到当前字段*/
-        public void fieldGetSet(Map<T,Map<Function<T,String>,Consumer<String>>> gsMap){
+        public void fieldGetSet(Map<T,Map<Function<T,String>,Consumer<String>>> gsMap, Predicate<T> p){
             gsMap.forEach((b,m)->{
             gsMap.forEach((b,m)->{
                 List<T> dl = dataList.stream().limit(dataList.indexOf(b)).collect(Collectors.toList());
                 List<T> dl = dataList.stream().limit(dataList.indexOf(b)).collect(Collectors.toList());
                 m.forEach((f,c)->{
                 m.forEach((f,c)->{
-                    c.accept(dl.stream().map(f).map(BaseUtils::str2BigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
+                    c.accept(dl.stream().filter(p).map(f).map(BaseUtils::str2BigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
                 });
                 });
             });
             });
         }
         }