dengsixing преди 1 година
родител
ревизия
a00a7a432b

+ 12 - 12
pom.xml

@@ -46,11 +46,11 @@
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-redis</artifactId>
-            <version>2.3.12.RELEASE</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-data-redis</artifactId>-->
+<!--            <version>2.3.12.RELEASE</version>-->
+<!--        </dependency>-->
 
         <dependency>
             <groupId>org.apache.commons</groupId>
@@ -78,13 +78,6 @@
             <version>1.5.1</version>
         </dependency>
 
-        <!--        htt请求工具-->
-        <dependency>
-            <groupId>com.dtflys.forest</groupId>
-            <artifactId>forest-spring-boot-starter</artifactId>
-            <version>1.5.19</version>
-        </dependency>
-
         <dependency>
             <groupId>com.google.firebase</groupId>
             <artifactId>firebase-admin</artifactId>
@@ -122,6 +115,13 @@
             <version>3.0.6.0</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.dtflys.forest</groupId>
+            <artifactId>forest-spring-boot-starter</artifactId>
+            <version>1.5.36</version>
+        </dependency>
+
+
     </dependencies>
 
 

+ 2 - 0
src/main/java/com/fdkankan/SceneApplication.java

@@ -1,5 +1,6 @@
 package com.fdkankan;
 
+import com.dtflys.forest.springboot.annotation.ForestScan;
 import com.yomahub.tlog.core.enhance.bytes.AspectLogEnhance;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
@@ -13,6 +14,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @EnableFeignClients
 @EnableScheduling
 @MapperScan("com.fdkankan.**.mapper")
+@ForestScan("com.fdkankan.scene.httpclient")
 public class SceneApplication {
 
     static {

+ 0 - 44
src/main/java/com/fdkankan/redis/config/RedisConfig.java

@@ -1,44 +0,0 @@
-package com.fdkankan.redis.config;
-
-
-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.core.RedisTemplate;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-@Configuration
-@AutoConfigureAfter(RedisAutoConfiguration.class)
-public class RedisConfig {
-
-    @Bean
-    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
-        RedisTemplate template = new RedisTemplate();
-        template.setConnectionFactory(redisConnectionFactory);
-        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
-
-        template.setKeySerializer(stringRedisSerializer);
-        template.setValueSerializer(stringRedisSerializer);
-        template.setHashKeySerializer(stringRedisSerializer);
-        template.setHashValueSerializer(stringRedisSerializer);
-
-        template.afterPropertiesSet();
-        return template;
-    }
-
-    /**
-     * 由于v4场景中心要获取v3的登录用户信息,而v3的jedis使用的是默认的jdk序列化器,所以这里提供了一个特殊的redistemplate,v3废弃后需要删除
-     * @param redisConnectionFactory
-     * @return
-     */
-    @Bean
-    public RedisTemplate<String, Object> redisTemplate2(RedisConnectionFactory redisConnectionFactory) {
-        RedisTemplate template = new RedisTemplate();
-        template.setConnectionFactory(redisConnectionFactory);
-        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
-        template.setKeySerializer(stringRedisSerializer);
-        return template;
-    }
-}

+ 59 - 0
src/main/java/com/fdkankan/redis/util/RedisClient.java

@@ -0,0 +1,59 @@
+package com.fdkankan.redis.util;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.scene.httpclient.CustomHttpClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+@Component
+public class RedisClient {
+
+    public final static String url_str_add = "/redis/string/add/";
+
+    public final static String url_str_get = "/redis/string/get/";
+
+    @Value("${redis.host}")
+    private String host;
+
+    @Value("${tieta.sysCode}")
+    private String sysCode;
+
+    @Value("${tieta.serverName}")
+    private String serverName;
+
+    @Resource
+    private CustomHttpClient customHttpClient;
+
+     public void add(String key, String value){
+         String url = host + url_str_add;
+         Map<String, Object> params = new HashMap<>();
+         params.put("key", this.genKey(key));
+         params.put("value", value);
+         JSONObject jsonObject = customHttpClient.postJson(url, params);
+         if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString("status"))){
+             throw new RuntimeException("redis add string error");
+         }
+     }
+
+    public String get(String key){
+        String url = host + url_str_get;
+        Map<String, Object> params = new HashMap<>();
+        params.put("key", this.genKey(key));
+        JSONObject jsonObject = customHttpClient.postJson(url, params);
+        if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString("status"))){
+            throw new RuntimeException("redis get string error");
+        }
+        return jsonObject.getString("data");
+    }
+
+    private String genKey(String key){
+         return sysCode + "_" + serverName + "_" + key;
+    }
+}
+

