|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|