yangyj 1 vuosi sitten
vanhempi
commit
a31e796ade

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

@@ -76,7 +76,7 @@ public class ConstructionSchedule implements  DataModel{
     @JSONField(name = "key_18",label="单项计划完成-ZJ",ordinal = 12)
     private String itemProgress;
     /**单项计划完成*/
-    @JSONField(name = "key_26",label="期末累计占该合同金额-ZJ",ordinal = 12)
+    @JSONField(name = "key_26",label="期末累计占该合同金额-ZJ",ordinal = 12)
     private String prePayPercent;
     @JSONField(name = "key_19",label="本期占该合同金额-ZJ",ordinal = 12)
     private String currentPayPercent;

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

@@ -3,6 +3,7 @@ package org.springblade.manager.vo;
 import cn.hutool.log.StaticLog;
 import com.aliyuncs.utils.MapUtils;
 import lombok.Data;
+import org.springblade.manager.dto.ElementData;
 import org.springblade.manager.dto.TreeNode;
 import org.springblade.meter.entity.InterimPayCertificateItem;
 
@@ -58,6 +59,7 @@ public class MeterInfo {
     public MeterPeriodInfo periodInfo;
     /**上期*/
     public MeterPeriodInfo previousPeriodInfo;
+
     /**需要延后生成FormData(元素对象)*/
     List<DataModel> delay =new LinkedList<>();
     /**合同工程清单*/

+ 3 - 2
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/RebateIncentiveAdvPay.java

@@ -4,6 +4,8 @@ import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;
 import org.springblade.common.utils.BaseUtils;
 
+import java.math.BigDecimal;
+
 /**
  * @author yangyj
  * @Date 2024/6/18 17:18
@@ -44,10 +46,9 @@ public class RebateIncentiveAdvPay implements  DataModel{
         if(x<0){
             /*扣回款本身就是负数*/
             x=Math.abs(x);
-            String s=Double.toString(x);
+            String s=new BigDecimal(x).setScale(5,BigDecimal.ROUND_HALF_UP).toPlainString();
             this.retained =s ;
             this.currentPay=s;
-            this.endPay=s;
         }
 
     }

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

