JensionDzero 2 lat temu
rodzic
commit
a19be80ee0

+ 1 - 1
.run/ruoyi-monitor-admin.run.xml

@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="ruoyi-monitor-admin" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
+  <configuration default="false" name="ruoyi-monitor-admin" type="docker-deploy" factoryName="dockerfile" server-name="jzyx">
     <deployment type="dockerfile">
       <settings>
         <option name="imageTag" value="ruoyi/ruoyi-monitor-admin:4.8.0" />

+ 1 - 1
.run/ruoyi-xxl-job-admin.run.xml

@@ -1,5 +1,5 @@
 <component name="ProjectRunConfigurationManager">
-  <configuration default="false" name="ruoyi-xxl-job-admin" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
+  <configuration default="false" name="ruoyi-xxl-job-admin" type="docker-deploy" factoryName="dockerfile" server-name="jzyx">
     <deployment type="dockerfile">
       <settings>
         <option name="imageTag" value="ruoyi/ruoyi-xxl-job-admin:4.8.0" />

+ 7 - 2
benyun-core/pom.xml

@@ -73,9 +73,14 @@
             <scope>test</scope>
         </dependency>
 
+<!--        <dependency>-->
+<!--            <groupId>redis.clients</groupId>-->
+<!--            <artifactId>jedis</artifactId>-->
+<!--        </dependency>-->
+
         <dependency>
-            <groupId>redis.clients</groupId>
-            <artifactId>jedis</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
         </dependency>
 
         <dependency>

+ 2 - 0
benyun-core/src/main/java/com/ruoyi/benyun/BenyunCoreApplication.java

@@ -13,4 +13,6 @@ public class BenyunCoreApplication {
         SpringApplication.run(BenyunCoreApplication.class, args);
     }
 
+
+
 }

+ 25 - 23
benyun-core/src/main/java/com/ruoyi/benyun/config/QuartzConfig.java

