# ScheduleEmployeesTask.java

    package cloud.wconnect.workperformance.businesstask.schedule;

    import cloud.wconnect.commonlib.businesstask.CheckReportMissedService;
    import cloud.wconnect.commonlib.businesstask.rule.MissedRuleByThreshold;
    import cloud.wconnect.commonlib.pojo.dto.CheckReportMissedDTO;
    import cloud.wconnect.commonlib.pojo.dto.NotifyDTO;
    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.commonlib.service.PropertyInternalService;
    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.commonlib.util.InternationalizationUtils;
    import cloud.wconnect.workperformance.cons.BusinessEnum;
    import cloud.wconnect.workperformance.cons.EventSubjectEnum;
    import cloud.wconnect.workperformance.entity.schedule.ScheduleSchedulerJob;
    import com.google.common.collect.Lists;
    import lombok.extern.slf4j.Slf4j;
    import org.apache.commons.lang3.StringUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.scheduling.annotation.Async;
    import org.springframework.stereotype.Component;

    /**
     * Schedule Employees
     *
     * @author yyt
     * @date 2023/11/20
     */
    @Slf4j
    @Component
    public class ScheduleEmployeesTask {

        @Autowired
        private CheckReportMissedService checkReportMissedService;
        @Autowired
        private PackageNotifyDTOUtil packageNotifyDTOUtil;
        @Autowired
        private PropertyInternalService propertyInternalService;

        /**
         * 业务名称
         */
        private final static String BUSINESS = BusinessEnum.SCHEDULE_EMPLOYEE.getBusiness();

        /**
         * subject
         */
        private final static String SUBJECT = EventSubjectEnum.ATTENDANCE_EMPLOYEE.getSubject();

        /**
         * 检查是否存在报告数据缺失
         *
         * <p>
         * 报告下发时间：每天上午 6:25:00
         * 检查报告缺失：每天上午 6:55:00
         * 阈值：23 小时 59 分钟
         * </p>
         *
         * @param schedulerJob 定时任务
         * @author yyt
         * @date 2023/11/20
         */
        @Async
        public void reportMissingCheck(ScheduleSchedulerJob schedulerJob) {
            log.info("ScheduleEmployeesTask.reportMissingCheck start...");

            Integer propertyId = schedulerJob.getPropertyId();
            PropertyDTO property = propertyInternalService.getOne(propertyId);
            if (!property.getStatus()) {
                log.info("ScheduleEmployeesTask.reportMissCheck end... the property is closed, no processing required");
                return;
            }

            //报告缺失时间集合
            String timezone = property.getTimezone();
            String missDate = InternationalizationUtils.formatDateTime(DateTimeUtils.dateNowTimestamp(timezone),
                    property.getInternationalization().getDateTime().getLongDate(), StringUtils.EMPTY, timezone, property.getLanguage());
            NotifyDTO notifyDTO = packageNotifyDTOUtil.getNotifyDTO(property, missDate, "Attendance Employees", schedulerJob.getCategory());

            // 封装 CheckReportMissedDTO 对象
            CheckReportMissedDTO job = CheckReportMissedDTO.builder()
                    .business(BUSINESS)
                    .subject(SUBJECT)
                    .ruleClazzList(Lists.newArrayList(MissedRuleByThreshold.class))
                    .propertyDTO(property)
                    .notifyDTO(notifyDTO)
                    .thresholdDTO(packageNotifyDTOUtil.getThresholdDTO(schedulerJob))
                    .build();
            checkReportMissedService.doCheck(job);
            log.info("ScheduleEmployeesTask.reportMissingCheck end");
        }

    }