From b173d31976fc4731b7c247d4038de92134eba317 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期四, 29 六月 2023 11:42:17 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

---
 service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java |  160 ++++++++++------------------------------------------
 1 files changed, 32 insertions(+), 128 deletions(-)

diff --git a/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java b/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
index df552c5..857f152 100755
--- a/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
+++ b/service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java
@@ -4,7 +4,7 @@
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.core.log.LoggerFactory;
 import com.java110.core.smo.IComputeFeeSMO;
-import com.java110.dto.RoomDto;
+import com.java110.dto.room.RoomDto;
 import com.java110.dto.fee.FeeConfigDto;
 import com.java110.dto.fee.FeeDto;
 import com.java110.dto.owner.OwnerCarDto;
@@ -12,14 +12,14 @@
 import com.java110.dto.report.ReportFeeDetailDto;
 import com.java110.dto.report.ReportFeeDto;
 import com.java110.dto.report.ReportRoomDto;
-import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsDto;
+import com.java110.dto.reportFee.ReportFeeMonthStatisticsDto;
 import com.java110.intf.community.IFloorInnerServiceSMO;
 import com.java110.intf.community.IRoomInnerServiceSMO;
 import com.java110.intf.community.IUnitInnerServiceSMO;
 import com.java110.intf.report.IGeneratorFeeMonthStatisticsInnerServiceSMO;
 import com.java110.intf.report.IReportFeeMonthStatisticsInnerServiceSMO;
 import com.java110.intf.user.IOwnerCarInnerServiceSMO;
-import com.java110.po.reportFeeMonthStatistics.ReportFeeMonthStatisticsPo;
+import com.java110.po.reportFee.ReportFeeMonthStatisticsPo;
 import com.java110.report.dao.IReportCommunityServiceDao;
 import com.java110.report.dao.IReportFeeMonthStatisticsServiceDao;
 import com.java110.report.dao.IReportFeeServiceDao;
@@ -167,6 +167,7 @@
 
         ReportCarDto reportCarDto = new ReportCarDto();
         reportCarDto.setCommunityId(reportFeeMonthStatisticsPo.getCommunityId());
+        reportCarDto.setLeaseTypes(new String[]{OwnerCarDto.LEASE_TYPE_MONTH,OwnerCarDto.LEASE_TYPE_INNER,OwnerCarDto.LEASE_TYPE_SALE,OwnerCarDto.LEASE_TYPE_NO_MONEY});
         int count = reportCommunityServiceDaoImpl.getCarCount(reportCarDto);
 
 
@@ -336,92 +337,12 @@
 
         Calendar calender = Calendar.getInstance();
         calender.setTime(endTime);
-        int year = calender.get(Calendar.YEAR);
-        int month = calender.get(Calendar.MONTH);
 
         ReportFeeMonthStatisticsPo tmpReportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
         tmpReportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
         tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime, DateUtil.DATE_FORMATE_STRING_A));
         tmpReportFeeMonthStatisticsPo.setOweAmount("0");
         reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
