# RevenueMarketSegmentSummaryYesterdayPostProcessor.java

    package cloud.wconnect.rateshop.businesstask.revenue;

    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.commonlib.pojo.dto.scheduler.JobParameterDTO;
    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.rateshop.cons.BusinessEnum;
    import cloud.wconnect.rateshop.cons.EventSubjectEnum;
    import cloud.wconnect.rateshop.cons.revenue.RevenueImportCons;
    import cloud.wconnect.rateshop.service.revenue.IRevenueImportLogService;
    import cloud.wconnect.rateshop.service.revenue.IRevenueSchedulerJobService;
    import org.apache.commons.collections.MapUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;

    import java.util.Map;

    /**
     * Service: Market Segment Summary Yesterday 报告缺失后续逻辑处理
     *
     * @author yyt
     * 2026/3/4
     */
    @Service
    public class RevenueMarketSegmentSummaryYesterdayPostProcessor implements IReportMissedPostProcessor {

        @Autowired
        private IRevenueImportLogService revenueImportLogService;
        @Autowired
        private IRevenueSchedulerJobService schedulerJobService;

        private static final String SUBJECT = EventSubjectEnum.MARKET_SEGMENT_SUMMARY_YESTERDAY.getSubject();

        private static final String BUSINESS = BusinessEnum.REVENUE.getBusiness();

        /**
         * 判断支持类型
         *
         * @param reportMissedDTO reportMissedDTO
         * @return true:支持，false：不支持
         * @author yyt
         * @date 2026/3/4
         **/
        @Override
        public boolean supports(ReportMissedDTO reportMissedDTO) {
            return reportMissedDTO.getBusiness().equals(BUSINESS) && reportMissedDTO.getSubject().equals(SUBJECT);
        }

        /**
         * 处理报告缺失后续逻辑
         *
         * @param reportMissedDTO reportMissedDTO
         * @author yyt
         * @date 2026/3/4
         **/
        @Override
        public void afterPostProcess(ReportMissedDTO reportMissedDTO) {
            PropertyDTO property = reportMissedDTO.getPropertyDTO();
            String timezone = property.getTimezone();
            Map<String, Long> dateRange = schedulerJobService.getDateRange(property, RevenueImportCons.MARKET_SEGMENT_SUMMARY_YESTERDAY);
            if (MapUtils.isEmpty(dateRange)) {
                return;
            }

            revenueImportLogService.handleSaveSystemImportRecord(property, RevenueImportCons.MARKET_SEGMENT_SUMMARY_YESTERDAY,
                    DateTimeUtils.dateNow(timezone).toEpochSecond(), dateRange.get(JobParameterDTO.START_DATE), dateRange.get(JobParameterDTO.END_DATE),
                    ReportImportResultCons.IMPORT_RESULT_MISSED, null);
        }

    }