LightPoollingAuctionSchedule.java
1.3 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
package com.glsx.usedcar.task;
import com.glsx.usedcar.module.auction.service.AuctionService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
*
*/
@Slf4j
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LightPoollingAuctionSchedule {
private final AuctionService auctionService;
/**
* 自动竞价定时任务
* 500毫秒更新一次
*/
@Scheduled(fixedDelay = 1000, initialDelay = 1000 * 5)
public void autoBidding() {
long start = System.currentTimeMillis();
try {
auctionService.autoBidding();
} catch (Exception e) {
log.error("自动竞价定时任务异常", e);
}
}
/**
* 明拍竞价中模式为轮询出价的车辆更新为拍卖中
*/
@Scheduled(fixedDelay = 1000, initialDelay = 1000 * 5)
public void switchNextAuctionVehicle() {
try {
auctionService.switchNextAuctionVehicle();
} catch (Exception e) {
log.error("自动更新明拍竞价中模式为轮询出价的车辆更新为拍卖中出现异常", e);
}
}
}