Prechádzať zdrojové kódy

redis工具迁移到commoen-redis工程

by su 3 rokov pred
rodič
commit
8ca6794327
17 zmenil súbory, kde vykonal 809 pridanie a 90 odobranie
  1. 5 0
      4dkankan-center-scene/pom.xml
  2. 1 1
      4dkankan-center-scene/src/main/java/com/fdkankan/scene/SceneApplication.java
  3. 2 6
      4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/SceneFileController.java
  4. 87 0
      4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/TestController.java
  5. 7 6
      4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneAppServiceImpl.java
  6. 10 11
      4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneProAppServiceImpl.java
  7. 6 5
      4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java
  8. 33 18
      4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneServiceImpl.java
  9. 5 5
      4dkankan-center-scene/src/main/resources/bootstrap.yml
  10. 36 0
      4dkankan-common-redis/pom.xml
  11. 57 0
      4dkankan-common-redis/src/main/java/com/fdkankan/redis/config/RedisConfig.java
  12. 12 11
      4dkankan-common/src/main/java/com/fdkankan/common/constant/RedisUtil.java
  13. 530 0
      4dkankan-common-redis/src/main/java/com/fdkankan/redis/util/RedisUtil.java
  14. 0 24
      4dkankan-common/src/main/java/com/fdkankan/common/config/RedisConfig.java
  15. 1 0
      4dkankan-common/src/main/java/com/fdkankan/common/constant/ErrorCode.java
  16. 13 2
      4dkankan-common/src/main/java/com/fdkankan/common/constant/RedisKey.java
  17. 4 1
      4dkankan-gateway/src/main/java/com/fdkankan/gateway/filter/AccessLogFilter.java

+ 5 - 0
4dkankan-center-scene/pom.xml

@@ -39,6 +39,11 @@
             <artifactId>4dkankan-common-mq</artifactId>
             <version>2.0.0</version>
         </dependency>
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-common-redis</artifactId>
+            <version>2.0.0</version>
+        </dependency>
 
 <!--        <dependency>-->
 <!--            <groupId>com.alibaba.cloud</groupId>-->

+ 1 - 1
4dkankan-center-scene/src/main/java/com/fdkankan/scene/SceneApplication.java

@@ -12,7 +12,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @EnableFeignClients("com.fdkankan.*.api.feign")
 @EnableDiscoveryClient
 @EnableScheduling
