chengf
2025-08-05 c4a333b83ba54bcadf2a6a2b34fe66ab88a6ba9d
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,10 @@
        ReportCarDto reportCarDto = new ReportCarDto();
        reportCarDto.setCommunityId(reportFeeMonthStatisticsPo.getCommunityId());
        reportCarDto.setLeaseTypes(new String[]{OwnerCarDto.LEASE_TYPE_INNER,
                OwnerCarDto.LEASE_TYPE_STORE,
                OwnerCarDto.LEASE_TYPE_NO_MONEY,
                OwnerCarDto.LEASE_TYPE_RESERVE});
        int count = reportCommunityServiceDaoImpl.getCarCount(reportCarDto);
@@ -438,39 +442,40 @@
                    Integer.parseInt(tmpReportFeeDto.getDecimalPlace())) + "");
            reportFeeMonthStatisticsServiceDaoImpl.updateReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
        } else {
            reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
            reportFeeMonthStatisticsPo.setReceivedAmount("0");
            reportFeeMonthStatisticsPo.setReceivableAmount("0");
            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(DateUtil.getMonth() + "");
            reportFeeMonthStatisticsPo.setFeeYear(DateUtil.getYear() + "");
            reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getNextMonthFirstDay(DateUtil.DATE_FORMATE_STRING_A));
            reportFeeMonthStatisticsPo.setObjId(reportRoomDto.getRoomId());
            reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
            reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
            if (RoomDto.ROOM_TYPE_ROOM.equals(reportRoomDto.getRoomType())) {
                reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "栋" + reportRoomDto.getUnitNum() + "单元" + reportRoomDto.getRoomNum() + "室");
                reportFeeMonthStatisticsPo.setObjNameNum(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getUnitNum() + "-" + reportRoomDto.getRoomNum());
            } else {
                reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "栋" + reportRoomDto.getRoomNum() + "室");
                reportFeeMonthStatisticsPo.setObjNameNum(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getRoomNum());
            }
            //计算历史欠费
            reportFeeMonthStatisticsPo.setHisOweAmount(getHisOweAmount(tmpReportFeeDto) + "");
            reportFeeMonthStatisticsPo.setCurReceivableAmount(getCurFeeReceivableAmount(tmpReportFeeDto) + "");
            reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
            reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
            reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
            reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
            //如果是 水费 电费 煤气费
            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())
            ) {
                reportFeeMonthStatisticsPo.setOweAmount(oweAmount + "");
                reportFeeMonthStatisticsPo.setReceivedAmount("0");
                reportFeeMonthStatisticsPo.setReceivableAmount("0");
                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(DateUtil.getMonth() + "");
                reportFeeMonthStatisticsPo.setFeeYear(DateUtil.getYear() + "");
                reportFeeMonthStatisticsPo.setCurMaxTime(DateUtil.getNextMonthFirstDay(DateUtil.DATE_FORMATE_STRING_A));
                reportFeeMonthStatisticsPo.setObjId(reportRoomDto.getRoomId());
                reportFeeMonthStatisticsPo.setObjType(FeeDto.PAYER_OBJ_TYPE_ROOM);
                reportFeeMonthStatisticsPo.setFeeName(StringUtil.isEmpty(tmpReportFeeDto.getImportFeeName()) ? tmpReportFeeDto.getFeeName() : tmpReportFeeDto.getImportFeeName());
                if (RoomDto.ROOM_TYPE_ROOM.equals(reportRoomDto.getRoomType())) {
                    reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "栋" + reportRoomDto.getUnitNum() + "单元" + reportRoomDto.getRoomNum() + "室");
                    reportFeeMonthStatisticsPo.setObjNameNum(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getUnitNum() + "-" + reportRoomDto.getRoomNum());
                } else {
                    reportFeeMonthStatisticsPo.setObjName(reportRoomDto.getFloorNum() + "栋" + reportRoomDto.getRoomNum() + "室");
                    reportFeeMonthStatisticsPo.setObjNameNum(reportRoomDto.getFloorNum() + "-" + reportRoomDto.getRoomNum());
                }
                //计算历史欠费
                reportFeeMonthStatisticsPo.setHisOweAmount(getHisOweAmount(tmpReportFeeDto) + "");
                reportFeeMonthStatisticsPo.setCurReceivableAmount(getCurFeeReceivableAmount(tmpReportFeeDto) + "");
                reportFeeMonthStatisticsPo.setCurReceivedAmount(getReceivedAmount(tmpReportFeeDto, 1) + "");
                reportFeeMonthStatisticsPo.setHisOweReceivedAmount(getReceivedAmount(tmpReportFeeDto, 2) + "");
                reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + "");
                reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
                reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo));
            } else {
                //处理水电费,水电费根据开始时间要在相应月补充数据
@@ -514,7 +519,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);
@@ -589,7 +594,7 @@
            return feePriceDec.subtract(hisDayDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_UP).doubleValue();
        }
        month = computeFeeSMOImpl.dayCompare(curDate, tmpReportFeeDto.getDeadlineTime());
        month = DateUtil.dayCompare(curDate, tmpReportFeeDto.getDeadlineTime());
        if (month < 0) {
            return 0;
        }
