Explorar o código

中期支付证书变更

huangtf hai 7 meses
pai
achega
d4e30ea5ae

+ 11 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/InterimPaymentCertificate.java

@@ -57,6 +57,17 @@ public class InterimPaymentCertificate implements  DataModel{
     private Boolean isSummary=false;
 
 
+    /**本期末支付金额*/
+    @JSONField(name = "key_12",label="本期末变更金额",ordinal = 10)
+    private String currentPeriodEndChangeMoney;
+    /**上期末支付金额*/
+    @JSONField(name = "key_13",label="上期末变更金额",ordinal = 11)
+    private String previousPeriodEndChangeMoney;
+    /**本期支付金额*/
+    @JSONField(name = "key_14",label="本期变更金额",ordinal = 12)
+    private String currentPeriodChangeMoney;
+
+
     public InterimPaymentCertificate(String chapterSeq) {
         this.chapterSeq = chapterSeq;
     }

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

@@ -91,12 +91,6 @@ public class ExecutorInit extends FormulaExecutor {
         //变更令部分
         List<ChangeToken> changeTokenList = changeTokenFc.apply(tec.getContractId());
         tec.meterInfo.setChangeTokenList(changeTokenList) ;
-        if (changeTokenList.size() > 0) {
-            List<ChangeToken> changeTokenList0 = getFilteredChangeTokens(changeTokenList,tec.periodInfo,0);
-            List<ChangeToken> changeTokenList1 = getFilteredChangeTokens(changeTokenList,tec.periodInfo,1);
-            System.out.println();
-        }
-
 
         /*每页内容都一样*/
         tec.getRepeatKeys().addAll(periodMap.keySet());
@@ -120,41 +114,4 @@ public class ExecutorInit extends FormulaExecutor {
         });
     }
 
-
-    /**
-     * type=0 返回本期
-     *  periodInfo.startDate   <  changeApprovalDate <= periodInfo.endDate  的changeTokenList
-     *
-     * type=1 返回上期末
-     *  changeApprovalDate < periodInfo.startDate 的changeTokenList
-     *
-     * type=2 返回本期末
-     * changeApprovalDate <= periodInfo.startDate  的changeTokenList
-     * @param changeTokenList
-     * @param periodInfo
-     * @param type
-     * @return
-     */
-    public  List<ChangeToken> getFilteredChangeTokens(List<ChangeToken> changeTokenList, MeterPeriodInfo periodInfo, int type) {
-        switch (type) {
-            case 0:
-                return changeTokenList.stream()
-                        .filter(token -> (periodInfo.getStartDate().isBefore(token.getChangeApprovalDate())
-                                && !periodInfo.getEndDate().isBefore(token.getChangeApprovalDate())))
-                        .collect(Collectors.toList());
-            case 1:
-                return changeTokenList.stream()
-                        .filter(token -> token.getChangeApprovalDate().isBefore(periodInfo.getStartDate()))
-                        .collect(Collectors.toList());
-            case 2:
-                return changeTokenList.stream()
-                        .filter(token -> !token.getChangeApprovalDate().isAfter(periodInfo.getStartDate()))
-                        .collect(Collectors.toList());
-            default:
-                throw new IllegalArgumentException("Unsupported type: " + type);
-        }
-    }
-
-
-
 }

+ 74 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -107,6 +107,40 @@ public class ExecutorMeter extends FormulaExecutor {
         return line;
     }
 