+ 0 - 145
src/main/java/com/fdkankan/redis/util/RedisLockUtil.java

@@ -1,145 +0,0 @@
-package com.fdkankan.redis.util;
-
-import cn.hutool.core.lang.UUID;
-import cn.hutool.core.util.StrUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-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.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
-@Component
-@Slf4j
-public class RedisLockUtil {
-
-    private ConcurrentHashMap<String, String> THREADID_LOCKVAL_MAP = new ConcurrentHashMap<>();
-
-    @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";
-
-    /**
-     * 加锁,自旋重试三次
-     * 默认以线程id作为锁的值
-     *
-     * @param lockKey 锁key
-     * @param expireTime 锁过期时间 单位 毫秒
-     * @return
-     */
-    public boolean lock(String lockKey, int expireTime) {
-        return this.lock(lockKey, null, expireTime);
-    }
-
-    /**
-     * 加锁,自旋重试三次
-     * @param lockKey 锁key
-     * @param lockVal 锁value
-     * @param expireTime 锁过期时间 单位 毫秒
-     * @return
-     */
-    public boolean lock(String lockKey, String lockVal, int expireTime) {
-        boolean locked = false;
-        int tryCount = 3;
-        String threadId = null;
-        String uuid = null;
-        if(lockVal == null){
-            threadId = String.valueOf(Thread.currentThread().getId());
-            uuid = UUID.randomUUID().toString();
-            lockVal = uuid + ":" + threadId;
-            log.info("加锁lockval:{}",lockVal);
-        }
-        while (tryCount > 0) {
-            locked = redisTemplate.opsForValue().setIfAbsent(lockKey, lockVal, expireTime, TimeUnit.SECONDS);
-            if(locked){
-                if(threadId != null){
-                    THREADID_LOCKVAL_MAP.put(threadId, lockVal);
-                }
-                return locked;
-            }
-            tryCount--;
-            try {
-                Thread.sleep(300);
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-        }
-        return locked;
-    }
-
-    /**
-     * 非原子解锁,可能解别人锁,不安全
-     *
-     * @return
-     */
-    public boolean unlock(String lockKey) {
-        return this.unlock(lockKey, null);
-    }
-
-    /**
-     * 非原子解锁,可能解别人锁,不安全
-     *
-     * @return
-     */
-    public boolean unlock(String lockKey, String lockVal) {
-        if(lockVal == null){
-            String threadId = String.valueOf(Thread.currentThread().getId());
-            lockVal = THREADID_LOCKVAL_MAP.get(threadId);
-        }
-        if (StrUtil.isEmpty(lockKey) || Objects.isNull(lockVal))
-            return false;
-        boolean releaseLock = false;
-        String val = (String) redisTemplate.opsForValue().get(lockKey);
-        if (lockVal.equals(val)) {
-            releaseLock = redisTemplate.delete(lockKey);
-        }
-        return releaseLock;
-    }
-
-    /**
-     * 使用lua脚本解锁,不会解除别人锁
-     *
-     * @param
-     * @return
-     */
-    public boolean unlockLua(String lockKey) {
-        return this.unlockLua(lockKey, null);
-    }
-
-    /**
-     * 使用lua脚本解锁,不会解除别人锁
-     *
-     * @param
-     * @return
-     */
-    public boolean unlockLua(String lockKey, String lockVal) {
-        if(lockVal == null){
-            String threadId = String.valueOf(Thread.currentThread().getId());
-            lockVal = THREADID_LOCKVAL_MAP.get(threadId);
-        }
-        log.info("解锁lockval:{}",lockVal);
-        if (StrUtil.isEmpty(lockKey) || Objects.isNull(lockVal))
-            return false;
-        DefaultRedisScript<Long> redisScript = new DefaultRedisScript();
-        redisScript.setScriptText(UNLOCK_LUA);
-        redisScript.setResultType(Long.class);
-
-        Object result = redisTemplate.execute(redisScript, Arrays.asList(lockKey), lockVal);
-        return result.equals(Long.valueOf(1));
-    }
-
-
-
-
-
-}

+ 0 - 498
src/main/java/com/fdkankan/redis/util/RedisUtil.java

@@ -1,498 +0,0 @@
-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.time.Duration;
-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) {
-        if (time > 0) {
-            redisTemplate.expire(key, time, TimeUnit.SECONDS);
-        }
-        return true;
-    }
-    /**
-     * 根据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) {
-        return redisTemplate.hasKey(key);
-    }
-    /**
-     * 删除缓存
-     *
-     * @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 String get(String key) {
-        return key == null ? null : (String) redisTemplate.opsForValue().get(key);
-    }
-    /**
-     * 普通缓存放入
-     *
-     * @param key   键
-     * @param value 值
-     * @return true成功 false失败
-     */
-    public boolean set(String key, String value) {
-        redisTemplate.opsForValue().set(key, value);
-        return true;
-    }
-    /**
-     * 普通缓存放入并设置时间
-     *
-     * @param key   键
-     * @param value 值
-     * @param time  时间(秒) time要大于0 如果time小于等于0 将设置无限期
-     * @return true成功 false 失败
-     */
-    public boolean set(String key, String value, long time) {
-        if (time > 0) {
-            redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
-        } else {
-            set(key, value);
-        }
-        return true;
-    }
-    /**
-     * 递增
-     *
-     * @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 String hget(String key, String item) {
-        return (String)redisTemplate.opsForHash().get(key, item);
-    }
-
-    /**
-     * HashGet
-     *
-     * @param key  键 不能为null
-     * @return 值
-     */
-    public List<String> hgetValues(String key) {
-        return redisTemplate.opsForHash().values(key);
-    }
-    /**
-     * 获取hashKey对应的所有键值
-     *
-     * @param key 键
-     * @return 对应的多个键值
-     */
-    public Map<String, String> hmget(String key) {
-        return redisTemplate.opsForHash().entries(key);
-    }
-
-
-    /**
-     * <p>
-            查询指定key中匹配多项
-     * </p>
-     * @author dengsixing
-     * @date 2022/2/8
-     * @param key
-     * @param items
-     * @return java.util.List<java.lang.String>
-     **/
-    public List<String> hMultiGet(String key, List<String> items) {
-        return redisTemplate.opsForHash().multiGet(key, items);
-    }
-
-    /**
-     * HashSet
-     *
-     * @param key 键
-     * @param map 对应多个键值
-     * @return true 成功 false 失败
-     */
-    public boolean hmset(String key, Map<String, Object> map) {
-        redisTemplate.opsForHash().putAll(key, map);
-        return true;
-    }
-    /**
-     * HashSet 并设置时间
-     *
-     * @param key  键
-     * @param map  对应多个键值
-     * @param time 时间(秒)
-     * @return true成功 false失败
-     */
-    public boolean hmset(String key, Map<String, Object> map, long time) {
-        redisTemplate.opsForHash().putAll(key, map);
-        if (time > 0) {
-            expire(key, time);
-        }
-        return true;
-    }
-    /**
-     * 向一张hash表中放入数据,如果不存在将创建
-     *
-     * @param key   键
-     * @param item  项
-     * @param value 值
-     * @return true 成功 false失败
-     */
-    public boolean hset(String key, String item, Object value) {
-        redisTemplate.opsForHash().put(key, item, value);
-        return true;
-    }
-    /**
-     * 向一张hash表中放入数据,如果不存在将创建
-     *
-     * @param key   键
-     * @param item  项
-     * @param value 值
-     * @param time  时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
-     * @return true 成功 false失败
-     */
-    public boolean hset(String key, String item, Object value, long time) {
-        redisTemplate.opsForHash().put(key, item, value);
-        if (time > 0) {
-            expire(key, time);
-        }
-        return true;
-    }
-    /**
-     * 删除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) {
-        return redisTemplate.opsForSet().members(key);
-    }
-    /**
-     * 根据value从一个set中查询,是否存在
-     *
-     * @param key   键
-     * @param value 值
-     * @return true 存在 false不存在
-     */
-    public boolean sHasKey(String key, Object value) {
-        return redisTemplate.opsForSet().isMember(key, value);
-    }
-    /**
-     * 将数据放入set缓存
-     *
-     * @param key    键
-     * @param values 值 可以是多个
-     * @return 成功个数
-     */
-    public long sSet(String key, Object... values) {
-        return redisTemplate.opsForSet().add(key, values);
-    }
-    /**
-     * 将set数据放入缓存
-     *
-     * @param key    键
-     * @param time   时间(秒)
-     * @param values 值 可以是多个
-     * @return 成功个数
-     */
-    public long sSet(String key, long time, Object... values) {
-        Long count = redisTemplate.opsForSet().add(key, values);
-        if (time > 0)
-            expire(key, time);
-        return count;
-    }
-    /**
-     * 获取set缓存的长度
-     *
-     * @param key 键
-     * @return
-     */
-    public long sGetSize(String key) {
-        return redisTemplate.opsForSet().size(key);
-    }
-
-    /**
-     * 获取set缓存的长度
-     *
-     * @param key 键
-     * @return
-     */
-    public boolean sExists(String key, Object value) {
-        return redisTemplate.opsForSet().isMember(key, value);
-    }
-
-    /**
-     * 移除值为value的
-     *
-     * @param key    键
-     * @param values 值 可以是多个
-     * @return 移除的个数
-     */
-    public long setRemove(String key, Object... values) {
-        return redisTemplate.opsForSet().remove(key, values);
-    }
-    // ===============================list=================================
-    /**
-     * 获取list缓存的内容
-     *
-     * @param key   键
-     * @param start 开始
-     * @param end   结束 0 到 -1代表所有值
-     * @return
-     */
-    public List<Object> lGet(String key, long start, long end) {
-        return redisTemplate.opsForList().range(key, start, end);
-    }
-    /**
-     * 获取list缓存的长度
-     *
-     * @param key 键
-     * @return
-     */
-    public long lGetSize(String key) {
-        return redisTemplate.opsForList().size(key);
-    }
-    /**
-     * 通过索引 获取list中的值
-     *
-     * @param key   键
-     * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
-     * @return
-     */
-    public Object lGetIndex(String key, long index) {
-        return redisTemplate.opsForList().index(key, index);
-    }
-    /**
-     * 将list放入缓存
-     * @param key   键
-     * @param value 值
-     * @return
-     */
-    public boolean lRightPush(String key, Object value) {
-        redisTemplate.opsForList().rightPush(key, value);
-        return true;
-    }
-    /**
-     * 将list放入缓存
-     *
-     * @param key   键
-     * @param value 值
-     * @param time  时间(秒)
-     * @return
-     */
-    public boolean lRightPush(String key, Object value, long time) {
-        redisTemplate.opsForList().rightPush(key, value);
-        if (time > 0)
-            expire(key, time);
-        return true;
-    }
-    /**
-     * 将list放入缓存
-     *
-     * @param key   键
-     * @param value 值
-     * @return
-     */
-    public boolean lRightPushAll(String key, List<Object> value) {
-        redisTemplate.opsForList().rightPushAll(key, value);
-        return true;
-    }
-
-    /**
-     * 将list放入缓存
-     *
-     * @param key   键
-     * @param value 值
-     * @param time  时间(秒)
-     * @return
-     */
-    public boolean lRightPushAll(String key, List<Object> value, long time) {
-        redisTemplate.opsForList().rightPushAll(key, value);
-        if (time > 0)
-            expire(key, time);
-        return true;
-    }
-
-    /**
-     * 将list放入缓存
-     *
-     * @param key   键
-     * @param value 值
-     * @return
-     */
-    public boolean lLeftPushAll(String key, List<Object> value) {
-        redisTemplate.opsForList().leftPushAll(key, value);
-        return true;
-    }
-
-    /**
-     * 将list放入缓存
-     *
-     * @param key   键
-     * @param value 值
-     * @return
-     */
-    public boolean lLeftPush(String key, String value) {
-        redisTemplate.opsForList().leftPush(key, value);
-        return true;
-    }
-
-    /**
-     *
-     * @param key   键
-     * @return
-     */
-    public String lLeftPop(String key) {
-        return (String)redisTemplate.opsForList().leftPop(key);
-    }
-
-    /**
-     * 根据索引修改list中的某条数据
-     *
-     * @param key   键
-     * @param index 索引
-     * @param value 值
-     * @return
-     */
-    public boolean lUpdateByIndex(String key, long index, Object value) {
-        redisTemplate.opsForList().set(key, index, value);
-        return true;
-    }
-    /**
-     * 移除N个值为value
-     *
-     * @param key   键
-     * @param count 移除多少个
-     * @param value 值
-     * @return 移除的个数
-     */
-    public long lRemove(String key, long count, Object value) {
-        return redisTemplate.opsForList().remove(key, count, value);
-    }
-
-    /**
-     * 移除N个值为value
-     *
-     * @param pattern   键
-     * @return 移除的个数
-     */
-    public Set<String> keys(String pattern) {
-        return redisTemplate.keys(pattern);
-    }
-
-    public void expire(String key,Duration time){
-        redisTemplate.expire(key, time);
-    }
-}

