CarInfoJob.java
1.7 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
package com.bs.cardata.job;
import com.bs.cardata.utils.DataUtils;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.bs.cardata.service.CarDataService;
import java.util.List;
/**
* @author
* @Description
* @create 2022/12/09 9:11
*/
@Slf4j
@Component
public class CarInfoJob {
@Autowired
private CarDataService carDataService;
@XxlJob("carDataSyncJob")
public void execute() {
try {
log.info("job:车辆信息同步开始");
/*List<String> baseUrlList = DataUtils.getBaseUrlList();
for (String baseurl : baseUrlList) {
try {
log.info("车辆信息同步:" + baseurl + " 启动。");
carDataService.syncCarInfo(baseurl);
} catch (Exception e) {
log.info("需要计算的行程数据获取异常:" + baseurl + e.getMessage());
}
}*/
// 2026-01-27: 切换到新接口,一次性获取所有数据
String newApiUrl = "https://www.autohome.com.cn/web-main/car/web/price/treeMenu?extendseries=1";
try {
log.info("车辆信息同步:" + newApiUrl + " 启动。");
carDataService.syncCarInfo(newApiUrl);
} catch (Exception e) {
log.info("车辆信息同步异常:" + newApiUrl + e.getMessage());
}
log.info("job:车辆信息同步结束");
} catch (Exception e) {
log.info("job:车辆信息同步,exception msg:" + e.getMessage());
}
}
}