|
@@ -16,15 +16,14 @@ import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.function.BiFunction;
|
|
|
import java.util.function.BinaryOperator;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.IntStream;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* @author yangyj
|
|
@@ -605,16 +604,11 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
/*把所有计量期根据打印日期按自然月分类,支付信息按计量期分类*/
|
|
|
LinkedHashMap<Long,MeterPeriodInfo> meterPeriodInfoMap = tec.meterInfo.getMeterPeriodInfoLinkedHashMap();
|
|
|
LinkedHashMap<Integer,MeterPeriodInfo> monthMeterMap=meterPeriodInfoMap.values().stream().collect(Collectors.toMap(e->e.getFormPrintDate().getMonthValue(),t->t,(v1,v2)->v2,LinkedHashMap::new));
|
|
|
- /*根据计量期分组*/
|
|
|
- Map<Long,List<Payment>> paymentGroup=paymentsPeriodEnd.stream().collect(Collectors.groupingBy(Payment::getPeriodId,Collectors.toList()));
|
|
|
- monthMeterMap.forEach((k,v)->{
|
|
|
- for(int i = 1; i<= k; i++){
|
|
|
- MeterPeriodInfo tmp = monthMeterMap.get(k);
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- totalList.forEach(sis->{
|
|
|
- BaseInfo baseInfo =tec.meterInfo.getBaseInfo();
|
|
|
+ /*根据清单编号、计量期分组*/
|
|
|
+ Map<String,Map<Long,List<Payment>>> paymentGroup=paymentsPeriodEnd.stream().collect(Collectors.groupingBy(Payment::getNumber,Collectors.groupingBy(Payment::getPeriodId,Collectors.toList())));
|
|
|
+ int max=monthMeterMap.keySet().stream().max(Comparator.comparingInt(t->t)).orElse(12);
|
|
|
+ BaseInfo baseInfo =tec.meterInfo.getBaseInfo();
|
|
|
+ totalList.forEach(sis->{
|
|
|
/*单项占合同价的比例*/
|
|
|
sis.setItemPercent(ratioFc.apply(sis.getChangeMoney(),baseInfo.getTotalAmount().toString()));
|
|
|
/*单项计划完成完成比例*/
|
|
@@ -624,8 +618,70 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
/*本期末累计支付金额占合同比*/
|
|
|
sis.setPayPercent(ratioFc.apply(sis.getCurrentPeriodEndPay(),sis.getChangeMoney()));
|
|
|
/*根据月份来获取payment*/
|
|
|
- sis.getFormNumber();
|
|
|
+ Map<Long,List<Payment>> meterPaymentGroup = paymentGroup.get(sis.getFormNumber());
|
|
|
+ /*当前月已经累计的*/
|
|
|
+ List<Payment> pl =new ArrayList<>();
|
|
|
+ for(int i=1;i<=max;i++){
|
|
|
+ MeterPeriodInfo period = monthMeterMap.get(i);
|
|
|
+ if(period!=null) {
|
|
|
+ List<Payment> pays = meterPaymentGroup.get(period.getId());
|
|
|
+ if (Func.isNotEmpty(pays)) {
|
|
|
+ pl.addAll(pays);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(pl.size()>0) {
|
|
|
+ sis.getMonthlyCompletion().add(new ArrayList<>(pl));
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
+ /*输出设置*/
|
|
|
+ /*合同按月计划完成进度*/
|
|
|
+ fieldDataFcMap.put(SubprojectInterimPaymentSummary.TBN+":key_21",dl->dl.stream().flatMap(e->{
|
|
|
+ List<List<Payment>> l= e.getMonthlyCompletion();
|
|
|
+ return IntStream.range(0,12).boxed().map(month->{
|
|
|
+ if(month>=l.size()){
|
|
|
+ return StringPool.EMPTY;
|
|
|
+ }else{
|
|
|
+ List<Payment> cur=l.get(month);
|
|
|
+ String money=cur.stream().map(Payment::getMoneyAsBigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toString();
|
|
|
+ String change =cur.get(0).getChangeMoney();
|
|
|
+ return ratioFc.apply(money,change);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+ /*分页*/
|
|
|
+ List<List<SubprojectInterimPaymentSummary>> pageList = BaseUtils.splitList(totalList,capacity);
|
|
|
+ BiFunction<List<SubprojectInterimPaymentSummary>,Function<SubprojectInterimPaymentSummary,String>,String> sumFc= (page,fc)->page.stream().map(fc).map(BaseUtils::str2BigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toString();
|
|
|
+ pageList.forEach(page->{
|
|
|
+ dataList.addAll(page);
|
|
|
+ SubprojectInterimPaymentSummary sis = new SubprojectInterimPaymentSummary("合计 (万元)");
|
|
|
+ /*合同金额*/
|
|
|
+ sis.setContractMoney(sumFc.apply(page,SubprojectInterimPaymentSummary::getContractMoney));
|
|
|
+ /*变更后的金额*/
|
|
|
+ sis.setChangeMoney(sumFc.apply(page,SubprojectInterimPaymentSummary::getChangeMoney));
|
|
|
+ /*实际工程量金额*/
|
|
|
+ sis.setCurrentPeriodPay(page.stream().map(SubprojectInterimPaymentSummary::getCurrentPeriodPay).map(BaseUtils::str2BigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
|
|
|
+ dataList.add(sis);
|
|
|
+ });
|
|
|
+ /*实际完成,累计完成、按月完成*/
|
|
|
+ List<List<List<Payment>>> all =totalList.stream().map(SubprojectInterimPaymentSummary::getMonthlyCompletion).collect(Collectors.toList());
|
|
|
+ FormulaUtils.beRelyFrom(fdm,SubprojectInterimPaymentSummary.TBN+":key_22").forEach(e->e.setRepeat(true));
|
|
|
+ FormulaUtils.beRelyFrom(fdm,SubprojectInterimPaymentSummary.TBN+":key_23").forEach(e->e.setRepeat(true));
|
|
|
+ /*每月合计进度*/
|
|
|
+ List<String> monthlySum= IntStream.range(0,max).boxed().map(month->{
|
|
|
+ List<Payment> tmp= all.stream().flatMap(row->row.get(month).stream()).collect(Collectors.toList());
|
|
|
+ return ratioFc.apply(tmp.stream().map(Payment::getMoneyAsBigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toString(),baseInfo.getTotalAmount().toString());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ FormulaUtils.elementFindByCode(fdm,SubprojectInterimPaymentSummary.TBN+":key_22").ifPresent(t->{
|
|
|
+ elementWriter.write(t,monthlySum);
|
|
|
+ });
|
|
|
+
|
|
|
+ AtomicReference<Double> cp = new AtomicReference<>(0.0);
|
|
|
+ FormulaUtils.elementFindByCode(fdm,SubprojectInterimPaymentSummary.TBN+":key_23").ifPresent(t->{
|
|
|
+ elementWriter.write(t, monthlySum.stream().map(e->{double r=BaseUtils.obj2DoubleZero(e)- cp.get();
|
|
|
+ cp.set(BaseUtils.obj2DoubleZero(e));return r;}).collect(Collectors.toList()));
|
|
|
+ });
|
|
|
+
|
|
|
}else{
|
|
|
LinkedHashMap<String,List<SubprojectInterimPaymentSummary>> chapterGroup= totalList.stream().collect(Collectors.groupingBy(e->getPrefix(e.getFormNumber()),LinkedHashMap::new,Collectors.toList()));
|
|
|
AtomicInteger loop = new AtomicInteger(chapterGroup.size());
|