@@ -87,7 +87,7 @@ public class ExecutorInit extends FormulaExecutor {
             periodInfo();;
             /*计量单元树*/
             tec.meterInfo.setMeterTreeMap(getMeterTreeMapAsync(tec.getContractId()));
-            /*开工报表*/
+            /*动员预付款*/
             startInfo();
             //变更令部分
             changeToken();
@@ -174,7 +174,7 @@ public class ExecutorInit extends FormulaExecutor {
     private void startInfo(){
         List<StartPayForm> startPayFormAll=stayPayFormFc.apply(tec.getContractId());
         if(startPayFormAll!=null&&startPayFormAll.size()>0){
-            /*获取合同段所有的开工报告信息*/
+            /*获取合同段所有的动员预付款支付信息*/
             tec.meterInfo.setStartPayFormAll(startPayFormAll);
         }
     }

+ 46 - 20
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -745,12 +745,6 @@ public class ExecutorMeter extends FormulaExecutor {
                  List<InterimPaymentCertificate> payItemZj=new ArrayList<>();
                  if(MeterInfo.MB_ZJ.equals(tec.meterInfo.getTemplate())){
                      /*假如章节*/
-              /*       dataList.forEach(ipc->{
-                         InterimPayCertificateItem ic=  new InterimPayCertificateItem();
-                         ic.setCertificateId(tec.getReportId());
-                         BeanUtils.copyProperties(ipc,ic);
-                         itemList.add(ic);
-                     });*/
                      InterimPaymentCertificate xj=new InterimPaymentCertificate("小计",true);
                      addGetSetConfig(xj,summaryConfigMap,InterimPaymentCertificate::getContractAmount,xj::setContractAmount);
                      addGetSetConfig(xj,summaryConfigMap,InterimPaymentCertificate::getRevisedTotal,xj::setRevisedTotal);
@@ -780,7 +774,18 @@ public class ExecutorMeter extends FormulaExecutor {
                      payItemZj.add(new InterimPaymentCertificate("索赔金额",MINUS_ONE));
                      payItemZj.add(new InterimPaymentCertificate("违约罚金",MINUS_ONE));
                      payItemZj.add(new InterimPaymentCertificate("迟付款利息"));
-                     payItemZj.add(new InterimPaymentCertificate("动员预付款"));
+                     InterimPaymentCertificate startPay =new InterimPaymentCertificate("动员预付款");
+                     if(tec.meterInfo.getStartPayFormAll()!=null){
+                        List<StartPayForm> startPayForm = tec.getMeterInfo().getStartPayFormAll();
+                        if(startPayForm.size()>0){
+                           String current= startPayForm.stream().filter(s->s.getPeriodSort()<=tec.periodInfo.getSort()).map(s->BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO,BigDecimal::add).toPlainString();
+                           String  end= startPayForm.stream().filter(s-> s.getPeriodSort().equals(tec.periodInfo.getSort())).map(s->BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO,BigDecimal::add).toPlainString();
+                           startPay.setCurrentPeriodPay(current);
+                           startPay.setCurrentPeriodEndPay(end);
+                           startPay.setPreviousPeriodEndPay(subtractFc.apply(end,current));
+                        }
+                     }
+                     payItemZj.add(startPay);
                      payItemZj.add(new InterimPaymentCertificate("扣回动员预付款"));
                      payItemZj.add(new InterimPaymentCertificate("材料设备垫付款"));
                      payItemZj.add(new InterimPaymentCertificate("扣回材料设备垫付款"));
@@ -817,8 +822,32 @@ public class ExecutorMeter extends FormulaExecutor {
                      dataList.addAll(payItemZj);
                      /*生成中期支付证书可编辑列表*/
                      /*合并手写内容*/
+                     RebateIncentiveAdvPay rebateIncentiveAdvPay = new RebateIncentiveAdvPay();
                      for (InterimPaymentCertificate certificate : dataList) {
-                         InterimPayCertificateItem ic=  currentMap.getOrDefault(certificate.getChapterSeq(),new InterimPayCertificateItem());
+                         InterimPayCertificateItem ic=  currentMap.getOrDefault(payItemZj.contains(certificate)?certificate.getChapterSeq():certificate.getFormName(),new InterimPayCertificateItem());
+                         if("小计".equals(certificate.getChapterSeq())){
+                             /*本期扣回动员预付款*/
+                             BaseInfo baseInfo = tec.meterInfo.getBaseInfo();
+                             BigDecimal subtotal=  dataList.stream().limit(dataList.indexOf(certificate)).map(e->BaseUtils.str2BigDecimal(e.getCurrentPeriodEndPay())).reduce(BigDecimal.ZERO,BigDecimal::add);
+                             rebateIncentiveAdvPay.setSubtotal(subtotal.toPlainString());
+                             String dyTotalAmount=baseInfo.getDyTotalAmount().toPlainString();
+                             rebateIncentiveAdvPay.calc(baseInfo.getContractAmount().toPlainString(),dyTotalAmount);
+                             InterimPayCertificateItem preSubTotal = previousMap.get("小计");
+                             if(preSubTotal!=null){
+                                 rebateIncentiveAdvPay.setEndPay(addFc.apply(rebateIncentiveAdvPay.getCurrentPay(),preSubTotal.getCurrentPeriodEndPay()));
+                             }else{
+                                 rebateIncentiveAdvPay.setEndPay(rebateIncentiveAdvPay.getCurrentPay());
+                             }
+                             /*当扣完动员预付款的时候,小计总额*/
+                             interimPayCertificateItemGroup.values().stream().flatMap(v->v.values().stream()).filter(e->"小计".equals(e.getChapterSeq())).sorted(Comparator.comparing(InterimPayCertificateItem::getCurrentPeriodEndPay)).filter(e->BaseUtils.str2BigDecimal(e.getCurrentPeriodEndPay()).compareTo(BaseUtils.str2BigDecimal(dyTotalAmount))>0).findFirst().ifPresent(t->{
+                                   rebateIncentiveAdvPay.setMeterAmount(t.getCurrentPeriodEndPay());
+                                   rebateIncentiveAdvPay.setRatio(ratioFc.apply(t.getCurrentPeriodEndPay(),baseInfo.getContractAmount().toPlainString()));
+                             });
+                         }else if("扣回动员预付款".equals(certificate.getChapterSeq())){
+                             certificate.setCurrentPeriodEndPay(rebateIncentiveAdvPay.getEndPay());
+                             certificate.setCurrentPeriodPay(rebateIncentiveAdvPay.getCurrentPay());
+                             certificate.setPreviousPeriodEndPay(rebateIncentiveAdvPay.getPreviousPay());
+                         }
                          BeanUtils.copyProperties(certificate,ic);
                          /*同时兼容几个表后,支付章名称和章节号有点混乱,需要注意纠正*/
                          if(!payItemZj.contains(certificate)){
@@ -830,14 +859,8 @@ public class ExecutorMeter extends FormulaExecutor {
                          }
                          itemList.add(ic);
                      }
-                     RebateIncentiveAdvPay rebateIncentiveAdvPay = new RebateIncentiveAdvPay();
                      /*分行合计列,合计的时候需要计入手填部分*/
                      fieldGetSet(summaryConfigMap,x->!x.getIsSummary(),InterimPaymentCertificate::getInvertState);
-                     payItemZj.stream().filter(t->t.getChapterSeq()!=null&&t.getChapterSeq().contains("小计")).findFirst().ifPresent(t->{
-                         rebateIncentiveAdvPay.setSubtotal(t.getCurrentPeriodEndPay());
-                         BaseInfo baseInfo = tec.meterInfo.getBaseInfo();
-                         rebateIncentiveAdvPay.calc(baseInfo.getContractAmount().toPlainString(),baseInfo.getDyTotalAmount().toPlainString());
-                     });
                      if(peerMap.size()>0) {
                          /*等合计项目计算完毕,再赋值*/
                          peerMap.forEach((sc, item) -> {
@@ -1245,19 +1268,20 @@ public class ExecutorMeter extends FormulaExecutor {
                 cs.setCurrentPayPercent(ratioFc.apply(cs.getCurrentPeriodPay(),cs.getChangeMoney()));
                 /* 本期末累计支付金额占合同比*/
                 cs.setPayPercent(ratioFc.apply(cs.getCurrentPeriodEndPay(),cs.getChangeMoney()));
-                /**上期末占合合同金额*/
-                cs.setPrePayPercent(ratioFc.apply(subtractFc.apply(cs.getCurrentPeriodEndPay(),cs.getCurrentPeriodPay()),cs.getContractMoney()));
+                /**本期末占合合同金额 */
+                cs.setPrePayPercent(ratioFc.apply(cs.getCurrentPeriodEndPay(),cs.getContractMoney()));
                 /*变更金额*/
                 cs.setChangeMoneyAll(subtractFc.apply(cs.getChangeMoney(),cs.getContractMoney()));
                 dataList.add(cs);
             });
             /*每月合计进度*/
             try {
+                String totalAmount=dataList.stream().map(ConstructionSchedule::getContractMoney).map(BaseUtils::str2BigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toPlainString();
                 int max = monthMoney.keySet().stream().max(Comparator.comparingInt(i->i)).orElse(12);
                 /*没月累计*/
                 List<String> monthlySum= IntStream.rangeClosed(1,max).boxed().map(month->{
                     BigDecimal tmp=  monthMoney.entrySet().stream().filter(e->e.getKey()<=month).map(Map.Entry::getValue).reduce(BigDecimal.ZERO,BigDecimal::add);
-                    return  multiFc.apply(ratioFc.apply(tmp.toPlainString(),baseInfo.getTotalAmount().toString()),"100");
+                    return  multiFc.apply(ratioFc.apply(tmp.toPlainString(),totalAmount),"100");
                 }).collect(Collectors.toList());
                 FormulaUtils.elementFindByCode(fdm,ConstructionSchedule.TBN+":key_22").ifPresent(t->{
                     elementWriter.write(t,monthlySum);
@@ -1265,24 +1289,26 @@ public class ExecutorMeter extends FormulaExecutor {
                 /*本月*/
                 List<String> monthlyCount= IntStream.rangeClosed(1,max).boxed().map(month->{
                     BigDecimal tmp=  monthMoney.entrySet().stream().filter(e-> e.getKey().equals(month)).map(Map.Entry::getValue).reduce(BigDecimal.ZERO,BigDecimal::add);
-                    return  ratioFc.apply(tmp.toPlainString(),baseInfo.getTotalAmount().toString());
+                    return  ratioFc.apply(tmp.toPlainString(),totalAmount);
                 }).collect(Collectors.toList());
                 FormulaUtils.elementFindByCode(fdm,ConstructionSchedule.TBN+":key_23").ifPresent(t->{
                     elementWriter.write(t,monthlyCount);
                 });
                 List<String> planMonthSum=new ArrayList<>();
                 if(chapterSchedules!=null&&chapterSchedules.size()>0) {
+                    String totalAmountPlan=totalAmount;
+                            /*chapterSchedules.stream().map(ChapterSchedule::getEight).map(BaseUtils::str2BigDecimal).reduce(BigDecimal.ZERO,BigDecimal::add).toPlainString();*/
                     chapterSchedules.forEach(ChapterSchedule::updateArray);
                     List<BigDecimal> planMonth = IntStream.range(0,12).boxed().map(i->chapterSchedules.stream().map(e->e.getArr()[i]).reduce(BigDecimal.ZERO,BigDecimal::add)).collect(Collectors.toList());
                     /*计划本月*/
                     FormulaUtils.elementFindByCode(fdm, ConstructionSchedule.TBN + ":key_28").ifPresent(t -> {
-                        List<String> value=planMonth.stream().map(BigDecimal::toPlainString).map(s-> multiFc.apply(ratioFc.apply(s,baseInfo.getTotalAmount().toString()),"100")).collect(Collectors.toList());
+                        List<String> value=planMonth.stream().map(BigDecimal::toPlainString).map(s-> multiFc.apply(ratioFc.apply(s,totalAmountPlan),"100")).collect(Collectors.toList());
                         elementWriter.write(t, value);
                     });
                     /*计划累计*/
                     planMonthSum = IntStream.range(0,12).boxed().map(i-> {
                                 String tmp=  planMonth.stream().filter(e -> planMonth.indexOf(e) <= i).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
-                                return multiFc.apply(ratioFc.apply(tmp,baseInfo.getTotalAmount().toString()),"100");
+                                return multiFc.apply(ratioFc.apply(tmp,totalAmountPlan),"100");
                             }
                     ).collect(Collectors.toList());
                     List<String> finalPlanMonthSum = planMonthSum;

+ 8 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -2875,7 +2875,13 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         formulaHandleChains.add(new ExecutorCalc(tec));
         /*格式化*/
         formulaHandleChains.add(new ExecutorFormat(tec));
-        formulaHandleChains.forEach(FormulaHandleChain::handle);
+        formulaHandleChains.forEach(executor->{
+            try {
+                executor.handle();
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        });
         tec.after();
         executionTime.info("公式计算");
         saveInterimPayCertificateItems(tec.meterInfo.getInterimPayCertificateItems());
@@ -2900,7 +2906,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
     }
 
     public List<NodeTable> getTableListMeter(Map<String,String> parent){
-      return this.getSqlList("select a.p_key_id as pkeyId, a.node_name as nodeName, a.init_table_name as initTableName, a.html_url as htmlUrl, a.excel_id as excelId from m_wbs_tree_private a join m_wbs_tree_private b on(a.parent_id=b.id and a.project_id=b.project_id) where a.ancestors like ? and LENGTH(a.html_url) > 0 and a.is_deleted = 0 and a.project_id = ? and a.wbs_id = ?  ORDER BY b.sort",NodeTable.class,parent.get("path")+"%",parent.get("projectId"),parent.get("wbsId"));
+      return this.getSqlList("select a.p_key_id as pkeyId, a.node_name as nodeName, a.init_table_name as initTableName, a.html_url as htmlUrl, a.excel_id as excelId from m_wbs_tree_private a join m_wbs_tree_private b on(a.parent_id=b.id and a.project_id=b.project_id) where a.ancestors like ? and LENGTH(a.html_url) > 0 and a.is_deleted = 0 and a.project_id = ? and a.wbs_id = ?  ORDER BY b.sort,a.sort",NodeTable.class,parent.get("path")+"%",parent.get("projectId"),parent.get("wbsId"));
     }