Pārlūkot izejas kodu

perf(消费服务): 消费机根据人员编号获取人员信息、根据卡流水号获取钱包信息优化

autumnal_wind 11 mēneši atpakaļ
vecāks
revīzija
b18a8c8f11

+ 2 - 1
ruoyi-server/ruoyi-server-consume/src/main/java/org/dromara/server/consume/business/BaseBusiness.java

@@ -79,12 +79,13 @@ public class BaseBusiness {
     private final SyncRemoteSendMessageRecordService syncRemoteSendMessageRecordService;
     private final IXfCardLimitedService cardLimitedService;
     private final ThreadPoolTaskExecutor taskExecutor;
+    private final InitBusiness initBusiness;
 
     @DubboReference
     private final RemoteRegisterInfoService remoteRegisterInfoService;
     @DubboReference
     private final RemoteCardService remoteCardService;
-    private final InitBusiness initBusiness;
+
 
     //region 原始消费记录处理
 

+ 5 - 4
ruoyi-server/ruoyi-server-consume/src/main/java/org/dromara/server/consume/business/CardBusiness.java

@@ -21,6 +21,7 @@ import org.dromara.common.json.utils.JsonUtils;
 import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.server.common.constant.ConsumeConstants;
 import org.dromara.server.consume.cache.CardCacheManager;
+import org.dromara.server.consume.cache.UserAccountCacheManager;
 import org.dromara.server.consume.domain.bo.PtBagBo;
 import org.dromara.server.consume.domain.vo.PtBagVo;
 import org.dromara.server.consume.domain.vo.yc.BagInfo;
@@ -50,6 +51,7 @@ import java.util.Objects;
 public class CardBusiness {
     private final IPtBagService ptBagService;
     private final CardCacheManager cardCacheManager;
+    private final UserAccountCacheManager userAccountCacheManager;
 
     public ReturnResult getCardBagsByCardNo(Long cardNo) {
         RemoteCardVo remoteCardVo = getCardFromCache(cardNo, ConsumeConstants.CARD_NO);
@@ -94,13 +96,12 @@ public class CardBusiness {
 
     private Object setCardBagInfo(RemoteCardVo remoteCardVo) {
         CardBagInfo cardBagInfo = new CardBagInfo();
-        Long userId = remoteCardVo.getUserId();
-        List<RemoteUserAccountVo> listUserAccount = RedisUtils.getCacheList(CacheNames.PT_USER_ACCOUNT_LIST);
-        RemoteUserAccountVo userAccountVo = listUserAccount.parallelStream().filter(p -> userId.equals(p.getUserId()))
-            .findFirst().orElse(null);
+        // String StrUserId = String.valueOf(remoteCardVo.getUserId());
+        RemoteUserAccountVo userAccountVo = userAccountCacheManager.getByUserId(remoteCardVo.getUserId());
         if (userAccountVo == null) {
             return null;
         }
+
         PtBagBo bagBo = new PtBagBo();
         bagBo.setUserId(remoteCardVo.getUserId());
         List<PtBagVo> bagVos = ptBagService.queryList(bagBo);

+ 7 - 6
ruoyi-server/ruoyi-server-consume/src/main/java/org/dromara/server/consume/business/EmployeeBusiness.java

@@ -14,6 +14,7 @@ import org.dromara.common.core.enums.ResultCodeEnum;
 import org.dromara.common.json.utils.JsonUtils;
 import org.dromara.common.redis.utils.RedisUtils;
 import org.dromara.server.common.constant.ConsumeConstants;
+import org.dromara.server.consume.cache.CardCacheManager;
 import org.dromara.server.consume.cache.UserAccountCacheManager;
 import org.dromara.server.consume.domain.vo.yc.*;
 import org.dromara.system.api.RemoteDeptService;
@@ -36,13 +37,13 @@ import java.util.List;
 @RequiredArgsConstructor
 public class EmployeeBusiness {
     private final UserAccountCacheManager userAccountCacheManager;
-    private final CardBusiness cardBusiness;
+    private final CardCacheManager cardCacheManager;
 
     @DubboReference
     private final RemoteDeptService remoteDeptService;
 
     public ReturnResult getEmployeeVoByNumb(String userNumb) {
-        RemoteUserAccountVo userAccountVo = getAccountFromCache(userNumb, ConsumeConstants.USER_NUMB);
+        RemoteUserAccountVo userAccountVo = userAccountCacheManager.getByUserNumb(userNumb);
         if (userAccountVo == null) {
             ErrorResult result = new ErrorResult();
             result.setStatusCode(HttpStatus.NOT_FOUND.value());
@@ -84,14 +85,14 @@ public class EmployeeBusiness {
         departmentVo.setDepartmentName(userAccountVo.getDeptName());
 
         Long userId = userAccountVo.getUserId();
-        RemoteCardVo remoteCardVo = cardBusiness.getCardFromCache(userId, ConsumeConstants.CARD_USER);
-
-        if (remoteCardVo == null) {
+        Object objCard = cardCacheManager.getByUserId(userId);
+        if (objCard == null) {
             log.warn("无人员有效卡片信息,userNumb:{},userId:{}", userAccountVo.getUserNumb(), userAccountVo.getUserId());
             return null;
         }
+        RemoteCardVo remoteCardVo = JsonUtils.parseObject(objCard.toString(), RemoteCardVo.class);
         UserCardVo userCardVo = new UserCardVo();
-        Long cardNo = 0L;
+        Long cardNo;
         CardStatusVo cardStatusVo = new CardStatusVo();
         int cardStatusId = Integer.parseInt(remoteCardVo.getStatus());
         cardStatusVo.setCardStatusID(cardStatusId);

+ 8 - 8
ruoyi-server/ruoyi-server-consume/src/main/java/org/dromara/server/consume/task/InitTasks.java

@@ -32,14 +32,14 @@ public class InitTasks implements ApplicationRunner {
     public void run(ApplicationArguments args) throws Exception {
         log.info("初始化消费验证基础数据");
         long startTime = System.currentTimeMillis();
-        // initBusiness.initGlobalData();
-        // initBusiness.initTermInfo();
-        // initBusiness.initMealTypeInfo();
-        // initBusiness.initDiscountAndOther();
-        // initBusiness.initUserCard();
-        // initBusiness.initUserAccount();
-        // initBusiness.initXfCardLimited();
-        // initBusiness.initUserBalance();
+        initBusiness.initGlobalData();
+        initBusiness.initTermInfo();
+        initBusiness.initMealTypeInfo();
+        initBusiness.initDiscountAndOther();
+        initBusiness.initUserCard();
+        initBusiness.initUserAccount();
+        initBusiness.initXfCardLimited();
+        initBusiness.initUserBalance();
         validationParam.refresh();
 
         log.info("初始化消费验证基础数据完成。耗时:{} ms", System.currentTimeMillis() - startTime);