+ 15 - 0
src/main/java/com/fdkankan/scene/httpclient/CustomHttpClient.java

@@ -0,0 +1,15 @@
+package com.fdkankan.scene.httpclient;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.dtflys.forest.annotation.JSONBody;
+import com.dtflys.forest.annotation.Post;
+import com.dtflys.forest.annotation.Var;
+
+public interface CustomHttpClient {
+
+    @Post("{url}")
+    JSONObject postJson(@Var("url") String url, @JSONBody Object object);
+
+
+}

+ 6 - 6
src/main/java/com/fdkankan/scene/service/impl/SceneServiceImpl.java

@@ -1,12 +1,13 @@
 package com.fdkankan.scene.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.feign.TietaFeignClient;
 import com.fdkankan.redis.constant.RedisKey;
-import com.fdkankan.redis.util.RedisUtil;
+import com.fdkankan.redis.util.RedisClient;
 import com.fdkankan.scene.bean.ResultData;
 import com.fdkankan.scene.entity.Scene;
 import com.fdkankan.scene.entity.SceneFileMapping;
@@ -45,7 +46,7 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
     @Autowired
     private SceneFileMappingService sceneFileMappingService;
     @Autowired
-    private RedisUtil redisUtil;
+    private RedisClient redisClient;
     @Resource
     private TietaFeignClient tietaFeignClient;
 