-    }
-
-    /**
-     * 瑙e喅涓婄嚎鍓� 娆犺垂鏁版嵁
-     *
-     * @param tmpReportCarDto
-     * @param tmpReportFeeDto
-     */
-    private void dealBeforeUploadCarFee(ReportFeeDto tmpReportFeeDto, ReportCarDto tmpReportCarDto) {
-
-
-        Calendar preMonthDate = Calendar.getInstance();
-        preMonthDate.set(Calendar.DAY_OF_MONTH, 1);
-        preMonthDate.add(Calendar.DAY_OF_MONTH, -1);
-
-        //褰撴湀涓�鏃�
-        Calendar curMonthDate = Calendar.getInstance();
-        curMonthDate.set(Calendar.DAY_OF_MONTH, 1);
-        curMonthDate.set(Calendar.HOUR_OF_DAY, 0);
-        curMonthDate.set(Calendar.MINUTE, 0);
-        curMonthDate.set(Calendar.SECOND, 0);
-        if (tmpReportFeeDto.getEndTime().getTime() > curMonthDate.getTime().getTime()) { //璇存槑娌℃湁娆犺垂
-            return;
-        }
-
-        ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
-        reportFeeMonthStatisticsDto.setCommunityId(tmpReportCarDto.getCommunityId());
-        reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
-        reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
-        reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
-        reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
-        reportFeeMonthStatisticsDto.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
-        reportFeeMonthStatisticsDto.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
-        List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
-                reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
-                ReportFeeMonthStatisticsDto.class);
-        //涓婁釜鏈堟湁鏁版嵁 涓嶅鐞�
-        if (statistics != null && statistics.size() > 0) {
-            return;
-        }
-
-        if (tmpReportFeeDto.getDeadlineTime().getTime() < curMonthDate.getTime().getTime()) {
-            curMonthDate.setTime(tmpReportFeeDto.getDeadlineTime());
-        }
-
-        double receivableAmount = 0.0;
-        if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
-            receivableAmount = tmpReportFeeDto.getFeePrice();
-        } else {
-            double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curMonthDate.getTime());
-            BigDecimal curDegree = new BigDecimal(month);
-            receivableAmount = curDegree.multiply(new BigDecimal(tmpReportFeeDto.getFeePrice())).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
-        }
-
-
-        ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo = new ReportFeeMonthStatisticsPo();
-        reportFeeMonthStatisticsPo.setDeadlineTime(DateUtil.getFormatTimeString(curMonthDate.getTime(), DateUtil.DATE_FORMATE_STRING_A));
-
-        reportFeeMonthStatisticsPo.setOweAmount(receivableAmount + "");
-        reportFeeMonthStatisticsPo.setReceivedAmount("0");
-        reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
-        reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
-        reportFeeMonthStatisticsPo.setCommunityId(tmpReportFeeDto.getCommunityId());
-        reportFeeMonthStatisticsPo.setConfigId(tmpReportFeeDto.getConfigId());
-        reportFeeMonthStatisticsPo.setFeeCreateTime(DateUtil.getFormatTimeString(tmpReportFeeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
-        reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
-        reportFeeMonthStatisticsPo.setFeeMonth((preMonthDate.get(Calendar.MONTH) + 1) + "");
-        reportFeeMonthStatisticsPo.setFeeYear(preMonthDate.get(Calendar.YEAR) + "");
-        reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(DateUtil.getFirstDate(), DateUtil.DATE_FORMATE_STRING_A));
-        reportFeeMonthStatisticsPo.setObjId(tmpReportCarDto.getCarId());
-        reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_CAR);
-        reportFeeMonthStatisticsPo.setFeeName(tmpReportFeeDto.getFeeName());
-        reportFeeMonthStatisticsPo.setObjName(tmpReportCarDto.getCarNum() + "(" + tmpReportCarDto.getAreaNum() + "鍋滆溅鍦�" + tmpReportCarDto.getNum() + "杞︿綅)");
-        reportFeeMonthStatisticsPo.setObjNameNum(tmpReportCarDto.getAreaNum() + "-" + tmpReportCarDto.getNum() + "-" + tmpReportCarDto.getCarNum());
-        reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
-        reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
-
-
     }
 
     /**
@@ -466,8 +387,7 @@
         reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
         reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId()); //杩欓噷涓嶈兘娉ㄩ噴锛屽洜涓轰竴涓垂鐢ㄥ娆″垱寤烘椂浼氬瓨鍦ㄨ鐩� 瀛樺湪bug闂
         reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
-        int year = DateUtil.getYear();
-        int month = DateUtil.getMonth();
+
         reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
         reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
         List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
@@ -484,11 +404,6 @@
         Date targetEndDate = (Date) targetEndDateAndOweMonth.get("targetEndDate");
         tmpReportFeeDto.setDeadlineTime(targetEndDate);
         double oweAmount = getOweAmount(tmpReportFeeDto, reportRoomDto, null); //娆犺垂
-
-        //double receivableAmount = getReceivableAmount(tmpReportFeeDto, receivedAmount); //搴旀敹
-        //瑙e喅涓婄嚎鏃� 涔嬪墠娆犺垂娌℃湁鍒峰叆瀵艰嚧璐圭敤閲戦瀵逛笉涓婇棶棰樺鐞�
-        //dealBeforeUploadRoomFee(reportRoomDto, tmpReportFeeDto);
-
         double feePrice = computeFeeSMOImpl.getReportFeePrice(tmpReportFeeDto, reportRoomDto, null);
         tmpReportFeeDto.setFeePrice(feePrice);
 
@@ -497,8 +412,7 @@
         if (!ListUtil.isNull(statistics)) {
             ReportFeeMonthStatisticsDto statistic = statistics.get(0);
             reportFeeMonthStatisticsPo.setStatisticsId(statistic.getStatisticsId());
-            //reportFeeMonthStatisticsPo.setReceivableAmount(receivableAmount + "");
-            //reportFeeMonthStatisticsPo.setReceivedAmount("0");
+
             reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
             reportFeeMonthStatisticsPo.setFeeId(tmpReportFeeDto.getFeeId());
             reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
@@ -523,33 +437,9 @@
             reportFeeMonthStatisticsPo.setPreReceivedAmount(MoneyUtil.computePriceScale(getReceivedAmount(tmpReportFeeDto, 3),
                     tmpReportFeeDto.getScale(),
                     Integer.parseInt(tmpReportFeeDto.getDecimalPlace())) + "");
-            /*if (!StringUtil.isEmpty(statistic.getObjType()) && statistic.getObjType().equals("3333")) { //鎴垮眿
-                if (!StringUtil.isEmpty(statistic.getObjId())) {
-                    //鑾峰彇浠樿垂瀵硅薄ID
-                    String objId = statistic.getObjId();
-                    RoomDto roomDto = new RoomDto();
-                    roomDto.setRoomId(objId);
-                    List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
-                    if (roomDtos != null && roomDtos.size() == 1) {
-                        String roomNum = roomDtos.get(0).getRoomNum();
-                        UnitDto unitDto = new UnitDto();
-                        unitDto.setUnitId(roomDtos.get(0).getUnitId());
-                        List<UnitDto> unitDtos = unitInnerServiceSMOImpl.queryUnits(unitDto);
-                        if (unitDtos != null && unitDtos.size() == 1) {
-                            String unitNum = unitDtos.get(0).getUnitNum();
-                            FloorDto floorDto = new FloorDto();
-                            floorDto.setFloorId(unitDtos.get(0).getFloorId());
-                            List<FloorDto> floorDtos = floorInnerServiceSMOImpl.queryFloors(floorDto);
-                            if(floorDtos != null && floorDtos.size() == 1){
-                                String floorNum = floorDtos.get(0).getFloorNum();
-                                statistic.setObjNameNum(floorNum + "-" + unitNum + "-" + roomNum);
-                            }
-                        }
-                    }
-                }
-            }*/
             reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
         } else {
+
             reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
             reportFeeMonthStatisticsPo.setReceivedAmount("0");
             reportFeeMonthStatisticsPo.setReceivableAmount("0");
@@ -578,9 +468,16 @@
             reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
             reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
             reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
-            reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
-            //澶勭悊姘寸數璐癸紝姘寸數璐规牴鎹紑濮嬫椂闂磋鍦ㄧ浉搴旀湀琛ュ厖鏁版嵁
-            dealMeteWater(reportFeeMonthStatisticsPo, tmpReportFeeDto);
+            //濡傛灉鏄� 姘磋垂 鐢佃垂 鐓ゆ皵璐�
+            if (!FeeConfigDto.FEE_TYPE_CD_METER.equals(tmpReportFeeDto.getFeeTypeCd())
+                    && !FeeConfigDto.FEE_TYPE_CD_WATER.equals(tmpReportFeeDto.getFeeTypeCd())
+                    && !FeeConfigDto.FEE_TYPE_CD_GAS.equals(tmpReportFeeDto.getFeeTypeCd())
+            ) {
+                reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
+            } else {
+                //澶勭悊姘寸數璐癸紝姘寸數璐规牴鎹紑濮嬫椂闂磋鍦ㄧ浉搴旀湀琛ュ厖鏁版嵁
+                dealMeteWater(reportFeeMonthStatisticsPo, tmpReportFeeDto);
+            }
         }
 
 
@@ -606,7 +503,7 @@
         if (!FeeConfigDto.FEE_TYPE_CD_METER.equals(tmpReportFeeDto.getFeeTypeCd())
                 && !FeeConfigDto.FEE_TYPE_CD_WATER.equals(tmpReportFeeDto.getFeeTypeCd())
                 && !FeeConfigDto.FEE_TYPE_CD_GAS.equals(tmpReportFeeDto.getFeeTypeCd())
-                ) {
+        ) {
             return;
         }
         //鏍规嵁璐圭敤寮�濮嬫椂闂� 璁$畻鏈堜唤
@@ -619,7 +516,7 @@
         reportFeeMonthStatisticsDto.setCommunityId(tmpReportFeeDto.getCommunityId());
         reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
         reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
-        //reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+        reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
         reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
         reportFeeMonthStatisticsDto.setFeeYear(curYear);
         reportFeeMonthStatisticsDto.setFeeMonth(curMonth);
@@ -718,6 +615,9 @@
         Date curDate = DateUtil.getFirstDate();//11鏈�1鏃�
         //璇存槑娌℃湁鍘嗗彶娆犺垂
         if (curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
+            return 0.0;
+        }
+        if(FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())){
             return 0.0;
         }
 
@@ -910,14 +810,18 @@
         if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
             return computeOnceFee(tmpReportFeeDto);
         }
-        OwnerCarDto ownerCarDto = new OwnerCarDto();
-        ownerCarDto.setCommunityId(tmpReportFeeDto.getCommunityId());
-        ownerCarDto.setCarId(tmpReportFeeDto.getCarId());
-        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
-        if (ownerCarDtos == null || ownerCarDtos.size() < 1) {
+//        OwnerCarDto ownerCarDto = new OwnerCarDto();
+//        ownerCarDto.setCommunityId(tmpReportFeeDto.getCommunityId());
+//        ownerCarDto.setCarId(tmpReportFeeDto.getCarId());
+//        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+//        if (ownerCarDtos == null || ownerCarDtos.size() < 1) {
+//            return 0.0;
+//        }
+        Date endTime = reportCarDto.getEndTime();
+
+        if(endTime == null){
             return 0.0;
         }
-        Date endTime = ownerCarDtos.get(0).getEndTime();
 
         Date maxEndDate = tmpReportFeeDto.getDeadlineTime();
         if (FeeDto.FEE_FLAG_CYCLE.equals(tmpReportFeeDto.getFeeFlag())) {

--
Gitblit v1.8.0