@@ -32,7 +32,8 @@ public class QuartzConfig {
     @Bean
     public Trigger AnalyseTrigger() {
         //定义Cron表达式
-        CronScheduleBuilder cron = CronScheduleBuilder.cronSchedule("0 0 0 1/15 * ? ");
+        //CronScheduleBuilder cron = CronScheduleBuilder.cronSchedule("0 0 0 1/15 * ? ");
+        CronScheduleBuilder cron = CronScheduleBuilder.cronSchedule("0 30 17 11 11 ? ");
         cron.inTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
 
         return TriggerBuilder
@@ -43,30 +44,31 @@ public class QuartzConfig {
             .build();
     }
 
-    @Bean
-    public JobDetail WriteRedisJobDetail() {
-        log.info("WriteRedisJobDetail");
+//    @Bean
+//    public JobDetail WriteRedisJobDetail() {
+//        log.info("WriteRedisJobDetail");
+//
+//        return JobBuilder.newJob(WriteRedisJob.class) //newJob方法就是在绑定要运行的Job接口实现。
+//            .withIdentity("writeRedisJobDetail") //给当前JobDetail对象取名字
+//            .storeDurably() //及时没有触发器绑定当前JobDetail对象,也不会被删除
+//            .build();
+//    }
 
-        return JobBuilder.newJob(WriteRedisJob.class) //newJob方法就是在绑定要运行的Job接口实现。
-            .withIdentity("writeRedisJobDetail") //给当前JobDetail对象取名字
-            .storeDurably() //及时没有触发器绑定当前JobDetail对象,也不会被删除
-            .build();
-    }
 
 
-
-    @Bean
-    public Trigger WriteRedisTrigger(){
-        //定义Cron表达式
-        CronScheduleBuilder cron  = CronScheduleBuilder.cronSchedule("0 0 0 * * ? *");
-        cron.inTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
-
-        return TriggerBuilder
-            .newTrigger()
-            .forJob(WriteRedisJobDetail()) //绑定要运行的JobDetail对象,这是得到的是Spring容器里的JobDetail
-            .withIdentity("writeRedisTrigger") //给当前Trigger对象起名字,名字任意
-            .withSchedule(cron) //绑定cron表达式
-            .build();
-    }
+//    @Bean
+//    public Trigger WriteRedisTrigger(){
+//        //定义Cron表达式
+//        CronScheduleBuilder cron  = CronScheduleBuilder.cronSchedule("0 0 0 * * ? *");
+//
+//        cron.inTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+//
+//        return TriggerBuilder
+//            .newTrigger()
+//            .forJob(WriteRedisJobDetail()) //绑定要运行的JobDetail对象,这是得到的是Spring容器里的JobDetail
+//            .withIdentity("writeRedisTrigger") //给当前Trigger对象起名字,名字任意
+//            .withSchedule(cron) //绑定cron表达式
+//            .build();
+//    }
 
 }

+ 1 - 1
benyun-core/src/main/java/com/ruoyi/benyun/config/RedisConfiguration.java

@@ -32,6 +32,7 @@ public class RedisConfiguration {
         RedisTemplate<Object,Object>  redisTemplate = new RedisTemplate();
 
         redisTemplate.setConnectionFactory(redisConnectionFactory);
+
         // 设置Redis的key使用字符串序列化器,解决key可读性差的问题。
         redisTemplate.setKeySerializer(new StringRedisSerializer());
         redisTemplate.setHashKeySerializer(new StringRedisSerializer());
@@ -43,7 +44,6 @@ public class RedisConfiguration {
         redisTemplate.setValueSerializer(valueSerializer());
         redisTemplate.setHashValueSerializer(valueSerializer());
 
-        redisTemplate.setConnectionFactory(redisConnectionFactory);
         return redisTemplate;
     }
 

+ 3 - 0
benyun-core/src/main/java/com/ruoyi/benyun/init/BenyunCoreInit.java

@@ -1,6 +1,7 @@
 package com.ruoyi.benyun.init;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.benyun.config.RedisConfiguration;
 import com.ruoyi.benyun.constant.RedisInitContant;
 import com.ruoyi.benyun.entity.AddrCategory;
 import com.ruoyi.benyun.mapper.AddrCategoryDao;
@@ -11,6 +12,7 @@ import com.ruoyi.benyun.entity.TypeBy;
 import com.ruoyi.benyun.utils.InitMapUtil;
 import com.ruoyi.common.core.domain.R;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.data.redis.core.BoundHashOperations;
@@ -24,6 +26,7 @@ import java.util.Set;
 import java.util.concurrent.*;
 
 @Configuration
+//@AutoConfigureAfter(RedisConfiguration.class)
 public class BenyunCoreInit {
     @Autowired
     AddrCategoryDao addrCategoryDao;

+ 85 - 85
benyun-core/src/main/java/com/ruoyi/benyun/utils/WdRedisStoreage.java

@@ -114,91 +114,91 @@ public class WdRedisStoreage {
         //给网点打标签并存入redis中
         //writeWdGeoRedis2();
     }
-
-    public void clearSql2(){
-        List<String> wdId = new ArrayList<>();
-        List<String> storeId = new ArrayList<>();
-        List<String> houseId = new ArrayList<>();
-        List<String> buildId = new ArrayList<>();
-        List<String> trafficId = new ArrayList<>();
-        List<String> enterpriseId = new ArrayList<>();
-        long start = System.currentTimeMillis();
-
-        try{
-            System.out.println("开始清理");
-
-            QueryWrapper<WdInfo> wdInfoOriginQueryWrapper = new QueryWrapper<>();
-            wdInfoOriginQueryWrapper.select("hash", "count(hash) as audit").groupBy("hash").having("count(hash) >= 2");
-            List<WdInfo> wdInfoOrigins = wdInfoDao.selectList(wdInfoOriginQueryWrapper);
-
-            HashMap<String, Integer> hashMap = new HashMap<>();
-            for (WdInfo wdInfo : wdInfoOrigins) {
-                hashMap.put(wdInfo.getHash(), wdInfo.getAudit());
-            }
-
-
-            HashMap<String,Integer> hashMap1 = new HashMap<>();
-            hashMap1.put("total",1);
-            CompletableFuture<Void> future = null;
-            for (String s : hashMap.keySet()) {
-                FutureTask
-                future = CompletableFuture.runAsync(()->{
-                    synchronized (this){
-                        if(hashMap1.get("total")%1000 == 0){
-                            writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
-                            wdId.clear();
-                            storeId.clear();
-                            houseId.clear();
-                            buildId.clear();
-                            trafficId.clear();
-                            enterpriseId.clear();
-                        }
-                    }
-
-                    QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
-                    queryWrapper.eq("hash",s);
-                    queryWrapper.orderByDesc("collect_time");
-                    queryWrapper.last("limit " + (hashMap.get(s) - 1));
-                    List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
-                    for (WdInfo wdInfo : wdInfos) {
-                        wdId.add(wdInfo.getWdId());
-
-                        switch (wdInfo.getWdTypeCode()){
-                            case "1":
-                                storeId.add(wdInfo.getWdId());
-                                break;
-                            case "2":
-                                houseId.add(wdInfo.getWdId());
-                                break;
-                            case "3":
-                                buildId.add(wdInfo.getWdId());
-                                break;
-                            case "4":
-                                trafficId.add(wdInfo.getWdId());
-                                break;
-                            case "5":
-                                enterpriseId.add(wdInfo.getWdId());
-                                break;
-                            default:
-                                break;
-                        }
-                    }
-                    System.out.println("进度:"+wdInfoOrigins.size()+"/"+hashMap1.get("total"));
-                    hashMap1.put("total",hashMap1.get("total")+1);
-                },executorService);
-            }
-            future.get();
-        }catch (Exception e){
-            e.printStackTrace();
-        }finally {
-            //删除
-            writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
-            long end = System.currentTimeMillis();
-            System.out.println("完成清理 "+(end-start)/(1000*60));
-        }
-
-
-    }
+//
+//    public void clearSql2(){
+//        List<String> wdId = new ArrayList<>();
+//        List<String> storeId = new ArrayList<>();
+//        List<String> houseId = new ArrayList<>();
+//        List<String> buildId = new ArrayList<>();
+//        List<String> trafficId = new ArrayList<>();
+//        List<String> enterpriseId = new ArrayList<>();
+//        long start = System.currentTimeMillis();
+//
+//        try{
+//            System.out.println("开始清理");
+//
+//            QueryWrapper<WdInfo> wdInfoOriginQueryWrapper = new QueryWrapper<>();
+//            wdInfoOriginQueryWrapper.select("hash", "count(hash) as audit").groupBy("hash").having("count(hash) >= 2");
+//            List<WdInfo> wdInfoOrigins = wdInfoDao.selectList(wdInfoOriginQueryWrapper);
+//
+//            HashMap<String, Integer> hashMap = new HashMap<>();
+//            for (WdInfo wdInfo : wdInfoOrigins) {
+//                hashMap.put(wdInfo.getHash(), wdInfo.getAudit());
+//            }
+//
+//
+//            HashMap<String,Integer> hashMap1 = new HashMap<>();
+//            hashMap1.put("total",1);
+//            CompletableFuture<Void> future = null;
+//            for (String s : hashMap.keySet()) {
+//                FutureTask
+//                future = CompletableFuture.runAsync(()->{
+//                    synchronized (this){
+//                        if(hashMap1.get("total")%1000 == 0){
+//                            writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
+//                            wdId.clear();
+//                            storeId.clear();
+//                            houseId.clear();
+//                            buildId.clear();
+//                            trafficId.clear();
+//                            enterpriseId.clear();
+//                        }
+//                    }
+//
+//                    QueryWrapper<WdInfo> queryWrapper = new QueryWrapper<>();
+//                    queryWrapper.eq("hash",s);
+//                    queryWrapper.orderByDesc("collect_time");
+//                    queryWrapper.last("limit " + (hashMap.get(s) - 1));
+//                    List<WdInfo> wdInfos = wdInfoDao.selectList(queryWrapper);
+//                    for (WdInfo wdInfo : wdInfos) {
+//                        wdId.add(wdInfo.getWdId());
+//
+//                        switch (wdInfo.getWdTypeCode()){
+//                            case "1":
+//                                storeId.add(wdInfo.getWdId());
+//                                break;
+//                            case "2":
+//                                houseId.add(wdInfo.getWdId());
+//                                break;
+//                            case "3":
+//                                buildId.add(wdInfo.getWdId());
+//                                break;
+//                            case "4":
+//                                trafficId.add(wdInfo.getWdId());
+//                                break;
+//                            case "5":
+//                                enterpriseId.add(wdInfo.getWdId());
+//                                break;
+//                            default:
+//                                break;
+//                        }
+//                    }
+//                    System.out.println("进度:"+wdInfoOrigins.size()+"/"+hashMap1.get("total"));
+//                    hashMap1.put("total",hashMap1.get("total")+1);
+//                },executorService);
+//            }
+//            future.get();
+//        }catch (Exception e){
+//            e.printStackTrace();
+//        }finally {
+//            //删除
+//            writeService.clearSql2(wdId,storeId,houseId,buildId,trafficId,enterpriseId);
+//            long end = System.currentTimeMillis();
+//            System.out.println("完成清理 "+(end-start)/(1000*60));
+//        }
+//
+//
+//    }
 
     public void writeWdGeoRedis1(String time){
         //1.将网点坐标存入redis中

+ 6 - 2
benyun-core/src/main/resources/application-prod.yaml

@@ -156,13 +156,15 @@ spring:
   #      maxWait: 3   #连接池最大阻塞等待时间(使用负值表示没有限制)
   #      maxActive: 8 #连接池最大连接数(使用赋值表示没有限制)
   redis:
+    host: 192.168.2.36
+    port: 7001
+    timeout: 5000ms  #连接超时时间
     cluster:
       # 集群节点
-      nodes: 192.168.2.99:7001,192.168.2.99:7002,192.168.2.99:7003,192.168.2.99:7004,192.168.2.99:7005,192.168.2.99:7006
+      nodes: 192.168.2.36:7001,192.168.2.36:7002,192.168.2.36:7003,192.168.2.36:7004,192.168.2.36:7005,192.168.2.36:7006
       # 最大重定向次数
       max-redirects: 5
     # 密码
-    database: 1
     password: 123456
     lettuce:
       pool:
@@ -171,6 +173,8 @@ spring:
         max-wait: -1
         max-idle: 8
         enabled: true
+
+
 #mybatis-plus配置
 mybatis-plus:
   mapper-locations: classpath*:/*mapper/**/*.xml  #告诉mybatis数据库映射文件mapper.xml的位置

+ 13 - 8
benyun-core/src/test/java/com/ruoyi/benyun/BenyunCoreApplicationTests.java

@@ -1,22 +1,35 @@
 package com.ruoyi.benyun;
 
 import com.ruoyi.benyun.constant.RedisContant;
+import com.ruoyi.benyun.constant.RedisInitContant;
 import com.ruoyi.benyun.mapper.WdInfoDao;
 import com.ruoyi.benyun.service.WriteService;
 import com.ruoyi.benyun.utils.WdRedisStoreage;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.redis.core.BoundValueOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.data.redis.serializer.RedisSerializer;
 
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 @SpringBootTest
 class BenyunCoreApplicationTests {
     @Autowired
     WdRedisStoreage wdRedisStoreage;
 
+    @Autowired
+    RedisTemplate redisTemplate;
+
+    @Autowired
+    StringRedisTemplate stringRedisTemplate;
+
     @Autowired
     WdInfoDao wdInfoDao;
 
@@ -25,14 +38,6 @@ class BenyunCoreApplicationTests {
 
     @Test
     void contextLoads() {
-        ArrayList<String> list = new ArrayList<>();
-        list.add(RedisContant.WD_TAG+"_"+"00003743d4b047aab0e8ab9481225fbf");
-        list.add(RedisContant.WD_TAG+"_"+"000040593b0e4c7f82b798d30604f350");
-        list.add(RedisContant.WD_TAG+"_"+"0000f8d2a49043cf8e4525241faf5fb9");
-        List<List<String>> wdTagList = wdRedisStoreage.getWdTagList(list);
-        System.out.println(wdTagList);
-
-        //List<String> wdTag = wdRedisStoreage.getWdTag(null);
     }
 
 

+ 9 - 9
ruoyi-admin/src/main/resources/application-prod.yml

@@ -110,17 +110,16 @@ spring:
     cluster:
       # 集群节点
       nodes:
-        - 192.168.2.99:7001
-        - 192.168.2.99:7002
-        - 192.168.2.99:7003
-        - 192.168.2.99:7004
-        - 192.168.2.99:7005
-        - 192.168.2.99:7006
+        - 192.168.2.36:7001
+        - 192.168.2.36:7002
+        - 192.168.2.36:7003
+        - 192.168.2.36:7004
+        - 192.168.2.36:7005
+        - 192.168.2.36:7006
       # 最大重定向次数
       max-redirects: 5
     # 密码
     password: 123456
-    database: 1
     lettuce:
       pool:
         min-idle: 0
@@ -130,14 +129,13 @@ spring:
         enabled: true
     timeout: 600000
 
-#  #redisson:
+#redisson:
 #  # redis key前缀
 #  keyPrefix:
 #  # 线程池数量
 #  threads: 16
 #  # Netty线程池数量
 #  nettyThreads: 32
-##  # 单节点配置
 ##  singleServerConfig:
 #  # 单节点配置
 #  clusterServersConfig:
@@ -154,6 +152,8 @@ spring:
 #    # 发布和订阅连接池大小
 #    subscriptionConnectionPoolSize: 50
 
+
+
 --- # mail 邮件发送
 mail:
   enabled: false

+ 0 - 2
ruoyi-demo/src/main/java/com/ruoyi/demo/config/RedisConfiguration.java

@@ -42,8 +42,6 @@ public class RedisConfiguration {
         redisTemplate.setValueSerializer(valueSerializer());
         redisTemplate.setHashValueSerializer(valueSerializer());
 
-        redisTemplate.setConnectionFactory(redisConnectionFactory);
-
         return redisTemplate;
     }
 

+ 4 - 4
ruoyi-demo/src/main/java/com/ruoyi/demo/controller/ChannelAnalyseController.java

@@ -73,10 +73,10 @@ public class ChannelAnalyseController {
         String md5 = channelMapAceeptVo.getHash();
 
         //2.查看redis中是否存在有缓存
-//        List<StoreWdCategoryCount> wdCount = (List<StoreWdCategoryCount>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_CATEGORY).get(md5);
-//        if (wdCount != null) {
-//            return R.ok(wdCount);
-//        }
+        List<StoreWdCategoryCount> wdCount = (List<StoreWdCategoryCount>) redisTemplate.boundHashOps(RedisContant.CHANNEL_ANALYSE_CATEGORY).get(md5);
+        if (wdCount != null) {
+            return R.ok(wdCount);
+        }
 
 
         List<StoreWdCategoryCount> category = channelAnalyseService.category(channelMapAceeptVo);

+ 3 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/init/BenyunCoreInit.java

@@ -2,6 +2,7 @@ package com.ruoyi.demo.init;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 
+import com.ruoyi.demo.config.RedisConfiguration;
 import com.ruoyi.demo.constant.RedisInitContant;
 import com.ruoyi.demo.entity.AddrCategory;
 import com.ruoyi.demo.entity.ManageType;
@@ -10,8 +11,10 @@ import com.ruoyi.demo.mapper.AddrCategoryDao;
 import com.ruoyi.demo.mapper.TypeByDao;
 import com.ruoyi.demo.service.ManageTypeService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
 import org.springframework.data.redis.core.BoundHashOperations;
 import org.springframework.data.redis.core.RedisTemplate;
 

+ 0 - 1
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/ChannelMapServiceImpl.java

@@ -237,7 +237,6 @@ public class ChannelMapServiceImpl implements ChannelMapService {
             WdTopologicalInfoBo wdTopologicalInfoBo = new WdTopologicalInfoBo(wdInfo);
             wdTopologicalInfoBo.setAddrCodeInfo(initMapUtil.getInitAddrCodeMap(wdInfo.getAddrCode()));
             List<String> tags = wdRedisStoreage.getWdTag(wdInfo);
-            System.out.println(tags);
             wdTopologicalInfoBo.setTag(tags);
             result.add(wdTopologicalInfoBo);
         }

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/SysLoginService.java

@@ -198,6 +198,7 @@ public class SysLoginService {
      */
     public void validateCaptcha(String username, String code, String uuid) {
         String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, "");
+        System.out.println("verifyKey"+verifyKey);
         String captcha = RedisUtils.getCacheObject(verifyKey);
         RedisUtils.deleteObject(verifyKey);
         if (captcha == null) {