parent
777b028df9
commit
42e24a3c01
@ -0,0 +1,49 @@
|
||||
package com.dsic.gj_erp.controller;
|
||||
|
||||
import cn.hutool.cron.CronUtil;
|
||||
import cn.hutool.cron.task.Task;
|
||||
import com.dsic.gj_erp.service.钢材到货情况统计Service;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ScheduledService {
|
||||
|
||||
private final 钢材到货情况统计Service 钢材到货情况统计Service;
|
||||
|
||||
private boolean scheduleStartFlag=false;
|
||||
|
||||
@PostConstruct
|
||||
public void execute(){
|
||||
synchronized (this){
|
||||
if (this.scheduleStartFlag){
|
||||
return;
|
||||
}
|
||||
this.scheduleStartFlag=true;
|
||||
}
|
||||
钢材到货情况统计Service.init();
|
||||
this.start();
|
||||
System.out.println("定时任务启动成功");
|
||||
}
|
||||
|
||||
private void start(){
|
||||
// 支持秒级别定时任务
|
||||
CronUtil.setMatchSecond(true);
|
||||
|
||||
if (CronUtil.getScheduler().isStarted()){
|
||||
CronUtil.stop();
|
||||
CronUtil.start();
|
||||
}
|
||||
|
||||
if (!CronUtil.getScheduler().isStarted()){
|
||||
CronUtil.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue