4.8增加set缓存 车辆vin 标识
parent
1c6cebb2cc
commit
01c11cea01
|
@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,6 +120,9 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
Result.error(result);
|
Result.error(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//刷新set缓存
|
||||||
|
reCache();
|
||||||
|
|
||||||
result = "删除成功!";
|
result = "删除成功!";
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -175,16 +179,8 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
vehicleAndLogoService.vehicleBindLogo(editParams.getVehicleId(), editParams.getLogoIds());
|
vehicleAndLogoService.vehicleBindLogo(editParams.getVehicleId(), editParams.getLogoIds());
|
||||||
|
|
||||||
|
|
||||||
// //mq
|
//刷新set缓存
|
||||||
// List<Long> logoList = getBindLogoById(editParams.getVehicleId());
|
reCache();
|
||||||
// if (0 != logoList.size()) {
|
|
||||||
// String ids = "";
|
|
||||||
// for (Long l : logoList) {
|
|
||||||
// ids = "," + l;
|
|
||||||
// }
|
|
||||||
// ids = ids.substring(1);
|
|
||||||
// remoteFenceService.vehicleQueue(editParams.getVehicleId() + "-" + ids);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
result = "编辑成功!";
|
result = "编辑成功!";
|
||||||
|
@ -254,16 +250,9 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
//执行添加电子围栏
|
//执行添加电子围栏
|
||||||
int i = vehicleAndLogoService.vehicleBindLogo(vehicle.getVehicleId(), insertParams.getLogoIds());
|
int i = vehicleAndLogoService.vehicleBindLogo(vehicle.getVehicleId(), insertParams.getLogoIds());
|
||||||
|
|
||||||
//
|
|
||||||
// List<Long> logoList = getBindLogoById(vehicle.getVehicleId());
|
//刷新set缓存
|
||||||
// if (0 != logoList.size()) {
|
reCache();
|
||||||
// String ids = "";
|
|
||||||
// for (Long l : logoList) {
|
|
||||||
// ids = "," + l;
|
|
||||||
// }
|
|
||||||
// ids = ids.substring(1);
|
|
||||||
// remoteFenceService.vehicleQueue(vehicle.getVehicleId() + "-" + ids);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
result = "新增成功!";
|
result = "新增成功!";
|
||||||
|
@ -337,7 +326,6 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Scheduled(cron = "0/1 * * * * *")
|
@Scheduled(cron = "0/1 * * * * *")
|
||||||
public void aa() {
|
public void aa() {
|
||||||
System.out.println("********************************************************");
|
System.out.println("********************************************************");
|
||||||
|
@ -362,7 +350,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
|
|
||||||
//执行修改下线状态的方法
|
//执行修改下线状态的方法
|
||||||
// Integer i = this.onOrOutLineByVIN(vehicle.getVin() + "," + 0);
|
// Integer i = this.onOrOutLineByVIN(vehicle.getVin() + "," + 0);
|
||||||
Integer i = this.onOrOutLineByVIN(vehicle.getVin() , 0);
|
Integer i = this.onOrOutLineByVIN(vehicle.getVin(), 0);
|
||||||
|
|
||||||
if (0 == i) {
|
if (0 == i) {
|
||||||
log.error("下线状态修改失败");
|
log.error("下线状态修改失败");
|
||||||
|
@ -379,4 +367,24 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 车辆绑定标识的缓存
|
||||||
|
* */
|
||||||
|
// @Scheduled(cron = "0/1 * * * * *")
|
||||||
|
public void reCache() {
|
||||||
|
//先获取所有车辆的信息
|
||||||
|
List<Vehicle> list = list(new VehicleListParams());
|
||||||
|
|
||||||
|
//通过车辆的id获取对应的标识
|
||||||
|
list.forEach(vehicle -> {
|
||||||
|
List<Long> bindLogoById = getBindLogoById(vehicle.getVehicleId());
|
||||||
|
|
||||||
|
bindLogoById.forEach(logoId -> {
|
||||||
|
HashSet<Long> longs = new HashSet<>();
|
||||||
|
longs.add(logoId);
|
||||||
|
redis.setCacheSet("车辆vin和标识:" + vehicle.getVin(), longs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue