From 65763d38cf9b6b8067a293d9c99297efea0de3e3 Mon Sep 17 00:00:00 2001
From: 928255095 <928255095@qq.com>
Date: 星期二, 07 九月 2021 22:04:15 +0800
Subject: [PATCH] Merge branch 'xinghong-dev' into 'master'

---
 service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java |  102 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 84 insertions(+), 18 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 ae2c917..470c651 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
@@ -6,13 +6,20 @@
 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;
@@ -26,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 {
@@ -43,6 +45,15 @@
 
     @Autowired
     private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
+
+    @Autowired
+    private IRepairInnerServiceSMO repairInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
 
     @Autowired
     private IComputeFeeSMO computeFeeSMOImpl;
@@ -231,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());
                 }
             }
@@ -403,6 +414,64 @@
                 }
                 //璐圭敤椤圭洰
                 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);
+                        if (ownerRoomRelDtos != null && ownerRoomRelDtos.size() == 0) { //鏌ヨ鏉℃暟涓�0鏉�
+                            OwnerRoomRelDto ownerRoomRel = new OwnerRoomRelDto();
+                            ownerRoomRel.setRoomId(repairDtos.get(0).getRepairObjId());
+                            ownerRoomRel.setStatusCd("1"); //鐪嬬湅涓氫富鎴垮眿鍏崇郴鏁版嵁鏄惁鍒犻櫎浜�
+                            List<OwnerRoomRelDto> ownerRoomRels = ownerRoomRelInnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRel);
+                            Assert.listOnlyOne(ownerRoomRels, "鏌ヨ涓氫富鎴垮眿鍏崇郴琛ㄩ敊璇紒");
+                            OwnerDto owner = new OwnerDto();
+                            owner.setOwnerId(ownerRoomRels.get(0).getOwnerId());
+                            owner.setOwnerTypeCd("1001"); //涓氫富鏈汉
+                            List<OwnerDto> owners = ownerInnerServiceSMOImpl.queryOwners(owner);
+                            if (owners != null && owners.size() == 0) { //鏌ュ嚭鏉℃暟涓�0鏉�
+                                //鍒ゆ柇涓氫富鏄惁鍒犻櫎浜�
+                                OwnerDto newOwner = new OwnerDto();
+                                newOwner.setOwnerId(ownerRoomRels.get(0).getOwnerId());
+                                newOwner.setOwnerTypeCd("1001"); //涓氫富鏈汉
+                                newOwner.setStatusCd("1");
+                                List<OwnerDto> newOwners = ownerInnerServiceSMOImpl.queryOwners(newOwner);
+                                Assert.listOnlyOne(newOwners, "鏌ヨ涓氫富淇℃伅閿欒锛�");
+                                reportFeeMonthStatistics.setOwnerName(newOwners.get(0).getName());
+                            } else if (owners != null && owners.size() == 1) { //鏌ュ嚭鏉℃暟涓�1鏉�
+                                reportFeeMonthStatistics.setOwnerName(owners.get(0).getName());
+                            } else {
+                                throw new IllegalArgumentException("鏌ヨ涓氫富淇℃伅閿欒锛�");
+                            }
+                        } else if (ownerRoomRelDtos != null && ownerRoomRelDtos.size() == 1) { //鏌ヨ鏉℃暟涓�1鏉�
+                            OwnerDto ownerDto = new OwnerDto();
+                            ownerDto.setOwnerId(ownerRoomRelDtos.get(0).getOwnerId());
+                            ownerDto.setOwnerTypeCd("1001"); //涓氫富鏈汉
+                            List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwners(ownerDto);
+                            if (ownerDtos != null && ownerDtos.size() == 0) { //涓氫富鏌ヨ鏉℃暟涓�0鏉�
+                                //鍒ゆ柇涓氫富鏄惁鍒犻櫎浜�
+                                OwnerDto newOwner = new OwnerDto();
+                                newOwner.setOwnerId(ownerRoomRelDtos.get(0).getOwnerId());
+                                newOwner.setOwnerTypeCd("1001"); //涓氫富鏈汉
+                                newOwner.setStatusCd("1");
+                                List<OwnerDto> newOwners = ownerInnerServiceSMOImpl.queryOwners(newOwner);
+                                Assert.listOnlyOne(newOwners, "鏌ヨ涓氫富淇℃伅閿欒锛�");
+                                reportFeeMonthStatistics.setOwnerName(newOwners.get(0).getName());
+                            } else if (ownerDtos != null || ownerDtos.size() == 1) {
+                                reportFeeMonthStatistics.setOwnerName(ownerDtos.get(0).getName());
+                            } else {
+                                throw new IllegalArgumentException("鏌ヨ涓氫富淇℃伅閿欒锛�");
+                            }
+                        } else {
+                            throw new IllegalArgumentException("鏌ヨ涓氫富鎴垮眿鍏崇郴琛ㄩ敊璇紒");
+                        }
+                    }
+                }
                 reportList.add(reportFeeMonthStatistics);
             }
             //搴旀敹鎬婚噾棰�(灏忚)
@@ -861,7 +930,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);
 
@@ -880,7 +949,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);
 
@@ -899,8 +968,8 @@
         for (Map paramIn : reportFeeMonthStatisticsDtos) {
 
             startTime = (Date) paramIn.get("startTime");
-            endTime = (Date) paramIn.get("startTime");
-            double money = (double) paramIn.get("oweAmount");
+            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);
@@ -909,7 +978,7 @@
             }
 
             //姣忔湀閲戦
-            BigDecimal monthAmount = new BigDecimal(money).divide(new BigDecimal(month), 2, BigDecimal.ROUND_HALF_EVEN);
+            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);
@@ -921,7 +990,7 @@
             }
 
             if (startTime.getTime() >= curStart.getTime()) {
-                paramIn.put("btAmount", money);
+                paramIn.put("btAmount", money.doubleValue());
                 paramIn.put("bfAmount", 0);
             }
         }
@@ -963,12 +1032,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