From 7b07c064e0097a52a05abe22227e458707ded339 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 1 Apr 2025 16:05:30 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=8D=B8=E8=BD=A6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/DistributionStockArticleClient.java | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java index b9cd8d4f0..ee527e818 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionStockArticleClient.java @@ -81,30 +81,36 @@ public class DistributionStockArticleClient implements IDistributionStockArticle String key = orderCode + warehouseId; - Boolean exists = bladeRedis.exists(key); - if(exists){ - String idStr = bladeRedis.get(key); - if("1".equals(idStr)){ - return 1L; - }else{ - return Long.valueOf(idStr); - } - }else{ - bladeRedis.setEx(key,"1",30L); - DistributionStockArticleEntity distributionStockArticle = distributionStockArticleService.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); - if(ObjectUtils.isNotEmpty(distributionStockArticle)){ - bladeRedis.setEx(key,distributionStockArticle.getId().toString(),30L); - return distributionStockArticle.getId(); + try{ + Boolean exists = bladeRedis.exists(key); + if(exists){ + String idStr = bladeRedis.get(key); + if("1".equals(idStr)){ + return 1L; + }else{ + return Long.valueOf(idStr); + } }else{ - boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity); - if(saveFlag){ + bladeRedis.setEx(key,"1",30L); + DistributionStockArticleEntity distributionStockArticle = distributionStockArticleService.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); + if(ObjectUtils.isNotEmpty(distributionStockArticle)){ bladeRedis.setEx(key,distributionStockArticle.getId().toString(),30L); - return distributionStockArticleEntity.getId(); + return distributionStockArticle.getId(); }else{ - return 0L; + boolean saveFlag = distributionStockArticleService.save(distributionStockArticleEntity); + if(saveFlag){ + bladeRedis.setEx(key,distributionStockArticle.getId().toString(),30L); + return distributionStockArticleEntity.getId(); + }else{ + return 0L; + } } } + }catch (Exception e){ + log.error("#######addData: 保存订单失败",e); + return 0L; } + } @Override