Browse Source

合同中期支付项

yangyj 8 months ago
parent
commit
714d897687

+ 3 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MeterPeriodInfo.java

@@ -32,6 +32,9 @@ public class MeterPeriodInfo {
     /**上期累计金额*/
     @JSONField(name = "key_4",label="上期累计金额",ordinal = 4)
     private String  preTotal;
+    /**本期支付金额*/
+    @JSONField(name = "key_6",label="本期支付金额",ordinal = 4)
+    private String  curTotal;
     /**请款理由*/
     @JSONField(name = "key_5",label="请款理由",ordinal = 5)
     private String  cause;

+ 23 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MidPayItem.java

@@ -0,0 +1,23 @@
+package org.springblade.manager.vo;
+
+import lombok.Data;
+import org.springblade.core.tool.utils.Func;
+
+/**
+ * @author yangyj
+ * @Date 2024/3/8 10:02
+ * @description 中期支付项
+ */
+@Data
+public class MidPayItem {
+    private String payName;
+    private String payNumber;
+    /*编号为空的时候,取名称覆盖*/
+    public void setPayNumber(String payNumber) {
+        if(Func.isBlank(payNumber)&&Func.isNotEmpty(payNumber)){
+            this.payNumber=this.payName;
+        }else {
+            this.payNumber = payNumber;
+        }
+    }
+}

+ 17 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -35,6 +35,7 @@ import java.util.stream.Stream;
 public class ExecutorMeter extends FormulaExecutor {
     private Function<Long, List<Material>> materialFormFc;
     private Function<Long, List<Payment>> paymentListFc;
+    private Function<Long, List<MidPayItem>> midPayItemListFc;
     private Function<Long, List<InventoryForm>> inventoryFormFc;
     private Function<Long, List<MeterApply>> meterApplyFc;
     private Function<Long, List<StartPayForm>> stayPayFormFc;
@@ -309,7 +310,6 @@ public class ExecutorMeter extends FormulaExecutor {
             /*数据获取start*/
               /*支付数据*/
              List<Payment> paymentList=paymentListFc.apply(tec.getContractId());
-
              /*合同计量清单*/
              List<InventoryForm> inventoryForms = inventoryFormFc.apply(tec.getContractId());
              InventoryForm root = null;
@@ -326,6 +326,7 @@ public class ExecutorMeter extends FormulaExecutor {
                 }
             }
 
+            Map<String,InterimPaymentCertificate> paymentCertificateMap = new LinkedHashMap<>();
              if(Func.isNotEmpty(paymentList)){
                  /*之前的计量期数据*/
                  previous = paymentList.stream().filter(e->e.getSort()<tec.periodInfo.getSort()).collect(Collectors.toList());
@@ -355,13 +356,25 @@ public class ExecutorMeter extends FormulaExecutor {
                          ipc.setCurrentPeriodPay(StringUtils.handleNull(currentMoney.get(cm.getKey())));
                          /*由已知求未知*/
                          ipc.calculate();
-                         dataList.add(ipc);
+                         //dataList.add(ipc);
+                         paymentCertificateMap.put(ch,ipc);
                      }
                  }
              }
-            /*数据获取end*/
             /*本期实际支付合计计算*/
-            interimPaymentCertificates=dataList;
+            interimPaymentCertificates= new ArrayList<>(paymentCertificateMap.values());
+            /*合同段支付项*/
+            List<MidPayItem> midPayItemList=midPayItemListFc.apply(tec.getContractId());
+             if(Func.isNotEmpty(midPayItemList)){
+                 midPayItemList.forEach(e->{
+                     InterimPaymentCertificate ipc = paymentCertificateMap.get(e.getPayNumber());
+                     if(ipc==null){
+                         ipc= new InterimPaymentCertificate(e.getPayName());
+                     }
+                      dataList.add(ipc);
+                 });
+             }
+            /*数据获取end*/
              double total=dataList.stream().map(InterimPaymentCertificate::getCurrentPeriodPay).mapToDouble(BaseUtils::obj2DoubleZero).sum();
              if(total>0){
                  FormData ft =tec.formDataMap.get(InterimPaymentCertificate.TBN+ StringPool.COLON+"key_9");

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IFormulaDao.java

@@ -1,5 +1,6 @@
 package org.springblade.manager.service;
 
+import org.springblade.manager.formula.impl.ExecutorMeter;
 import org.springblade.manager.vo.*;
 import java.util.List;
 import java.util.Map;
@@ -18,6 +19,8 @@ public interface IFormulaDao {
     Function<Long, MeterPeriodInfo> getInterimMeterPeriodFc();
     /**获取支付数据*/
     Function<Long, List<Payment>> getPaymentListFc();
+    /**合同段中期支付项*/
+    Function<Long, List<MidPayItem>> getMidPayItemListFc();
     /**获取合同计量清单*/
     Function<Long,List<InventoryForm>> getInventoryFormFc();
     /**获取计量单元树*/

+ 10 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaDaoImpl.java

@@ -60,7 +60,7 @@ public class FormulaDaoImpl implements IFormulaDao {
     @Override
     public Function<Long,MeterPeriodInfo> getMeterPeriodFc(){
         return id-> {
-           List<MeterPeriodInfo> beans = this.jdbcTemplate.query("select b.id,b.period_number periodNumber,b.period_name periodName,a.print_date formPrintDate ,a.repayment_cause cause from s_material_start_statement a join  s_meter_period b on a.meter_period_id=b.id where a.id="+id, new BeanPropertyRowMapper<>(MeterPeriodInfo.class));
+           List<MeterPeriodInfo> beans = this.jdbcTemplate.query("select b.id,b.period_number periodNumber,b.period_name periodName,b.current_amount curTotal,a.print_date formPrintDate ,a.repayment_cause cause from s_material_start_statement a join  s_meter_period b on a.meter_period_id=b.id where a.id="+id, new BeanPropertyRowMapper<>(MeterPeriodInfo.class));
             if(beans.size()>0){
                 MeterPeriodInfo bean = beans.get(0);
                 List<Map<String,Object>> listMap= this.jdbcTemplate.queryForList("select sum(b.current_amount) currentAmount from s_meter_period a join s_meter_period b on (a.contract_id=b.contract_id and a.type=b.type) where a.id="+bean.getId()+" and  a.sort>b.sort");
@@ -100,7 +100,7 @@ public class FormulaDaoImpl implements IFormulaDao {
     @Override
     public Function<Long, MeterPeriodInfo> getInterimMeterPeriodFc() {
         return certificateId->{
-            String sql="select a.id, a.period_number periodNumber,a.sort ,b.print_date formPrintDate from  s_contract_meter_period a join s_interim_pay_certificate b on a.id=b.contract_period_id where a.is_deleted=0 and b.id="+certificateId;
+            String sql="select a.id, a.period_number periodNumber,a.sort ,b.print_date formPrintDate ,b.pay_money curTotal from  s_contract_meter_period a join s_interim_pay_certificate b on a.id=b.contract_period_id where a.is_deleted=0 and b.id="+certificateId;
             return this.jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<>(MeterPeriodInfo.class));
         };
     }
@@ -113,6 +113,14 @@ public class FormulaDaoImpl implements IFormulaDao {
         };
     }
 
+    @Override
+    public Function<Long, List<MidPayItem>> getMidPayItemListFc() {
+        return contractId->{
+            String paySql="select pay_name,pay_number from s_meter_mid_pay_item_contract where contract_id =? and is_deleted=0 ORDER BY sort ";
+            return this.jdbcTemplate.query(paySql,new BeanPropertyRowMapper<>(MidPayItem.class),contractId);
+        };
+    }
+
     @Override
     public Function<Long, List<InventoryForm>> getInventoryFormFc() {
         return  contractId->{