-@ComponentScan(basePackages = {"com.fdkankan.common", "com.fdkankan.scene"})
+@ComponentScan(basePackages = {"com.fdkankan.common", "com.fdkankan.scene","com.fdkankan.redis"})
 @MapperScan("com.fdkankan.**.mapper")
 public class SceneApplication {
 

+ 2 - 6
4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/SceneFileController.java

@@ -1,11 +1,9 @@
 package com.fdkankan.scene.controller;
 
-import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fdkankan.common.constant.RedisUtil;
 import com.fdkankan.common.controller.BaseController;
 import com.fdkankan.common.response.ResultData;
-import com.fdkankan.common.util.RSAEncrypt;
+import com.fdkankan.redis.util.RedisLockUtil;
 import com.fdkankan.scene.service.*;
 import com.fdkankan.scene.vo.ResponseSceneFile;
 import lombok.extern.log4j.Log4j2;
@@ -19,8 +17,6 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.Base64;
-
 /**
  * 场景文件上传模块
  */
@@ -75,7 +71,7 @@ public class SceneFileController extends BaseController {
     private ISceneResourceCameraService sceneResourceCameraService;
 
     @Autowired
-    RedisUtil redisUtil;
+    RedisLockUtil redisLockUtil;
 
     @Autowired
     RedisTemplate redisTemplate;

+ 87 - 0
4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/TestController.java

@@ -3,12 +3,20 @@ package com.fdkankan.scene.controller;
 import com.fdkankan.common.constant.ConstantFilePath;
 import com.fdkankan.common.util.MatrixToImageWriterUtil;
 import com.fdkankan.platform.api.feign.PlatformClient;
+import com.fdkankan.platform.api.vo.User;
+import com.fdkankan.redis.util.RedisUtil;
+import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/api/device")
@@ -17,6 +25,9 @@ public class TestController {
     @Autowired
     PlatformClient platformClient;
 
+    @Autowired
+    RedisUtil redisUtil;
+
     @GetMapping("/test")
     public String test() throws Exception {
 
@@ -35,4 +46,80 @@ public class TestController {
 //                ConstantFilePath.SCENE_PATH + "images/images" + "123123" + "/QRShareLogo.png");
     }
 
+    @GetMapping("/testSetStr")
+    public boolean testSetStr() throws Exception {
+        return redisUtil.set("testSetStr", "123123123123aaaa");
+    }
+
+    @GetMapping("/testGetStr")
+    public String testGetStr() throws Exception {
+        return (String)redisUtil.get("testSetStr");
+    }
+
+    @GetMapping("/testSetObject")
+    public boolean testSetObject() throws Exception {
+        User user = new User();
+        user.setCity("珠海");
+        user.setId(123l);
+        return redisUtil.set("testSetObject", user);
+    }
+
+    @GetMapping("/testGetObject")
+    public User testGetObject() throws Exception {
+        User user = new User();
+        user.setCity("珠海");
+        user.setId(123l);
+        return (User)redisUtil.get("testSetObject");
+    }
+
+    @GetMapping("/testSetList")
+    public boolean testSetList() throws Exception {
+
+        List<User> users = Lists.newArrayList();
+        User user1 = new User();
+        user1.setCity("珠海");
+        user1.setId(123l);
+
+        User user2 = new User();
+        user2.setCity("广州");
+        user2.setId(124l);
+
+        users.add(user1);
+        users.add(user2);
+
+
+        return redisUtil.lRightPushAll("testList1", users);
+    }
+
+    @GetMapping("/testGetList")
+    public List<User> testGetList() throws Exception {
+//        List<User> testList = (List<User>) redisUtil.lGet("testList1", 0, -1);
+        return redisUtil.lGet("testList1", 0, -1);
+    }
+
+    @GetMapping("/testSetMap")
+    public boolean testSetMap() throws Exception {
+
+        Map<String, User> userMap = new HashMap<>();
+
+        User user1 = new User();
+        user1.setCity("珠海");
+        user1.setId(123l);
+
+        User user2 = new User();
+        user2.setCity("广州");
+        user2.setId(124l);
+
+        userMap.put("user1", user1);
+        userMap.put("user2", user2);
+
+
+        return redisUtil.hmset("userMap", userMap);
+    }
+
+    @GetMapping("/testGetMap")
+    public Map<String ,User> testGetMap() throws Exception {
+        return redisUtil.hmget("userMap");
+    }
+
 }

+ 7 - 6
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneAppServiceImpl.java

@@ -10,6 +10,7 @@ import com.fdkankan.common.util.ConvertCommonUtils;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.common.util.UploadToOssUtil;
 import com.fdkankan.common.util.WeiXinUtils;
+import com.fdkankan.redis.util.RedisLockUtil;
 import com.fdkankan.scene.entity.Scene;
 import com.fdkankan.scene.entity.SceneExt;
 import com.fdkankan.scene.mapper.ISceneMapper;
@@ -62,6 +63,8 @@ public class SceneAppServiceImpl extends ServiceImpl<ISceneMapper, Scene> implem
     ISceneService sceneService;
     @Autowired
     ISceneExtService sceneExtService;
+    @Autowired
+    RedisLockUtil redisLockUtil;
 
 
     @Override
@@ -500,8 +503,6 @@ public class SceneAppServiceImpl extends ServiceImpl<ISceneMapper, Scene> implem
         return 1;
     }
 
-    @Autowired
-    RedisUtil redisUtil;
 
     @Override
     public Object uploadPic(String sceneNum, String folderName, MultipartFile file) throws IOException {
@@ -521,7 +522,7 @@ public class SceneAppServiceImpl extends ServiceImpl<ISceneMapper, Scene> implem
         String lockKey = String.format(RedisKey.LOCK_UPLOAD_PIC, sceneNum);
 //        Boolean lock = redisTemplate.opsForValue()
 //                                    .setIfAbsent(lockKey, Thread.currentThread().getId(), RedisKey.EXPIRE_TIME_10_MINUTE, TimeUnit.MILLISECONDS);
-        Boolean lock = redisUtil.lock(lockKey, RedisKey.EXPIRE_TIME_10_MINUTE);
+        Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_10_MINUTE);
 
         if(!lock){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
@@ -551,7 +552,7 @@ public class SceneAppServiceImpl extends ServiceImpl<ISceneMapper, Scene> implem
             log.error("上传图片失败", e);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5037);
         }finally {
-            redisUtil.unlock(lockKey, Thread.currentThread().getId());
+            redisLockUtil.unlock(lockKey);
         }
 
         return targetFile.getName();
@@ -574,7 +575,7 @@ public class SceneAppServiceImpl extends ServiceImpl<ISceneMapper, Scene> implem
         }
 
         String lockKey = String.format(RedisKey.LOCK_UPLOAD_VOICE, sceneNum);
-        Boolean lock = redisUtil.lock(lockKey, RedisKey.EXPIRE_TIME_30_MINUTE);
+        Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_30_MINUTE);
 
         if(!lock){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
@@ -621,7 +622,7 @@ public class SceneAppServiceImpl extends ServiceImpl<ISceneMapper, Scene> implem
             log.error("上传图片失败", e);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5040);
         }finally {
-            redisUtil.unlock(lockKey, Thread.currentThread().getId());
+            redisLockUtil.unlock(lockKey);
         }
 
         return originalFileName;