@@ -69,9 +70,8 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
         String num = param.getNum();
         SceneInfoVO sceneInfoVO = null;
         String key = String.format(RedisKey.SCENE_JSON, num);
-        boolean hasKey = redisUtil.hasKey(key);
-        if(hasKey){
-            String sceneJson = redisUtil.get(key);
+        String sceneJson = redisClient.get(key);
+        if(StrUtil.isNotEmpty(sceneJson)){
             sceneInfoVO = JSON.parseObject(sceneJson, SceneInfoVO.class);
             sceneInfoVO.getControls().setShowRule(1);
             sceneInfoVO.getControls().setShowFloorplan(0);
@@ -92,7 +92,7 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
             SceneEditControlsVO sceneEditControlsBean = SceneEditControlsVO.builder().showRule(1).showFloorplan(0).showDollhouse(0).showMap(1).showPanorama(1).showVR(1).showTitle(1).build();
             sceneInfoVO.setControls(sceneEditControlsBean);
 
-            redisUtil.set(key, JSON.toJSONString(sceneInfoVO));
+            redisClient.add(key, JSON.toJSONString(sceneInfoVO));
         }
 
         List<SceneFileMapping> mappingList = sceneFileMappingService.list(new LambdaQueryWrapper<SceneFileMapping>().eq(SceneFileMapping::getNum, num));

+ 18 - 10
src/main/resources/application-test.yml

@@ -1,25 +1,27 @@
 spring:
   application:
-    name: chntzcgl-vr
+    name: chntzcgl-zcszhgl-vr
     syscode: CT00017
   cloud:
     nacos:
       discovery:
         server-addr: 10.190.26.194:8848
-        access-key: 852c563e9199f718d0dc25f6c2acd7d6
+        access-key: 84f0bbec3a6e3ebf0c694462febce169
+#        server-addr: 10.180.22.20:8848
+#        access-key: b4eb646cfa43a3e748d7b81d718d795f
   datasource:
     url: jdbc:oracle:thin:@//10.180.41.39:1521/resdb
     username: RES_VR
     password: IDCqawsed@123.
     driver-class-name: oracle.jdbc.OracleDriver
-  redis:
-    timeout: 6000ms
-    password: Qwt@1620b!v
-    cluster:
-     nodes:
-       - 10.190.22.98:7001
-       - 10.190.22.99:7001
-       - 10.190.22.100:7001
+#  redis:
+#    timeout: 6000ms
+#    password: Qwt@1620b!v
+#    cluster:
+#     nodes:
+#       - 10.190.22.98:7001
+#       - 10.190.22.99:7001
+#       - 10.190.22.100:7001
 
 fyun:
   type: local
@@ -31,9 +33,14 @@ fyun:
   host: /oss/
 
 tieta:
+  sysCode: CT00017
+  serverName: scene
   checkToken:
     syscode: CHNTRMS2
 
+redis:
+  host: http://10.190.22.99:8081
+
 tlog:
   enable-invoke-time-print: true
 
@@ -42,3 +49,4 @@ tlog:
 
 
 
+