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 | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 102 insertions(+), 13 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 63376b1..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,17 +20,17 @@
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;
import org.springframework.stereotype.Service;
+import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.*;
@@ -39,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;
@@ -111,7 +114,7 @@
for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 : reportFeeMonthStatisticsList) {
reportFeeMonthStatisticsDto1.setAllReceivableAmount(tmpReportFeeMonthStatisticsDto.getAllReceivableAmount());
reportFeeMonthStatisticsDto1.setAllReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllReceivedAmount());
- reportFeeMonthStatisticsDto1.setAllOweAmount(tmpReportFeeMonthStatisticsDto.getAllOweAmount());
+ reportFeeMonthStatisticsDto1.setAllHisOweReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllHisOweReceivedAmount());
}
}
} else {
@@ -242,6 +245,7 @@
reportFeeMonthStatisticsDto1.setAllReceivableAmount(tmpReportFeeMonthStatisticsDto.getAllReceivableAmount());
reportFeeMonthStatisticsDto1.setAllReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllReceivedAmount());
reportFeeMonthStatisticsDto1.setAllOweAmount(tmpReportFeeMonthStatisticsDto.getAllOweAmount());
+ reportFeeMonthStatisticsDto1.setAllHisOweReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllHisOweReceivedAmount());
}
}
} else {
@@ -389,17 +393,21 @@
Double allVacantHousingDiscount = 0.0;
//绌虹疆鎴垮噺鍏�(澶ц)
Double allVacantHousingReduction = 0.0;
- int size = 0;
+
+
+ //鍚村鏂� 娉ㄩ噴 鎰熻鍜屼笂闈㈢殑369 鍔熻兘閲嶅
+ //int size = 0;
if (count > 0) {
//鏌ヨ缂磋垂鏄庣粏
reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryPayFeeDetail(reportFeeMonthStatisticsDto);
- if (reportFeeMonthStatisticsDtos != null && reportFeeMonthStatisticsDtos.size() > 0) {
- //鏌ヨ鎵�鏈夌即璐规槑缁嗚褰�
- ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 = BeanConvertUtil.covertBean(reportFeeMonthStatisticsDto, ReportFeeMonthStatisticsDto.class);
- reportFeeMonthStatisticsDto1.setPage(PageDto.DEFAULT_PAGE);
- List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos1 = reportFeeMonthStatisticsInnerServiceSMOImpl.queryPayFeeDetail(reportFeeMonthStatisticsDto1);
- size = reportFeeMonthStatisticsDtos1.size();
- }
+ //鍚村鏂� 娉ㄩ噴 鎰熻鍜屼笂闈㈢殑369 鍔熻兘閲嶅
+// if (reportFeeMonthStatisticsDtos != null && reportFeeMonthStatisticsDtos.size() > 0) {
+// //鏌ヨ鎵�鏈夌即璐规槑缁嗚褰�
+// ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 = BeanConvertUtil.covertBean(reportFeeMonthStatisticsDto, ReportFeeMonthStatisticsDto.class);
+// reportFeeMonthStatisticsDto1.setPage(PageDto.DEFAULT_PAGE);
+// List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos1 = reportFeeMonthStatisticsInnerServiceSMOImpl.queryPayFeeDetail(reportFeeMonthStatisticsDto1);
+// size = reportFeeMonthStatisticsDtos1.size();
+// }
//鏌ヨ搴旀敹銆佸疄鏀舵�婚噾棰�(澶ц)
List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsList = reportFeeMonthStatisticsInnerServiceSMOImpl.queryAllPayFeeDetail(reportFeeMonthStatisticsDto);
//鏌ヨ(浼樻儬銆佸噺鍏嶃�佹粸绾抽噾銆佺┖缃埧鎵撴姌銆佺┖缃埧鍑忓厤閲戦绛�)澶ц鎬婚噾棰�
@@ -444,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());
@@ -451,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")) {
//鑾峰彇浼樻儬閲戦
@@ -574,8 +595,16 @@
}
}
}
- reportList.add(reportFeeMonthStatistics);
+ if (!hasInReportListAndMerge(reportList, reportFeeMonthStatistics)) {
+ reportList.add(reportFeeMonthStatistics);
+ }
}
+
+ //濡傛灉鏄溅浣嶅埛鎴垮眿淇℃伅
+ if (ownerIds.size() > 0) {
+ refreshReportFeeMonthStatistics(ownerIds, reportFeeMonthStatisticsDtos);
+ }
+
//搴旀敹鎬婚噾棰�(灏忚)
reportFeeMonthStatisticsTotalDto.setTotalReceivableAmount(String.format("%.2f", totalReceivableAmount));
//瀹炴敹閲戦(灏忚)
@@ -610,13 +639,73 @@
reportFeeMonthStatisticsTotalDto = new ReportFeeMonthStatisticsTotalDto();
}
- ResultVo resultVo = new ResultVo((int) Math.ceil((double) size / (double) reportFeeMonthStatisticsDto.getRow()), size, reportList, reportFeeMonthStatisticsTotalDto);
+ ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reportFeeMonthStatisticsDto.getRow()), count, reportList, reportFeeMonthStatisticsTotalDto);
ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
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())) {
+ combineSydwCore(reportFeeMonthStatistics, reportFeeMonthStatisticsDto);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //閽堝鎵�鐢ㄥ璞�
+ private static ReportFeeMonthStatisticsDto combineSydwCore(ReportFeeMonthStatisticsDto sourceBean, ReportFeeMonthStatisticsDto targetBean) {
+ Class sourceBeanClass = sourceBean.getClass();
+ Class targetBeanClass = targetBean.getClass();
+ Field[] sourceFields = sourceBeanClass.getDeclaredFields();
+ Field[] targetFields = sourceBeanClass.getDeclaredFields();
+ for (int i = 0; i < sourceFields.length; i++) {
+ Field sourceField = sourceFields[i];
+ Field targetField = targetFields[i];
+ sourceField.setAccessible(true);
+ targetField.setAccessible(true);
+ try {
+ if (!(sourceField.get(sourceBean) == null)) {
+ targetField.set(targetBean, sourceField.get(sourceBean));
+ }
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ return targetBean;
+ }
+
@Override
public ResponseEntity<String> queryDeadlineFee(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryDeadlineFeeCount(reportFeeMonthStatisticsDto);
--
Gitblit v1.8.0