From 28e7d3937f819a3486b22bfa1c84aee172aaccb4 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 17 一月 2022 17:46:42 +0800
Subject: [PATCH] 优化代码
---
service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 53 insertions(+), 2 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 57351e0..8ff0124 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
@@ -20,12 +20,11 @@
import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO;
import com.java110.report.bmo.reportFeeMonthStatistics.IGetReportFeeMonthStatisticsBMO;
import com.java110.utils.util.Assert;
-import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.java110.core.log.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -40,6 +39,9 @@
public class GetReportFeeMonthStatisticsBMOImpl implements IGetReportFeeMonthStatisticsBMO {
private static final Logger logger = LoggerFactory.getLogger(GetReportFeeMonthStatisticsBMOImpl.class);
+
+
+ private int MAX_ROWS = 500; // 鏈�澶ц鏁�
@Autowired
private IReportFeeMonthStatisticsInnerServiceSMO reportFeeMonthStatisticsInnerServiceSMOImpl;
@@ -391,6 +393,8 @@
Double allVacantHousingDiscount = 0.0;
//绌虹疆鎴垮噺鍏�(澶ц)
Double allVacantHousingReduction = 0.0;
+
+
//鍚村鏂� 娉ㄩ噴 鎰熻鍜屼笂闈㈢殑369 鍔熻兘閲嶅
//int size = 0;
if (count > 0) {
@@ -448,6 +452,7 @@
Double totalVacantHousingReduction = 0.0;
//婊炵撼閲�(灏忚)
Double totalLateFee = 0.0;
+ List<String> ownerIds = new ArrayList<>();
for (ReportFeeMonthStatisticsDto reportFeeMonthStatistics : reportFeeMonthStatisticsDtos) {
//搴旀敹閲戦
Double receivableAmount = Double.valueOf(reportFeeMonthStatistics.getReceivableAmount());
@@ -455,6 +460,18 @@
Double receivedAmount = Double.valueOf(reportFeeMonthStatistics.getReceivedAmount());
totalReceivableAmount = totalReceivableAmount + receivableAmount;
totalReceivedAmount = totalReceivedAmount + receivedAmount;
+
+ if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(reportFeeMonthStatistics.getPayerObjType())) {
+ ownerIds.add(reportFeeMonthStatistics.getOwnerId());
+ }
+
+ // 鏈�澶ц褰曟椂 灏卞幓鍒锋柊
+ //濡傛灉鏄溅浣嶅埛鎴垮眿淇℃伅
+ if (ownerIds.size() == MAX_ROWS) {
+ refreshReportFeeMonthStatistics(ownerIds, reportFeeMonthStatisticsDtos);
+ ownerIds = new ArrayList<>();
+ }
+
//浼樻儬閲戦
if (!StringUtil.isEmpty(reportFeeMonthStatistics.getDiscountSmallType()) && reportFeeMonthStatistics.getDiscountSmallType().equals("1")) {
//鑾峰彇浼樻儬閲戦
@@ -582,6 +599,12 @@
reportList.add(reportFeeMonthStatistics);
}
}
+
+ //濡傛灉鏄溅浣嶅埛鎴垮眿淇℃伅
+ if (ownerIds.size() > 0) {
+ refreshReportFeeMonthStatistics(ownerIds, reportFeeMonthStatisticsDtos);
+ }
+
//搴旀敹鎬婚噾棰�(灏忚)
reportFeeMonthStatisticsTotalDto.setTotalReceivableAmount(String.format("%.2f", totalReceivableAmount));
//瀹炴敹閲戦(灏忚)
@@ -623,6 +646,34 @@
return responseEntity;
}
+ /**
+ * @param ownerIds
+ * @param reportFeeMonthStatisticsDtos
+ */
+ private void refreshReportFeeMonthStatistics(List<String> ownerIds, List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos) {
+
+ if (ownerIds == null || ownerIds.size() < 1) {
+ return;
+ }
+
+ OwnerDto ownerDto = new OwnerDto();
+ ownerDto.setOwnerIds(ownerIds.toArray(new String[ownerIds.size()]));
+ List<OwnerDto> ownerDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryRoomAndParkingSpace(ownerDto);
+ String objName = "";
+ for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
+ if (!FeeDto.PAYER_OBJ_TYPE_CAR.equals(reportFeeMonthStatisticsDto.getPayerObjType())) {
+ continue;
+ }
+ for (OwnerDto ownerDto1 : ownerDtos) {
+ if (!reportFeeMonthStatisticsDto.getOwnerId().equals(ownerDto1.getOwnerId())) {
+ continue;
+ }
+ objName = reportFeeMonthStatisticsDto.getObjName() + "(" + ownerDto1.getFloorNum() + "鏍�" + ownerDto1.getUnitNum() + "鍗曞厓" + ownerDto1.getRoomNum() + "瀹�)";
+ reportFeeMonthStatisticsDto.setObjName(objName);
+ }
+ }
+ }
+
private boolean hasInReportListAndMerge(List<ReportFeeMonthStatisticsDto> reportList, ReportFeeMonthStatisticsDto reportFeeMonthStatistics) {
for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportList) {
if (reportFeeMonthStatisticsDto.getDetailId().equals(reportFeeMonthStatistics.getDetailId())) {
--
Gitblit v1.8.0