|
@@ -26,11 +26,11 @@ import java.util.stream.IntStream;
|
|
|
/**
|
|
|
* @author yangyj
|
|
|
* @Date 2023/12/19 17:40
|
|
|
- * @description TODO
|
|
|
+ * @description 计量相关报表计算
|
|
|
*/
|
|
|
@EqualsAndHashCode(callSuper = true)
|
|
|
@Data
|
|
|
-public class ExecutorSpecial extends FormulaExecutor {
|
|
|
+public class ExecutorMeter extends FormulaExecutor {
|
|
|
private Function<Long, List<Material>> materialFormFc;
|
|
|
private Function<Long, List<Payment>> paymentListFc;
|
|
|
private Function<Long, List<InventoryForm>> inventoryFormFc;
|
|
@@ -60,7 +60,7 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
/**根据清单编号获取支付项目章节编号*/
|
|
|
public String getPrefix(String fn){
|
|
|
for(InventoryForm itf:chapters){
|
|
|
- String prefix=itf.getChapter();
|
|
|
+ String prefix=itf.getFormNumber();
|
|
|
fn= fn.split("-")[0];
|
|
|
if(BaseUtils.isNumber(fn)){
|
|
|
fn=String.valueOf(100*Integer.parseInt(fn)/100);
|
|
@@ -244,8 +244,9 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @EqualsAndHashCode(callSuper = true)
|
|
|
+
|
|
|
@Data
|
|
|
+ @EqualsAndHashCode(callSuper = true)
|
|
|
public class InterimPayCert extends BaseSpecial<InterimPaymentCertificate> implements Special{
|
|
|
|
|
|
@Override
|
|
@@ -293,7 +294,7 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
}
|
|
|
for(InventoryForm itf:inventoryForms){
|
|
|
assert root != null;
|
|
|
- if(itf.getParentId().equals(root.getParentId())){
|
|
|
+ if(itf.getParentId().equals(root.getId())){
|
|
|
chapters.add(itf);
|
|
|
}
|
|
|
}
|
|
@@ -310,6 +311,7 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
/*合同金额*/
|
|
|
Map<String,BigDecimal[]> contractMoney = this.contractMoneySum.apply(inventoryForms);
|
|
|
for(Map.Entry<String,BigDecimal[]> cm:contractMoney.entrySet()){
|
|
|
+ if(Func.isEmpty(cm.getKey()))continue;
|
|
|
InterimPaymentCertificate ipc = new InterimPaymentCertificate();
|
|
|
BigDecimal[] bmMoney =cm.getValue();
|
|
|
ipc.setContractAmount(bmMoney[0].toString());
|
|
@@ -323,15 +325,17 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
}
|
|
|
/*数据获取end*/
|
|
|
/*本期实际支付合计计算*/
|
|
|
- functionMap.put(InterimPaymentCertificate.TBN+ StringPool.COLON+"key_9",(List<InterimPaymentCertificate> list)-> Collections.singletonList(list.stream().map(InterimPaymentCertificate::getCurrentPeriodPay).mapToDouble(Double::parseDouble).sum()));
|
|
|
+ fieldDataFcMap.put(InterimPaymentCertificate.TBN+ StringPool.COLON+"key_9",(List<InterimPaymentCertificate> list)-> Collections.singletonList(list.stream().map(InterimPaymentCertificate::getCurrentPeriodPay).mapToDouble(Double::parseDouble).sum()));
|
|
|
/*内容输出*/
|
|
|
putOut();
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- @EqualsAndHashCode(callSuper = true)
|
|
|
+
|
|
|
+
|
|
|
@Data
|
|
|
+ @EqualsAndHashCode(callSuper = true)
|
|
|
public class InterimSum extends BaseSpecial<InterimPaymentSummary> implements Special{
|
|
|
@Override
|
|
|
public boolean ready() {
|
|
@@ -369,15 +373,18 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @EqualsAndHashCode(callSuper = true)
|
|
|
+
|
|
|
+
|
|
|
@Data
|
|
|
+ @EqualsAndHashCode(callSuper = true)
|
|
|
public class SubIPaySum extends BaseSpecial<SubprojectInterimPaymentSummary> implements Special{
|
|
|
-
|
|
|
+ /*分项工程中期支付汇总表*/
|
|
|
@Override
|
|
|
public boolean ready() {
|
|
|
return current.size()>0;
|
|
|
}
|
|
|
|
|
|
+ /*清单合计类*/
|
|
|
@Data
|
|
|
class Summary{
|
|
|
/*清单编号、支付编号*/
|
|
@@ -389,21 +396,21 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
/**合同数量*/
|
|
|
private Integer contractTotal=0;
|
|
|
/**变更数量*/
|
|
|
- private Integer revisedTotal=0;
|
|
|
+ private Integer changeTotal =0;
|
|
|
/**本次完成数量*/
|
|
|
- private Integer currentPeriodComplete=0;
|
|
|
+ private Integer currentPeriodCompleted=0;
|
|
|
/**累计完成数量*/
|
|
|
- private Integer completed=0;
|
|
|
+ private Integer currentPeriodEndCompleted =0;
|
|
|
/**合同金额*/
|
|
|
- private BigDecimal contractAmount=BigDecimal.ZERO;
|
|
|
+ private BigDecimal contractMoney =BigDecimal.ZERO;
|
|
|
/**变更后A金额*/
|
|
|
- private BigDecimal revisedAmount=BigDecimal.ZERO;
|
|
|
- /**上次支付金额*/
|
|
|
- private BigDecimal previousPeriodEndPay=BigDecimal.ZERO;
|
|
|
+ private BigDecimal changeMoney =BigDecimal.ZERO;
|
|
|
+ /**支付金额*/
|
|
|
+ private BigDecimal money=BigDecimal.ZERO;
|
|
|
+ /**本次支付金额*/
|
|
|
+ private BigDecimal currentPeriodPay=BigDecimal.ZERO;
|
|
|
/**累计支付B金额*/
|
|
|
private BigDecimal currentPeriodEndPay=BigDecimal.ZERO;
|
|
|
- /**比例*/
|
|
|
- private BigDecimal payRatio=BigDecimal.ZERO;
|
|
|
|
|
|
public Summary() {
|
|
|
}
|
|
@@ -413,18 +420,30 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
this.itemName=p.getName();
|
|
|
this.unit = p.getUnit();
|
|
|
this.contractTotal=p.getContractTotal();
|
|
|
- this.revisedTotal= p.getChangeTotal();
|
|
|
- this.completed=p.getCompleted();
|
|
|
- this.contractAmount=new BigDecimal(p.getContractMoney());
|
|
|
- this.revisedAmount=new BigDecimal(p.getChangeMoney());
|
|
|
- this.currentPeriodEndPay=p.getMoneyAsBigDecimal();
|
|
|
+ this.changeTotal = p.getChangeTotal();
|
|
|
+ this.currentPeriodCompleted =p.getCompleted();
|
|
|
+ this.contractMoney =new BigDecimal(p.getContractMoney());
|
|
|
+ this.changeMoney =new BigDecimal(p.getChangeMoney());
|
|
|
+ this.money=p.getMoneyAsBigDecimal();
|
|
|
}
|
|
|
+
|
|
|
+ /*同一个清单累加*/
|
|
|
public Summary add(Summary next){
|
|
|
if(Func.isBlank(this.itemName)){
|
|
|
this.itemName=next.itemName;
|
|
|
}
|
|
|
- this.completed=next.getCompleted()+this.completed;;
|
|
|
- this.currentPeriodEndPay=this.previousPeriodEndPay.add(next.getPreviousPeriodEndPay());
|
|
|
+ /*本期完成*/
|
|
|
+ this.currentPeriodCompleted =next.getCurrentPeriodCompleted()+this.currentPeriodCompleted;;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*当前期合并往期计算累计值*/
|
|
|
+ public Summary merge(Summary previous){
|
|
|
+ if(previous!=null){
|
|
|
+ this.currentPeriodPay=this.money.add(BigDecimal.ZERO);
|
|
|
+ this.money=this.money.add(previous.money);
|
|
|
+ this.currentPeriodEndPay=this.money;
|
|
|
+ }
|
|
|
return this;
|
|
|
}
|
|
|
}
|
|
@@ -432,15 +451,15 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
/*按清单编号求和*/
|
|
|
public Map<String,Summary> toSummary(List<Payment> payments) {
|
|
|
return payments.stream()
|
|
|
- .collect( Collectors.groupingBy(Payment::getNumber,
|
|
|
- Collectors.reducing(new Summary(),
|
|
|
- Summary::new,
|
|
|
- Summary::add
|
|
|
- )));
|
|
|
-
|
|
|
+ .collect(Collectors.groupingBy(Payment::getNumber,
|
|
|
+ Collectors.collectingAndThen(
|
|
|
+ Collectors.mapping(Summary::new, Collectors.reducing(Summary::add)),
|
|
|
+ op -> op.orElseGet(Summary::new)
|
|
|
+ )
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /*分项工程中期支付汇总表*/
|
|
|
@Override
|
|
|
public void parse() {
|
|
|
builderFormDatas(SubprojectInterimPaymentSummary.class);
|
|
@@ -455,18 +474,19 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
sis.setItemName(summary.getItemName());
|
|
|
sis.setUnit(summary.getUnit());
|
|
|
sis.setContractTotal(summary.getContractTotal().toString());
|
|
|
- sis.setRevisedTotal(summary.getRevisedTotal().toString());
|
|
|
- sis.setComplete(summary.getCompleted().toString());
|
|
|
- sis.setContractAmount(summary.getContractAmount().toString());
|
|
|
- sis.setRevisedAmount(summary.getRevisedAmount().toString());
|
|
|
- if(pre!=null){
|
|
|
- sis.setCurrentPeriodPay(pre.getCurrentPeriodEndPay().toString());
|
|
|
- summary.add(pre);
|
|
|
- sis.setCurrentPeriodEndPay(summary.getCurrentPeriodEndPay().toString());
|
|
|
- sis.setPayRatio(ratioFc.apply(sis.getCurrentPeriodEndPay(),sis.getRevisedAmount()));
|
|
|
- }
|
|
|
+ sis.setChangeTotal(summary.getChangeTotal().toString());
|
|
|
+ sis.setContractMoney(summary.getContractMoney().toString());
|
|
|
+ sis.setChangeMoney(summary.getChangeMoney().toString());
|
|
|
+ sis.setCurrentPeriodCompleted(summary.getCurrentPeriodCompleted().toString());
|
|
|
+ /*当前期和往期统计*/
|
|
|
+ summary.merge(pre);
|
|
|
+ sis.setCurrentPeriodPay(summary.getCurrentPeriodPay().toString());
|
|
|
+ sis.setCurrentPeriodEndPay(summary.getCurrentPeriodEndPay().toString());
|
|
|
+ sis.setPayRatio(ratioFc.apply(sis.getCurrentPeriodEndPay(),sis.getChangeMoney()));
|
|
|
totalList.add(sis);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
LinkedHashMap<String,List<SubprojectInterimPaymentSummary>> chapterGroup= totalList.stream().collect(Collectors.groupingBy(e->getPrefix(e.getFormNumber()),LinkedHashMap::new,Collectors.toList()));
|
|
|
AtomicInteger loop = new AtomicInteger(chapterGroup.size());
|
|
|
chapterGroup.forEach((k,v)->{
|
|
@@ -506,9 +526,10 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
}
|
|
|
});
|
|
|
/*内容输出*/
|
|
|
- putOut();
|
|
|
+ putOut(SubprojectInterimPaymentSummary.class);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public void subtotal(SubprojectInterimPaymentSummary b, List<SubprojectInterimPaymentSummary> result ,List<SubprojectInterimPaymentSummary> data){
|
|
|
b.calculate(data);
|
|
|
result.add(b);
|
|
@@ -518,10 +539,12 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @EqualsAndHashCode(callSuper = true)
|
|
|
+
|
|
|
+
|
|
|
@Data
|
|
|
+ @EqualsAndHashCode(callSuper = true)
|
|
|
public class SubIMeterPay extends BaseSpecial<SubInterimMeterPaySummary> implements Special{
|
|
|
-
|
|
|
+ /*分项工程中期计量支付表*/
|
|
|
@Override
|
|
|
public boolean ready() {
|
|
|
return current.size()>0;
|
|
@@ -534,10 +557,14 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
smps.setUnit(payment.getUnit());
|
|
|
smps.setRevisedTotal(StringUtils.handleNull(payment.getChangeTotal()));
|
|
|
smps.setCurrentPeriodCompleted(StringUtils.handleNull(payment.getCompleted()));
|
|
|
- smps.setCompleted(StringUtils.handleNull(payment.getCompleted()+prePayment.getCompleted()));
|
|
|
- smps.setRevisedAmount(payment.getChangeMoney());
|
|
|
+ smps.setCompleted(payment.getCompleted().toString());
|
|
|
+ smps.setChangeMoney(payment.getChangeMoney());
|
|
|
smps.setCurrentPeriodPay(payment.getMoney());
|
|
|
- smps.setCurrentPeriodEndPay(StringUtils.handleNull(new BigDecimal(payment.getMoney()).add(new BigDecimal(prePayment.getMoney()))));
|
|
|
+ smps.setCurrentPeriodEndPay(payment.getMoney());
|
|
|
+ if(prePayment!=null){
|
|
|
+ smps.completedAdd(prePayment.getCompleted());
|
|
|
+ smps.currentPeriodEndPayAdd(prePayment.getMoney());
|
|
|
+ }
|
|
|
return smps;
|
|
|
};
|
|
|
|
|
@@ -548,11 +575,11 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
/*根据每一期的s_middle_meter_apply,s_inventory_form_apply 获取对应的计量清单,然后根据清单Id配合s_inventory_form_meter查找计量单元信息*/
|
|
|
/*s_change_token_inventory每个清单关联的变更令,s_change_token_meter每个计量单元关联的变更令*/
|
|
|
try {
|
|
|
- Map<Long, TreeNode<MeterTree>> treeNodeMap = tec.getMeterTreeMap().get();
|
|
|
- Optional<TreeNode<MeterTree>> optionalTreeNode= treeNodeMap.values().stream().filter(TreeNode::isTop).findAny();
|
|
|
- if(optionalTreeNode.isPresent()) {
|
|
|
+ Map<Long, TreeNode<MeterTree>> treeNodeMap = tec.meterTreeMap.get();
|
|
|
+ Optional<TreeNode<MeterTree>> opTreeNode= treeNodeMap.values().stream().filter(TreeNode::isTop).findAny();
|
|
|
+ if(opTreeNode.isPresent()) {
|
|
|
/*计量单元根节点*/
|
|
|
- TreeNode<MeterTree> top= optionalTreeNode.get();
|
|
|
+ TreeNode<MeterTree> top= opTreeNode.get();
|
|
|
Map<Long, List<Payment>> paymentGroup = current.stream().collect(Collectors.groupingBy(Payment::getMeterId));
|
|
|
Map<String,Payment> preMeterPaymentGroup = previous.stream().collect(Collectors.toMap(Payment::meterFormKey,p->p,(p1,p2)->p2));
|
|
|
FormulaUtils.treeNodeSort(0,top);
|
|
@@ -584,7 +611,7 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
return tmp.stream();
|
|
|
}).collect(Collectors.toList());
|
|
|
/*内容输出*/
|
|
|
- putOut();
|
|
|
+ putOut(SubInterimMeterPaySummary.class);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
@@ -649,8 +676,10 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @EqualsAndHashCode(callSuper = true)
|
|
|
+
|
|
|
+
|
|
|
@Data
|
|
|
+ @EqualsAndHashCode(callSuper = true)
|
|
|
public class IMeterPaySummary extends BaseSpecial<InterimMeterPaySummary> implements Special{
|
|
|
/*private Integer capacity=20;*/
|
|
|
@Override
|
|
@@ -674,12 +703,14 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
summary.setMoney(StringUtils.number2StringZero(sum,2));
|
|
|
dataList.add(summary);
|
|
|
}
|
|
|
- putOut();
|
|
|
+ putOut(InterimMeterPaySummary.class);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Data
|
|
|
- public class IMeter implements Special{
|
|
|
+ @EqualsAndHashCode(callSuper = true)
|
|
|
+ public class IMeter extends BaseSpecial<InterimMeter> implements Special{
|
|
|
private Integer capacity=7;
|
|
|
@Override
|
|
|
public boolean ready() {
|
|
@@ -688,14 +719,9 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
|
|
|
@Override
|
|
|
public void parse() {
|
|
|
- LinkedHashMap<String,FormData> fdm = FormulaUtils.toFormDataMap(new InterimMeter());
|
|
|
- /*获取实际输出行数*/
|
|
|
- this.capacity=getLineSize(new ArrayList<>(fdm.keySet()));
|
|
|
- Map<String,Function<List<InterimMeter>,List<Object>>> functionMap =FormulaUtils.fieldDataFcMap(InterimMeter.class);
|
|
|
- tec.getFormDataMap().putAll(fdm);
|
|
|
+ builderFormDatas(InterimMeter.class);
|
|
|
List<MeterApply> meterApplyList=meterApplyFc.apply(tec.getPeriodId());
|
|
|
Map<Long,List<Payment>> paymentGroup = current.stream().collect(Collectors.groupingBy(Payment::getMiddleMeterId));
|
|
|
- List<InterimMeter> dataList = new ArrayList<>();
|
|
|
for(MeterApply meterApply:meterApplyList){
|
|
|
List<Payment> paymentList = paymentGroup.get(meterApply.getId());
|
|
|
List<List<Payment>> pageData = BaseUtils.splitList(paymentList,this.capacity);
|
|
@@ -721,7 +747,7 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
dataList.add(iim);
|
|
|
}
|
|
|
}
|
|
|
- FormulaUtils.put2FormData(fdm,functionMap,dataList);
|
|
|
+ putOut(InterimMeter.class);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -730,7 +756,7 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
/*数据模型包含的元素*/
|
|
|
public LinkedHashMap<String,FormData> fdm;
|
|
|
/*元素内容输出对应的映射函数*/
|
|
|
- public Map<String,Function<List<T>,List<Object>>> functionMap;
|
|
|
+ public Map<String,Function<List<T>,List<Object>>> fieldDataFcMap;
|
|
|
/*获取实际输出行数*/
|
|
|
public Integer capacity;
|
|
|
/*输出值*/
|
|
@@ -738,7 +764,7 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
/*用实例去构建带有初始化数据的元素*/
|
|
|
public void builderFormDatas(T bean){
|
|
|
fdm = FormulaUtils.toFormDataMap(bean);
|
|
|
- functionMap =FormulaUtils.fieldDataFcMap(bean.getClass());
|
|
|
+ fieldDataFcMap =FormulaUtils.fieldDataFcMap(bean.getClass());
|
|
|
capacity=getLineSize(new ArrayList<>(fdm.keySet()));
|
|
|
tec.getFormDataMap().putAll(fdm);
|
|
|
dataList=new ArrayList<>();
|
|
@@ -746,14 +772,31 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
/*用元类class 创建空元素*/
|
|
|
public void builderFormDatas(Class<T> clazz){
|
|
|
fdm = FormulaUtils.toFormDataMap(clazz);
|
|
|
- functionMap =FormulaUtils.fieldDataFcMap(clazz);
|
|
|
+ fieldDataFcMap =FormulaUtils.fieldDataFcMap(clazz);
|
|
|
capacity=getLineSize(new ArrayList<>(fdm.keySet()));
|
|
|
tec.getFormDataMap().putAll(fdm);
|
|
|
dataList=new ArrayList<>();
|
|
|
}
|
|
|
+ /*总页数*/
|
|
|
+ public int totalPage(){
|
|
|
+ return (int)Math.ceil(dataList.size()/(double)capacity);
|
|
|
+ }
|
|
|
+ /*页码计算*/
|
|
|
+ public void pageNumber(Class<T> clazz){
|
|
|
+ FormData pageFd = fdm.get(FormulaUtils.getPageCode(clazz));
|
|
|
+ if(pageFd!=null) {
|
|
|
+ int total = totalPage();
|
|
|
+ String pageTmp = "第$1页 共" + total + "页";
|
|
|
+ pageFd.setValues(IntStream.range(0, total).boxed().map(i -> new ElementData(pageTmp.replace("$1", i.toString()))).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
/*写入对应的元素*/
|
|
|
public void putOut(){
|
|
|
- FormulaUtils.put2FormData(fdm,functionMap,dataList);
|
|
|
+ FormulaUtils.put2FormData(fdm, fieldDataFcMap,dataList);
|
|
|
+ };
|
|
|
+ public void putOut(Class<T> clazz){
|
|
|
+ pageNumber(clazz);
|
|
|
+ FormulaUtils.put2FormData(fdm, fieldDataFcMap,dataList);
|
|
|
};
|
|
|
}
|
|
|
interface Special{
|
|
@@ -761,8 +804,9 @@ public class ExecutorSpecial extends FormulaExecutor {
|
|
|
boolean ready();
|
|
|
/**解析数据*/
|
|
|
void parse();
|
|
|
+
|
|
|
}
|
|
|
- public ExecutorSpecial(TableElementConverter tec) {
|
|
|
+ public ExecutorMeter(TableElementConverter tec) {
|
|
|
super(tec);
|
|
|
}
|
|
|
}
|