|
@@ -28,7 +28,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.function.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.IntStream;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* @author yangyj
|
|
@@ -80,6 +79,7 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
private BinaryOperator<String> multiFc = (a,b)-> BaseUtils.str2BigDecimal(a).multiply(BaseUtils.str2BigDecimal(b)).toString();
|
|
|
/*加法*/
|
|
|
private BinaryOperator<String> addFc = (a,b)-> BaseUtils.str2BigDecimal(a).add(BaseUtils.str2BigDecimal(b)).toString();
|
|
|
+
|
|
|
/**根据清单编号获取支付项目章节编号*/
|
|
|
public String getPrefix(String fn){
|
|
|
if(fn!=null) {
|
|
@@ -353,14 +353,14 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
/* Arrays.asList("正常监理服务费","其他费用","附加监理服务费","额外服务费","缺陷期监理服务费","小计","费用调整","合计","监理单位违约金","奖励","动员预付款","扣回动员预付款","实际支付金额");*/
|
|
|
{
|
|
|
itemNamesMap.put("正常监理服务费","100");
|
|
|
- itemNamesMap.put("其他费用","-100");
|
|
|
+ itemNamesMap.put("其他费用","300");
|
|
|
itemNamesMap.put("附加监理服务费","-100");
|
|
|
itemNamesMap.put("额外服务费","-100");
|
|
|
itemNamesMap.put("缺陷期监理服务费","200");
|
|
|
itemNamesMap.put("小计","-1");
|
|
|
itemNamesMap.put("费用调整","-100");
|
|
|
itemNamesMap.put("合计","-1");
|
|
|
- itemNamesMap.put("监理单位违约金","-100");
|
|
|
+ itemNamesMap.put("监理单位违约金","-101");
|
|
|
itemNamesMap.put("奖励","-100");
|
|
|
itemNamesMap.put("动员预付款","-100");
|
|
|
itemNamesMap.put("扣回动员预付款","-100");
|
|
@@ -395,34 +395,7 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
SupervisionCertificate sc = new SupervisionCertificate();
|
|
|
sc.setItemName(k);
|
|
|
sc.setMonth(tec.periodInfo.getMonth());
|
|
|
- if(!v.isEmpty()&&!v.equals("-1")&&!v.equals("-100")){
|
|
|
- InterimPayCertificateItem current = currentMap.computeIfAbsent(k,w->new InterimPayCertificateItem());
|
|
|
- List<Payment> p = pre.stream().filter(e->getPrefix(e.getNumber()).equals(v)).collect(Collectors.toList());
|
|
|
- List<Payment> c = cur.stream().filter(e->getPrefix(e.getNumber()).equals(v)).collect(Collectors.toList());
|
|
|
- List<Payment> t = end.stream().filter(e->getPrefix(e.getNumber()).equals(v)).collect(Collectors.toList());
|
|
|
- t.stream().findFirst().ifPresent(payment->{
|
|
|
- sc.setPrice(payment.getPrice());
|
|
|
- sc.setContractAmount(payment.getContractMoney());
|
|
|
- /*本期*/
|
|
|
- sc.setCurrentAmount(c.stream().map(e->BaseUtils.str2BigDecimal(e.getMoney())).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
|
|
|
- sc.setCurrentRatio(ratioFc.apply(sc.getCurrentAmount(),sc.getContractAmount()));
|
|
|
- /*上期末*/
|
|
|
- sc.setPreviousEndAmount(p.stream().map(e->BaseUtils.str2BigDecimal(e.getMoney())).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
|
|
|
- sc.setPreviousEndRatio(ratioFc.apply(sc.getPreviousEndAmount(),sc.getContractAmount()));
|
|
|
- /*本期末*/
|
|
|
- sc.setPeriodEndAmount(t.stream().map(e->BaseUtils.str2BigDecimal(e.getMoney())).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
|
|
|
- sc.setPeriodEndRatio(ratioFc.apply(sc.getPeriodEndAmount(),sc.getContractAmount()));
|
|
|
-
|
|
|
- current.setFormName(v);
|
|
|
- current.setChapterSeq(k);
|
|
|
- current.setContractAmount(payment.getContractMoney());
|
|
|
- current.setPreviousPeriodEndPay(sc.getPeriodEndAmount());
|
|
|
- current.setCurrentPeriodPay(sc.getCurrentAmount());
|
|
|
- current.setCurrentPeriodEndPay(sc.getPeriodEndAmount());
|
|
|
- itemList.add(current);
|
|
|
- });
|
|
|
-
|
|
|
- }else if(v.equals("-1")){
|
|
|
+ if(v.equals("-1")){
|
|
|
sc.setIsSummary(true);
|
|
|
addGetSetConfig(sc,summaryConfigMap,SupervisionCertificate::getContractAmount,sc::setContractAmount);
|
|
|
addGetSetConfig(sc,summaryConfigMap,SupervisionCertificate::getPeriodEndAmount,sc::setPeriodEndAmount);
|
|
@@ -432,13 +405,16 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
peerMap.put(sc,current);
|
|
|
current.setChapterSeq(sc.getItemName());
|
|
|
itemList.add(current);
|
|
|
- }else if(v.equals("-100")){
|
|
|
+ }else if(v.equals("-100")||v.equals("-101")){
|
|
|
InterimPayCertificateItem previous = finalPreviousMap.get(k);
|
|
|
InterimPayCertificateItem current = currentMap.computeIfAbsent(k,w->new InterimPayCertificateItem());
|
|
|
sc.setCurrentAmount(current.getCurrentPeriodPay());
|
|
|
if(previous!=null) {
|
|
|
sc.setPreviousEndAmount(previous.getCurrentPeriodEndPay());
|
|
|
}
|
|
|
+ if(v.equals("-101")){
|
|
|
+ sc.setInvertState(MINUS_ONE);
|
|
|
+ }
|
|
|
sc.setPreviousEndAmount(addFc.apply(sc.getCurrentAmount(),sc.getPreviousEndAmount()));
|
|
|
current.setChapterSeq(sc.getItemName());
|
|
|
current.setPreviousPeriodEndPay(sc.getPeriodEndAmount());
|
|
@@ -446,11 +422,38 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
current.setCurrentPeriodEndPay(sc.getPeriodEndAmount());
|
|
|
current.setNoApply(1);
|
|
|
itemList.add(current);
|
|
|
+ } else{
|
|
|
+ InterimPayCertificateItem current = currentMap.computeIfAbsent(k,w->new InterimPayCertificateItem());
|
|
|
+ List<Payment> p = pre.stream().filter(e->getPrefix(e.getNumber()).equals(v)).collect(Collectors.toList());
|
|
|
+ List<Payment> c = cur.stream().filter(e->getPrefix(e.getNumber()).equals(v)).collect(Collectors.toList());
|
|
|
+ List<Payment> t = end.stream().filter(e->getPrefix(e.getNumber()).equals(v)).collect(Collectors.toList());
|
|
|
+ t.stream().findFirst().ifPresent(payment->{
|
|
|
+ sc.setPrice(payment.getPrice());
|
|
|
+ sc.setContractAmount(payment.getContractMoney());
|
|
|
+ /*本期*/
|
|
|
+ sc.setCurrentAmount(c.stream().map(e->BaseUtils.str2BigDecimal(e.getMoney())).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
|
|
|
+ sc.setCurrentRatio(ratioFc.apply(sc.getCurrentAmount(),sc.getContractAmount()));
|
|
|
+ /*上期末*/
|
|
|
+ sc.setPreviousEndAmount(p.stream().map(e->BaseUtils.str2BigDecimal(e.getMoney())).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
|
|
|
+ sc.setPreviousEndRatio(ratioFc.apply(sc.getPreviousEndAmount(),sc.getContractAmount()));
|
|
|
+ /*本期末*/
|
|
|
+ sc.setPeriodEndAmount(t.stream().map(e->BaseUtils.str2BigDecimal(e.getMoney())).reduce(BigDecimal.ZERO,BigDecimal::add).toString());
|
|
|
+ sc.setPeriodEndRatio(ratioFc.apply(sc.getPeriodEndAmount(),sc.getContractAmount()));
|
|
|
+
|
|
|
+ current.setFormName(v);
|
|
|
+ current.setChapterSeq(k);
|
|
|
+ current.setContractAmount(payment.getContractMoney());
|
|
|
+ current.setPreviousPeriodEndPay(sc.getPeriodEndAmount());
|
|
|
+ current.setCurrentPeriodPay(sc.getCurrentAmount());
|
|
|
+ current.setCurrentPeriodEndPay(sc.getPeriodEndAmount());
|
|
|
+ itemList.add(current);
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
dataList.add(sc);
|
|
|
});
|
|
|
/*分行合计列*/
|
|
|
- fieldGetSet(summaryConfigMap,x->!x.getIsSummary());
|
|
|
+ fieldGetSet(summaryConfigMap,x->!x.getIsSummary(),SupervisionCertificate::getInvertState);
|
|
|
if(peerMap.size()>0) {
|
|
|
/*等合计项目计算完毕,再赋值*/
|
|
|
peerMap.forEach((sc, item) -> {
|
|
@@ -1448,6 +1451,7 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
|
|
|
@Data
|
|
|
class BaseSpecial<T>{
|
|
|
+ public final BigDecimal MINUS_ONE=BigDecimal.valueOf(-1);
|
|
|
/*数据模型包含的元素*/
|
|
|
public LinkedHashMap<String,FormData> fdm;
|
|
|
/*元素内容输出对应的映射函数*/
|
|
@@ -1500,13 +1504,25 @@ public class ExecutorMeter extends FormulaExecutor {
|
|
|
pageNumber(clazz);
|
|
|
FormulaUtils.put2FormData(fdm, fieldDataFcMap,dataList);
|
|
|
};
|
|
|
+ BinaryOperator<BigDecimal>invert =(flag,b)->{
|
|
|
+ if(flag.equals(BigDecimal.ONE)){
|
|
|
+ return b;
|
|
|
+ }else{
|
|
|
+ return b.multiply(flag);
|
|
|
+ }
|
|
|
+ };
|
|
|
/*批量计算列表中之前的字段和,并赋值到当前字段*/
|
|
|
public void fieldGetSet(Map<T,Map<Function<T,String>,Consumer<String>>> gsMap, Predicate<T> p){
|
|
|
+ fieldGetSet(gsMap,p,bean->BigDecimal.ONE);
|
|
|
+ }
|
|
|
+ public void fieldGetSet(Map<T,Map<Function<T,String>,Consumer<String>>> gsMap, Predicate<T> p,Function<T,BigDecimal> sign){
|
|
|
if(dataList.size()>0) {
|
|
|
gsMap.forEach((b, m) -> {
|
|
|
List<T> dl = dataList.stream().limit(dataList.indexOf(b)).collect(Collectors.toList());
|
|
|
m.forEach((f, c) -> {
|
|
|
- c.accept(dl.stream().filter(p).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());*/
|
|
|
+ /*扣款项需要根据符号状态sign转成负数,依靠invert实现*/
|
|
|
+ c.accept(dl.stream().filter(p).map(e-> invert.apply(sign.apply(e),BaseUtils.str2BigDecimal(f.apply(e)))).reduce(BigDecimal.ZERO, BigDecimal::add).toString());
|
|
|
});
|
|
|
});
|
|
|
}
|