From b06ccd76e50812d81ee689dcd609bb02ac5c4ed4 Mon Sep 17 00:00:00 2001
From: xiaogang <905166056@qq.com>
Date: 星期四, 11 八月 2022 14:48:52 +0800
Subject: [PATCH] 1、优化页面展示行问题

---
 service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java |  162 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 110 insertions(+), 52 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 8ff0124..8440ddd 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,6 +33,7 @@
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 @Service("getReportFeeMonthStatisticsBMOImpl")
@@ -86,6 +87,7 @@
 
     @Override
     public ResponseEntity<String> queryReportFeeSummary(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+
         int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryReportFeeSummaryCount(reportFeeMonthStatisticsDto);
 
         List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = new ArrayList<>();
@@ -231,6 +233,8 @@
 
     @Override
     public ResponseEntity<String> queryReportFloorUnitFeeSummary(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+        reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
+        reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
         int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryReportFloorUnitFeeSummaryCount(reportFeeMonthStatisticsDto);
 
         List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = null;
@@ -261,17 +265,46 @@
 
     @Override
     public ResponseEntity<String> queryFeeBreakdown(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+
+        if(StringUtil.isEmpty(reportFeeMonthStatisticsDto.getYearMonth())){
+            reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear()+"");
+            reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth()+"");
+        }
+
         int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryFeeBreakdownCount(reportFeeMonthStatisticsDto);
 
         List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = null;
         if (count > 0) {
             reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryFeeBreakdown(reportFeeMonthStatisticsDto);
             ReportFeeMonthStatisticsDto tmpReportFeeMonthStatisticsDto = reportFeeMonthStatisticsInnerServiceSMOImpl.queryFeeBreakdownMajor(reportFeeMonthStatisticsDto);
+            reportFeeMonthStatisticsDto.setPage(PageDto.DEFAULT_PAGE);
+            List<ReportFeeMonthStatisticsDto> reportFeeMonthStatistics = reportFeeMonthStatisticsInnerServiceSMOImpl.queryFeeBreakdown(reportFeeMonthStatisticsDto);
+            BigDecimal allOweAmount = new BigDecimal(0.0);
+            BigDecimal allHisOweReceivedAmount = new BigDecimal(0.0);
+            for (ReportFeeMonthStatisticsDto reportFeeMonthStatistic : reportFeeMonthStatistics) {
+                //鑾峰彇鍘嗗彶娆犺垂
+                BigDecimal hisOweAmount = new BigDecimal(reportFeeMonthStatistic.getHisOweAmount());
+                //鑾峰彇褰撴湀搴旀敹
+                BigDecimal curReceivableAmount = new BigDecimal(reportFeeMonthStatistic.getCurReceivableAmount());
+                //鑾峰彇褰撴湀瀹炴敹
+                BigDecimal curReceivedAmount = new BigDecimal(reportFeeMonthStatistic.getCurReceivedAmount());
+                //鑾峰彇娆犲�鸿拷鍥�
+                BigDecimal hisOweReceivedAmount = new BigDecimal(reportFeeMonthStatistic.getHisOweReceivedAmount());
+                //璁$畻娆犺垂閲戦
+                BigDecimal oweAmount = hisOweAmount.add(curReceivableAmount).subtract(curReceivedAmount).subtract(hisOweReceivedAmount);
+                if (oweAmount.compareTo(BigDecimal.ZERO) == 1) { //娆犺垂閲戦澶т簬0
+                    allOweAmount = allOweAmount.add(oweAmount);
+                }
+                if (hisOweReceivedAmount.compareTo(BigDecimal.ZERO) == 1) { //娆犺垂杩藉洖澶т簬0
+                    allHisOweReceivedAmount = allHisOweReceivedAmount.add(hisOweReceivedAmount);
+                }
+            }
             if (reportFeeMonthStatisticsDtos != null && reportFeeMonthStatisticsDtos.size() > 0) {
                 for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 : reportFeeMonthStatisticsDtos) {
                     reportFeeMonthStatisticsDto1.setAllReceivableAmount(tmpReportFeeMonthStatisticsDto.getAllReceivableAmount());
                     reportFeeMonthStatisticsDto1.setAllReceivedAmount(tmpReportFeeMonthStatisticsDto.getAllReceivedAmount());
-                    reportFeeMonthStatisticsDto1.setAllOweAmount(tmpReportFeeMonthStatisticsDto.getAllOweAmount());
+                    reportFeeMonthStatisticsDto1.setAllOweAmount(allOweAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toString());
+                    reportFeeMonthStatisticsDto1.setAllHisOweReceivedAmount(allHisOweReceivedAmount.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
                 }
             }
         } else {
@@ -287,51 +320,51 @@
 
     @Override
     public ResponseEntity<String> queryFeeDetail(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+
+
+        reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
+        reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
+
         int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryFeeDetailCount(reportFeeMonthStatisticsDto);
 
         List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = null;
-        //搴旀敹鎬婚噾棰�(澶ц)
-        Double allReceivableAmount = 0.0;
-        //瀹炴敹閲戦(澶ц)
-        Double allReceivedAmount = 0.0;
         if (count > 0) {
             reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryFeeDetail(reportFeeMonthStatisticsDto);
             List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsList = reportFeeMonthStatisticsInnerServiceSMOImpl.queryAllFeeDetail(reportFeeMonthStatisticsDto);
-            allReceivableAmount = Double.valueOf(reportFeeMonthStatisticsList.get(0).getAllReceivableAmount());
-            allReceivedAmount = Double.valueOf(reportFeeMonthStatisticsList.get(0).getAllReceivedAmount());
+            reportFeeMonthStatisticsDto.setPage(PageDto.DEFAULT_PAGE);
+            List<ReportFeeMonthStatisticsDto> reportFeeMonthStatistics = reportFeeMonthStatisticsInnerServiceSMOImpl.queryFeeDetail(reportFeeMonthStatisticsDto);
+            BigDecimal allOweAmount = new BigDecimal(0.0);
+            BigDecimal allHisOweReceivedAmount = new BigDecimal(0.0);
+            for (ReportFeeMonthStatisticsDto reportFeeMonthStatistic : reportFeeMonthStatistics) {
+                //鑾峰彇鍘嗗彶娆犺垂
+                BigDecimal hisOweAmount = new BigDecimal(reportFeeMonthStatistic.getHisOweAmount());
+                //鑾峰彇褰撴湀搴旀敹
+                BigDecimal curReceivableAmount = new BigDecimal(reportFeeMonthStatistic.getCurReceivableAmount());
+                //鑾峰彇褰撴湀瀹炴敹
+                BigDecimal curReceivedAmount = new BigDecimal(reportFeeMonthStatistic.getCurReceivedAmount());
+                //鑾峰彇娆犺垂杩藉洖
+                BigDecimal hisOweReceivedAmount = new BigDecimal(reportFeeMonthStatistic.getHisOweReceivedAmount());
+                //璁$畻娆犺垂閲戦
+                BigDecimal oweAmount = hisOweAmount.add(curReceivableAmount).subtract(curReceivedAmount).subtract(hisOweReceivedAmount);
+                if (oweAmount.compareTo(BigDecimal.ZERO) == 1) { //娆犺垂閲戦澶т簬0
+                    allOweAmount = allOweAmount.add(oweAmount);
+                }
+                if (hisOweReceivedAmount.compareTo(BigDecimal.ZERO) == 1) { //娆犺垂杩藉洖澶т簬0
+                    allHisOweReceivedAmount = allHisOweReceivedAmount.add(hisOweReceivedAmount);
+                }
+            }
+            if (reportFeeMonthStatisticsDtos != null && reportFeeMonthStatisticsDtos.size() > 0) {
+                for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 : reportFeeMonthStatisticsDtos) {
+                    reportFeeMonthStatisticsDto1.setAllReceivableAmount(reportFeeMonthStatisticsList.get(0).getAllReceivableAmount());
+                    reportFeeMonthStatisticsDto1.setAllReceivedAmount(reportFeeMonthStatisticsList.get(0).getAllReceivedAmount());
+                    reportFeeMonthStatisticsDto1.setAllOweAmount(allOweAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toString());
+                    reportFeeMonthStatisticsDto1.setAllHisOweReceivedAmount(allHisOweReceivedAmount.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
+                }
+            }
         } else {
             reportFeeMonthStatisticsDtos = new ArrayList<>();
         }
-
-        //搴旀敹鎬婚噾棰�(灏忚)
-        Double totalReceivableAmount = 0.0;
-        //瀹炴敹鎬婚噾棰�(灏忚)
-        Double totalReceivedAmount = 0.0;
-        List<ReportFeeMonthStatisticsDto> reportList = new ArrayList<>();
-        for (ReportFeeMonthStatisticsDto reportFeeMonthStatistics : reportFeeMonthStatisticsDtos) {
-            //搴旀敹閲戦
-            Double receivableAmount = Double.valueOf(reportFeeMonthStatistics.getReceivableAmount());
-            //瀹炴敹閲戦
-            Double receivedAmount = Double.valueOf(reportFeeMonthStatistics.getReceivedAmount());
-            totalReceivableAmount = totalReceivableAmount + receivableAmount;
-            totalReceivedAmount = totalReceivedAmount + receivedAmount;
-        }
-
-        //鏌ヨ璇ュ皬鍖轰笅鐨勮垂鐢ㄩ」鐩�
-        FeeConfigDto feeConfigDto = new FeeConfigDto();
-        feeConfigDto.setCommunityId(reportFeeMonthStatisticsDto.getCommunityId());
-        List<FeeConfigDto> feeConfigDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
-
-        for (ReportFeeMonthStatisticsDto reportFeeMonthStatistics : reportFeeMonthStatisticsDtos) {
-            reportFeeMonthStatistics.setTotalReceivableAmount(String.format("%.2f", totalReceivableAmount));
-            reportFeeMonthStatistics.setTotalReceivedAmount(String.format("%.2f", totalReceivedAmount));
-            reportFeeMonthStatistics.setAllReceivableAmount(String.format("%.2f", allReceivableAmount));
-            reportFeeMonthStatistics.setAllReceivedAmount(String.format("%.2f", allReceivedAmount));
-            reportFeeMonthStatistics.setFeeConfigDtos(feeConfigDtos);
-            reportList.add(reportFeeMonthStatistics);
-        }
-
-        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reportFeeMonthStatisticsDto.getRow()), count, reportList);
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reportFeeMonthStatisticsDto.getRow()), count, reportFeeMonthStatisticsDtos);
 
         ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
 
