@@ -1,5 +1,6 @@ | |||||
smtweb: | smtweb: | ||||
machine-id: 1 | machine-id: 1 | ||||
enable-job: true | |||||
file: | file: | ||||
local-path: /data/sw/files/ | local-path: /data/sw/files/ | ||||
url: http://127.0.0.1:8888/sw/files/ | url: http://127.0.0.1:8888/sw/files/ | ||||
@@ -23,10 +23,13 @@ public class CoreAutoConfiguration implements WebMvcConfigurer { | |||||
*/ | */ | ||||
@Value("${smtweb.machine-id}") | @Value("${smtweb.machine-id}") | ||||
private int machineId; | private int machineId; | ||||
@Value("${smtweb.enable-job}") | |||||
private boolean enableJob; | |||||
@Bean | @Bean | ||||
public IdGenerator idGenerator() { | public IdGenerator idGenerator() { | ||||
SwConsts.SysParam.machineId = machineId; | SwConsts.SysParam.machineId = machineId; | ||||
SwConsts.SysParam.enableJob = enableJob; | |||||
return new IdGenerator(machineId); | return new IdGenerator(machineId); | ||||
} | } | ||||
@@ -13,6 +13,8 @@ public interface SwConsts { | |||||
public static String RUN_PROJECTS = ""; | public static String RUN_PROJECTS = ""; | ||||
//启动时赋值:服务器编号 | //启动时赋值:服务器编号 | ||||
public static int machineId; | public static int machineId; | ||||
//是否执行定时任务 | |||||
public static boolean enableJob = false; | |||||
} | } | ||||
//错误码 | //错误码 | ||||
@@ -21,12 +21,6 @@ public abstract class BaseSysService implements Runnable { | |||||
@Override | @Override | ||||
public void run() { | public void run() { | ||||
boolean isNeedJob = true; | |||||
if (!isNeedJob) { | |||||
log.debug(getTitle() + ":::未开启需要执行任务,忽略执行........."); | |||||
return; | |||||
} | |||||
try { | try { | ||||
final String id = this.getClass().getName(); | final String id = this.getClass().getName(); | ||||
SingleRequestHelper.singleRequest(SwConsts.REDIS_KEY_BASE_JOB, id, "任务执行中,本次忽略.........", new SingleRequestHelper.ISingleWork() { | SingleRequestHelper.singleRequest(SwConsts.REDIS_KEY_BASE_JOB, id, "任务执行中,本次忽略.........", new SingleRequestHelper.ISingleWork() { | ||||