| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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.fee.FeeConfigDto; |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | import com.java110.dto.report.ReportCarDto; |
| | |
| | | import com.java110.report.dao.IReportFeeServiceDao; |
| | | import com.java110.utils.util.*; |
| | | import org.slf4j.Logger; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | private void feeDataFiltering(String communityId) { |
| | | Map reportFeeDto = new HashMap(); |
| | | reportFeeDto.put("communityId", communityId); |
| | | reportFeeMonthStatisticsServiceDaoImpl.deleteInvalidFee(reportFeeDto); |
| | | List<Map> feeDtos = reportFeeMonthStatisticsServiceDaoImpl.queryInvalidFeeMonthStatistics(reportFeeDto); |
| | | |
| | | List<String> feeIds = new ArrayList<>(); |
| | | for (Map feeDto : feeDtos) { |
| | | if (!feeDto.containsKey("feeId") || StringUtil.isNullOrNone(feeDto.get("feeId"))) { |
| | | continue; |
| | | } |
| | | |
| | | feeIds.add(feeDto.get("feeId").toString()); |
| | | |
| | | if (feeIds.size() >= 50) { |
| | | reportFeeDto.put("feeIds", feeIds); |
| | | reportFeeMonthStatisticsServiceDaoImpl.deleteInvalidFee(reportFeeDto); |
| | | feeIds = new ArrayList<>(); |
| | | } |
| | | } |
| | | reportFeeDto.put("feeIds", feeIds); |
| | | if (feeIds.size() > 0) { |
| | | reportFeeMonthStatisticsServiceDaoImpl.deleteInvalidFee(reportFeeDto); |
| | | } |
| | | } |
| | | |
| | | private void dealFinishFee(String communityId) { |
| | |
| | | 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() + ""); |
| | |
| | | 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() + ""); |
| | |
| | | reportFeeMonthStatisticsPo.setPreReceivedAmount(getReceivedAmount(tmpReportFeeDto, 3) + ""); |
| | | reportFeeMonthStatisticsPo.setUpdateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A)); |
| | | reportFeeMonthStatisticsServiceDaoImpl.saveReportFeeMonthStatisticsInfo(BeanConvertUtil.beanCovertMap(reportFeeMonthStatisticsPo)); |
| | | //处理水电费,水电费根据开始时间要在相应月补充数据 |
| | | dealMeteWater(reportFeeMonthStatisticsPo, tmpReportFeeDto); |
| | | } |
| | | |
| | | |
| | |
| | | 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)); |
| | | } |
| | | |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | | //这里需要判断 结束时间 是否 大于了当月最后一天,当月天数 * 每天金额 |
| | |
| | | } |
| | | Date endTime = ownerCarDtos.get(0).getEndTime(); |
| | | |
| | | Date maxEndDate = tmpReportFeeDto.getDeadlineTime(); |
| | | if (FeeDto.FEE_FLAG_CYCLE.equals(tmpReportFeeDto.getFeeFlag())) { |
| | | maxEndDate = tmpReportFeeDto.getConfigEndTime(); |
| | | } |
| | | |
| | | //1.0 费用到期时间和费用结束时间 都不在当月 |
| | | if (!belongCurMonth(tmpReportFeeDto.getEndTime()) |
| | | && !belongCurMonth(endTime) |
| | |
| | | if (!belongCurMonth(tmpReportFeeDto.getEndTime()) |
| | | && belongCurMonth(endTime)) { |
| | | //算天数 |
| | | double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), tmpReportFeeDto.getConfigEndTime()); |
| | | double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), maxEndDate); |
| | | BigDecimal curDegree = new BigDecimal(month); |
| | | return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | } |
| | |
| | | return computeOnceFee(tmpReportFeeDto); |
| | | } |
| | | |
| | | Date maxEndDate = tmpReportFeeDto.getDeadlineTime(); |
| | | if (FeeDto.FEE_FLAG_CYCLE.equals(tmpReportFeeDto.getFeeFlag())) { |
| | | maxEndDate = tmpReportFeeDto.getConfigEndTime(); |
| | | } |
| | | |
| | | //1.0 费用到期时间和费用结束时间 都不在当月 |
| | | if (!belongCurMonth(tmpReportFeeDto.getEndTime()) |
| | | && !belongCurMonth(tmpReportFeeDto.getConfigEndTime()) |
| | | && !belongCurMonth(maxEndDate) |
| | | && tmpReportFeeDto.getEndTime().getTime() < DateUtil.getFirstDate().getTime()) { |
| | | return feePrice; |
| | | } |
| | | |
| | | //2.0 费用到期时间 在当月,费用结束时间不在当月 |
| | | if (belongCurMonth(tmpReportFeeDto.getEndTime()) |
| | | && !belongCurMonth(tmpReportFeeDto.getConfigEndTime())) { |
| | | && !belongCurMonth(maxEndDate)) { |
| | | //算天数 |
| | | double month = computeFeeSMOImpl.dayCompare(tmpReportFeeDto.getEndTime(), DateUtil.getNextMonthFirstDate()); |
| | | BigDecimal curDegree = new BigDecimal(month); |
| | |
| | | } |
| | | //3.0 费用到期时间 不在当月,费用结束时间在当月 |
| | | if (!belongCurMonth(tmpReportFeeDto.getEndTime()) |
| | | && belongCurMonth(tmpReportFeeDto.getConfigEndTime())) { |
| | | && belongCurMonth(maxEndDate)) { |
| | | //算天数 |
| | | double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), tmpReportFeeDto.getConfigEndTime()); |
| | | double month = computeFeeSMOImpl.dayCompare(DateUtil.getFirstDate(), maxEndDate); |
| | | BigDecimal curDegree = new BigDecimal(month); |
| | | return curDegree.multiply(feePriceDec).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | } |