StartCommand.java
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.bsth;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.bsth.common.GetSchedulePlanThread;
import com.bsth.security.SecurityMetadataSourceService;
import com.bsth.util.DateUtils;
import com.bsth.vehicle.gpsdata.GpsRefreshThread;
/**
* 随应用启动运行
* @author PanZhao
*
*/
@Component
public class StartCommand implements CommandLineRunner{
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
SecurityMetadataSourceService invocationSecurityMetadataSourceService;
public static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2);
@Autowired
GpsRefreshThread gpsRefreshThread;
@Autowired
GetSchedulePlanThread getSchedulePlanThread;
@Override
public void run(String... arg0){
try {
//启动时加载所有资源
invocationSecurityMetadataSourceService.loadResourceDefine();
/**
* GPS实时数据更新线程,每次执行完成4秒后开始下一次
* 如果抛出异常,后续执行将被取消
*/
//scheduler.scheduleWithFixedDelay(gpsRefreshThread, 0, 4, TimeUnit.SECONDS);
/**
* 定时0点从计划排班表抓取当天实际排班
*/
//scheduler.scheduleAtFixedRate(getSchedulePlanThread
// , 0//DateUtils.getTimesnight() - System.currentTimeMillis() / 1000
// , 60 * 60 * 24, TimeUnit.SECONDS);
} catch (Exception e) {
e.printStackTrace();
}
}
}