# HotelKpiHistoryAndForecastPostProcessor.java

    package cloud.wconnect.workperformance.businesstask.hotelkpi;

    import cloud.wconnect.commonlib.businesstask.postprocessor.IReportMissedPostProcessor;
    import cloud.wconnect.commonlib.cons.ReportImportResultCons;
    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.commonlib.pojo.dto.ReportMissedDTO;
    import cloud.wconnect.workperformance.cons.BusinessEnum;
    import cloud.wconnect.workperformance.cons.EventSubjectEnum;
    import cloud.wconnect.workperformance.cons.hotelkpi.HotelKpiReportCategoryEnum;
    import cloud.wconnect.workperformance.service.hotelkpi.IHotelKpiImportLogService;
    import cloud.wconnect.workperformance.service.hotelkpi.IHotelKpiReportService;
    import jakarta.annotation.Resource;
    import org.springframework.stereotype.Service;

    import java.util.List;

    /**
     * Service: history-and-forecast/service--30d--1d 报告缺失后置处理类
     *
     * @author zc
     * @date 2024/7/11
     */
    @Service
    public class HotelKpiHistoryAndForecastPostProcessor implements IReportMissedPostProcessor {

        @Resource
        private IHotelKpiImportLogService importLogService;
        @Resource
        private IHotelKpiReportService reportService;

        /**
         * 是否支持
         *
         * @param reportMissedDTO 报告缺失后置处理程序 DTO
         * @return boolean
         * @author zc
         * @date 2024/7/11
         */
        @Override
        public boolean supports(ReportMissedDTO reportMissedDTO) {
            return reportMissedDTO.getBusiness().equals(BusinessEnum.HOTEL_KPI.getBusiness())
                    && reportMissedDTO.getSubject().equals(EventSubjectEnum.HISTORY_AND_FORECAST_SERVICE_HISTORY_THIRTY_DAY_HUNDRED_DAY.getSubject());
        }

        /**
         * 后置处理
         *
         * @param reportMissedDTO 报告缺失后置处理程序 DTO
         * @author zc
         * @date 2024/7/11
         */
        @Override
        public void afterPostProcess(ReportMissedDTO reportMissedDTO) {
            PropertyDTO propertyDTO = reportMissedDTO.getPropertyDTO();
            // 报告数据日期
            List<Long> dateRange = reportService.getDateRange(propertyDTO.getTimezone(),
                    HotelKpiReportCategoryEnum.HISTORY_AND_FORECAST.getCategory());
            // 保存异常记录
            importLogService.save(propertyDTO, dateRange, "", ReportImportResultCons.IMPORT_RESULT_MISSED,
                    HotelKpiReportCategoryEnum.HISTORY_AND_FORECAST.getCategory(), 0);
        }

    }