From 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 19 七月 2022 21:49:55 +0800
Subject: [PATCH] 优化添加设备 功能

---
 service-report/src/main/java/com/java110/report/smo/impl/GeneratorFeeMonthStatisticsInnerServiceSMOImpl.java |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 51 insertions(+), 3 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 de69a24..ab4860d 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
@@ -5,6 +5,7 @@
 import com.java110.core.log.LoggerFactory;
 import com.java110.core.smo.IComputeFeeSMO;
 import com.java110.dto.RoomDto;
+import com.java110.dto.fee.FeeConfigDto;
 import com.java110.dto.fee.FeeDto;
 import com.java110.dto.owner.OwnerCarDto;
 import com.java110.dto.report.ReportCarDto;
@@ -243,7 +244,7 @@
         reportFeeMonthStatisticsDto.setCommunityId(tmpReportCarDto.getCommunityId());
         reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
         reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
-        //reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+        reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());//杩欓噷涓嶈兘娉ㄩ噴 濡傛灉涓�涓垂鐢ㄥ垱寤哄鏉℃椂浼氭湁bug
         reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
         reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
         reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
@@ -441,7 +442,7 @@
         reportFeeMonthStatisticsDto.setCommunityId(reportRoomDto.getCommunityId());
         reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
         reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
-        //reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+        reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId()); //杩欓噷涓嶈兘娉ㄩ噴锛屽洜涓轰竴涓垂鐢ㄥ娆″垱寤烘椂浼氬瓨鍦ㄨ鐩� 瀛樺湪bug闂
         reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
         reportFeeMonthStatisticsDto.setFeeYear(DateUtil.getYear() + "");
         reportFeeMonthStatisticsDto.setFeeMonth(DateUtil.getMonth() + "");
@@ -513,6 +514,8 @@
             reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
             reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
             reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
+            //澶勭悊姘寸數璐癸紝姘寸數璐规牴鎹紑濮嬫椂闂磋鍦ㄧ浉搴旀湀琛ュ厖鏁版嵁
+            dealMeteWater(reportFeeMonthStatisticsPo, tmpReportFeeDto);
         }
 
 
@@ -524,6 +527,45 @@
         tmpReportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getFormatTimeString(endTime, DateUtil.DATE_FORMATE_STRING_A));
         tmpReportFeeMonthStatisticsPo.setOweAmount("0");
         reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsOwe(BeanConvertUtil.beanCovertMap(tmpReportFeeMonthStatisticsPo));
+    }
+
+    /**
+     * 澶勭悊姘寸數璐�
+     *
+     * @param reportFeeMonthStatisticsPo
+     * @param tmpReportFeeDto
+     */
+    private void dealMeteWater(ReportFeeMonthStatisticsPo reportFeeMonthStatisticsPo, ReportFeeDto 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())
+        ) {
+            return;
+        }
+        //鏍规嵁璐圭敤寮�濮嬫椂闂� 璁$畻鏈堜唤
+        Date endTime = tmpReportFeeDto.getEndTime();
+        //鍘婚櫎 0 鍥犱负琛ㄩ噷鐨勬湀浠芥槸娌℃湁闆�
+        String curMonth = Integer.parseInt(DateUtil.getFormatTimeString(endTime, "MM"))+"";
+        String curYear = DateUtil.getFormatTimeString(endTime, "YYYY");
+        //鏌ヨ鏄惁瀛樺湪 鏁版嵁
+        ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = new ReportFeeMonthStatisticsDto();
+        reportFeeMonthStatisticsDto.setCommunityId(tmpReportFeeDto.getCommunityId());
+        reportFeeMonthStatisticsDto.setConfigId(tmpReportFeeDto.getConfigId());
+        reportFeeMonthStatisticsDto.setObjId(tmpReportFeeDto.getPayerObjId());
+        //reportFeeMonthStatisticsDto.setFeeId(tmpReportFeeDto.getFeeId());
+        reportFeeMonthStatisticsDto.setObjType(tmpReportFeeDto.getPayerObjType());
+        reportFeeMonthStatisticsDto.setFeeYear(curYear);
+        reportFeeMonthStatisticsDto.setFeeMonth(curMonth);
+        List<ReportFeeMonthStatisticsDto> statistics = BeanConvertUtil.covertBeanList(
+                reportFeeMonthStatisticsServiceDaoImpl.getReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsDto)),
+                ReportFeeMonthStatisticsDto.class);
+        if (!ListUtil.isNull(statistics)) {
+            return;
+        }
+        reportFeeMonthStatisticsPo.setStatisticsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_statisticsId));
+        reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
     }
 
 
@@ -551,13 +593,19 @@
         BigDecimal feePriceDec = new BigDecimal(tmpReportFeeDto.getFeePrice());
 
         Date curDate = DateUtil.getFirstDate();
+        Date nowDate = DateUtil.getCurrentDate();
         double month = 0.0;
         //宸茬粡瓒呰繃鎴鏃堕棿 鍜� 杩樻病鏈夊埌寮�濮嬫椂闂�
         if (curDate.getTime() > tmpReportFeeDto.getDeadlineTime().getTime()
-                || curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
+                || nowDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
             return 0.0;
         }
 
+        //濡傛灉 1鍙峰皬浜� 璁¤垂璧峰鏃堕棿 閭d箞 灏哻urDate 鏀逛负 褰撳墠鏃堕棿
+        if (curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
+            curDate = tmpReportFeeDto.getEndTime();
+        }
+
         //杩欓噷闇�瑕佸垽鏂� 缁撴潫鏃堕棿 鏄惁 澶т簬浜嗗綋鏈堟渶鍚庝竴澶╋紝褰撴湀澶╂暟 * 姣忓ぉ閲戦
         Calendar nextDateC = Calendar.getInstance();
         nextDateC.setTime(curDate);

--
Gitblit v1.8.0