+ 10 - 11
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneProAppServiceImpl.java

@@ -9,6 +9,7 @@ import com.fdkankan.common.constant.*;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.response.ResultData;
 import com.fdkankan.common.util.*;
+import com.fdkankan.redis.util.RedisLockUtil;
 import com.fdkankan.scene.entity.ScenePro;
 import com.fdkankan.scene.entity.SceneProEdit;
 import com.fdkankan.scene.entity.SceneProEditExt;
@@ -62,14 +63,12 @@ public class SceneProAppServiceImpl extends ServiceImpl<ISceneProMapper, ScenePr
     @Autowired
     ISceneProService sceneProService;
     @Autowired
-    ISceneProMapper sceneProMapper;
-    @Autowired
     @Qualifier("uploadToOssUtil")
     UploadToOssUtil uploadToOssUtil;
     @Autowired
     ISceneProEditService sceneProEditService;
     @Autowired
-    RedisUtil redisUtil;
+    RedisLockUtil redisLockUtil;
     @Autowired
     ISceneProEditExtService sceneProEditExtService;
 
@@ -455,7 +454,7 @@ public class SceneProAppServiceImpl extends ServiceImpl<ISceneProMapper, ScenePr
         }
 
         String lockKey = String.format(RedisKey.LOCK_UPLOAD_PRO_PIC, sceneNum);
-        Boolean lock = redisUtil.lock(lockKey, RedisKey.EXPIRE_TIME_10_MINUTE);
+        Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_10_MINUTE);
 
         if(!lock){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
@@ -485,7 +484,7 @@ public class SceneProAppServiceImpl extends ServiceImpl<ISceneProMapper, ScenePr
             log.error("上传图片失败", e);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5037);
         }finally {
-            redisUtil.unlock(lockKey, Thread.currentThread().getId());
+            redisLockUtil.unlock(lockKey);
         }
 
         return ResultData.ok(targetFile.getName());
@@ -509,7 +508,7 @@ public class SceneProAppServiceImpl extends ServiceImpl<ISceneProMapper, ScenePr
         }
 
         String lockKey = String.format(RedisKey.LOCK_UPLOAD_PRO_VOICE, sceneNum);
-        Boolean lock = redisUtil.lock(lockKey, RedisKey.EXPIRE_TIME_30_MINUTE);
+        Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_30_MINUTE);
 
         if(!lock){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
@@ -557,7 +556,7 @@ public class SceneProAppServiceImpl extends ServiceImpl<ISceneProMapper, ScenePr
             log.error("上传图音频失败", e);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5040);
         }finally {
-            redisUtil.unlock(lockKey, Thread.currentThread().getId());
+            redisLockUtil.unlock(lockKey);
         }
 
         return ResultData.ok(originalFileName);
@@ -1116,7 +1115,7 @@ public class SceneProAppServiceImpl extends ServiceImpl<ISceneProMapper, ScenePr
     public ResultData uploadFloorJsonAndRebuild(SceneEditVO sceneEdit) throws Exception {
 
         String lockKey = String.format(RedisKey.LOCK_UPLOAD_FLOORJSON_REBUILD, sceneEdit.getSceneNum());
-        Boolean lock = redisUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
+        Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
         if(!lock){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
         }
@@ -1186,7 +1185,7 @@ public class SceneProAppServiceImpl extends ServiceImpl<ISceneProMapper, ScenePr
             log.error("画墙重建模型失败...", e);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5039);
         }finally {
-            redisUtil.unlock(lockKey, Thread.currentThread().getId());
+            redisLockUtil.unlock(lockKey);
         }
 
         return ResultData.ok();
@@ -1329,7 +1328,7 @@ public class SceneProAppServiceImpl extends ServiceImpl<ISceneProMapper, ScenePr
         }
 
         String lockKey = String.format(RedisKey.LOCK_UPLOAD_FLOORPLAN_PNG, sceneNum);
-        Boolean lock = redisUtil.lock(lockKey, RedisKey.EXPIRE_TIME_30_MINUTE);
+        Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_30_MINUTE);
         if(!lock){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
         }
@@ -1392,7 +1391,7 @@ public class SceneProAppServiceImpl extends ServiceImpl<ISceneProMapper, ScenePr
             log.error("上传图片多媒体数据失败...", e);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5041);
         }finally {
-            redisUtil.unlock(lockKey, Thread.currentThread().getId());
+            redisLockUtil.unlock(lockKey);
         }
 
         return ResultData.ok("images"+File.separator+"images"+sceneNum + File.separator + fileName);

+ 6 - 5
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -16,6 +16,7 @@ import com.fdkankan.common.constant.*;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.response.ResultData;
 import com.fdkankan.common.util.*;
+import com.fdkankan.redis.util.RedisLockUtil;
 import com.fdkankan.scene.entity.*;
 import com.fdkankan.scene.mapper.ISceneProMapper;
 import com.fdkankan.scene.service.*;
