From 4e01e72b92e3605641f8ed7f6fb775274ad5e997 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期四, 18 十一月 2021 11:41:15 +0800
Subject: [PATCH] 优化代码
---
service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java | 104 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 98 insertions(+), 6 deletions(-)
diff --git a/service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java b/service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java
index 81654b6..66ddb92 100755
--- a/service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java
+++ b/service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java
@@ -33,12 +33,7 @@
import java.math.BigDecimal;
import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
@Service("getReportFeeMonthStatisticsBMOImpl")
public class GetReportFeeMonthStatisticsBMOImpl implements IGetReportFeeMonthStatisticsBMO {
@@ -93,6 +88,9 @@
List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = new ArrayList<>();
if (count > 0) {
List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsList = reportFeeMonthStatisticsInnerServiceSMOImpl.queryReportFeeSummary(reportFeeMonthStatisticsDto);
+ if (reportFeeMonthStatisticsDto.getConfigIds() != null) {
+ reportFeeMonthStatisticsList = dealConfigReportFeeMonthStatisticsList(reportFeeMonthStatisticsList);
+ }
for (ReportFeeMonthStatisticsDto reportFeeMonthStatistics : reportFeeMonthStatisticsList) {
//鑾峰彇搴旀敹閲戦
double receivableAmount = Double.parseDouble(reportFeeMonthStatistics.getReceivableAmount());
@@ -127,6 +125,100 @@
return responseEntity;
}
+ /**
+ * 灏哻onfigId group by 鍚庢暟鎹� 鍚堝苟澶勭悊
+ *
+ * @param reportFeeMonthStatisticsList
+ * @return
+ */
+ private List<ReportFeeMonthStatisticsDto> dealConfigReportFeeMonthStatisticsList(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsList) {
+ List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = new ArrayList<>();
+ BigDecimal hisOweAmountDec = null;
+ BigDecimal curReceivableAmountDec = null;
+ BigDecimal curReceivedAmountDec = null;
+ BigDecimal hisOweReceivedAmountDec = null;
+ BigDecimal preReceivedAmountDec = null;
+ BigDecimal receivableAmountDec = null;
+ BigDecimal receivedAmountDec = null;
+ List<FeeConfigDto> feeConfigDtos = null;
+ FeeConfigDto feeConfigDto = null;
+ for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsList) {
+ ReportFeeMonthStatisticsDto tmpReportFeeMonthStatisticsDto = hasReportFeeMonthStatisticsDto(reportFeeMonthStatisticsDtos, reportFeeMonthStatisticsDto);
+ if (tmpReportFeeMonthStatisticsDto == null) {
+ feeConfigDtos = new ArrayList<>();
+ feeConfigDto = new FeeConfigDto();
+ feeConfigDto.setConfigId(reportFeeMonthStatisticsDto.getConfigId());
+ feeConfigDto.setAmount(Double.parseDouble(reportFeeMonthStatisticsDto.getReceivedAmount()));
+ feeConfigDtos.add(feeConfigDto);
+ reportFeeMonthStatisticsDto.setFeeConfigDtos(feeConfigDtos);
+ reportFeeMonthStatisticsDtos.add(reportFeeMonthStatisticsDto);
+ continue;
+ }
+ feeConfigDtos = tmpReportFeeMonthStatisticsDto.getFeeConfigDtos();
+ feeConfigDto = new FeeConfigDto();
+ feeConfigDto.setConfigId(reportFeeMonthStatisticsDto.getConfigId());
+ feeConfigDto.setAmount(Double.parseDouble(reportFeeMonthStatisticsDto.getReceivedAmount()));
+ feeConfigDtos.add(feeConfigDto);
+ tmpReportFeeMonthStatisticsDto.setFeeConfigDtos(feeConfigDtos);
+
+ //鍘嗗彶娆犺垂
+ hisOweAmountDec = new BigDecimal(tmpReportFeeMonthStatisticsDto.getHisOweAmount());
+ hisOweAmountDec = hisOweAmountDec.add(new BigDecimal(reportFeeMonthStatisticsDto.getHisOweAmount()))
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
+ tmpReportFeeMonthStatisticsDto.setHisOweAmount(hisOweAmountDec.doubleValue());
+
+
+ //褰撴湀搴旀敹
+ curReceivableAmountDec = new BigDecimal(tmpReportFeeMonthStatisticsDto.getCurReceivableAmount());
+ curReceivableAmountDec = curReceivableAmountDec.add(new BigDecimal(reportFeeMonthStatisticsDto.getCurReceivableAmount()))
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
+ tmpReportFeeMonthStatisticsDto.setCurReceivableAmount(curReceivableAmountDec.doubleValue());
+
+ //褰撴湀瀹炴敹
+ curReceivedAmountDec = new BigDecimal(tmpReportFeeMonthStatisticsDto.getCurReceivedAmount());
+ curReceivedAmountDec = curReceivedAmountDec.add(new BigDecimal(reportFeeMonthStatisticsDto.getCurReceivedAmount()))
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
+ tmpReportFeeMonthStatisticsDto.setCurReceivedAmount(curReceivedAmountDec.doubleValue());
+
+ //娆犺垂杩藉洖
+ hisOweReceivedAmountDec = new BigDecimal(tmpReportFeeMonthStatisticsDto.getHisOweReceivedAmount());
+ hisOweReceivedAmountDec = hisOweReceivedAmountDec.add(new BigDecimal(reportFeeMonthStatisticsDto.getHisOweReceivedAmount()))
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
+ tmpReportFeeMonthStatisticsDto.setHisOweReceivedAmount(hisOweReceivedAmountDec.doubleValue());
+
+ //棰勪氦璐�
+ preReceivedAmountDec = new BigDecimal(tmpReportFeeMonthStatisticsDto.getPreReceivedAmount());
+ preReceivedAmountDec = preReceivedAmountDec.add(new BigDecimal(reportFeeMonthStatisticsDto.getPreReceivedAmount()))
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
+ tmpReportFeeMonthStatisticsDto.setPreReceivedAmount(preReceivedAmountDec.doubleValue());
+
+ //鎬昏垂鐢�
+ receivableAmountDec = new BigDecimal(Double.parseDouble(tmpReportFeeMonthStatisticsDto.getReceivableAmount()));
+ receivableAmountDec = receivableAmountDec.add(new BigDecimal(Double.parseDouble(reportFeeMonthStatisticsDto.getReceivableAmount())))
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
+ tmpReportFeeMonthStatisticsDto.setReceivableAmount(receivableAmountDec.doubleValue() + "");
+
+ //瀹炴敹
+ receivedAmountDec = new BigDecimal(Double.parseDouble(tmpReportFeeMonthStatisticsDto.getReceivedAmount()));
+ receivedAmountDec = receivedAmountDec.add(new BigDecimal(Double.parseDouble(reportFeeMonthStatisticsDto.getReceivedAmount())))
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
+ tmpReportFeeMonthStatisticsDto.setReceivedAmount(receivedAmountDec.doubleValue() + "");
+ }
+
+ return reportFeeMonthStatisticsDtos;
+ }
+
+ private ReportFeeMonthStatisticsDto hasReportFeeMonthStatisticsDto(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos, ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+ for (ReportFeeMonthStatisticsDto tmpReportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
+ if (tmpReportFeeMonthStatisticsDto.getFeeYear().equals(reportFeeMonthStatisticsDto.getFeeYear())
+ && tmpReportFeeMonthStatisticsDto.getFeeMonth().equals(reportFeeMonthStatisticsDto.getFeeMonth())) {
+ return tmpReportFeeMonthStatisticsDto;
+ }
+ }
+
+ return null;
+ }
+
@Override
public ResponseEntity<String> queryReportFloorUnitFeeSummary(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryReportFloorUnitFeeSummaryCount(reportFeeMonthStatisticsDto);
--
Gitblit v1.8.0