@@ -615,6 +620,9 @@
        if (curDate.getTime() < tmpReportFeeDto.getEndTime().getTime()) {
            return 0.0;
        }
        if(FeeDto.STATE_FINISH.equals(tmpReportFeeDto.getState())){
            return 0.0;
        }
        if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
            //说明一次性费用都欠了
@@ -636,9 +644,9 @@
        double month = 0.0;
        if (tmpReportFeeDto.getDeadlineTime().getTime() < curDate.getTime()) {
            month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
            month = DateUtil.dayCompare(tmpReportFeeDto.getEndTime(), tmpReportFeeDto.getDeadlineTime());
        } else {
            month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curDate);
            month = DateUtil.dayCompare(tmpReportFeeDto.getEndTime(), curDate);
        }
        BigDecimal curDegree = new BigDecimal(month);
        return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
@@ -692,7 +700,7 @@
        if (FeeDto.FEE_FLAG_ONCE.equals(tmpReportFeeDto.getFeeFlag())) {
            receivableAmount = tmpReportFeeDto.getFeePrice();
        } else {
            double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), curMonthDate.getTime());
            double month = DateUtil.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();
        }
@@ -805,14 +813,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())) {
@@ -830,7 +842,7 @@
        if (belongCurMonth(tmpReportFeeDto.getEndTime())
                && !belongCurMonth(endTime)) {
            //算天数
            double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
            double month = DateUtil.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
            BigDecimal curDegree = new BigDecimal(month);
            return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
        }
@@ -838,7 +850,7 @@
        if (!belongCurMonth(tmpReportFeeDto.getEndTime())
                && belongCurMonth(endTime)) {
            //算天数
            double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), maxEndDate);
            double month = DateUtil.dayCompare(DateUtil.getFirstDate(), maxEndDate);
            BigDecimal curDegree = new BigDecimal(month);
            return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
        }
@@ -851,7 +863,7 @@
                || tmpReportFeeDto.getDeadlineTime().getTime() < nowTime.getTime()) {
            return 0.0;
        }
        double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getDeadlineTime(), tmpReportFeeDto.getEndTime());
        double month = DateUtil.dayCompare(tmpReportFeeDto.getDeadlineTime(), tmpReportFeeDto.getEndTime());
        month = Math.ceil(month);
        if (month == 0) {
@@ -900,7 +912,7 @@
        if (belongCurMonth(tmpReportFeeDto.getEndTime())
                && !belongCurMonth(maxEndDate)) {
            //算天数
            double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
            double month = DateUtil.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate());
            BigDecimal curDegree = new BigDecimal(month);
            return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
        }
@@ -908,7 +920,7 @@
        if (!belongCurMonth(tmpReportFeeDto.getEndTime())
                && belongCurMonth(maxEndDate)) {
            //算天数
            double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), maxEndDate);
            double month = DateUtil.dayCompare(DateUtil.getFirstDate(), maxEndDate);
            BigDecimal curDegree = new BigDecimal(month);
            return curDegree.multiply(feePriceDec).setScale(FeeConfigConstant.FEE_SCALE, BigDecimal.ROUND_HALF_EVEN).doubleValue();
        }