From 35cc5c42f1718a08b8657faff59679e340b858a4 Mon Sep 17 00:00:00 2001 From: "zhenghaiyang@ele-cloud.com" Date: Tue, 5 Dec 2023 14:30:13 +0800 Subject: [PATCH] =?UTF-8?q?feature=201.=E4=BF=AE=E6=94=B9=E4=BE=9D?= =?UTF-8?q?=E8=B5=96redisson=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- order-management-invoice/pom.xml | 2 +- .../impl/OrderInvoiceInfoServiceImpl.java | 30 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/order-management-invoice/pom.xml b/order-management-invoice/pom.xml index 388550ea..f05356d5 100644 --- a/order-management-invoice/pom.xml +++ b/order-management-invoice/pom.xml @@ -20,7 +20,7 @@ org.redisson redisson-spring-boot-starter - 3.23.1 + 3.12.5 diff --git a/order-management-invoice/src/main/java/com/dxhy/order/invoice/module/invoice/service/impl/OrderInvoiceInfoServiceImpl.java b/order-management-invoice/src/main/java/com/dxhy/order/invoice/module/invoice/service/impl/OrderInvoiceInfoServiceImpl.java index 4f9b53c0..0e7db9cb 100644 --- a/order-management-invoice/src/main/java/com/dxhy/order/invoice/module/invoice/service/impl/OrderInvoiceInfoServiceImpl.java +++ b/order-management-invoice/src/main/java/com/dxhy/order/invoice/module/invoice/service/impl/OrderInvoiceInfoServiceImpl.java @@ -1705,8 +1705,8 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { return redInvoiceRespPo; } -// @Resource -// private RedissonClient redisson; + @Resource + private RedissonClient redisson; @SneakyThrows @Override @@ -1718,12 +1718,12 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { //组装发票报文 //金额、数量、税额跟跟换为负数,折扣行要与被折扣行合并 //校验重复提交数据覆盖问题 -// RLock lock = redisson.getLock(redInvoiceSaveReqPo.getFpqqlsh()); + RLock lock = redisson.getLock(redInvoiceSaveReqPo.getFpqqlsh()); // boolean redRedisLock = redisService.setNx(redInvoiceSaveReqPo.getFpqqlsh(), key, RedisConstant.REDIS_EXPIRE_TIME_2HOUR); for (int i = 0; i < 3; i++) { -// try { -// if(!lock.isLocked()){ -// lock.lock(); + try { + if(!lock.isLocked()){ + lock.lock(); Map paramMap = redisService.pullAllHashMap(key); if(paramMap != null){ String value = redisService.pullHashMap(key, innerKey); @@ -1750,16 +1750,16 @@ public class OrderInvoiceInfoServiceImpl implements OrderInvoiceInfoService { redisService.set(redSyjeKey,syfpje); hashMap.put(redItemList.get(0).getId(),syfpje); } -// lock.unlock(); + lock.unlock(); return R.ok().put(OrderManagementConstant.DATA,hashMap); -// } else { -// Thread.sleep(2000); -// log.info("获取redis锁请等待,三次之后还是获取锁失败则返回。。。"); -// } -// } catch (InterruptedException e) { -// lock.unlock(); -// throw new RuntimeException(e); -// } + } else { + Thread.sleep(2000); + log.info("获取redis锁请等待,三次之后还是获取锁失败则返回。。。"); + } + } catch (InterruptedException e) { + lock.unlock(); + throw new RuntimeException(e); + } } return R.ok(); }