wuxw
2022-07-19 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54
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号小于 计费起始时间 那么 将curDate 改为 当前时间
        if (curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
            curDate = tmpReportFeeDto.getEndTime();
        }
        //这里需要判断 结束时间 是否 大于了当月最后一天,当月天数 * 每天金额
        Calendar nextDateC = Calendar.getInstance();
        nextDateC.setTime(curDate);