2022-07-06 18:32:05 +08:00
|
|
|
package org.nl.start;
|
|
|
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.nl.modules.quartz.domain.QuartzJob;
|
|
|
|
|
import org.nl.modules.quartz.repository.QuartzJobRepository;
|
|
|
|
|
import org.nl.modules.quartz.utils.QuartzManage;
|
|
|
|
|
import org.nl.wql.WQLCore;
|
|
|
|
|
import org.springframework.boot.ApplicationArguments;
|
|
|
|
|
import org.springframework.boot.ApplicationRunner;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 随项目启动模块
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Component
|
|
|
|
|
@RequiredArgsConstructor
|
2022-09-24 09:42:05 +08:00
|
|
|
public class Init implements ApplicationRunner {
|
2022-07-06 18:32:05 +08:00
|
|
|
private final QuartzJobRepository quartzJobRepository;
|
|
|
|
|
private final QuartzManage quartzManage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void init() throws Exception {
|
|
|
|
|
//初始化WQL
|
|
|
|
|
initWql();
|
|
|
|
|
//初始化任务调度
|
|
|
|
|
initQuartz();
|
|
|
|
|
System.out.println("项目启动成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initQuartz() {
|
|
|
|
|
log.info("--------------------注入定时任务---------------------");
|
|
|
|
|
List<QuartzJob> quartzJobs = quartzJobRepository.findByIsPauseIsFalse();
|
|
|
|
|
quartzJobs.forEach(quartzManage::addJob);
|
|
|
|
|
log.info("--------------------定时任务注入完成---------------------");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initWql() throws Exception {
|
|
|
|
|
WQLCore.ROOT = "org.nl";
|
|
|
|
|
WQLCore.init();
|
|
|
|
|
log.info("WQL初始化成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run(ApplicationArguments args) throws Exception {
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
|
|
|
|
}
|