修复切换后定时任务不执行的BUG

This commit is contained in:
mxd 2020-06-20 22:38:25 +08:00
parent 5c519efa53
commit 512a7e4cfa
2 changed files with 3 additions and 3 deletions

View File

@ -59,7 +59,7 @@ public interface SpiderFlowMapper extends BaseMapper<SpiderFlow>{
int resetNextExecuteTime(@Param("id") String id);
@Update("update sp_flow set next_execute_time = null")
int resetNextExecuteTime();
int resetNextExecuteTimeAll();
@Select("select id,name from sp_flow")
List<SpiderFlow> selectFlows();

View File

@ -54,7 +54,7 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
@PostConstruct
private void initJobs(){
//清空所有任务下次执行时间
sfMapper.resetNextExecuteTime();
sfMapper.resetNextExecuteTimeAll();
//获取启用corn的任务
List<SpiderFlow> spiderFlows = sfMapper.selectList(new QueryWrapper<SpiderFlow>().eq("enabled", "1"));
if(spiderFlows != null && !spiderFlows.isEmpty()){
@ -139,12 +139,12 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
public void start(String id){
spiderJobManager.remove(id);
sfMapper.resetSpiderStatus(id, "1");
SpiderFlow spiderFlow = getById(id);
Date nextExecuteTime = spiderJobManager.addJob(spiderFlow);
if (nextExecuteTime != null) {
spiderFlow.setNextExecuteTime(nextExecuteTime);
sfMapper.updateById(spiderFlow);
sfMapper.resetSpiderStatus(id, "1");
}
}