Former-commit-id: fdf2b911963f82e16406d782fc49cd1c672a76c3
master
wangbing 5 years ago
parent 35a070acdd
commit 2f70382e51

@ -519,6 +519,7 @@ public class SpringBootCallable implements Callable {
File excelconverter = Tool.createPath(excel.getAbsolutePath(), "converter");
File exception = Tool.createPath(excel.getAbsolutePath(), "exception");
File excelstyle = Tool.createPath(excel.getAbsolutePath(), "style");
File schedule = Tool.createPath(root.getAbsolutePath(), "schedule");
File utils = Tool.createPath(root.getAbsolutePath(), "utils");
File validation = Tool.createPath(root.getAbsolutePath(), "validation");
@ -549,6 +550,10 @@ public class SpringBootCallable implements Callable {
freeMarkerManager.outputTemp(Tool.createFile(excelstyle.getAbsolutePath(), name), option + "/java/frame/excel/style/" + name, ctx);
}
//schedule
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/schedule/")) {
freeMarkerManager.outputTemp(Tool.createFile(schedule.getAbsolutePath(), name), option + "/java/frame/schedule/" + name, ctx);
}
//utils
for (String name : ResourceUtil.getResourceFiles("/modules/SpringBoot/java/frame/utils/")) {
freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), name), option + "/java/frame/utils/" + name, ctx);

@ -0,0 +1,14 @@
package ${basePackage}.frame.schedule;
import org.springframework.scheduling.config.CronTask;
import org.springframework.scheduling.config.Task;
public abstract class RunCronTask extends RunTask {
abstract String cron();
@Override
public Task build() {
return new CronTask(this, cron());
}
}

@ -0,0 +1,28 @@
package ${basePackage}.frame.schedule;
import org.springframework.scheduling.config.FixedDelayTask;
import org.springframework.scheduling.config.FixedRateTask;
import org.springframework.scheduling.config.Task;
public abstract class RunRepeatTask extends RunTask {
public abstract void config(Config config);
public class Config {
int interval = 10 * 60 * 1000;
int initialDelay = 0;
boolean fix = false;
}
@Override
public Task build() {
Config config = new Config();
config(config);
if (config.fix) {
return new FixedRateTask(this, config.interval, config.initialDelay);
} else {
return new FixedDelayTask(this, config.interval, config.initialDelay);
}
}
}

@ -0,0 +1,16 @@
package ${basePackage}.frame.schedule;
public abstract class RunSqlTask extends RunRepeatTask {
public abstract String getSql();
@Override
public void config(Config config) {
}
@Override
public void run() {
//exec sql
}
}

@ -0,0 +1,22 @@
package ${basePackage}.frame.schedule;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.Task;
import java.util.Date;
import java.util.concurrent.ScheduledFuture;
public abstract class RunTask implements Runnable {
public abstract String taskId();
public abstract Task build();
public void configChange(ThreadPoolTaskScheduler scheduler) {
ScheduledFuture<?> schedule = scheduler.schedule(this, new Date());
if (!schedule.cancel(true)) {
}
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.