# JournalByCashierAndTransactionCodeServicePostProcessor.java

    package cloud.wconnect.frontoffice.businesstask.adjustment;

    import cloud.wconnect.commonlib.businesstask.postprocessor.IReportMissedPostProcessor;
    import cloud.wconnect.commonlib.cons.BaseConstant;
    import cloud.wconnect.commonlib.cons.ReportImportResultCons;
    import cloud.wconnect.commonlib.cons.SystemPlatformEnum;
    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.frontoffice.cons.BusinessEnum;
    import cloud.wconnect.frontoffice.cons.EventSubjectEnum;
    import cloud.wconnect.frontoffice.cons.adjustment.AdjNotifyConfigTypeEnum;
    import cloud.wconnect.frontoffice.entity.adjustment.AdJournalLog;
    import cloud.wconnect.frontoffice.service.adjustment.IAdJournalLogService;
    import cloud.wconnect.frontoffice.service.adjustment.ISchedulerService;
    import lombok.extern.slf4j.Slf4j;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Component;

    import java.util.Map;

    /**
     * @author lichen
     * @description Journal by Cashier and Transaction Code/service 报告缺失的后置处理
     * @date 2023/4/5 17:57
     */
    @Component
    @Slf4j
    public class JournalByCashierAndTransactionCodeServicePostProcessor implements IReportMissedPostProcessor {

        @Autowired
        private IAdJournalLogService adjournalLogService;
        @Autowired
        private ISchedulerService schedulerService;

        /**
         * 业务名称
         */
        private final static String BUSINESS = BusinessEnum.ADJUSTMENT_REQUESTS.getBusiness();
        /**
         * subject
         */
        private final static String SUBJECT = EventSubjectEnum.YESTERDAY_JOURNAL_BY_CASHIER_AND_TRANSACTION_CODE_SERVICE.getSubject();

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

        @Override
        public void afterPostProcess(ReportMissedDTO reportMissedDTO) {
            PropertyDTO propertyDTO = reportMissedDTO.getPropertyDTO();
            //报告数据日期
            Map<String, Long> dateRange = schedulerService.getDateRange(propertyDTO, AdjNotifyConfigTypeEnum.JOURNAL_REPORT_MISSED.getType());
            //新增adJouranlLog
            AdJournalLog adJournalLog = new AdJournalLog();
            adJournalLog.setPropertyId(propertyDTO.getId());
            adJournalLog.setStartDate(dateRange.get(JobParameterDTO.START_DATE));
            adJournalLog.setEndDate(dateRange.get(JobParameterDTO.END_DATE));
            adJournalLog.setCreatedBy(0);
            adJournalLog.setCreatedTime(DateTimeUtils.nowTimestamp());
            adJournalLog.setResolvedBy(BaseConstant.ZERO);
            adJournalLog.setResolvedTime(BaseConstant.LONG_ZERO);
            adJournalLog.setStatus(ReportImportResultCons.IMPORT_RESULT_MISSED);
            // 资产的PMS类型等于Shiji时，reportType字段才有值
            if (propertyDTO.getPmsType().equals(SystemPlatformEnum.SHI_JI.getDesc())) {
                adJournalLog.setReportType(AdjNotifyConfigTypeEnum.JOURNAL_REPORT_MISSED.getType());
            }
            adjournalLogService.save(adJournalLog);
        }
    }