LaneSyncScheduled.java
1.88 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
package com.viontech.scheduled;
import com.viontech.constant.Gb1400Constants;
import com.viontech.constant.RedisConstants;
import com.viontech.handler.TrafficDataConvertHandler;
import com.viontech.service.Gb1400Service;
import com.viontech.service.TrafficEventService;
import com.viontech.utils.DateUtil;
import com.viontech.vo.traffic.LaneModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* @author msl
* @date 2022/5/7
*/
@Slf4j
@Component
public class LaneSyncScheduled {
@Resource
private TrafficEventService trafficEventService;
@Resource
private Gb1400Service gb1400Service;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private TrafficDataConvertHandler trafficDataConvertHandler;
@Scheduled(cron = "0 */2 * * * ?")
public void handleIllegal() {
log.info("开始处理车道数据");
if (!Gb1400Constants.LinkStatus) {
return;
}
Object o = redisTemplate.opsForValue().get(RedisConstants.FANXING_TO_GB1400_LANE_LASTTIME);
//上次对接到的车道记录时间
String lastTimeUtc = "";
if (o == null) {
//初次查询12小时前的数据
lastTimeUtc = DateUtil.formatDate(DateUtil.addHours(new Date(), -12), DateUtil.TIMESTAMP_FORMAT);
} else {
lastTimeUtc = (String) o;
}
//查询
LaneModel laneQry = new LaneModel();
laneQry.setOffset(0);
laneQry.setLimit(10);
List<LaneModel> laneModels = trafficEventService.selectLaneDatas(laneQry);
log.info("结束处理车道数据");
}
}