# OooRoomPostProcessor.java

    package cloud.wconnect.frontoffice.businesstask.oooroom;

    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.oooroom.OooImportLog;
    import cloud.wconnect.frontoffice.service.oooroom.IOooImportLogService;
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Component;

    import java.util.Objects;

    /**
     * out of order 报告缺失后续逻辑处理
     *
     * @author yyt
     * 2023/8/9
     */
    @Component
    public class OooRoomPostProcessor implements IReportMissedPostProcessor {

        @Autowired
        private IOooImportLogService oooImportLogService;

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

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

        @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();
            Integer propertyId = property.getId();
            long dateNowTimestamp = DateTimeUtils.dateNowTimestamp(property.getTimezone());
            // 当日没有 报告缺失异常时，插入异常
            OooImportLog exceptionImportLog = oooImportLogService.getOne(new QueryWrapper<OooImportLog>().lambda()
                    .eq(OooImportLog::getPropertyId, propertyId)
                    .eq(OooImportLog::getTheDate, dateNowTimestamp)
                    .eq(OooImportLog::getStatus, ReportImportResultCons.IMPORT_RESULT_MISSED)
                    .eq(OooImportLog::getCreatedBy, BaseConstant.ZERO)
                    .last("limit 1"));
            if (Objects.nonNull(exceptionImportLog)) {
                return;
            }
            oooImportLogService.save(new OooImportLog()
                    .setPropertyId(propertyId)
                    .setTheDate(dateNowTimestamp)
                    .setStatus(ReportImportResultCons.IMPORT_RESULT_MISSED)
                    .setCreatedBy(BaseConstant.ZERO)
                    .setCreatedTime(DateTimeUtils.nowTimestamp())
                    .setResolvedBy(BaseConstant.ZERO)
                    .setResolvedTime(BaseConstant.LONG_ZERO));
        }

    }