# DbPmsMarketCodeStatisticsLast2DayPostProcessor.java

    package cloud.wconnect.workperformance.businesstask.database;

    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.redis.PropertyBusinessDateRedisService;
    import cloud.wconnect.workperformance.cons.BusinessEnum;
    import cloud.wconnect.workperformance.cons.EventSubjectEnum;
    import cloud.wconnect.workperformance.cons.database.DbPmsReportDataRangeEnum;
    import cloud.wconnect.workperformance.cons.database.DbPmsReportTypeEnum;
    import cloud.wconnect.workperformance.service.database.IDbReportImportLogService;
    import cloud.wconnect.workperformance.service.database.IDbReportService;
    import jakarta.annotation.Resource;
    import org.springframework.stereotype.Service;

    import java.util.List;

    /**
     * Service: market-code-statistics/service--2d 报告缺失后置处理类
     *
     * @author zc
     * @date 2025/12/12
     */
    @Service
    public class DbPmsMarketCodeStatisticsLast2DayPostProcessor implements IReportMissedPostProcessor {

        @Resource
        private IDbReportImportLogService importLogService;
        @Resource
        private IDbReportService reportService;
        @Resource
        private PropertyBusinessDateRedisService businessDateRedisService;

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

        /**
         * 后置处理
         *
         * @param reportMissedDTO 报告缺失后置处理程序 DTO
         * @author zc
         * @date 2025/12/12
         */
        @Override
        public void afterPostProcess(ReportMissedDTO reportMissedDTO) {
            PropertyDTO propertyDTO = reportMissedDTO.getPropertyDTO();
            long businessDate = businessDateRedisService.getEffectiveBusinessDateOrDefault(propertyDTO.getId(), propertyDTO.getTimezone());
            // 报告数据日期
            List<Long> dateRange = reportService.getDateRange(businessDate, DbPmsReportDataRangeEnum.MARKET_CODE_STATISTICS_LAST_2_DAY.getType());
            // 保存异常记录
            importLogService.save(propertyDTO, businessDate, dateRange, "", ReportImportResultCons.IMPORT_RESULT_MISSED,
                    DbPmsReportTypeEnum.MARKET_CODE_STATISTICS.getType(), 0);
        }

    }