|
@@ -4,16 +4,19 @@ import com.mixsmart.utils.FormulaUtils;
|
|
import com.mixsmart.utils.StringUtils;
|
|
import com.mixsmart.utils.StringUtils;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
import lombok.EqualsAndHashCode;
|
|
import lombok.EqualsAndHashCode;
|
|
-import org.springblade.common.utils.BaseUtils;
|
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.StringPool;
|
|
import org.springblade.core.tool.utils.StringPool;
|
|
import org.springblade.manager.dto.ElementData;
|
|
import org.springblade.manager.dto.ElementData;
|
|
import org.springblade.manager.dto.FormData;
|
|
import org.springblade.manager.dto.FormData;
|
|
import org.springblade.manager.formula.FormulaExecutor;
|
|
import org.springblade.manager.formula.FormulaExecutor;
|
|
import org.springblade.manager.vo.*;
|
|
import org.springblade.manager.vo.*;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.function.BiFunction;
|
|
|
|
+import java.util.function.BinaryOperator;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.IntStream;
|
|
import java.util.stream.IntStream;
|
|
@@ -34,6 +37,8 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
super(tec);
|
|
super(tec);
|
|
}
|
|
}
|
|
private List<Special> specialList = new ArrayList<>();
|
|
private List<Special> specialList = new ArrayList<>();
|
|
|
|
+ private List<Payment> dataSource=new ArrayList<>();
|
|
|
|
+ private List<InterimPaymentCertificate> interimPaymentCertificates =new ArrayList<>();
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void handle() {
|
|
public void handle() {
|
|
@@ -41,6 +46,7 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
this.specialList.add(new MaterialCalc());
|
|
this.specialList.add(new MaterialCalc());
|
|
}else if(MeterType.INTERIM.equals(tec.getMeterType())){
|
|
}else if(MeterType.INTERIM.equals(tec.getMeterType())){
|
|
this.specialList.add(new InterimPayCert());
|
|
this.specialList.add(new InterimPayCert());
|
|
|
|
+ this.specialList.add(new InterimSum());
|
|
}
|
|
}
|
|
this.specialList.stream().filter(Special::ready).forEach(Special::parse);
|
|
this.specialList.stream().filter(Special::ready).forEach(Special::parse);
|
|
}
|
|
}
|
|
@@ -194,8 +200,6 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
private Function<List<InventoryForm>, Map<String, BigDecimal[]>> contractMoneySum = data -> data.stream()
|
|
private Function<List<InventoryForm>, Map<String, BigDecimal[]>> contractMoneySum = data -> data.stream()
|
|
.collect(Collectors.groupingBy(
|
|
.collect(Collectors.groupingBy(
|
|
form -> getPrefix(form.getFormNumber()),
|
|
form -> getPrefix(form.getFormNumber()),
|
|
@@ -216,8 +220,6 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
Collectors.reducing(BigDecimal.ZERO, Payment::getMoneyAsBigDecimal, BigDecimal::add)
|
|
Collectors.reducing(BigDecimal.ZERO, Payment::getMoneyAsBigDecimal, BigDecimal::add)
|
|
));
|
|
));
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
public String getPrefix(String fn){
|
|
public String getPrefix(String fn){
|
|
for(InventoryForm itf:this.chapters){
|
|
for(InventoryForm itf:this.chapters){
|
|
String prefix=itf.getChapter();
|
|
String prefix=itf.getChapter();
|
|
@@ -232,13 +234,15 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
public void parse() {
|
|
public void parse() {
|
|
LinkedHashMap<String,FormData> fdm = FormulaUtils.toFormDataMap(new InterimPaymentCertificate());
|
|
LinkedHashMap<String,FormData> fdm = FormulaUtils.toFormDataMap(new InterimPaymentCertificate());
|
|
tec.getFormDataMap().putAll(fdm);
|
|
tec.getFormDataMap().putAll(fdm);
|
|
-
|
|
|
|
Map<String,Function<List<InterimPaymentCertificate>,List<Object>>> functionMap =FormulaUtils.fieldDataFcMap(InterimPaymentCertificate.class);
|
|
Map<String,Function<List<InterimPaymentCertificate>,List<Object>>> functionMap =FormulaUtils.fieldDataFcMap(InterimPaymentCertificate.class);
|
|
|
|
|
|
List<InterimPaymentCertificate> dataList = new ArrayList<>();
|
|
List<InterimPaymentCertificate> dataList = new ArrayList<>();
|
|
/*数据获取start*/
|
|
/*数据获取start*/
|
|
/*支付数据*/
|
|
/*支付数据*/
|
|
List<Payment> paymentList=paymentListFc.apply(tec.getContractId());
|
|
List<Payment> paymentList=paymentListFc.apply(tec.getContractId());
|
|
|
|
+ if(!paymentList.isEmpty()){
|
|
|
|
+ dataSource.addAll(paymentList);
|
|
|
|
+ }
|
|
/*计量期*/
|
|
/*计量期*/
|
|
MeterPeriodInfo periodInfo=interimMeterPeriodFc.apply(tec.getPeriodId());
|
|
MeterPeriodInfo periodInfo=interimMeterPeriodFc.apply(tec.getPeriodId());
|
|
/*合同计量清单*/
|
|
/*合同计量清单*/
|
|
@@ -290,7 +294,69 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ @Data
|
|
|
|
+ public class InterimSum implements Special{
|
|
|
|
+ @Override
|
|
|
|
+ public boolean ready() {
|
|
|
|
+ return interimPaymentCertificates.size()>0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*合计字段*/
|
|
|
|
+ BiFunction<List<InterimPaymentSummary>,Function<InterimPaymentSummary,String>,String>
|
|
|
|
+ bfc= (list,fc) -> StringUtils.number2String(list.stream().map(fc).mapToDouble(Double::parseDouble).sum(),1);
|
|
|
|
+ /*求百分比*/
|
|
|
|
+ BinaryOperator<String> ratioFc = (a,b)->{
|
|
|
|
+ /*合同金额*/
|
|
|
|
+ BigDecimal aBd =new BigDecimal(a);
|
|
|
|
+ /*变更金额*/
|
|
|
|
+ BigDecimal bBd =new BigDecimal(b);
|
|
|
|
+ if(BigDecimal.ZERO.compareTo(bBd)==0){
|
|
|
|
+ return "0.0";
|
|
|
|
+ }
|
|
|
|
+ return aBd.multiply(new BigDecimal(100)).divide(bBd, 2, RoundingMode.HALF_UP).toString();
|
|
|
|
+ };
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void parse() {
|
|
|
|
+ LinkedHashMap<String,FormData> fdm = FormulaUtils.toFormDataMap(new InterimPaymentSummary());
|
|
|
|
+ Map<String,Function<List<InterimPaymentSummary>,List<Object>>> functionMap =FormulaUtils.fieldDataFcMap(InterimPaymentSummary.class);
|
|
|
|
+ tec.getFormDataMap().putAll(fdm);
|
|
|
|
+ List<InterimPaymentSummary> dataList=new ArrayList<>();
|
|
|
|
+ for(InterimPaymentCertificate ipc:interimPaymentCertificates){
|
|
|
|
+ InterimPaymentSummary ips = new InterimPaymentSummary();
|
|
|
|
+ BeanUtils.copyProperties(ipc,ips);
|
|
|
|
+ ips.calculate();
|
|
|
|
+ dataList.add(ips);
|
|
|
|
+ }
|
|
|
|
+ if(!dataList.isEmpty()){
|
|
|
|
+ /*最后一行的合计*/
|
|
|
|
+ InterimPaymentSummary summary = new InterimPaymentSummary();
|
|
|
|
+ summary.setSummary(true);
|
|
|
|
+ summary.setItemName("合计");
|
|
|
|
+ summary.setContractAmount(bfc.apply(dataList,InterimPaymentSummary::getContractAmount));
|
|
|
|
+ summary.setRevisedAmount(bfc.apply(dataList,InterimPaymentSummary::getRevisedAmount));
|
|
|
|
+ summary.setCurrentPeriodPay(bfc.apply(dataList,InterimPaymentSummary::getCurrentPeriodPay));
|
|
|
|
+ summary.setCurrentPeriodEndPay(bfc.apply(dataList,InterimPaymentSummary::getCurrentPeriodEndPay));
|
|
|
|
+ summary.setPayRatioA(ratioFc.apply(summary.getCurrentPeriodEndPay(),summary.getContractAmount()));
|
|
|
|
+ summary.setPayRatioA(ratioFc.apply(summary.getCurrentPeriodEndPay(),summary.getRevisedAmount()));
|
|
|
|
+ dataList.add(summary);
|
|
|
|
+ /*内容输出*/
|
|
|
|
+ FormulaUtils.put2FormData(fdm,functionMap,dataList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ @Data
|
|
|
|
+ public class SubIPaySum implements Special{
|
|
|
|
+ @Override
|
|
|
|
+ public boolean ready() {
|
|
|
|
+ return dataSource.size()>0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void parse() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|