master
chents 3 years ago
parent 326751c1dd
commit cb333d0a0c
  1. 1
      src/main/java/org/springblade/modules/business/controller/CommonApiController.java
  2. 7
      src/main/java/org/springblade/modules/job/CarInfoTask.java

@ -140,7 +140,6 @@ public class CommonApiController extends BladeController {
@GetMapping("get-car-speed") @GetMapping("get-car-speed")
public R getCarSpeed(@RequestParam String carNo) { public R getCarSpeed(@RequestParam String carNo) {
CarInfoVO info = carInfoService.getCarInfo(carNo); CarInfoVO info = carInfoService.getCarInfo(carNo);
carInfoTask.getCarSpeed(carNo);
if (Func.isEmpty(info)) { if (Func.isEmpty(info)) {
return R.fail("未获取到车辆信息, 请检查车是否已掉线"); return R.fail("未获取到车辆信息, 请检查车是否已掉线");
} }

@ -48,10 +48,6 @@ public class CarInfoTask {
System.out.println("======存入实时车辆信息到redis成功========="); System.out.println("======存入实时车辆信息到redis成功=========");
} }
@Scheduled(cron = "0/1 * * * * ?")
public void setCarInfo() {
// redisTemplate.opsForValue().set("car-current-number", device);
}
@Scheduled(cron = "0/10 * * * * ?") @Scheduled(cron = "0/10 * * * * ?")
public void parseCarInfo() { public void parseCarInfo() {
@ -103,7 +99,8 @@ public class CarInfoTask {
} }
@Scheduled(cron = "0/1 * * * * ?") @Scheduled(cron = "0/1 * * * * ?")
public void getCarSpeed(String carNo) { public void getCarSpeed() {
String carNo = (String) redisTemplate.opsForValue().get("car-current-number");
CarInfoVO info = carInfoService.getCarInfo(carNo); CarInfoVO info = carInfoService.getCarInfo(carNo);
if (Func.isEmpty(info)) { if (Func.isEmpty(info)) {
throw new RuntimeException("未获取到车辆信息, 请检查车是否已掉线"); throw new RuntimeException("未获取到车辆信息, 请检查车是否已掉线");

Loading…
Cancel
Save