StartCommand.java
1.84 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
64
package com.bsth;
import com.bsth.data.msg_queue.SignalAndAttConsumeQueue;
import com.bsth.data.real_park.CarParkRealHandler;
import com.bsth.data.real_park.thread.RealParkDataPersistenceThread;
import com.bsth.data.signal.thread.SignalPstThread;
import com.bsth.security.SecurityMetadataSourceService;
import com.bsth.service.berth.impl.BerthServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* 随应用启动运行
* @author PanZhao
*
*/
@Component
public class StartCommand implements CommandLineRunner{
@Autowired
SecurityMetadataSourceService invocationSecurityMetadataSourceService;
@Autowired
SignalPstThread signalPstThread;
@Autowired
RealParkDataPersistenceThread realParkDataPersistenceThread;
@Autowired
CarParkRealHandler carParkRealHandler;
@Autowired
BerthServiceImpl.BerthCacheRefreshThread berthCacheRefreshThread;
@Override
public void run(String... arg0){
try {
//启动时加载所有资源
invocationSecurityMetadataSourceService.loadResourceDefine();
//signal、牌照识别、查询一体机数据消费队列
SignalAndAttConsumeQueue.start();
ScheduledExecutorService sexec = Application.mainServices;
//进出场数据入库线程
sexec.scheduleWithFixedDelay(signalPstThread, 30, 10, TimeUnit.SECONDS);
//泊位数据刷新
sexec.scheduleWithFixedDelay(berthCacheRefreshThread, 0, 60 * 15, TimeUnit.SECONDS);
//从数据库恢复场内实时停放数据
carParkRealHandler.recovery();
//实时场内停放数据入库
sexec.scheduleWithFixedDelay(realParkDataPersistenceThread, 40, 30, TimeUnit.SECONDS);
} catch (Exception e) {
e.printStackTrace();
}
}
}