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