From 35f4412614a4801dc26f9284c8c15457e1db2a7f Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期五, 15 三月 2024 14:55:40 +0800
Subject: [PATCH] 优化代码
---
service-report/src/main/java/com/java110/report/smo/impl/QueryPayFeeDetailInnerServiceSMOImpl.java | 176 ++++++++++++++++++++++------------------------------------
1 files changed, 68 insertions(+), 108 deletions(-)
diff --git a/service-report/src/main/java/com/java110/report/smo/impl/QueryPayFeeDetailInnerServiceSMOImpl.java b/service-report/src/main/java/com/java110/report/smo/impl/QueryPayFeeDetailInnerServiceSMOImpl.java
index 91f1361..f4bb3a5 100644
--- a/service-report/src/main/java/com/java110/report/smo/impl/QueryPayFeeDetailInnerServiceSMOImpl.java
+++ b/service-report/src/main/java/com/java110/report/smo/impl/QueryPayFeeDetailInnerServiceSMOImpl.java
@@ -16,6 +16,7 @@
import com.java110.dto.room.RoomDto;
import com.java110.intf.community.IParkingSpaceV1InnerServiceSMO;
import com.java110.intf.community.IRepairInnerServiceSMO;
+import com.java110.intf.community.IRoomInnerServiceSMO;
import com.java110.intf.community.IRoomV1InnerServiceSMO;
import com.java110.intf.fee.IFeeAccountDetailServiceSMO;
import com.java110.intf.fee.IFeeDetailInnerServiceSMO;
@@ -67,6 +68,9 @@
@Autowired
private IRoomV1InnerServiceSMO roomV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
@Autowired
private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
@@ -136,31 +140,86 @@
roomDto.setCommunityId(reportFeeMonthStatisticsDtos.get(0).getCommunityId());
List<RoomDto> roomDtos = roomV1InnerServiceSMOImpl.queryRooms(roomDto);
- if(!ListUtil.isNull(roomDtos)){
+ if (!ListUtil.isNull(roomDtos)) {
for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
- for(RoomDto tmpRoomDto: roomDtos){
- if(reportFeeMonthStatisticsDto.getPayerObjId().equals(tmpRoomDto.getRoomId())){
+ for (RoomDto tmpRoomDto : roomDtos) {
+ if (reportFeeMonthStatisticsDto.getPayerObjId().equals(tmpRoomDto.getRoomId())) {
reportFeeMonthStatisticsDto.setBuiltUpArea(tmpRoomDto.getBuiltUpArea());
}
}
}
}
+ computeParkingSpace(reportFeeMonthStatisticsDtos, payerObjIds);
+
+ }
+
+ private void computeParkingSpace(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos, List<String> payerObjIds) {
OwnerCarDto ownerCarDto = new OwnerCarDto();
ownerCarDto.setMemberIds(payerObjIds.toArray(new String[payerObjIds.size()]));
ownerCarDto.setCommunityId(reportFeeMonthStatisticsDtos.get(0).getCommunityId());
List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
- if(!ListUtil.isNull(ownerCarDtos)){
- for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
- for(OwnerCarDto tmpOwnerCarDto: ownerCarDtos){
- if(reportFeeMonthStatisticsDto.getPayerObjId().equals(tmpOwnerCarDto.getMemberId())){
- reportFeeMonthStatisticsDto.setPsName(tmpOwnerCarDto.getAreaNum()+"-"+tmpOwnerCarDto.getNum());
- }
+ if (ListUtil.isNull(ownerCarDtos)) {
+ return;
+ }
+ freshRoomInfo(ownerCarDtos);
+ for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
+ for (OwnerCarDto tmpOwnerCarDto : ownerCarDtos) {
+ if (!reportFeeMonthStatisticsDto.getPayerObjId().equals(tmpOwnerCarDto.getMemberId())) {
+ continue;
}
+ reportFeeMonthStatisticsDto.setPsName(tmpOwnerCarDto.getAreaNum() + "-" + tmpOwnerCarDto.getNum());
+ reportFeeMonthStatisticsDto.setRoomName(tmpOwnerCarDto.getRoomName());
}
}
+ }
+
+ /**
+ * 鍒峰叆鎴垮眿淇℃伅
+ *
+ * @param ownerCarDtos
+ */
+ private void freshRoomInfo(List<OwnerCarDto> ownerCarDtos) {
+
+ if (ListUtil.isNull(ownerCarDtos) || ownerCarDtos.size() > 30) {
+ return;
+ }
+ for (OwnerCarDto ownerCarDto : ownerCarDtos) {
+ doFreshRoomInfo(ownerCarDto);
+ }
+ }
+
+ /**
+ * 杞︿綅淇℃伅鍒峰叆鎴垮眿淇℃伅
+ *
+ * @param ownerCarDto
+ */
+ private void doFreshRoomInfo(OwnerCarDto ownerCarDto) {
+ OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
+ ownerRoomRelDto.setOwnerId(ownerCarDto.getOwnerId());
+ ownerRoomRelDto.setPage(1);
+ ownerRoomRelDto.setRow(3); //鍙睍绀�3涓埧灞嬩互鍐� 涓嶇劧椤甸潰澶贡
+ List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelInnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto);
+ if (ListUtil.isNull(ownerRoomRelDtos)) {
+ ownerCarDto.setRoomName("-");
+ return;
+ }
+ List<String> roomIds = new ArrayList<>();
+ for (OwnerRoomRelDto tOwnerRoomRelDto : ownerRoomRelDtos) {
+ roomIds.add(tOwnerRoomRelDto.getRoomId());
+ }
+ RoomDto roomDto = new RoomDto();
+ roomDto.setCommunityId(ownerCarDto.getCommunityId());
+ roomDto.setRoomIds(roomIds.toArray(new String[roomIds.size()]));
+ List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
+ String roomName = "";
+ for (RoomDto tRoomDto : roomDtos) {
+ roomName += (tRoomDto.getFloorNum() + "-" + tRoomDto.getUnitNum() + "-" + tRoomDto.getRoomNum() + "-" + "/");
+ }
+ roomName = roomName.endsWith("/") ? roomName.substring(0, roomName.length() - 1) : roomName;
+ ownerCarDto.setRoomName(roomName);
}
/**
@@ -206,49 +265,6 @@
}
- //澶勭悊璐︽埛鎶垫墸
- private ReportFeeMonthStatisticsDto dealFeeAccountDetail(ReportFeeMonthStatisticsDto reportFeeMonthStatistics) {
- //鑾峰彇璐圭敤鏄庣粏id
- String detailId = reportFeeMonthStatistics.getDetailId();
- FeeAccountDetailDto feeAccountDetailDto = new FeeAccountDetailDto();
- feeAccountDetailDto.setDetailId(detailId);
- feeAccountDetailDto.setCommunityId(reportFeeMonthStatistics.getCommunityId());
- List<FeeAccountDetailDto> feeAccountDetailList = feeAccountDetailServiceSMOImpl.queryFeeAccountDetails(feeAccountDetailDto);
- BigDecimal noDeduction = new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP); //鏃犳姷鎵�
- BigDecimal cashDeduction = new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP); //鐜伴噾璐︽埛鎶垫墸
- BigDecimal pointDeduction = new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP); //绉垎璐︽埛鎶垫墸
- BigDecimal discountCouponDeduction = new BigDecimal(0.00).setScale(2, BigDecimal.ROUND_HALF_UP); //浼樻儬鍗锋姷鎵�
- if (feeAccountDetailList != null && feeAccountDetailList.size() > 0) {
- for (FeeAccountDetailDto feeAccountDetail : feeAccountDetailList) {
- //鎶垫墸绫诲瀷 1001 鏃犳姷鎵� 1002 鐜伴噾璐︽埛鎶垫墸 1003 绉垎璐︽埛鎶垫墸 1004 浼樻儬鍒告姷鎵�
- if (!StringUtil.isEmpty(feeAccountDetail.getState()) && feeAccountDetail.getState().equals("1001")) { //鏃犳姷鎵�
- //鑾峰彇璐︽埛鎶垫墸閲戦
- BigDecimal amount = new BigDecimal(feeAccountDetail.getAmount());
- noDeduction = noDeduction.add(amount).setScale(2, BigDecimal.ROUND_HALF_UP);
- }
- if (!StringUtil.isEmpty(feeAccountDetail.getState()) && feeAccountDetail.getState().equals("1002")) { //鐜伴噾璐︽埛鎶垫墸
- //鑾峰彇璐︽埛鎶垫墸閲戦
- BigDecimal amount = new BigDecimal(feeAccountDetail.getAmount());
- cashDeduction = cashDeduction.add(amount).setScale(2, BigDecimal.ROUND_HALF_UP);
- }
- if (!StringUtil.isEmpty(feeAccountDetail.getState()) && feeAccountDetail.getState().equals("1003")) { //绉垎璐︽埛鎶垫墸
- //鑾峰彇璐︽埛鎶垫墸閲戦
- BigDecimal amount = new BigDecimal(feeAccountDetail.getAmount());
- pointDeduction = pointDeduction.add(amount).setScale(2, BigDecimal.ROUND_HALF_UP);
- }
- if (!StringUtil.isEmpty(feeAccountDetail.getState()) && feeAccountDetail.getState().equals("1004")) { //浼樻儬鍗锋姷鎵�
- //鑾峰彇璐︽埛鎶垫墸閲戦
- BigDecimal amount = new BigDecimal(feeAccountDetail.getAmount());
- discountCouponDeduction = discountCouponDeduction.add(amount).setScale(2, BigDecimal.ROUND_HALF_UP);
- }
- }
- }
- reportFeeMonthStatistics.setNoDeduction(String.valueOf(noDeduction)); //鏃犳姷鎵�
- reportFeeMonthStatistics.setCashDeduction(String.valueOf(cashDeduction)); //鐜伴噾璐︽埛鎶垫墸
- reportFeeMonthStatistics.setPointDeduction(String.valueOf(pointDeduction)); //绉垎璐︽埛鎶垫墸
- reportFeeMonthStatistics.setDiscountCouponDeduction(String.valueOf(discountCouponDeduction)); //浼樻儬鍗锋姷鎵�
- return reportFeeMonthStatistics;
- }
@Override
public ResultVo queryPrepayment(@RequestBody ReportFeeMonthStatisticsPrepaymentDto reportFeeMonthStatisticsPrepaymentDto) {
@@ -741,61 +757,5 @@
return reportFeeMonthStatisticsPrepaymentTotal;
}
- /**
- * @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 (!StringUtil.isEmpty(reportFeeMonthStatisticsDto.getOwnerId()) && !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;
- }
}
--
Gitblit v1.8.0