dengsixing 1 anno fa
parent
commit
f819097cd8

+ 12 - 5
pom.xml

@@ -118,11 +118,11 @@
       <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.springframework.boot</groupId>-->
+<!--      <artifactId>spring-boot-starter-data-redis</artifactId>-->
+<!--      <version>2.3.12.RELEASE</version>-->
+<!--    </dependency>-->
 
     <dependency>
       <groupId>org.apache.commons</groupId>
@@ -133,6 +133,13 @@
       <artifactId>commons-pool2</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>com.dtflys.forest</groupId>
+      <artifactId>forest-spring-boot-starter</artifactId>
+      <version>1.5.36</version>
+    </dependency>
+
+
   </dependencies>
 
   <build>

+ 3 - 1
src/main/java/com/fdkankan/Application.java

@@ -1,5 +1,6 @@
 package com.fdkankan;
 
+import com.dtflys.forest.springboot.annotation.ForestScan;
 import com.fdkankan.project.tieta.service.IConvertService;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,6 +16,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @EnableScheduling
 @EnableAsync
 @MapperScan("com.fdkankan.project.tieta.mapper")
+@ForestScan("com.fdkankan.project.tieta.httpclient")
 public class Application implements CommandLineRunner {
 
     @Autowired
@@ -26,7 +28,7 @@ public class Application implements CommandLineRunner {
 
     @Override
     public void run(String... args) throws Exception {
-        convertService.scenePushHistory();
+//        convertService.scenePushHistory();
     }
 }
 

+ 1 - 1
src/main/java/com/fdkankan/project/tieta/constant/Constant.java

@@ -4,6 +4,6 @@ public class Constant {
 
     public static final String QUEUE_SCENE_CONVERT = "queue-scene-convert";
 
-    public static final String REDIS_SCENE_CONVERT_HISTORY = "scene:convert:history";
+    public static final String REDIS_SCENE_CONVERT_HISTORY = "scene:convert:history:%s";
 
 }

+ 22 - 7
src/main/java/com/fdkankan/project/tieta/controller/ConvertController.java

@@ -1,25 +1,28 @@
 package com.fdkankan.project.tieta.controller;
 
-import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.project.tieta.bean.ResultData;
 import com.fdkankan.project.tieta.constant.Constant;
-import com.fdkankan.project.tieta.dto.SendConvertDTO;
 import com.fdkankan.project.tieta.dto.ScenePushDTO;
+import com.fdkankan.project.tieta.dto.SendConvertDTO;
 import com.fdkankan.project.tieta.entity.FullphotoFileindex;
 import com.fdkankan.project.tieta.service.FullphotoFileindexService;
 import com.fdkankan.project.tieta.service.IConvertService;
 import com.fdkankan.project.tieta.utils.FdfsUtil;
-import com.fdkankan.redis.util.RedisUtil;
+import com.fdkankan.redis.util.RedisClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import java.io.File;
-import java.util.*;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 @RestController
 @RequestMapping("/convert")
@@ -27,8 +30,8 @@ public class ConvertController {
 
     @Autowired
     private IConvertService convertService;
-    @Autowired
-    private RedisUtil redisUtil;
+    @Resource
+    private RedisClient redisClient;
 
     @PostMapping("/sendConvert")
     public ResultData sendConvert(@RequestBody @Validated SendConvertDTO dto){
@@ -69,11 +72,23 @@ public class ConvertController {
 
     @GetMapping("/deleteRedisKey")
     public ResultData deleteRedisKey(){
-        redisUtil.del(Constant.REDIS_SCENE_CONVERT_HISTORY);
         return ResultData.ok();
 
     }
 
+    @GetMapping("/redisStringAdd")
+    public ResultData redisStringAdd(){
+        redisClient.add("123123_123123_test", "123123123");
+        return ResultData.ok();
+
+    }
+
+    @GetMapping("/redisStringGet")
+    public ResultData redisStringGet(){
+        return ResultData.ok(redisClient.get("123123_123123_test"));
+
+    }
+
     @GetMapping("/pushDemo")
     public ResultData pushDemo(){
         String path  = "D:\\test\\tieta\\50个全景制品数据包\\";

+ 16 - 0
src/main/java/com/fdkankan/project/tieta/httpclient/HttpClient.java

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

+ 10 - 13
src/main/java/com/fdkankan/project/tieta/service/impl/ConvertServiceImpl.java

@@ -1,9 +1,8 @@
 package com.fdkankan.project.tieta.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.project.tieta.bean.ResultData;
 import com.fdkankan.project.tieta.constant.Constant;
@@ -13,14 +12,13 @@ import com.fdkankan.project.tieta.dto.SendConvertDTO;
 import com.fdkankan.project.tieta.entity.FullphotoFileindex;
 import com.fdkankan.project.tieta.service.FullphotoFileindexService;
 import com.fdkankan.project.tieta.service.IConvertService;
+import com.fdkankan.redis.util.RedisClient;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
-import com.fdkankan.redis.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.log4j.spi.ErrorCode;
-import org.apache.tomcat.Jar;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -34,8 +32,8 @@ public class ConvertServiceImpl implements IConvertService {
     private RabbitMqProducer mqProducer;
     @Autowired
     private FullphotoFileindexService fullphotoFileindexService;
-    @Autowired
-    private RedisUtil redisUtil;
+    @Resource
+    private RedisClient redisClient;
 
     @Override
     public void sendConvert(SendConvertDTO dto) {
@@ -62,7 +60,7 @@ public class ConvertServiceImpl implements IConvertService {
             return item;
         }).collect(Collectors.toList());
         playload.put("fileList", fileList);
-        mqProducer.sendByWorkQueue(Constant.QUEUE_SCENE_CONVERT + "-2", playload);
+        mqProducer.sendByWorkQueue(Constant.QUEUE_SCENE_CONVERT, playload);
         return ResultData.ok();
     }
 
@@ -77,13 +75,12 @@ public class ConvertServiceImpl implements IConvertService {
             fullphotoFileindices = fullphotoFileindexPage.getRecords();
             if(CollUtil.isNotEmpty(fullphotoFileindices)){
                 for (FullphotoFileindex item : fullphotoFileindices) {
-                    boolean doned = redisUtil.hHasKey(Constant.REDIS_SCENE_CONVERT_HISTORY, item.getStationCode() + "_" + item.getEntityId());
-                    if(!doned){
+                    String key = String.format(Constant.REDIS_SCENE_CONVERT_HISTORY, item.getStationCode() + "_" + item.getEntityId());
+                    String value = redisClient.get(key);
+                    if(StrUtil.isEmpty(value)){
                         try {
                             this.scenePush(ScenePushDTO.builder().stationCode(item.getStationCode()).entityId(item.getEntityId()).build());
-                            Map<String, Object> map = new HashMap<>();
-                            map.put(item.getStationCode() + "_" + item.getEntityId(), "1");
-                            redisUtil.hmset(Constant.REDIS_SCENE_CONVERT_HISTORY, map);
+                            redisClient.add(key, "1");
                         }catch (Exception e){
                             log.error("history scene push fail, stationCode:{}, entityId:{}", item.getStationCode(), item.getEntityId(), e);
                         }

+ 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;
-    }
-}

+ 0 - 225
src/main/java/com/fdkankan/redis/constant/RedisKey.java

@@ -1,225 +0,0 @@
-package com.fdkankan.redis.constant;
-
-public class RedisKey {
-    /**
-     * 过期时间:1分钟
-     */
-    public static final int EXPIRE_TIME_1_MINUTE = 60;
-
-    /**
-     * 过期时间:5分钟
-     */
-    public static final int EXPIRE_TIME_5_MINUTE = 5*60;
-
-    /**
-     * 过期时间:10分钟
-     */
-    public static final int EXPIRE_TIME_10_MINUTE = 10*60;
-
-    /**
-     * 过期时间:30分钟
-     */
-    public static final int EXPIRE_TIME_30_MINUTE = 30*60;
-
-    /**
-     * 过期时间:2小时
-     */
-    public static final int EXPIRE_TIME_2_HOUR = 2*60*60;
-
-    /**
-     * 用户过期时间
-     */
-    public static final int USER_EXPIRE_TIME = 6*60*60;
-
-    /**
-     * 相机登陆7天有效期
-     */
-    public static final int CAMERA_EXPIRE_7_TIME = 7*24*60*60;
-
-    public static final String SYSTEM_PREFIX = "4dkankan";
-
-    /**
-     * 登录token
-     */
-    public static String TOKEN_USER = "token:type:%s:name:%s";
-
-    /**
-     * ssouser key
-     */
-    public static String SSO_USER = "sso_user:name:%s";
-    /**
-     * 开发者信息
-     */
-    public static String TM_DEVELOPER = "developer:appid:%s";
-
-    /**
-     * 场景浏览量
-     */
-    public static String SCENE_VISIT_CNT = "scene:visit:cnt";
-
-
-    /**
-     * 场景码池
-     */
-    public static String FDKANKAN_SCENE_NUMS = "4dkankan:scene:nums";
-
-
-    public static final String SCENE_BUILDING = SYSTEM_PREFIX+":scene:building:%s";
-
-    /**
-     * 场景下载进度
-     */
-    // TODO: 2022/3/29  这个是V3版本使用的key,V4版本稳定后,这个要删除
-    public static final String PREFIX_DOWNLOAD_PROGRESS="downloads:progress:%s";
-
-    /**
-     * 场景下载进度
-     */
-    public static final String PREFIX_DOWNLOAD_PROGRESS_V4="downloads:progress:v4:%s";
-
-    /**
-     * 即将要下载场景的场景码列表
-     */
-    public static final String DOWNLOAD_TASK="downloads:task";
-
-    /**
-     * 正在下载的场景码列表
-     */
-    public static final String SCENE_DOWNLOAD_ING="scene:downloads:ing";
-
-    /**
-     * 正在下载的场景码列表
-     */
-    public static final String SCENE_V3_DOWNLOAD_ING="scene:v3:downloads:ing";
-
-    /**
-     * scenejson缓存
-     */
-    public static final String SCENE_JSON = "scenejson:num:%s";
-
-    /**
-     * 场景热点hash列表
-     */
-    public static final String SCENE_HOT_DATA = "scene:hotdata:num:%s";
-
-    /**
-     * 热点icons数据列表
-     */
-    public static final String SCENE_HOT_ICONS = "scene:hoticons:num:%s";
-
-    /**
-     * 场景关联数据列表
-     */
-    public static final String SCENE_LINKPAN_DATA = "scene:LinkPan:num:%s";
-
-    /**
-     * 场景关联styles数据列表
-     */
-    public static final String SCENE_LINKPAN_STYLES = "scene:LinkPanStyles:num:%s";
-
-    /**
-     * 场景关联styles数据列表
-     */
-    public static final String SCENE_BILLBOARDS_STYLES = "scene:billboardsStyles:num:%s";
-
-    /**
-     * 场景指示牌数据列表
-     */
-    public static final String SCENE_BILLBOARDS = "scene:billboards:num:%s";
-
-    public static final String SCENE_CUT_MODEL = "scene:cutmodel:num:%s";
-
-    /**
-     * 场景下载任务列表
-     */
-    public static final String SCENE_DOWNLOADS_TASK_V4 = "scene:downloads:task:v4";
-
-    /**
-     * 场景升级进度
-     */
-    public static final String scene_upgrade_progress_num = "scene:upgrade:progress:num:%s";
-
-    /**
-     * v3版本user类型token
-     */
-    public static final String TOKEN_V3 = "token#%s";
-
-    /**
-     * user类型token
-     */
-    public static final String USER_TOKEN_KEY = "token#%s";
-
-    /**
-     * 场景协作管理
-     */
-    public static final String SCENE_COOPERATION_NUM_USERID = "scene:cooperation:num:userId";
-
-
-    /**
-     * 管理后台key
-     */
-    public static final String  MANAGE_MENU ="manage_menu";
-    public static final String  MANAGE_PERM_USER ="manage_perm_user:%s";
-    public static final String  MANAGE_ROLE_USER ="manage_role_user:%s";
-
-    /**
-     * 马赛克列表
-     */
-    public static final String SCENE_MOSAIC_DATA = "scene:mosaic:num:%s";
-
-    /**
-     * 滤镜列表
-     */
-    public static final String SCENE_filter_DATA = "scene:filter:num:%s";
-
-    /**
-     * 场景资源清理,查询场景limit下标
-     */
-    public static final String SCENE_CLEAN_INDEX = "scene:clean:index";
-
-    /**
-     * 上传matterprodata状态
-     */
-    public static final String SCENE_UPLOAD_MATTERPRO_NUM= "scene:upload:matterpro:num";
-
-    /**
-     * 人体抠图任务id
-     */
-    public static final String SCENE_BODY_SEGMENT= "scene:body:segment:uuid:%s";
-
-    /**
-     * 场景oss原始资源目录删除
-     */
-    public static final String SCENE_OSS_HOME_DIR_DELETE= "scene:oss:home:dir:delete:unicode:%s";
-
-    /**
-     * 场景oss原始资源目录上传
-     */
-    public static final String SCENE_OSS_HOME_DIR_UPLOAD= "scene:oss:home:dir:upload:unicode:%s";
-
-    /**
-     * 场景oss原始资源目录上传
-     */
-    public static final String SCENE_BUILD_EXPECT_TOTAL_TIME_NUM= "scene:build:expect:total:time:num:%s";
-
-    /**
-     * 场景oss原始资源目录上传
-     */
-    public static final String SCENE_BUILD_FINISH_NUM = "scene:build:finish:num:%s";
-
-    /**
-     * 场景oss原始资源目录上传
-     */
-    public static final String SINGLE_MODELING_SERVER_BUSY = "singleModelingServerBusy";
-
-    /**
-     * 打点系统应用id缓存
-     */
-    public static final String TRACK_APPID = "track:appid";
-
-    public static final String SCENE_DRAW = "scene:draw:num:%s";
-
-
-
-
-}

+ 0 - 192
src/main/java/com/fdkankan/redis/constant/RedisLockKey.java

@@ -1,192 +0,0 @@
-package com.fdkankan.redis.constant;
-
-import cn.hutool.core.io.FileUtil;
-
-import java.io.File;
-
-/**
- * <p>
- *   分布式锁key定义
- * </p>
- *
- * @author dengsixing
- * @since 2022/1/12
- **/
-public class RedisLockKey {
-
-    /**
-     * 场景浏览量
-     */
-    public static String LOCK_SCENE_VISIT_CNT = "lock:scene:visit:cnt:scenecode:%s";
-
-    /**
-     * 场景访问量更新锁 hash
-     */
-    public static String LOCK_SCENE_VISIT_UPDATE = "lock:scene:visit:update";
-
-    /**
-     *
-     *
-     *
-     * 场景上传图片锁
-     */
-    public static String LOCK_UPLOAD_PIC = "lock:upload:pic:scenecode:%s";
-
-    /**
-     * 场景pro上传图片锁
-     */
-    public static String LOCK_UPLOAD_PRO_PIC = "lock:upload:pro:pic:scenecode:%s";
-
-    /**
-     * 场景上传音频锁
-     */
-    public static String LOCK_UPLOAD_VOICE = "lock:upload:voice:scenecode:%s";
-
-    /**
-     * 场景pro上传音频锁
-     */
-    public static String LOCK_UPLOAD_PRO_VOICE = "lock:upload:pro:voice:scenecode:%s";
-
-    /**
-     * 画墙重建模型锁
-     */
-    public static String LOCK_UPLOAD_FLOORJSON_REBUILD = "lock:upload:floorjson:rebuild:scenecode:%s";
-
-    /**
-     * 上传图片多媒体数据锁
-     */
-    public static String LOCK_UPLOAD_FLOORPLAN_PNG = "lock:upload:floorplan:png:scenecode:%s";
-
-    /**
-     * 加载场景码池锁
-     */
-    public static String LOCK_FDKANKAN_SCENE_NUMS = "lock:4dkankan:scene:nums";
-
-    /**
-     * 同步场景
-     */
-    public static String LOCK_SCENE_SYNC = "lock:scene:sync:num:%s";
-
-    /**
-     * 热点数据恢复锁
-     */
-    public static String LOCK_HOT_DATA_SYNC = "lock:hot:data:sync:num:%s";
-
-    /**
-     * icons数据恢复锁
-     */
-    public static String LOCK_HOT_ICONS_SYNC = "lock:hot:icons:sync:num:%s";
-
-    /**
-     * 场景关联数据恢复锁
-     */
-    public static String LOCK_LINKPAN_DATA_SYNC = "lock:linkpan:data:sync:num:%s";
-
-    /**
-     * 场景关联styles数据恢复锁
-     */
-    public static String LOCK_LINKPAN_STYLES_SYNC = "lock:linkpan:styles:sync:num:%s";
-
-    /**
-     * 场景关联styles数据恢复锁
-     */
-    public static String LOCK_BILLBOARDS_STYLES_SYNC = "lock:Billboards:styles:sync:num:%s";
-
-    /**
-     * 场景指示牌数据恢复锁
-     */
-    public static String LOCK_BILLBOARDS_SYNC = "lock:billboards:sync:num:%s";
-
-    /**
-     * 裁剪模型数据恢复锁
-     */
-    public static String LOCK_CUT_MODEL_SYNC = "lock:cutmodel:sync:num:%s";
-
-    /**
-     * 热点数据写文件锁
-     */
-    public static String LOCK_HOT_JSON = "lock:hot:json:num:%s";
-
-    /**
-     * 批量生成场景码锁
-     */
-    public static String LOCK_BATCH_CREATE_NUM = "lock:batch:create:num";
-
-    /**
-     * 加载场景中断下载列表锁
-     */
-    public static String LOCK_SCENE_DOWNLOAD_ING = "lock:scene:downloads:ing";
-
-
-    /**
-     * 加载场景中断下载列表锁
-     */
-    public static String LOCK_STARTUP_MODELING_SERVER = "lock:startup:modeling:server";
-
-    /**
-     * 加载场景中断下载列表锁
-     */
-    public static String LOCK_SCENE_UPGRADE_V4 = "lock:scene:upgrade:v4:num:%s";
-
-    /**
-     * 场景关联数据写本地文件锁
-     */
-    public static String LOCK_LINK_SCENE_JSON = "lock:link:scene:json:num:%s";
-
-    /**
-     * 场景关联数据写本地文件锁
-     */
-    public static String LOCK_SCENE_UPGRADE_FAILED_ROLLBACK = "lock:scene:upgrade:failed:rollback";
-
-    /**
-     * 马赛克数据恢复锁
-     */
-    public static String LOCK_MOSAIC_DATA_SYNC = "lock:mosaic:data:sync:num:%s";
-
-    /**
-     * 马赛克数据写文件锁
-     */
-    public static String LOCK_MOSAIC_JSON = "lock:mosaic:json:num:%s";
-
-    /**
-     * 滤镜数据写文件锁
-     */
-    public static String LOCK_filter_JSON = "lock:filter:json:num:%s";
-
-    /**
-     * 滤镜数据恢复锁
-     */
-    public static String LOCK_FILTER_DATA_SYNC = "lock:filter:data:sync:num:%s";
-
-    /**
-     * 场景资源清理定时任务锁
-     */
-    public static final String LOCK_SCENE_CLEAN = "lock:scene:clean";
-
-    /**
-     * 思维打包下载锁
-     */
-    public static final String LOCK_DOWNLOAD_SIWEI_HTML = "lock:download:siwei:html";
-
-    /**
-     * 思维打包下载锁
-     */
-    public static final String LOCK_GET_MATTERPRO_NUM = "lock:get:matterpro:num";
-
-    public static final String LOCK_CLEAN_SCENE_ORIG_V3 = "lock:clean:scene:orig:v3";
-
-    public static final String LOCK_CLEAN_SCENE_ORIG_V4 = "lock:clean:scene:orig:v4";
-
-    public static final String LOCK_CLEAN_SCENE_DELETED_ORIG_V3 = "lock:clean:scene:deleted:orig:v3";
-
-    public static final String LOCK_CLEAN_SCENE_DELETED_ORIG_V4 = "lock:clean:scene:deleted:orig:v4";
-
-    public static String LOCK_SCENE_DRAW = "lock:sceneDraw:sync:num:%s";
-
-    public static void main(String[] args) {
-        FileUtil.copyContent(new File("F:\\test\\test"), new File("F:\\test\\test2"), true);
-    }
-
-
-
-}

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

@@ -0,0 +1,62 @@
+package com.fdkankan.redis.util;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.project.tieta.httpclient.HttpClient;
+import lombok.Data;
+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 HttpClient httpClient;
+
+
+     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 = httpClient.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 = httpClient.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);
-    }
-}

+ 13 - 14
src/main/resources/application-dev.yml

@@ -2,11 +2,11 @@ spring:
   application:
     name: 4dkankan-project-tieta
   rabbitmq:
-    host: 10.180.22.47
+    host: 10.180.22.49
     port: 5672
-    username: User_CHNTZCGL_ZYAPP_002
-    password: ZYAPP002@VR
-    virtual-host: Vhost_CHNTZCGL_ZYAPP_002
+    username: User_CHNTZCGL_ZCSZHGL_003
+    password: zcszhgl03_vr
+    virtual-host: Vhost_CHNTZCGL_ZCSZHGL_003
     connection-timeout: 0
     listener:
       simple:
@@ -16,30 +16,29 @@ spring:
     #开启消息投递确认机制
     publisher-confirm-type: correlated
   datasource:
-    url: jdbc:oracle:thin:@//10.180.41.37:1521/resdb
+    url: jdbc:oracle:thin:@//10.190.107.148:1521/resdb
     username: RES_FILE
     password: qNQVkH3YbA
-    #    username: RES_VR
-    #    password: IDCqawsed@123.
     driver-class-name: oracle.jdbc.OracleDriver
-  redis:
-    timeout: 6000ms
-    password: Qwt@1620b!v
-    cluster:
-      nodes:
-        - 10.180.22.54:7000
 mybatis-plus:
   mapper-locations: classpath:mapper/*Mapper.xml
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
+tieta:
+  sysCode: CT00017
+  serverName: vrpush
+
 fdfs:
   sysCode: CT00017
-  address: http://10.180.22.41:8761
+  address: http://10.180.22.83:8894
   api:
     getSignature: /ChinatowerFileService/getSignature
     uploadFile: /ChinatowerFileService/uploadFile/
 
+redis:
+  host: http://10.180.22.54:8081
+
 
 
 

+ 11 - 14
src/main/resources/application-test.yml

@@ -2,11 +2,11 @@ spring:
   application:
     name: 4dkankan-project-tieta
   rabbitmq:
-    host: 10.190.22.108
+    host: 10.190.22.110
     port: 5672
-    username: User_CHNTZCGL_ZYAPP_002
-    password: ZYAPP002@VR
-    virtual-host: Vhost_CHNTZCGL_ZYAPP_002
+    username: User_CHNTZCGL_ZCSZHGL_003
+    password: zcszhgl03_vr
+    virtual-host: Vhost_CHNTZCGL_ZCSZHGL_003
     connection-timeout: 0
     listener:
       simple:
@@ -19,22 +19,16 @@ spring:
     url: jdbc:oracle:thin:@//10.190.107.148:1521/resdb
     username: RES_FILE
     password: qNQVkH3YbA
-#    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
 mybatis-plus:
   mapper-locations: classpath:mapper/*Mapper.xml
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
+tieta:
+  sysCode: CT00017
+  serverName: vrpush
+
 fdfs:
   sysCode: CT00017
   address: http://10.190.22.115:8894
@@ -42,6 +36,9 @@ fdfs:
     getSignature: /ChinatowerFileService/getSignature
     uploadFile: /ChinatowerFileService/uploadFile/
 
+redis:
+  host: http://10.190.22.99:8081
+