+    /**
+     * type=0 返回本期
+     *  periodInfo.startDate   <  changeApprovalDate <= periodInfo.endDate  的changeTokenList
+     *
+     * type=1 返回上期末
+     *  changeApprovalDate < periodInfo.startDate 的changeTokenList
+     *
+     * type=2 返回本期末
+     * changeApprovalDate <= periodInfo.startDate  的changeTokenList
+     * @param changeTokenList
+     * @param periodInfo
+     * @param type
+     * @return
+     */
+    public  List<ChangeToken> getFilteredChangeTokens(List<ChangeToken> changeTokenList, MeterPeriodInfo periodInfo, int type) {
+        switch (type) {
+            case 0:
+                return changeTokenList.stream()
+                        .filter(token -> (periodInfo.getStartDate().isBefore(token.getChangeApprovalDate())
+                                && !periodInfo.getEndDate().isBefore(token.getChangeApprovalDate())))
+                        .collect(Collectors.toList());
+            case 1:
+                return changeTokenList.stream()
+                        .filter(token -> token.getChangeApprovalDate().isBefore(periodInfo.getStartDate()))
+                        .collect(Collectors.toList());
+            case 2:
+                return changeTokenList.stream()
+                        .filter(token -> !token.getChangeApprovalDate().isAfter(periodInfo.getEndDate()))
+                        .collect(Collectors.toList());
+            default:
+                throw new IllegalArgumentException("Unsupported type: " + type);
+        }
+    }
+
     @Override
     public void handle() {
         this.elementWriter=new MeterElementWriter();
@@ -404,6 +438,13 @@ public class ExecutorMeter extends FormulaExecutor {
                 }
             }
 
+            /* 本期变更 */
+            List<ChangeToken> changeTokenList0 = getFilteredChangeTokens(tec.meterInfo.getChangeTokenList(),tec.periodInfo,0);
+            /* 上期末变更 */
+            List<ChangeToken> changeTokenList1 = getFilteredChangeTokens(tec.meterInfo.getChangeTokenList(),tec.periodInfo,1);
+            /* 本期末变更 */
+            List<ChangeToken> changeTokenList2 = getFilteredChangeTokens(tec.meterInfo.getChangeTokenList(),tec.periodInfo,2);
+
             Map<String,InterimPaymentCertificate> paymentCertificateMap = new LinkedHashMap<>();
              if(Func.isNotEmpty(paymentList)){
                  /*之前的计量期数据*/
@@ -434,6 +475,14 @@ public class ExecutorMeter extends FormulaExecutor {
                          ipc.setRevisedAmount(bmMoney[1].toString());
                          ipc.setPreviousPeriodEndPay(StringUtils.handleNullZero(previousMoney.get(cm.getKey()),tec.getScale()));
                          ipc.setCurrentPeriodPay(StringUtils.handleNull(currentMoney.get(cm.getKey())));
+
+                         ipc.setCurrentPeriodChangeMoney(StringUtils.handleNullZero(sumChangeMoneyForChapter(changeTokenList0,ch)
+                                 ,tec.getPayRadicScale()));
+                         ipc.setPreviousPeriodEndChangeMoney(StringUtils.handleNullZero(sumChangeMoneyForChapter(changeTokenList1,ch)
+                                 ,tec.getPayRadicScale()));
+                         ipc.setCurrentPeriodEndChangeMoney(StringUtils.handleNullZero(sumChangeMoneyForChapter(changeTokenList2,ch)
+                                 ,tec.getPayRadicScale()));
+
                          /*由已知求未知*/
                          ipc.calculate();
                          //dataList.add(ipc);
@@ -490,6 +539,31 @@ public class ExecutorMeter extends FormulaExecutor {
             }
         }
 
+        /**
+         * Sums the changeMoney for all ChangeTokens with the specified chapter number.
+         *
+         * @param changeTokens List of ChangeToken objects to be evaluated.
+         * @param chapterNumber The chapter number to filter the ChangeTokens.
+         * @return The sum of changeMoney for all ChangeTokens with the specified chapter number.
+         */
+        public  BigDecimal sumChangeMoneyForChapter(List<ChangeToken> changeTokens, String chapterNumber) {
+            if (changeTokens == null || changeTokens.isEmpty()) {
+                return BigDecimal.ZERO;
+            }
+
+            BigDecimal sum = BigDecimal.ZERO;
+            for (ChangeToken token : changeTokens) {
+                if (token.getChapterNumber() != null && token.getChapterNumber().equals(chapterNumber)) {
+                    BigDecimal changeMoney = token.getChangeMoney();
+                    if (changeMoney != null) {
+                        sum = sum.add(changeMoney);
+                    }
+                }
+            }
+
+            return sum;
+        }
+
 
     }