# ScheduleEmployeePostProcessor.java

    package cloud.wconnect.workperformance.businesstask.schedule;

    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.workperformance.cons.BusinessEnum;
    import cloud.wconnect.workperformance.cons.EventSubjectEnum;
    import cloud.wconnect.workperformance.entity.schedule.ScheduleDepartmentEmployeeImportLog;
    import cloud.wconnect.workperformance.service.schedule.IScheduleDepartmentEmployeeImportLogService;
    import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Component;

    /**
     * Schedule Employee 报告缺失后续逻辑处理
     *
     * @author yyt
     * @date 2023/11/20
     */
    @Component
    public class ScheduleEmployeePostProcessor implements IReportMissedPostProcessor {

        @Autowired
        private IScheduleDepartmentEmployeeImportLogService scheduleDepartmentEmployeeImportLogService;

        /**
         * 校验是否支持
         *
         * @param reportMissedDTO 报告缺失后置处理程序 DTO
         * @return false： 不支持；true：支持
         * @author yyt
         * @date 2023/11/20
         */
        @Override
        public boolean supports(ReportMissedDTO reportMissedDTO) {
            return reportMissedDTO.getSubject().equals(EventSubjectEnum.ATTENDANCE_EMPLOYEE.getSubject())
                    && reportMissedDTO.getBusiness().equals(BusinessEnum.SCHEDULE_EMPLOYEE.getBusiness());
        }

        /**
         * 后置处理
         *
         * @param reportMissedDTO 报告缺失后置处理程序 DTO
         * @author yyt
         * @date 2023/11/20
         */
        @Override
        public void afterPostProcess(ReportMissedDTO reportMissedDTO) {
            PropertyDTO property = reportMissedDTO.getPropertyDTO();
            long theDate = DateTimeUtils.dateNowTimestamp(property.getTimezone());
            long count = scheduleDepartmentEmployeeImportLogService.count(new QueryWrapper<ScheduleDepartmentEmployeeImportLog>().lambda()
                    .eq(ScheduleDepartmentEmployeeImportLog::getPropertyId, property.getId())
                    .eq(ScheduleDepartmentEmployeeImportLog::getTheDate, theDate)
                    .eq(ScheduleDepartmentEmployeeImportLog::getImportResult, ReportImportResultCons.IMPORT_RESULT_MISSED)
                    .eq(ScheduleDepartmentEmployeeImportLog::getCreatedBy, BaseConstant.ZERO));
            if (count == BaseConstant.LONG_ZERO) {
                scheduleDepartmentEmployeeImportLogService.save(new ScheduleDepartmentEmployeeImportLog()
                        .setPropertyId(property.getId())
                        .setTheDate(theDate)
                        .setImportResult(ReportImportResultCons.IMPORT_RESULT_MISSED)
                        .setCreatedBy(0)
                        .setCreatedTime(DateTimeUtils.nowTimestamp())
                        .setResolvedBy(BaseConstant.ZERO)
                        .setResolvedTime(BaseConstant.LONG_ZERO));
            }
        }

    }