From a3d64094900f34d5da5108d8a1d0ecdb737664d4 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Sat, 6 Apr 2024 21:20:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=9A=84=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/BasicdataWarehouseClient.java | 73 ++++++++++--------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java index 419bfb59c..14ee1cda3 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java @@ -106,39 +106,19 @@ public class BasicdataWarehouseClient implements IBasicdataWarehouseClient { @Override public BasicdataWarehouseEntity getWarehouseEntityByWarehouseCode(String warehouseCode) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("warehouse_code",warehouseCode) + .eq("is_deleted",0) + .eq("enable_status",2); - String key =RedisKeyConstant.BASIC_DATA_WAREHOUSE_KEY + warehouseCode; - BasicdataWarehouseEntity o = bladeRedis.get(key); - log.info(">>> 获取的仓库的信息 o ={}",o); - if(ObjectUtils.isNull(o)){ - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("warehouse_code",warehouseCode) - .eq("is_deleted",0) - .eq("enable_status",2); - List list = warehouseWarehouseService.list(queryWrapper); - if(!Objects.isNull(list) && !list.isEmpty()){ - - // 寻找中心仓 - for (BasicdataWarehouseEntity basicdataWarehouseEntity : list) { - if(basicdataWarehouseEntity.getFunctionType().equals("2")){ - o = basicdataWarehouseEntity; - } - } - // 找不到 就去第一个 - if(ObjectUtils.isNull(o)){ - o= list.get(0); - } - - // 设定缓存时间 1小时的缓存时间 - bladeRedis.setEx(key,o, 60 * 60L); - } + List list = warehouseWarehouseService.list(queryWrapper); + if(!Objects.isNull(list) && !list.isEmpty()){ + return list.get(0); + }else{ + return null; } - return o; - - - } @@ -192,16 +172,39 @@ public class BasicdataWarehouseClient implements IBasicdataWarehouseClient { + String key =RedisKeyConstant.BASIC_DATA_WAREHOUSE_KEY + deptId; + BasicdataWarehouseEntity o = bladeRedis.get(key); + log.info(">>> 获取的仓库的信息 o ={}",o); + if(ObjectUtils.isNull(o)){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("department",deptId) + .eq("is_deleted",0) + .eq("enable_status",2); + List list = warehouseWarehouseService.list(queryWrapper); + if(!Objects.isNull(list) && !list.isEmpty()){ + + // 寻找中心仓 + for (BasicdataWarehouseEntity basicdataWarehouseEntity : list) { + if(basicdataWarehouseEntity.getFunctionType().equals("2")){ + o = basicdataWarehouseEntity; + } + } + // 找不到 就去第一个 + if(ObjectUtils.isNull(o)){ + o= list.get(0); + } + + // 设定缓存时间 1小时的缓存时间 + bladeRedis.setEx(key,o, 60 * 60L); + } + + } + + return o; - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("department",deptId) - .eq("is_deleted",0) - .eq("enable_status",2); - List list = warehouseWarehouseService.list(queryWrapper); - return list.get(0); } @Override