@@ -86,7 +87,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     @Autowired
     ISceneService sceneService;
     @Autowired
-    RedisUtil redisUtil;
+    RedisLockUtil redisLockUtil;
     @Autowired
     ISceneDataDownloadService sceneDataDownloadService;
 
@@ -239,7 +240,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     public ResultData uploadFloorJson(SceneEditVO sceneEdit) throws Exception {
 
         String lockKey = String.format(RedisKey.LOCK_UPLOAD_FLOORJSON_REBUILD, sceneEdit.getSceneNum());
-        Boolean lock = redisUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
+        Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
         if(!lock){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
         }
@@ -465,7 +466,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
             log.error("画墙重建模型失败...", e);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5039);
         }finally {
-            redisUtil.unlock(lockKey, Thread.currentThread().getId());
+            redisLockUtil.unlock(lockKey);
         }
 
         return ResultData.ok();
@@ -475,7 +476,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     public ResultData uploadFloorJsonAjk(String sceneNum, String ajkJson, String cameraJson, String floorPlanJson, MultipartFile[] file) throws Exception {
 
         String lockKey = String.format(RedisKey.LOCK_UPLOAD_FLOORJSON_REBUILD, sceneNum);
-        Boolean lock = redisUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
+        Boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_2_HOUR);
         if(!lock){
             throw new BusinessException(ErrorCode.FAILURE_CODE_5036);
         }
@@ -644,7 +645,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
             log.error("画墙重建模型失败...", e);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5039);
         }finally {
-            redisUtil.unlock(lockKey, Thread.currentThread().getId());
+            redisLockUtil.unlock(lockKey);
         }
 
         return ResultData.ok();

+ 33 - 18
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneServiceImpl.java

@@ -14,6 +14,8 @@ import com.fdkankan.common.constant.*;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.response.ResultData;
 import com.fdkankan.common.util.*;
+import com.fdkankan.redis.util.RedisLockUtil;
+import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.scene.entity.*;
 import com.fdkankan.scene.mapper.ISceneMapper;
 import com.fdkankan.scene.mapper.ISceneProMapper;
@@ -58,8 +60,6 @@ public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implement
     private String prefixAli;
 
     @Autowired
-    RedisTemplate redisTemplate;
-    @Autowired
     ISceneProMapper sceneProMapper;
     @Autowired
     ISceneProService sceneProService;
@@ -68,6 +68,10 @@ public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implement
     @Autowired
     @Qualifier("uploadToOssUtil")
     UploadToOssUtil uploadToOssUtil;
