From 01c11cea018f4d73cc9c56882762c169c84395a0 Mon Sep 17 00:00:00 2001 From: liuyunhu <3286117488@qq.com> Date: Mon, 8 Apr 2024 10:02:52 +0800 Subject: [PATCH] =?UTF-8?q?4.8=E5=A2=9E=E5=8A=A0set=E7=BC=93=E5=AD=98=20?= =?UTF-8?q?=20=E8=BD=A6=E8=BE=86vin=20=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/VehicleServiceImpl.java | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) 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); + }); + }); + } + }