@@ -393,8 +426,8 @@
         Double allVacantHousingDiscount = 0.0;
         //绌虹疆鎴垮噺鍏�(澶ц)
         Double allVacantHousingReduction = 0.0;
-
-
+        //璧犻�侀噾棰�(澶ц)
+        Double allGiftAmount = 0.0;
         //鍚村鏂� 娉ㄩ噴 鎰熻鍜屼笂闈㈢殑369 鍔熻兘閲嶅
         //int size = 0;
         if (count > 0) {
@@ -437,6 +470,10 @@
                 if (!StringUtil.isEmpty(reportFeeMonthStatistics.getDiscountSmallType()) && reportFeeMonthStatistics.getDiscountSmallType().equals("5")) {
                     allVacantHousingReduction = Double.valueOf(discountPrice);
                 }
+                //璧犻�侀噾棰�(澶ц)
+                if (!StringUtil.isEmpty(reportFeeMonthStatistics.getDiscountSmallType()) && reportFeeMonthStatistics.getDiscountSmallType().equals("6")) {
+                    allGiftAmount = Double.valueOf(discountPrice);
+                }
             }
             //搴旀敹鎬婚噾棰�(灏忚)
             Double totalReceivableAmount = 0.0;
@@ -450,6 +487,8 @@
             Double totalVacantHousingDiscount = 0.0;
             //绌虹疆鎴垮噺鍏嶉噾棰�(灏忚)
             Double totalVacantHousingReduction = 0.0;