+    @Autowired
+    RedisUtil redisUtil;
+    @Autowired
+    RedisLockUtil redisLockUtil;
 
     @Override
     public void updateUserIdByCameraId(Long userId, Long cameraId) {
@@ -1012,36 +1016,47 @@ public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implement
     @Override
     public ResultData updateViewCount(String sceneNum) {
         String key = String.format(RedisKey.SCENE_VISIT_CNT, sceneNum);
-        Integer count = (Integer) redisTemplate.opsForValue().get(key);
+        Integer count = (Integer) redisUtil.get(key);
         if(count == null){
-            Scene scene = this.getSceneBySceneCode(sceneNum);
-            if(scene == null){
-                ScenePro scenePro = sceneProMapper.findByNum(sceneNum);
-                if(scenePro != null){
-                    count = scenePro.getViewCount();
-                }else {
-                    count = 0;
+            String lockKey = String.format(RedisKey.LOCK_SCENE_VISIT_CNT, sceneNum);
+            boolean lock = redisLockUtil.lock(lockKey, RedisKey.EXPIRE_TIME_10_MINUTE);
+            try {
+                if(!lock){
+                    throw new BusinessException(ErrorCode.SYSTEM_BUSY);
+                }
+                count = (Integer) redisUtil.get(key);
+                if(count == null){
+                    Scene scene = this.getSceneBySceneCode(sceneNum);
+                    if(scene == null){
+                        ScenePro scenePro = sceneProMapper.findByNum(sceneNum);
+                        if(scenePro != null){
+                            count = scenePro.getViewCount();
+                        }else {
+                            count = 0;
+                        }
+                    }else {
+                        count = scene.getViewCount();
+                    }
+                    redisUtil.set(key, count);
                 }
-            }else {
-                count = scene.getViewCount();
+            }finally {
+                redisLockUtil.unlockLua(lockKey);
             }
         }
-        count++;
-        redisTemplate.opsForValue().set(key, count);
+        redisUtil.incr(key, 1);
         return ResultData.ok();
     }
 
     @Override
     public void updatePv(){
 
-        Boolean lock = redisTemplate.opsForValue().setIfAbsent(
-                RedisKey.LOCK_SCENE_VISIT_UPDATE, Thread.currentThread().getId()+"", RedisKey.EXPIRE_TIME_2_HOUR, TimeUnit.MILLISECONDS);
+        Boolean lock = redisLockUtil.lock(RedisKey.LOCK_SCENE_VISIT_UPDATE, RedisKey.EXPIRE_TIME_2_HOUR);
         if(!lock){
             return;
         }
 
         try {
-            Map<String, Integer> pvMap = redisTemplate.opsForHash().entries(RedisKey.SCENE_VISIT_CNT);
+            Map<String, Integer> pvMap = redisUtil.hmget(RedisKey.SCENE_VISIT_CNT);
             if(CollUtil.isEmpty(pvMap)){
                 return;
             }
@@ -1064,7 +1079,7 @@ public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implement
                 }
             }
         }finally {
-            redisTemplate.delete(RedisKey.LOCK_SCENE_VISIT_UPDATE);
+            redisLockUtil.unlockLua(RedisKey.LOCK_SCENE_VISIT_UPDATE);
 
         }
 

+ 5 - 5
4dkankan-center-scene/src/main/resources/bootstrap.yml

@@ -1,11 +1,11 @@
-server:
-  file:
-    location: /mnt/4Dkankan/
+#server:
+#  file:
+#    location: /mnt/4Dkankan/
 spring:
   application:
     name: 4dkankan-center-scene
-  resources:
-    static-locations: classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/, classpath:/web/, file:${server.file.location}
+#  resources:
+#    static-locations: classpath:/META-INF/resources/,classpath:/resources/, classpath:/static/, classpath:/web/, file:${server.file.location}
   cloud:
     nacos:
       config:

+ 36 - 0
4dkankan-common-redis/pom.xml

@@ -14,6 +14,15 @@
     <artifactId>4dkankan-common-redis</artifactId>
 
     <dependencies>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.google.protobuf</groupId>
             <artifactId>protobuf-java</artifactId>
@@ -33,6 +42,33 @@
             <artifactId>spring-boot-starter-data-redis</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+            <version>2.12.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+            <version>2.12.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.12.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 57 - 0
4dkankan-common-redis/src/main/java/com/fdkankan/redis/config/RedisConfig.java

@@ -0,0 +1,57 @@
+package com.fdkankan.redis.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+import javax.annotation.Resource;
+
+@Configuration
+@AutoConfigureAfter(RedisAutoConfiguration.class)
+public class RedisConfig {
+
+    @Autowired
+    LettuceConnectionFactory lettuceConnectionFactory;
+
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory redisConnectionFactory) {
+        RedisTemplate template = new RedisTemplate();
+        template.setConnectionFactory(redisConnectionFactory);
+        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
+        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+
+        /*
+        Jackson对象映射器(Object Mapper)可以把JSON解析为用户自定义类对象, 或者解析为JSON内置的树模型的对象
+         */
+        ObjectMapper om = new ObjectMapper();
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        /*
+         * DefaultTyping.NON_FINAL,将会为(String、Boolean、Integer、Double)除外的其他类型及非final类型的数组添加反序列化所需要的类型。
+         * JsonTypeInfo.As.PROPERTY,它将包含@class属性,作为序列化的一个属性,值就是完全限定名类型。当前类及其属性都会添加这个名为@class的属性。
+         */
+        om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance , ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
+
+        jackson2JsonRedisSerializer.setObjectMapper(om);
+
+        template.setKeySerializer(stringRedisSerializer);
+        template.setValueSerializer(jackson2JsonRedisSerializer);
+        template.setHashKeySerializer(stringRedisSerializer);
+        template.setHashValueSerializer(jackson2JsonRedisSerializer);
+
+        template.afterPropertiesSet();
+        template.setEnableTransactionSupport(true);
+        return template;
+    }
+}

+ 12 - 11
4dkankan-common/src/main/java/com/fdkankan/common/constant/RedisUtil.java

@@ -1,30 +1,29 @@
-package com.fdkankan.common.constant;
+package com.fdkankan.redis.util;
 
 import cn.hutool.core.util.StrUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.ClassPathResource;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.script.DefaultRedisScript;
 import org.springframework.stereotype.Component;
 
 import java.util.Arrays;
 import java.util.Objects;
-import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
 @Component
 @Slf4j
-public class RedisUtil {
+public class RedisLockUtil {
 
     @Autowired
     private RedisTemplate redisTemplate;
 
-    private static final String UNLOCK_LUA = "if redis.call('get',KEYS[1]) == ARGV[1] then\n" +
-                                "    return redis.call('del',KEYS[1])\n" +
-                                "else\n" +
-                                "    return 0\n" +
-                                "end";
+    private static final String UNLOCK_LUA =
+            "if redis.call('get',KEYS[1]) == ARGV[1] then\n" +
+            "    return redis.call('del',KEYS[1])\n" +
+            "else\n" +
+            "    return 0\n" +
+            "end";
 
     /**
      * 加锁,自旋重试三次
@@ -55,7 +54,8 @@ public class RedisUtil {
      * @param redisLockEntity
      * @return
      */
-    public boolean unlock(String lockKey, Long threadId) {
+    public boolean unlock(String lockKey) {
+        Long threadId = Thread.currentThread().getId();
         if (StrUtil.isEmpty(lockKey) || Objects.isNull(threadId))
             return false;
         boolean releaseLock = false;
@@ -72,7 +72,8 @@ public class RedisUtil {
      * @param
      * @return
      */
-    public boolean unlockLua(String lockKey, Long threadId) {
+    public boolean unlockLua(String lockKey) {
+        Long threadId = Thread.currentThread().getId();
         if (StrUtil.isEmpty(lockKey) || Objects.isNull(threadId))
             return false;
         DefaultRedisScript<Long> redisScript = new DefaultRedisScript();

+ 530 - 0
4dkankan-common-redis/src/main/java/com/fdkankan/redis/util/RedisUtil.java

@@ -0,0 +1,530 @@
+package com.fdkankan.redis.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+@Component
+@Slf4j
+public class RedisUtil<K, V> {
+
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+    /**
+     * 指定缓存失效时间
+     *
+     * @param key  键
+     * @param time 时间(秒)
+     * @return
+     */
+    public boolean expire(String key, long time) {
+        try {
+            if (time > 0) {
+                redisTemplate.expire(key, time, TimeUnit.SECONDS);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 根据key 获取过期时间
+     *
+     * @param key 键 不能为null
+     * @return 时间(秒) 返回0代表为永久有效
+     */
+    public long getExpire(String key) {
+        return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+    }
+    /**
+     * 判断key是否存在
+     *
+     * @param key 键
+     * @return true 存在 false不存在
+     */
+    public boolean hasKey(String key) {
+        try {
+            return redisTemplate.hasKey(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 删除缓存
+     *
+     * @param key 可以传一个值 或多个
+     */
+    @SuppressWarnings("unchecked")
+    public void del(String... key) {
+        if (key != null && key.length > 0) {
+            if (key.length == 1) {
+                redisTemplate.delete(key[0]);
+            } else {
+                redisTemplate.delete(CollectionUtils.arrayToList(key));
+            }
+        }
+    }
+    // ============================String=============================
+    /**
+     * 普通缓存获取
+     *
+     * @param key 键
+     * @return 值
+     */
+    public Object get(String key) {
+        return key == null ? null : redisTemplate.opsForValue().get(key);
+    }
+    /**
+     * 普通缓存放入
+     *
+     * @param key   键
+     * @param value 值
+     * @return true成功 false失败
+     */
+    public boolean set(String key, Object value) {
+        try {
+            redisTemplate.opsForValue().set(key, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 普通缓存放入并设置时间
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒) time要大于0 如果time小于等于0 将设置无限期
+     * @return true成功 false 失败
+     */
+    public boolean set(String key, Object value, long time) {
+        try {
+            if (time > 0) {
+                redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
+            } else {
+                set(key, value);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 递增
+     *
+     * @param key   键
+     * @param delta 要增加几(大于0)
+     * @return
+     */
+    public long incr(String key, long delta) {
+        if (delta < 0) {
+            throw new RuntimeException("递增因子必须大于0");
+        }
+        return redisTemplate.opsForValue().increment(key, delta);
+    }
+    /**
+     * 递减
+     *
+     * @param key   键
+     * @param delta 要减少几(小于0)
+     * @return
+     */
+    public long decr(String key, long delta) {
+        if (delta < 0) {
+            throw new RuntimeException("递减因子必须大于0");
+        }
+        return redisTemplate.opsForValue().increment(key, -delta);
+    }
+    // ================================Map=================================
+    /**
+     * HashGet
+     *
+     * @param key  键 不能为null
+     * @param item 项 不能为null
+     * @return 值
+     */
+    public Object hget(String key, String item) {
+        return redisTemplate.opsForHash().get(key, item);
+    }
+    /**
+     * 获取hashKey对应的所有键值
+     *
+     * @param key 键
+     * @return 对应的多个键值
+     */
+    public Map<Object, Object> hmget(String key) {
+        return redisTemplate.opsForHash().entries(key);
+    }
+    /**
+     * HashSet
+     *
+     * @param key 键
+     * @param map 对应多个键值
+     * @return true 成功 false 失败
+     */
+    public boolean hmset(String key, Map<String, Object> map) {
+        try {
+            redisTemplate.opsForHash().putAll(key, map);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * HashSet 并设置时间
+     *
+     * @param key  键
+     * @param map  对应多个键值
+     * @param time 时间(秒)
+     * @return true成功 false失败
+     */
+    public boolean hmset(String key, Map<String, Object> map, long time) {
+        try {
+            redisTemplate.opsForHash().putAll(key, map);
+            if (time > 0) {
+                expire(key, time);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 向一张hash表中放入数据,如果不存在将创建
+     *
+     * @param key   键
+     * @param item  项
+     * @param value 值
+     * @return true 成功 false失败
+     */
+    public boolean hset(String key, String item, Object value) {
+        try {
+            redisTemplate.opsForHash().put(key, item, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 向一张hash表中放入数据,如果不存在将创建
+     *
+     * @param key   键
+     * @param item  项
+     * @param value 值
+     * @param time  时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
+     * @return true 成功 false失败
+     */
+    public boolean hset(String key, String item, Object value, long time) {
+        try {
+            redisTemplate.opsForHash().put(key, item, value);
+            if (time > 0) {
+                expire(key, time);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 删除hash表中的值
+     *
+     * @param key  键 不能为null
+     * @param item 项 可以使多个 不能为null
+     */
+    public void hdel(String key, Object... item) {
+        redisTemplate.opsForHash().delete(key, item);
+    }
+    /**
+     * 判断hash表中是否有该项的值
+     *
+     * @param key  键 不能为null
+     * @param item 项 不能为null
+     * @return true 存在 false不存在
+     */
+    public boolean hHasKey(String key, String item) {
+        return redisTemplate.opsForHash().hasKey(key, item);
+    }
+    /**
+     * hash递增 如果不存在,就会创建一个 并把新增后的值返回
+     *
+     * @param key  键
+     * @param item 项
+     * @param by   要增加几(大于0)
+     * @return
+     */
+    public double hincr(String key, String item, double by) {
+        return redisTemplate.opsForHash().increment(key, item, by);
+    }
+    /**
+     * hash递减
+     *
+     * @param key  键
+     * @param item 项
+     * @param by   要减少记(小于0)
+     * @return
+     */
+    public double hdecr(String key, String item, double by) {
+        return redisTemplate.opsForHash().increment(key, item, -by);
+    }
+    // ============================set=============================
+    /**
+     * 根据key获取Set中的所有值
+     *
+     * @param key 键
+     * @return
+     */
+    public Set<Object> sGet(String key) {
+        try {
+            return redisTemplate.opsForSet().members(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+    /**
+     * 根据value从一个set中查询,是否存在
+     *
+     * @param key   键
+     * @param value 值
+     * @return true 存在 false不存在
+     */
+    public boolean sHasKey(String key, Object value) {
+        try {
+            return redisTemplate.opsForSet().isMember(key, value);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 将数据放入set缓存
+     *
+     * @param key    键
+     * @param values 值 可以是多个
+     * @return 成功个数
+     */
+    public long sSet(String key, Object... values) {
+        try {
+            return redisTemplate.opsForSet().add(key, values);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+    /**
+     * 将set数据放入缓存
+     *
+     * @param key    键
+     * @param time   时间(秒)
+     * @param values 值 可以是多个
+     * @return 成功个数
+     */
+    public long sSet(String key, long time, Object... values) {
+        try {
+            Long count = redisTemplate.opsForSet().add(key, values);
+            if (time > 0)
+                expire(key, time);
+            return count;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+    /**
+     * 获取set缓存的长度
+     *
+     * @param key 键
+     * @return
+     */
+    public long sGetSize(String key) {
+        try {
+            return redisTemplate.opsForSet().size(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+    /**
+     * 移除值为value的
+     *
+     * @param key    键
+     * @param values 值 可以是多个
+     * @return 移除的个数
+     */
+    public long setRemove(String key, Object... values) {
+        try {
+            Long count = redisTemplate.opsForSet().remove(key, values);
+            return count;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+    // ===============================list=================================
+    /**
+     * 获取list缓存的内容
+     *
+     * @param key   键
+     * @param start 开始
+     * @param end   结束 0 到 -1代表所有值
+     * @return
+     */
+    public List<Object> lGet(String key, long start, long end) {
+        try {
+            List<Object> range = redisTemplate.opsForList().range(key, start, end);
+            return range;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+    /**
+     * 获取list缓存的长度
+     *
+     * @param key 键
+     * @return
+     */
+    public long lGetSize(String key) {
+        try {
+            return redisTemplate.opsForList().size(key);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+    /**
+     * 通过索引 获取list中的值
+     *
+     * @param key   键
+     * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
+     * @return
+     */
+    public Object lGetIndex(String key, long index) {
+        try {
+            return redisTemplate.opsForList().index(key, index);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+    /**
+     * 将list放入缓存
+     * @param key   键
+     * @param value 值
+     * @return
+     */
+    public boolean lRightPush(String key, Object value) {
+        try {
+            redisTemplate.opsForList().rightPush(key, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒)
+     * @return
+     */
+    public boolean lRightPush(String key, Object value, long time) {
+        try {
+            redisTemplate.opsForList().rightPush(key, value);
+            if (time > 0)
+                expire(key, time);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @return
+     */
+    public boolean lRightPushAll(String key, List<Object> value) {
+        try {
+            redisTemplate.opsForList().rightPushAll(key, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒)
+     * @return
+     */
+    public boolean lRightPushAll(String key, List<Object> value, long time) {
+        try {
+            redisTemplate.opsForList().rightPushAll(key, value);
+            if (time > 0)
+                expire(key, time);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 根据索引修改list中的某条数据
+     *
+     * @param key   键
+     * @param index 索引
+     * @param value 值
+     * @return
+     */
+    public boolean lUpdateByIndex(String key, long index, Object value) {
+        try {
+            redisTemplate.opsForList().set(key, index, value);
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+    /**
+     * 移除N个值为value
+     *
+     * @param key   键
+     * @param count 移除多少个
+     * @param value 值
+     * @return 移除的个数
+     */
+    public long lRemove(String key, long count, Object value) {
+        try {
+            Long remove = redisTemplate.opsForList().remove(key, count, value);
+            return remove;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 0;
+        }
+    }
+}

+ 0 - 24
4dkankan-common/src/main/java/com/fdkankan/common/config/RedisConfig.java

@@ -1,24 +0,0 @@
-package com.fdkankan.common.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-@Configuration
-public class RedisConfig {
-
-    @Bean
-    public RedisTemplate<String,String> redisTemplate(RedisConnectionFactory factory){
-        RedisTemplate<String,String>template=new RedisTemplate<>();
-        //关联
-        template.setConnectionFactory(factory);
-        //设置key的序列化器
-        template.setKeySerializer(new StringRedisSerializer());
-        //设置value的序列化器
-        template.setValueSerializer(new StringRedisSerializer());
-        return template;
-    }
-
-}

+ 1 - 0
4dkankan-common/src/main/java/com/fdkankan/common/constant/ErrorCode.java

@@ -6,6 +6,7 @@ public enum ErrorCode {
     PARAM_ERROR(-2, "解析请求参数出错"),
     PARAM_REQUIRED(-3, "缺少必要参数"),
     PARAM_FORMAT_ERROR(-4, "解析请求参数出错"),
+    SYSTEM_BUSY(-5, "系统繁忙,请稍后再试!"),
     AUTH_FAIL(4000, "鉴权失败!"),
     NON_TOKEN(4001, "无token,请重新登录"),
     TOKEN_ILLEGAL(4002, "token不合法"),

+ 13 - 2
4dkankan-common/src/main/java/com/fdkankan/common/constant/RedisKey.java

@@ -3,9 +3,9 @@ package com.fdkankan.common.constant;
 public class RedisKey {
 
     /**
-     * 过期时间:2小时
+     * 过期时间:1分钟
      */
-    public static int EXPIRE_TIME_2_HOUR = 2*60*60*1000;
+    public static int EXPIRE_TIME_1_MINUTE = 1*60*1000;
 
     /**
      * 过期时间:10分钟
@@ -18,6 +18,13 @@ public class RedisKey {
     public static int EXPIRE_TIME_30_MINUTE = 30*60*1000;
 
     /**
+     * 过期时间:2小时
+     */
+    public static int EXPIRE_TIME_2_HOUR = 2*60*60*1000;
+
+
+
+    /**
      * 登录token
      */
     public static String TOKEN_USER_TYPE = "token:user:type:%s:%s";
@@ -31,6 +38,10 @@ public class RedisKey {
      * 场景浏览量
      */
     public static String SCENE_VISIT_CNT = "scene:visit:cnt:scenecode:%s";
+    /**
+     * 场景浏览量
+     */
+    public static String LOCK_SCENE_VISIT_CNT = "lock:scene:visit:cnt:scenecode:%s";
 
     /**
      * 场景访问量更新锁 hash

+ 4 - 1
4dkankan-gateway/src/main/java/com/fdkankan/gateway/filter/AccessLogFilter.java

@@ -37,6 +37,7 @@ import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
 import java.nio.charset.StandardCharsets;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -205,12 +206,13 @@ public class AccessLogFilter  implements GlobalFilter, Ordered {
     private ServerHttpResponseDecorator recordResponseLog(ServerWebExchange exchange, GatewayLog gatewayLog) {
         ServerHttpResponse response = exchange.getResponse();
         DataBufferFactory bufferFactory = response.bufferFactory();
+
         return new ServerHttpResponseDecorator(response) {
 
             @Override
             public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
                 if (body instanceof Flux) {
-                        Date responseTime = new Date();
+                    Date responseTime = Calendar.getInstance().getTime();
                     gatewayLog.setResponseTime(responseTime);
                     // 计算执行时间
                     long executeTime = (responseTime.getTime() - gatewayLog.getRequestTime().getTime());
@@ -239,6 +241,7 @@ public class AccessLogFilter  implements GlobalFilter, Ordered {
 
                             gatewayLog.setResponseData(responseResult);
 
+
                             return bufferFactory.wrap(content);
                         }));
                     }