From cddcf22a61489ee9c2dfee169d817ccd66f95430 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期五, 03 九月 2021 02:23:43 +0800
Subject: [PATCH] 优化代码
---
service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 105 insertions(+), 14 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 4d8fdb7..8d25830 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
@@ -1,17 +1,25 @@
package com.java110.report.bmo.reportFeeMonthStatistics.impl;
import com.alibaba.fastjson.JSONObject;
+import com.java110.core.smo.IComputeFeeSMO;
import com.java110.dto.PageDto;
import com.java110.dto.RoomDto;
import com.java110.dto.fee.FeeConfigDto;
import com.java110.dto.fee.FeeDto;
+import com.java110.dto.owner.OwnerDto;
+import com.java110.dto.owner.OwnerRoomRelDto;
+import com.java110.dto.repair.RepairDto;
import com.java110.dto.repair.RepairUserDto;
import com.java110.dto.report.ReportDeposit;
import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsDto;
import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsTotalDto;
+import com.java110.intf.community.IRepairInnerServiceSMO;
import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
import com.java110.intf.report.IReportFeeMonthStatisticsInnerServiceSMO;
+import com.java110.intf.user.IOwnerInnerServiceSMO;
+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;
@@ -25,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 {
@@ -42,6 +45,18 @@
@Autowired
private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
+
+ @Autowired
+ private IRepairInnerServiceSMO repairInnerServiceSMOImpl;
+
+ @Autowired
+ private IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMOImpl;
+
+ @Autowired
+ private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
+
+ @Autowired
+ private IComputeFeeSMO computeFeeSMOImpl;
/**
* @param reportFeeMonthStatisticsDto
@@ -227,8 +242,8 @@
ReportFeeMonthStatisticsDto tmpReportFeeMonthStatisticsDto = reportFeeMonthStatisticsInnerServiceSMOImpl.queryOweFeeDetailMajor(reportFeeMonthStatisticsDto);
if (reportFeeMonthStatisticsDtos != null && reportFeeMonthStatisticsDtos.size() > 0) {
for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 : reportFeeMonthStatisticsDtos) {
- reportFeeMonthStatisticsDto1.setAllReceivableAmount(tmpReportFeeMonthStatisticsDto.getAllReceivableAmount());
- reportFeeMonthStatisticsDto1.setAllReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllReceivedAmount());
+// reportFeeMonthStatisticsDto1.setAllReceivableAmount(tmpReportFeeMonthStatisticsDto.getAllReceivableAmount());
+// reportFeeMonthStatisticsDto1.setAllReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllReceivedAmount());
reportFeeMonthStatisticsDto1.setAllOweAmount(tmpReportFeeMonthStatisticsDto.getAllOweAmount());
}
}
@@ -399,6 +414,25 @@
}
//璐圭敤椤圭洰
reportFeeMonthStatistics.setFeeConfigDtos(feeConfigDtos);
+ if (!StringUtil.isEmpty(reportFeeMonthStatistics.getRepairId())) {
+ RepairDto repairDto = new RepairDto();
+ repairDto.setRepairId(reportFeeMonthStatistics.getRepairId());
+ //鏌ヨ鎶ヤ慨鍗�
+ List<RepairDto> repairDtos = repairInnerServiceSMOImpl.queryRepairs(repairDto);
+ Assert.listOnlyOne(repairDtos, "鏌ヨ鎶ヤ慨鍗曢敊璇紒");
+ if (!StringUtil.isEmpty(repairDtos.get(0).getRepairObjType()) && repairDtos.get(0).getRepairObjType().equals("004")) {
+ OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
+ ownerRoomRelDto.setRoomId(repairDtos.get(0).getRepairObjId());
+ List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelInnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto);
+ Assert.listOnlyOne(ownerRoomRelDtos, "鏌ヨ涓氫富鎴垮眿鍏崇郴琛ㄩ敊璇紒");
+ OwnerDto ownerDto = new OwnerDto();
+ ownerDto.setOwnerId(ownerRoomRelDtos.get(0).getOwnerId());
+ ownerDto.setOwnerTypeCd("1001"); //涓氫富鏈汉
+ List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwners(ownerDto);
+ Assert.listOnlyOne(ownerDtos, "鏌ヨ涓氫富淇℃伅閿欒锛�");
+ reportFeeMonthStatistics.setOwnerName(ownerDtos.get(0).getName());
+ }
+ }
reportList.add(reportFeeMonthStatistics);
}
//搴旀敹鎬婚噾棰�(灏忚)
@@ -832,7 +866,7 @@
reportFeeMonthStatisticsDtos = new ArrayList<>();
}
- ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) paramInfo.get("row")), count, reportFeeMonthStatisticsDtos);
+ ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (int) paramInfo.get("row")), count, reportFeeMonthStatisticsDtos);
ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
@@ -857,11 +891,71 @@
reportFeeMonthStatisticsDtos = new ArrayList<>();
}
- ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) paramInfo.get("row")), count, reportFeeMonthStatisticsDtos);
+ ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (int) paramInfo.get("row")), count, reportFeeMonthStatisticsDtos);
ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
return responseEntity;
+ }
+
+ @Override
+ public ResponseEntity<String> queryHuaningOweFeeDetail(Map paramInfo) {
+ Calendar calendar = Calendar.getInstance();
+ int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryHuaningOweFeeDetailCount(paramInfo);
+ List<Map> reportFeeMonthStatisticsDtos = null;
+ if (count > 0) {
+ reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryHuaningOweFeeDetail(paramInfo);
+ refreshOweFee(reportFeeMonthStatisticsDtos, paramInfo);
+ } else {
+ reportFeeMonthStatisticsDtos = new ArrayList<>();
+ }
+
+ ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (int) paramInfo.get("row")), count, reportFeeMonthStatisticsDtos);
+
+ ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+
+ return responseEntity;
+ }
+
+ private void refreshOweFee(List<Map> reportFeeMonthStatisticsDtos, Map paramInfo) {
+ Date startTime = null;
+ Date endTime = null;
+ Calendar calendar = Calendar.getInstance();
+ int curMonth = calendar.get(Calendar.MONTH) + 1;
+ calendar.set(Calendar.MONTH, 0);
+ Date curStart = calendar.getTime();
+
+
+ for (Map paramIn : reportFeeMonthStatisticsDtos) {
+
+ startTime = (Date) paramIn.get("startTime");
+ endTime = (Date) paramIn.get("endTime");
+ BigDecimal money = (BigDecimal) paramIn.get("oweAmount");
+ double month = Math.ceil(computeFeeSMOImpl.dayCompare(startTime, endTime));
+ if (month < 1) {
+ paramIn.put("btAmount", 0);
+ paramIn.put("bfAmount", 0);
+ continue;
+ }
+
+ //姣忔湀閲戦
+ BigDecimal monthAmount = money.divide(new BigDecimal(month), 2, BigDecimal.ROUND_HALF_EVEN);
+
+ if (startTime.getTime() < curStart.getTime()) {
+ BigDecimal btAmountDec = monthAmount.multiply(new BigDecimal(curMonth)).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+ paramIn.put("btAmount", btAmountDec.doubleValue());
+ double preMonth = Math.ceil(computeFeeSMOImpl.dayCompare(startTime, curStart));
+ BigDecimal bfAmountDec = monthAmount.multiply(new BigDecimal(preMonth)).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+ paramIn.put("bfAmount", bfAmountDec.doubleValue());
+ continue;
+ }
+
+ if (startTime.getTime() >= curStart.getTime()) {
+ paramIn.put("btAmount", money.doubleValue());
+ paramIn.put("bfAmount", 0);
+ }
+ }
+
}
@Override
@@ -899,12 +993,9 @@
}
private void freshReportOweDay(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos) {
-
- Date nowDate = DateUtil.getCurrentDate();
-
for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
try {
- int day = DateUtil.daysBetween(nowDate, DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getFeeCreateTime(),
+ int day = DateUtil.daysBetween(DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getDeadlineTime(), DateUtil.DATE_FORMATE_STRING_A), DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getFeeCreateTime(),
DateUtil.DATE_FORMATE_STRING_A));
reportFeeMonthStatisticsDto.setOweDay(day);
} catch (Exception e) {
--
Gitblit v1.8.0