package com.ruoyi.chargingPile.util;
|
|
|
import com.ruoyi.chargingPile.service.TChargingPileService;
|
import org.springframework.boot.web.context.WebServerInitializedEvent;
|
import org.springframework.context.ApplicationListener;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
|
|
/**
|
* 定时任务工具类
|
*/
|
@Component
|
public class TaskUtil implements ApplicationListener<WebServerInitializedEvent> {
|
|
@Resource
|
private TChargingPileService chargingPileService;
|
|
private Integer port = null;
|
|
|
@Override
|
public void onApplicationEvent(WebServerInitializedEvent event) {
|
port = event.getWebServer().getPort();
|
System.out.println("端口号:" + port);
|
}
|
|
/**
|
* 每隔1分钟去处理的定时任务
|
*/
|
@Scheduled(fixedRate = 60000)
|
public void taskMinute(){
|
if(null != port && port == 5300){
|
chargingPileService.updateStatus();
|
}
|
}
|
|
|
}
|