update:自启动定时任务增加参数主机管控
This commit is contained in:
@@ -11,6 +11,7 @@ import com.adc.da.slrs.tsTask.entity.TbTask;
|
|||||||
import com.adc.da.slrs.tsTask.service.ITbTaskService;
|
import com.adc.da.slrs.tsTask.service.ITbTaskService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
import org.springframework.scheduling.support.CronTrigger;
|
import org.springframework.scheduling.support.CronTrigger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -44,6 +45,10 @@ public class SchedulerConf {
|
|||||||
@Autowired
|
@Autowired
|
||||||
ITbTaskService iTbTaskService;
|
ITbTaskService iTbTaskService;
|
||||||
|
|
||||||
|
@Value("${isNotScheduled}")
|
||||||
|
private boolean isNotScheduled; //是否开启定时器
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化线程池任务调度
|
* 初始化线程池任务调度
|
||||||
*/
|
*/
|
||||||
@@ -112,10 +117,7 @@ public class SchedulerConf {
|
|||||||
* 根据ip开启定时任务
|
* 根据ip开启定时任务
|
||||||
*/
|
*/
|
||||||
public void startByIp() throws Exception {
|
public void startByIp() throws Exception {
|
||||||
// InetAddress addr = InetAddress.getLocalHost();
|
if(isNotScheduled){
|
||||||
// log.info("Local HostAddress: "+addr.getHostAddress());
|
|
||||||
// String hostname = addr.getHostName();
|
|
||||||
// log.info("Local host name: "+hostname);
|
|
||||||
List<String> addr = getIpAddress();
|
List<String> addr = getIpAddress();
|
||||||
//查询
|
//查询
|
||||||
List<TbTask> tbTaskList = tbTaskDao.selectList(null);
|
List<TbTask> tbTaskList = tbTaskDao.selectList(null);
|
||||||
@@ -135,6 +137,7 @@ public class SchedulerConf {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static List<String> getIpAddress() {
|
private static List<String> getIpAddress() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user