|
|
@ -7,19 +7,17 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
public class MyTimerTask {
|
|
|
|
public class ReportSchedule {
|
|
|
|
// private static final Logger logger = LoggerFactory.getLogger(MyTimerTask.class);
|
|
|
|
// private static final Logger logger = LoggerFactory.getLogger(ReportSchedule.class);
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
MqttServiceImpl mqttServiceimpl;
|
|
|
|
MqttServiceImpl mqttServiceimpl;
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(initialDelay = 1000, fixedRate = 1000 * 3600) //通过@Scheduled声明该方法是计划任务,使用fixedRate属性每隔固定时间执行
|
|
|
|
@Scheduled(initialDelay = 1000, fixedRate = 1000 * 3600) //通过@Scheduled声明该方法是计划任务,使用fixedRate属性每隔固定时间执行
|
|
|
|
public void init() {
|
|
|
|
public void reportRecord() {
|
|
|
|
log.info("运行定时任务:{}", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
log.info("运行定时任务");
|
|
|
|
mqttServiceimpl.reportRecord();
|
|
|
|
mqttServiceimpl.reportRecord();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|