Jelajahi Sumber

缓存处理

wuhb 6 bulan lalu
induk
melakukan
1c7f797ed3

+ 9 - 3
ygtx-admin/src/main/java/com/ygtx/web/controller/monitor/CacheController.java

@@ -24,7 +24,7 @@ import com.ygtx.system.domain.SysCache;
 
 /**
  * 缓存监控
- * 
+ *
  * @author ruoyi
  */
 @RestController
@@ -43,6 +43,7 @@ public class CacheController
         caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
         caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
         caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
+        caches.add(new SysCache("NOTIFY:", "通知数量"));
     }
 
     @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@@ -88,8 +89,13 @@ public class CacheController
     @GetMapping("/getValue/{cacheName}/{cacheKey}")
     public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey)
     {
-        String cacheValue = redisTemplate.opsForValue().get(cacheKey);
-        SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
+        SysCache sysCache;
+        if(cacheName.equals("NOTIFY:")){
+            sysCache = new SysCache(cacheName, cacheKey, redisTemplate.opsForList().index(cacheKey, 0));
+        }else{
+            String cacheValue = redisTemplate.opsForValue().get(cacheKey);
+            sysCache = new SysCache(cacheName, cacheKey, cacheValue);
+        }
         return AjaxResult.success(sysCache);
     }
 

+ 4 - 1
ygtx-common/src/main/java/com/ygtx/common/constant/CacheConstants.java

@@ -2,7 +2,7 @@ package com.ygtx.common.constant;
 
 /**
  * 缓存的key 常量
- * 
+ *
  * @author ruoyi
  */
 public class CacheConstants
@@ -41,4 +41,7 @@ public class CacheConstants
      * 登录账户密码错误次数 redis key
      */
     public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
+
+
+    public static final String NOTIFY_STORAGE_KEY="NOTIFY:STORAGE:USER_TASK_";
 }

+ 0 - 3
ygtx-common/src/main/java/com/ygtx/common/constant/UserConstants.java

@@ -89,7 +89,4 @@ public class UserConstants
     public static final String MESSAGE_STATUS_PROCEED = "PROCEED";//已处理
 
     public static final String NO = "N";
-
-    public static final String NOTIFY_KEY="NOTIFY:USER_TASK_";
-    public static final String NOTIFY_STORAGE_KEY="NOTIFY:STORAGE:USER_TASK_";
 }

+ 3 - 13
ygtx-gxt/src/main/java/com/ygtx/gxt/controller/mobile/GxtMobileNotifyController.java

@@ -1,25 +1,15 @@
 package com.ygtx.gxt.controller.mobile;
 
-import cn.hutool.json.JSONUtil;
-import com.alibaba.druid.support.json.JSONUtils;
-import com.ygtx.common.annotation.Log;
-import com.ygtx.common.constant.UserConstants;
+import com.ygtx.common.constant.CacheConstants;
 import com.ygtx.common.core.controller.BaseController;
 import com.ygtx.common.core.domain.AjaxResult;
-import com.ygtx.common.core.page.TableDataInfo;
 import com.ygtx.common.core.redis.RedisCache;
-import com.ygtx.common.enums.BusinessType;
 import com.ygtx.common.utils.DateUtils;
 import com.ygtx.gxt.domain.GxtNotifyMessage;
 import com.ygtx.gxt.domain.GxtRepairOrder;
 import com.ygtx.gxt.domain.GxtWorkOrder;
 import com.ygtx.gxt.domain.OrderScoreInfo;
 import com.ygtx.gxt.service.IGxtOrderMineService;
-import com.ygtx.gxt.service.IGxtOrderScoreService;
-import com.ygtx.gxt.service.IGxtRepairOrderService;
-import com.ygtx.gxt.service.IGxtWorkOrderService;
-import io.lettuce.core.dynamic.annotation.Param;
-import io.swagger.models.auth.In;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -55,7 +45,7 @@ public class GxtMobileNotifyController extends BaseController
                 int taskNum = 0;
                 if(!orderScoreInfos.isEmpty()){
                     taskNum = orderScoreInfos.size();
-                    Object taskNumStr = redisCache.lGet(UserConstants.NOTIFY_STORAGE_KEY, id);
+                    Object taskNumStr = redisCache.lGet(CacheConstants.NOTIFY_STORAGE_KEY, id);
                     if(taskNumStr!=null){
                         int prevTaskNum = Integer.parseInt(taskNumStr.toString());
                         if(taskNum < prevTaskNum){
@@ -67,7 +57,7 @@ public class GxtMobileNotifyController extends BaseController
                     }else{
                         isSend = true;
                     }
-                    redisCache.lPush(UserConstants.NOTIFY_STORAGE_KEY,id, taskNum+"");
+                    redisCache.lPush(CacheConstants.NOTIFY_STORAGE_KEY,id, taskNum+"");
                 }
                 GxtNotifyMessage notifyMessage = new GxtNotifyMessage();
                 if(isSend) {

TEMPAT SAMPAH
ygtx-ui/src/assets/images/gxt-release.png