# ArrivalPostProcessor.java

    package cloud.wconnect.frontoffice.businesstask.clc;

    import cloud.wconnect.commonlib.businesstask.postprocessor.IReportMissedPostProcessor;
    import cloud.wconnect.commonlib.cons.BaseConstant;
    import cloud.wconnect.commonlib.cons.ReportImportResultCons;
    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.commonlib.pojo.dto.ReportMissedDTO;
    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.frontoffice.cons.BusinessEnum;
    import cloud.wconnect.frontoffice.cons.EventSubjectEnum;
    import cloud.wconnect.frontoffice.entity.clc.ClcMissingReport;
    import cloud.wconnect.frontoffice.pojo.dto.clc.ClcSchedulerDTO;
    import cloud.wconnect.frontoffice.service.clc.IClcSchedulerService;
    import cloud.wconnect.frontoffice.service.clc.IClcMissingReportService;
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Component;

    import java.util.Objects;

    /**
     * arrival 报告缺失后续逻辑处理
     *
     * @author yyt
     * 2023/7/27
     */
    @Component
    public class ArrivalPostProcessor implements IReportMissedPostProcessor {

        @Autowired
        private IClcMissingReportService clcMissingReportService;
        @Autowired
        private IClcSchedulerService clcSchedulerService;

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

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

        @Override
        public boolean supports(ReportMissedDTO reportMissedDTO) {
            return reportMissedDTO.getBusiness().equals(BUSINESS) && reportMissedDTO.getSubject().equals(SUBJECT);
        }

        @Override
        public void afterPostProcess(ReportMissedDTO reportMissedDTO) {
            // 插入异常记录
            PropertyDTO property = reportMissedDTO.getPropertyDTO();
            // 没有报告缺失异常时，插入异常
            Long dateRange = clcSchedulerService.getDateRange(property, ClcSchedulerDTO.MISSING_ARRIVAL_REPORT);
            ClcMissingReport exceptionImportLog = clcMissingReportService.getOne(new QueryWrapper<ClcMissingReport>().lambda()
                    .eq(ClcMissingReport::getPropertyId, property.getId())
                    .eq(ClcMissingReport::getTheDate, dateRange)
                    .eq(ClcMissingReport::getReportType, ClcMissingReport.REPORT_TYPE_ARRIVALS)
                    .eq(ClcMissingReport::getStatus, ReportImportResultCons.IMPORT_RESULT_MISSED)
                    .eq(ClcMissingReport::getCreatedBy, BaseConstant.ZERO)
                    .last("limit 1"));
            if (Objects.nonNull(exceptionImportLog)) {
                return;
            }

            clcMissingReportService.saveOrUpdateRewrite(new ClcMissingReport()
                    .setPropertyId(property.getId())
                    .setTheDate(dateRange)
                    .setReportType(ClcMissingReport.REPORT_TYPE_ARRIVALS)
                    .setStatus(ReportImportResultCons.IMPORT_RESULT_MISSED)
                    .setCreatedBy(BaseConstant.ZERO)
                    .setCreatedTime(DateTimeUtils.nowTimestamp())
                    .setResolvedBy(BaseConstant.ZERO)
                    .setResolvedTime(BaseConstant.LONG_ZERO));
        }

    }