+            //璧犻�侀噾棰�(灏忚)
+            Double totalGiftAmount = 0.0;
             //婊炵撼閲�(灏忚)
             Double totalLateFee = 0.0;
             List<String> ownerIds = new ArrayList<>();
@@ -495,7 +534,7 @@
                 //婊炵撼閲�
                 if (!StringUtil.isEmpty(reportFeeMonthStatistics.getDiscountSmallType()) && reportFeeMonthStatistics.getDiscountSmallType().equals("3")) {
                     //鑾峰彇婊炵撼閲戦噾棰�
-                    Double discountPrice = (Double.valueOf(reportFeeMonthStatistics.getDiscountPrice())) * (-1);
+                    Double discountPrice = (Double.valueOf(reportFeeMonthStatistics.getDiscountPrice()));
                     totalLateFee = totalLateFee + discountPrice;
                     //婊炵撼閲�
                     reportFeeMonthStatistics.setLateFee(reportFeeMonthStatistics.getDiscountPrice());
@@ -521,6 +560,16 @@
                     reportFeeMonthStatistics.setVacantHousingReduction(reportFeeMonthStatistics.getDiscountPrice());
                 } else {
                     reportFeeMonthStatistics.setVacantHousingReduction("0");
+                }
+                //璧犻�侀噾棰�
+                if (!StringUtil.isEmpty(reportFeeMonthStatistics.getDiscountSmallType()) && reportFeeMonthStatistics.getDiscountSmallType().equals("6")) {
+                    //璧犻�侀噾棰�
+                    Double discountPrice = Double.valueOf(reportFeeMonthStatistics.getDiscountPrice());
+                    totalGiftAmount = totalGiftAmount + discountPrice;
+                    //璧犻�侀噾棰�
+                    reportFeeMonthStatistics.setGiftAmount(reportFeeMonthStatistics.getDiscountPrice());
+                } else {
+                    reportFeeMonthStatistics.setGiftAmount("0");
                 }
                 if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(reportFeeMonthStatistics.getPayerObjType())) {
                     reportFeeMonthStatistics.setObjName(reportFeeMonthStatistics.getFloorNum()
@@ -610,29 +659,33 @@
             //瀹炴敹閲戦(灏忚)
             reportFeeMonthStatisticsTotalDto.setTotalReceivedAmount(String.format("%.2f", totalReceivedAmount));
             //浼樻儬閲戦(灏忚)
-            reportFeeMonthStatisticsTotalDto.setTotalPreferentialAmount(String.valueOf(totalPreferentialAmount));
+            reportFeeMonthStatisticsTotalDto.setTotalPreferentialAmount(String.format("%.2f",totalPreferentialAmount));
             //鍑忓厤閲戦(灏忚)
-            reportFeeMonthStatisticsTotalDto.setTotalDeductionAmount(String.valueOf(totalDeductionAmount));
+            reportFeeMonthStatisticsTotalDto.setTotalDeductionAmount(String.format("%.2f",totalDeductionAmount));
             //婊炵撼閲�(灏忚)
-            reportFeeMonthStatisticsTotalDto.setTotalLateFee(String.valueOf(totalLateFee));
+            reportFeeMonthStatisticsTotalDto.setTotalLateFee(String.format("%.2f",totalLateFee));
             //绌虹疆鎴挎墦鎶�(灏忚)
-            reportFeeMonthStatisticsTotalDto.setTotalVacantHousingDiscount(String.valueOf(totalVacantHousingDiscount));
+            reportFeeMonthStatisticsTotalDto.setTotalVacantHousingDiscount(String.format("%.2f",totalVacantHousingDiscount));
             //绌虹疆鎴垮噺鍏�(灏忚)
-            reportFeeMonthStatisticsTotalDto.setTotalVacantHousingReduction(String.valueOf(totalVacantHousingReduction));
+            reportFeeMonthStatisticsTotalDto.setTotalVacantHousingReduction(String.format("%.2f",totalVacantHousingReduction));
+            //璧犻�佽鍒欓噾棰�(灏忚)
+            reportFeeMonthStatisticsTotalDto.setTotalGiftAmount(String.format("%.2f",totalGiftAmount));
             //搴旀敹閲戦(澶ц)
             reportFeeMonthStatisticsTotalDto.setAllReceivableAmount(String.format("%.2f", allReceivableAmount));
             //瀹炴敹閲戦(澶ц)
             reportFeeMonthStatisticsTotalDto.setAllReceivedAmount(String.format("%.2f", allReceivedAmount));
             //浼樻儬閲戦(澶ц)
-            reportFeeMonthStatisticsTotalDto.setAllPreferentialAmount(String.valueOf(allPreferentialAmount));
+            reportFeeMonthStatisticsTotalDto.setAllPreferentialAmount(String.format("%.2f",allPreferentialAmount));
             //鍑忓厤閲戦(澶ц)
-            reportFeeMonthStatisticsTotalDto.setAllDeductionAmount(String.valueOf(allDeductionAmount));
+            reportFeeMonthStatisticsTotalDto.setAllDeductionAmount(String.format("%.2f",allDeductionAmount));
             //婊炵撼閲�(澶ц)
-            reportFeeMonthStatisticsTotalDto.setAllLateFee(String.valueOf(allLateFee));
+            reportFeeMonthStatisticsTotalDto.setAllLateFee(String.format("%.2f",allLateFee));
             //绌虹疆鎴挎墦鎶橀噾棰�(澶ц)
-            reportFeeMonthStatisticsTotalDto.setAllVacantHousingDiscount(String.valueOf(allVacantHousingDiscount));
+            reportFeeMonthStatisticsTotalDto.setAllVacantHousingDiscount(String.format("%.2f",allVacantHousingDiscount));
             //绌虹疆鎴垮噺鍏嶉噾棰�(澶ц)
-            reportFeeMonthStatisticsTotalDto.setAllVacantHousingReduction(String.valueOf(allVacantHousingReduction));
+            reportFeeMonthStatisticsTotalDto.setAllVacantHousingReduction(String.format("%.2f",allVacantHousingReduction));
+            //璧犻�佽鍒欓噾棰�(澶ц)
+            reportFeeMonthStatisticsTotalDto.setAllGiftAmount(String.format("%.2f",allGiftAmount));
         } else {
             reportFeeMonthStatisticsDtos = new ArrayList<>();
             reportList.addAll(reportFeeMonthStatisticsDtos);
@@ -665,7 +718,7 @@
                 continue;
             }
             for (OwnerDto ownerDto1 : ownerDtos) {
-                if (!reportFeeMonthStatisticsDto.getOwnerId().equals(ownerDto1.getOwnerId())) {
+                if (!StringUtil.isEmpty(reportFeeMonthStatisticsDto.getOwnerId()) && !reportFeeMonthStatisticsDto.getOwnerId().equals(ownerDto1.getOwnerId())) {
                     continue;
                 }
                 objName = reportFeeMonthStatisticsDto.getObjName() + "(" + ownerDto1.getFloorNum() + "鏍�" + ownerDto1.getUnitNum() + "鍗曞厓" + ownerDto1.getRoomNum() + "瀹�)";
@@ -791,6 +844,8 @@
      */
     @Override
     public ResponseEntity<String> queryReportProficientCount(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+        reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear()+"");
+        reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth()+"");
         JSONObject result = reportFeeMonthStatisticsInnerServiceSMOImpl.queryReportProficientCount(reportFeeMonthStatisticsDto);
         ResponseEntity<String> responseEntity = new ResponseEntity<String>(result.toString(), HttpStatus.OK);
 
@@ -1225,7 +1280,8 @@
     private void freshReportOweDay(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos) {
         for (ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto : reportFeeMonthStatisticsDtos) {
             try {
-                int day = DateUtil.daysBetween(DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getDeadlineTime(), DateUtil.DATE_FORMATE_STRING_A), DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getFeeCreateTime(),
+                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                int day = DateUtil.daysBetween(DateUtil.getDateFromString(format.format(new Date()), DateUtil.DATE_FORMATE_STRING_A), DateUtil.getDateFromString(reportFeeMonthStatisticsDto.getFeeCreateTime(),
                         DateUtil.DATE_FORMATE_STRING_A));
                 reportFeeMonthStatisticsDto.setOweDay(day);
             } catch (Exception e) {
@@ -1235,6 +1291,8 @@
         }
     }
 
+
+
     private void freshReportDeadlineDay(List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos) {
 
         Date nowDate = DateUtil.getCurrentDate();

--
Gitblit v1.8.0