| | |
| | | import com.dy.common.schedulerTask.SchedulerTaskSupport; |
| | | import com.dy.pipIrrGlobal.util.Org; |
| | | import com.dy.pipIrrGlobal.util.OrgListenerSupport; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/22 14:39 |
| | | * @Description |
| | | * 监听器,实现功能:在系统启动时初始化,向数据库中插入数据 |
| | | * 监听器,实现功能:启动日统计定时任务 |
| | | * 本监听器不能采用ServletContextListener方式,因为Servlet上下文Context创建后 |
| | | * Spring容器并没有创建完,而本类中用了Spring容器中的Bean,即*Dao 。 |
| | | * 所以采用了Spring事件监听器来实现 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class StatisticsListener extends OrgListenerSupport implements ApplicationListener<ApplicationReadyEvent> { |
| | | |
| | | private static Logger log = LogManager.getLogger(StatisticsListener.class.getName()) ; |
| | | |
| | | protected static final String orgKey = "tag" ; |
| | | private static final String JobName = "statisticsJob" ; |
| | |
| | | HashMap<String , Object> jobDataMap = new HashMap<String , Object>() ; |
| | | jobDataMap.put(orgKey, vo.tag) ; |
| | | SchedulerTaskSupport.addDailyJob(JobName + vo.tag, JobGroupName, StatisticsJob.class, jobDataMap, startHour, startMinute ) ; |
| | | //SchedulerTaskSupport.addSecondlyJob(JobName + vo.tag, JobGroupName, TestJob.class, jobDataMap, 10, 10000, 0 ) ; |
| | | } |
| | | } |
| | | } |