Browse Source

版本分支提交

liukaixiong 4 years ago
parent
commit
b833d5e6c3
43 changed files with 1566 additions and 257 deletions
  1. 13 0
      README.md
  2. 24 0
      elab-annotation/src/main/java/com/elab/annotation/Author.java
  3. 19 0
      elab-annotation/src/main/java/com/elab/annotation/Description.java
  4. 55 69
      elab-core/src/main/java/com/elab/core/utils/DateUtils.java
  5. 37 0
      elab-core/src/test/java/com/elab/annno/AnnotationTest.java
  6. 40 8
      elab-core/src/test/java/com/elab/test/utils/GuavaUtilsCase.java
  7. 23 0
      elab-core/src/test/java/com/elab/test/utils/JSONUtilsTest.java
  8. 12 1
      elab-db/src/main/java/com/elab/core/dao/BasicBaseDao.java
  9. 2 0
      elab-db/src/main/java/com/elab/core/spring/binding/DaoProxy.java
  10. 2 0
      elab-db/src/main/java/com/elab/core/spring/binding/DaoProxyFactory.java
  11. 1 2
      elab-db/src/main/java/com/elab/core/spring/config/DataSourceConfigBean.java
  12. 2 0
      elab-db/src/test/java/com.db.service/dao/ITestDao.java
  13. 9 1
      elab-db/src/test/java/com.db.service/main/BasicBaseDaoProxyCase.java
  14. 39 0
      elab-db/src/test/java/com.db.service/main/SQLTest.java
  15. 8 0
      elab-db/src/test/resources/sql/test-sql.xml
  16. 8 4
      elab-kafka/src/main/java/com/elab/core/kafka/consumer/KafkaMsgListener.java
  17. 1 1
      elab-kafka/src/main/java/com/elab/core/kafka/sender/KafkaMonitorProducer.java
  18. 3 3
      elab-log/src/main/java/com/elab/log/ext/CatIdMonitorRule.java
  19. 34 0
      elab-log/src/main/java/com/elab/log/ext/CatSupplier.java
  20. 2 2
      elab-mq/src/main/java/com/elab/mq/listener/ConsumerInterceptor.java
  21. 6 68
      elab-mq/src/main/java/com/elab/mq/listener/MessageListenerWrapper.java
  22. 4 1
      elab-mq/src/main/java/com/elab/mq/msg/impl/MsgProducerImpl.java
  23. 85 0
      elab-mq/src/main/java/com/elab/mq/utils/RocketMonitorUtils.java
  24. 5 0
      elab-redis/src/main/java/com/elab/redis/annotation/CacheLoopSubmit.java
  25. 2 2
      elab-redis/src/main/java/com/elab/redis/config/CacheAutoConfiguration.java
  26. 29 0
      elab-redis/src/main/java/com/elab/redis/serializers/CompatibilityJsonRedisSerializer.java
  27. 522 0
      elab-redis/src/test/java/com/elab/marketing/auth/service/response/organize/OrganizeInfoModel.java
  28. 14 4
      elab-redis/src/test/java/com/elab/redis/cache/CacheTest.java
  29. 1 1
      elab-redis/src/test/java/com/elab/redis/service/impl/DemoServiceImpl.java
  30. 61 21
      elab-redis/src/test/java/com/elab/redis/spring/SpringDataTest.java
  31. 81 0
      elab-spring/README.md
  32. 29 0
      elab-spring/src/main/java/com/elab/spring/anno/MQOperation.java
  33. 47 0
      elab-spring/src/main/java/com/elab/spring/config/prop/ThreadPoolProperties.java
  34. 13 0
      elab-spring/src/main/java/com/elab/spring/config/prop/ThreadProperties.java
  35. 3 0
      elab-spring/src/main/java/com/elab/spring/intercept/RMQCacheConsumerInterceptor.java
  36. 2 51
      elab-spring/src/main/java/com/elab/spring/intercept/RMQCacheProducerInterceptor.java
  37. 2 0
      elab-spring/src/main/java/com/elab/spring/intercept/RMQMsgTableConsumerInterceptor.java
  38. 6 14
      elab-spring/src/main/java/com/elab/spring/intercept/RMQMsgTableProducerInterceptor.java
  39. 34 2
      elab-spring/src/main/java/com/elab/spring/utils/RestTemplateUtils.java
  40. 138 0
      elab-spring/src/main/java/com/elab/spring/utils/ThreadProcessUtils.java
  41. 32 0
      elab-spring/src/test/java/com/elab/spring/anno/TestAnnotation.java
  42. 13 1
      elab-spring/src/test/java/com/elab/spring/utils/RestTemplateUtilsTest.java
  43. 103 1
      elab-spring/src/test/java/com/elab/spring/utils/ThreadProcessUtilsTest.java

+ 13 - 0
README.md

@@ -9,3 +9,16 @@
 - [elab-redis](./elab-redis/README.md) : 基于redis的一些简单封装
 - elab-spring : 对Spring的一些拓展封装
 - [elab-kafka](./elab-kafka/README.md) : 基于Kafka使用的封装
+
+### 2.0.5.2-SNAPSHOT 改动记录
+1. 新增线程并行工具类,串联日志。
+2. 调整redis序列化: 兼容fastjson\jackson
+3. 持久层调整支持返回基本数据类型的数据
+```java
+   // 类似于这种
+   public List<基础数据类型> getList(xxx);
+```
+4.  RestTemplateUtils支持`PUT`、`DELETE`请求
+5. 数据收集器新增异常消息和异常栈的参数填充
+
+

+ 24 - 0
elab-annotation/src/main/java/com/elab/annotation/Author.java

@@ -0,0 +1,24 @@
+package com.elab.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * @Module 注解
+ * @Description 作者
+ * @Author liukaixiong
+ * @Date 2021/1/22 19:29
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface Author {
+
+    /**
+     * 作者名称
+     *
+     * @return
+     */
+    String[] nickname() default {};
+
+}

+ 19 - 0
elab-annotation/src/main/java/com/elab/annotation/Description.java

@@ -0,0 +1,19 @@
+package com.elab.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2021/1/22 19:34
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface Description {
+
+    String remark() default "";
+
+}

+ 55 - 69
elab-core/src/main/java/com/elab/core/utils/DateUtils.java

@@ -6,16 +6,18 @@ import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 
-/** 日期操作类
+/**
+ * 日期操作类
+ *
  * @author liuhx on 2017/1/2 14:23
  * @version V1.0
  * @email liuhx@elab-plus.com
  */
 public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
-    public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd",java.util.Locale.CHINA);
-    public static final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss",java.util.Locale.CHINA);
-    public static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",java.util.Locale.CHINA);
+    public static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", java.util.Locale.CHINA);
+    public static final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss", java.util.Locale.CHINA);
+    public static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", java.util.Locale.CHINA);
 
     /**
      * 返回当前时间
@@ -61,8 +63,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 将字符串转换为日期(不包括时间)
      *
-     * @param dateString
-     *            "yyyy-MM-dd"格式的日期字符串
+     * @param dateString "yyyy-MM-dd"格式的日期字符串
      * @return 日期
      */
     public static Date convertToDate(String dateString) {
@@ -86,8 +87,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 将字符串转换为日期(包括时间)
      *
-     * @param dateTimeString
-     *            "yyyy-MM-dd HH:mm:ss"格式的日期字符串
+     * @param dateTimeString "yyyy-MM-dd HH:mm:ss"格式的日期字符串
      * @return 日期时间
      */
     public static Date convertToDateTime(String dateTimeString) {
@@ -101,8 +101,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 将字符串转换为日期(包括时间)
      *
-     * @param dateString
-     *            "dd/MM/yyyy HH:mm"格式的日期字符串
+     * @param dateString "dd/MM/yyyy HH:mm"格式的日期字符串
      * @return 日期
      */
     public static Date convertSimpleToDateTime(String dateString) {
@@ -127,10 +126,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 获取月底
      *
-     * @param year
-     *            年 4位年度
-     * @param month
-     *            月 1~12
+     * @param year  年 4位年度
+     * @param month 月 1~12
      * @return 月底的Date对象。例如:2006-3-31 23:59:59.999
      */
     public static Date getMonthEnd(int year, int month) {
@@ -154,8 +151,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 获取月底
      *
-     * @param when
-     *            要计算月底的日期
+     * @param when 要计算月底的日期
      * @return 月底的Date对象。例如:2006-3-31 23:59:59.999
      */
     public static Date getMonthEnd(Date when) {
@@ -192,8 +188,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 获取给定日的最后一刻。
      *
-     * @param when
-     *            给定日
+     * @param when 给定日
      * @return 最后一刻。例如:2006-4-19 23:59:59.999
      */
     public static Date getDayEnd(Date when) {
@@ -206,8 +201,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 获取给定日的第一刻。
      *
-     * @param when
-     *            给定日
+     * @param when 给定日
      * @return 最后一刻。例如:2006-4-19 23:59:59.999
      */
     public static Date getDay(Date when) {
@@ -220,12 +214,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 日期加法
      *
-     * @param when
-     *            被计算的日期
-     * @param field
-     *            the time field. 在Calendar中定义的常数,例如Calendar.DATE
-     * @param amount
-     *            加数
+     * @param when   被计算的日期
+     * @param field  the time field. 在Calendar中定义的常数,例如Calendar.DATE
+     * @param amount 加数
      * @return 计算后的日期
      */
     public static Date add(Date when, int field, int amount) {
@@ -238,23 +229,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 计算给定的日期加上给定的天数。
      *
-     * @param when
-     *            给定的日期
-     * @param amount
-     *            给定的天数
+     * @param when   给定的日期
+     * @param amount 给定的天数
      * @return 计算后的日期
      */
     public static Date addDays(Date when, int amount) {
 
         return add(when, Calendar.DAY_OF_YEAR, amount);
     }
+
     /**
      * 计算给定的日期加上给定的分钟数。
      *
-     * @param when
-     *            给定的日期
-     * @param amount
-     *            给定的分钟数
+     * @param when   给定的日期
+     * @param amount 给定的分钟数
      * @return 计算后的日期
      */
     public static Date addMinutes(Date when, int amount) {
@@ -265,10 +253,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 计算给定的日期加上给定的秒数。
      *
-     * @param when
-     *            给定的日期
-     * @param amount
-     *            给定的秒数
+     * @param when   给定的日期
+     * @param amount 给定的秒数
      * @return 计算后的日期
      */
     public static Date addSeconds(Date when, int amount) {
@@ -279,10 +265,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 计算给定的日期加上给定的月数。
      *
-     * @param when
-     *            给定的日期
-     * @param amount
-     *            给定的月数
+     * @param when   给定的日期
+     * @param amount 给定的月数
      * @return 计算后的日期
      */
     public static Date addMonths(Date when, int amount) {
@@ -314,7 +298,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     }
 
     /**
-     *
      * @param date
      * @param n
      * @return
@@ -327,6 +310,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
     /**
      * 将Date对象类型转化为日期(2006-09-17 5:20:5)的字符串
+     *
      * @param date
      * @return String
      */
@@ -344,6 +328,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
     /**
      * 将String 类型的转化为日期格式(2006-09-17 5:20:5)
+     *
      * @param dateStr
      * @return Date
      */
@@ -363,23 +348,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 字符串转为时间类型
      *
-     * @param dateStr
-     *            <String>
+     * @param dateStr <String>
      * @return Date
      */
     public static final Date parseDate(String dateStr) {
+        return parseDateByFormat(dateStr, "yyyy-MM-dd");
+    }
 
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+    public static final Date parseDateByFormat(String dateStr, String format) {
 
-        try {
-            return df.parse(dateStr);
-        } catch (ParseException e) {
-            e.printStackTrace();
+        if (StringUtils.isEmpty(dateStr)) {
+            return null;
         }
-        return null;
-    }
-
-    public static final Date parseDateByFormat(String dateStr,String format) {
 
         SimpleDateFormat df = new SimpleDateFormat(format);
 
@@ -394,8 +374,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 得到具体时间如:几天前;几小时前;几分钟前;几秒钟前
      *
-     * @param time
-     *            传入一个Date类型的日期
+     * @param time 传入一个Date类型的日期
      * @return 根据当天当时当秒解析出距离当天当时当秒的字符串 String
      */
     public static String getTimeInterval(Date time) {
@@ -475,7 +454,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     public static String dateToString(Date date, String format) {
 
         try {
-            if(date!=null)
+            if (date != null)
                 return new SimpleDateFormat(format).format(date);
         } catch (Exception e) {
             e.printStackTrace();
@@ -486,6 +465,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
     /**
      * 系统日期减去传入日期得到天数
+     *
      * @param date1 传入日期
      * @return 天数
      * long
@@ -493,12 +473,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     public static long sub(Date date1) {
         Date d2 = convertToDate(dateParseShortString(new Date()));
         Date d1 = convertToDate(dateParseShortString(date1));
-        long day = (d2.getTime() - d1.getTime())/(24*60*60*1000);
+        long day = (d2.getTime() - d1.getTime()) / (24 * 60 * 60 * 1000);
         return day;
     }
 
     /**
      * 日期相减得到年数
+     *
      * @param date1 相减的日期
      * @return
      */
@@ -506,30 +487,32 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         Date d2 = convertToDate(dateParseShortString(new Date()));
         Date d1 = convertToDate(dateParseShortString(date1));
         long day = (d2.getYear() - d1.getYear());
-        return day+1;
+        return day + 1;
     }
 
     /**
      * 计算两个日期间的月份
+     *
      * @param date1 起始日期
      * @param date2 结束日期
      * @return
      */
-    public static long subDateGetMonth(Date date1,Date date2) {
-        DateCalculate  culate=DateCalculate.calculate(date1, date2);
+    public static long subDateGetMonth(Date date1, Date date2) {
+        DateCalculate culate = DateCalculate.calculate(date1, date2);
         return culate.getDifferenceOfMonths();
     }
 
     /**
      * 计算两个日期间的月份,不满一个月按一个月计算
+     *
      * @param date1 起始日期
      * @param date2 结束日期
      * @return
      */
-    public static long subDateGetFullMonth(Date date1,Date date2) {
-        DateCalculate  culate=DateCalculate.calculate(date1, date2);
-        long month=culate.getDifferenceOfMonths();
-        if(culate.getDifferenceOfDays() > 0)
+    public static long subDateGetFullMonth(Date date1, Date date2) {
+        DateCalculate culate = DateCalculate.calculate(date1, date2);
+        long month = culate.getDifferenceOfMonths();
+        if (culate.getDifferenceOfDays() > 0)
             month++;
         return month;
     }
@@ -538,7 +521,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     /**
      * 日期提前一天
      *
-     * @param when 被计算的日期
+     * @param when       被计算的日期
      * @param dateFormat 日期格式化
      * @return 计算后的日期
      */
@@ -551,6 +534,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
     /**
      * 当前日期提前一天
+     *
      * @return
      */
     public static String beforeOneDayByCurDate() {
@@ -559,7 +543,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
     /**
      * 日期提前一个月
-     * @param when 日期
+     *
+     * @param when       日期
      * @param dateFormat 日期格式化
      * @return
      */
@@ -572,6 +557,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
     /**
      * 当前日期提前一个月
+     *
      * @return
      */
     public static String beforeOneMonthByCurDate() {
@@ -583,10 +569,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         System.out.println(yesterday);
         String monthBefore = DateUtils.beforeOneMonthByCurDate();
         System.out.println(monthBefore);
-        Date date = DateUtils.parseDateByFormat(DateUtils.getCurrentTime(),"yyyy-MM-dd HH:mm:ss");
+        Date date = DateUtils.parseDateByFormat(DateUtils.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
         Date date2 = DateUtils.parseDate(DateUtils.getCurrentTime());
         System.out.println(DateUtils.getCurrentTime());
-        System.out.println("date2:"+date2);
+        System.out.println("date2:" + date2);
 
     }
 }

+ 37 - 0
elab-core/src/test/java/com/elab/annno/AnnotationTest.java

@@ -0,0 +1,37 @@
+package com.elab.annno;
+
+import java.lang.annotation.*;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2021/1/22 19:16
+ */
+public class AnnotationTest {
+    @Target(value = ElementType.TYPE)
+    @Retention(value = RetentionPolicy.RUNTIME)
+    @Inherited // 声明注解具有继承性
+    public @interface Author {
+
+        String[] author() default {};
+    }
+
+    @Target(value = ElementType.TYPE)
+    @Retention(value = RetentionPolicy.RUNTIME)
+    @Inherited // 声明注解具有继承性
+    public @interface Phone {
+        String[] phone();
+    }
+
+    @Author
+    @Phone(phone = {"abc"})
+    public @interface Invoke {
+
+    }
+
+    class Process {
+
+    }
+
+}

+ 40 - 8
elab-core/src/test/java/com/elab/test/utils/GuavaUtilsCase.java

@@ -1,15 +1,11 @@
 package com.elab.test.utils;
 
-import com.google.common.base.Joiner;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Splitter;
+import com.google.common.base.*;
 import com.google.common.collect.*;
+import org.checkerframework.checker.nullness.qual.Nullable;
 import org.junit.Test;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 工具类研究
@@ -64,6 +60,7 @@ public class GuavaUtilsCase {
         objectObjectArrayListMultimap.put("aaa", "b");
         objectObjectArrayListMultimap.put("aaa", "c");
         System.out.println("===");
+        List<Object> aaa = objectObjectArrayListMultimap.get("aaa");
 
         HashBiMap<String, String> objectObjectHashBiMap = HashBiMap.create();
         objectObjectHashBiMap.put("a", "b");
@@ -87,7 +84,42 @@ public class GuavaUtilsCase {
 
     @Test
     public void strTest() {
-        String text = "a,b,c,d";
+        List<String> strings = Arrays.asList("A", "B", "C", "D");
         Joiner joiner1 = Joiner.on(",").skipNulls();
+        String join = Joiner.on(",").join(strings);
+        System.out.println(join);
     }
+
+
+    @Test
+    public void checkTest() {
+        Preconditions.checkArgument(true, "条件不能为true");
+    }
+
+    @Test
+    public void sortTest() {
+        // 按照自然排序
+        List<Integer> integerList = Arrays.asList(1, 2, 3, 45);
+        Ordering.natural().nullsFirst().onResultOf(new Function<Object, Comparable>() {
+            @Override
+            public @Nullable Comparable apply(@Nullable Object input) {
+                return null;
+            }
+        });
+    }
+
+    @Test
+    public void functionTest() {
+        Function<Object, Object> objectObjectFunction = Functions.forMap(null);
+        boolean b1 = FluentIterable.of("a", "b").allMatch((o) -> {
+            return false;
+        });
+        boolean b = FluentIterable.of().allMatch(new Predicate() {
+            @Override
+            public boolean apply(Object input) {
+                return false;
+            }
+        });
+    }
+
 }

File diff suppressed because it is too large
+ 23 - 0
elab-core/src/test/java/com/elab/test/utils/JSONUtilsTest.java


+ 12 - 1
elab-db/src/main/java/com/elab/core/dao/BasicBaseDao.java

@@ -58,6 +58,9 @@ public class BasicBaseDao implements ApplicationContextAware,
 
     private ApplicationContext applicationContext;
 
+    /**
+     * 默认的基础类型
+     */
     private Set<Class> basicTypes = Sets.newHashSet(String.class, Integer.class, Double.class, Long.class, Float.class, Date.class);
 
 
@@ -276,12 +279,20 @@ public class BasicBaseDao implements ApplicationContextAware,
 
     private <T> List<T> findForList(Class<T> elementType, JdbcParamsModel jdbcParamsModel) {
         long start = System.currentTimeMillis();
-        List<T> ts = (List<T>) this.jdbcTemplate.query(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), new TimeRowMapperResultSetExtractor(new ThirdRowMapper<T>(elementType)));
+        List<T> ts = (List<T>) this.jdbcTemplate.query(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), new TimeRowMapperResultSetExtractor(getRowMapper(elementType)));
         long time = System.currentTimeMillis() - start;
         logger.debug(" SQL 执行耗时 : " + time);
         return ts;
     }
 
+    protected <T> RowMapper<T> getRowMapper(Class<T> elementType) {
+        if (basicTypes.contains(elementType)) {
+            return new SingleColumnRowMapper<>(elementType);
+        } else {
+            return new ThirdRowMapper<>(elementType);
+        }
+    }
+
     /**
      * 查询一个分页对象
      *

+ 2 - 0
elab-db/src/main/java/com/elab/core/spring/binding/DaoProxy.java

@@ -15,6 +15,8 @@ import java.util.Map;
  * JDK动态代理的具体实现类,这里会将具体的代理过程交给DaoMethod处理,该类只对做一次缓存
  * </p>
  *
+ * 方法的缓存
+ *
  * @author Liukx
  * @create 2018-01-03 11:31
  * @email liukx@elab-plus.com

+ 2 - 0
elab-db/src/main/java/com/elab/core/spring/binding/DaoProxyFactory.java

@@ -15,6 +15,8 @@ import java.util.concurrent.ConcurrentHashMap;
  * 持有整个dao集合对象,每当方法调用会从工厂里面找指定的代理方法
  * </p>
  *
+ * 代理的缓存
+ *
  * @author Liukx
  * @create 2018-01-03 11:30
  * @email liukx@elab-plus.com

+ 1 - 2
elab-db/src/main/java/com/elab/core/spring/config/DataSourceConfigBean.java

@@ -9,7 +9,6 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.core.env.Environment;
 
 import javax.sql.DataSource;
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -29,7 +28,7 @@ public class DataSourceConfigBean {
 
 
     @Bean(name = "default")
-    public DataSource getDefaultDataSource(@Autowired Environment env) throws SQLException {
+    public DataSource getDefaultDataSource(@Autowired Environment env) throws Exception {
         DruidDataSource dataSource = new DruidDataSource();
         dataSource.setDriverClassName(env.getProperty("default.driverClassName", "com.mysql.jdbc.Driver"));
         dataSource.setUrl(env.getProperty("default.url"));

+ 2 - 0
elab-db/src/test/java/com.db.service/dao/ITestDao.java

@@ -27,6 +27,8 @@ public interface ITestDao extends IBaseDaoSupport<TTest> {
 
     public List<TTest2> getTestList(TTest id);
 
+    public List<String> testListString(TTest id);
+
     public List<TTest> getTestList2(TTest id, ListDynamicSearch search);
 
 

+ 9 - 1
elab-db/src/test/java/com.db.service/main/BasicBaseDaoProxyCase.java

@@ -192,11 +192,19 @@ public class BasicBaseDaoProxyCase {
 
     @Test
     public void testSelectByName() throws Exception {
-        TTest bbb = testDao.selectByName("1", "某某某xx33333333");
+        TTest bbb = testDao.selectByName("1", "aaa");
         System.out.println(bbb.toString());
         Assert.assertTrue(bbb != null);
     }
 
+    @Test
+    public void testListString() throws Exception {
+        TTest test = new TTest();
+        test.setStatus("1");
+        List<String> resultList = testDao.testListString(test);
+        Assert.assertTrue(resultList.size() > 0);
+    }
+
     @Test
     public void testSelectByMapper() throws Exception {
         TTest test = new TTest();

+ 39 - 0
elab-db/src/test/java/com.db.service/main/SQLTest.java

@@ -0,0 +1,39 @@
+package com.db.service.main;
+
+import com.alibaba.druid.sql.SQLUtils;
+import com.alibaba.druid.sql.ast.SQLStatement;
+import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser;
+import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor;
+import com.alibaba.druid.sql.parser.SQLStatementParser;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/**
+ * @Module SQL
+ * @Description SQL测试
+ * @Author liukaixiong
+ * @Date 2021/1/28 18:33
+ */
+public class SQLTest {
+
+    @Test
+    public void testSQL() {
+        String sql = "select id,brand_id,house_id,brand_customer_id,mobile,share_sign,scene,source from brand_app_login_log\n" +
+                "where status =1 and share_sign <> '' and brand_customer_id = ? and brand_id = ? order by created desc limit 1";
+        SQLStatementParser parser = new MySqlStatementParser(sql);
+        SQLStatement statement = parser.parseStatement();
+        MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
+        statement.accept(visitor);
+        System.out.println(visitor);
+    }
+
+    @Test
+    public void testSQLUtils() {
+        String sql = "select id,brand_id,house_id,brand_customer_id,mobile,share_sign,scene,source from brand_app_login_log\n" +
+                "where status =1 and share_sign <> '' and brand_customer_id = ? and brand_id = ? order by created desc limit 1";
+        String sqlLog = SQLUtils.format(sql, "mysql", Arrays.asList(1000, 1));
+        System.out.println(sqlLog);
+    }
+
+}

+ 8 - 0
elab-db/src/test/resources/sql/test-sql.xml

@@ -86,6 +86,14 @@
         status = :status
     </sql>
 
+    <sql id="testListString">
+        select
+        username
+        from t_test
+        where
+        status = :status
+    </sql>
+
     <sql id="getTestList2">
         select
         id

+ 8 - 4
elab-kafka/src/main/java/com/elab/core/kafka/consumer/KafkaMsgListener.java

@@ -17,8 +17,8 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * @Module TODO
- * @Description TODO
+ * @Module 监听者
+ * @Description kafka的消息监听
  * @Author liukaixiong
  * @Date 2020/10/27 19:14
  */
@@ -52,7 +52,7 @@ public class KafkaMsgListener implements AcknowledgingMessageListener<String, St
                 }
             } catch (Exception e) {
                 logger.error("kafka消费失败", e);
-                sendMonitorData(data, -1, System.currentTimeMillis() - startTime);
+                sendMonitorData(data, -1, System.currentTimeMillis() - startTime, e);
                 throw e;
             }
             return acknowledgment;
@@ -60,7 +60,11 @@ public class KafkaMsgListener implements AcknowledgingMessageListener<String, St
     }
 
     private void sendMonitorData(ConsumerRecord<String, String> data, Integer status, Long time) {
-        MQDataDTO mqDataDTO = MonitorUtils.builderConsumerMqDataDTO(data.topic(), data.key(), data.partition() + "", data.offset(), data.value(), status, time);
+        sendMonitorData(data, status, time, null);
+    }
+
+    private void sendMonitorData(ConsumerRecord<String, String> data, Integer status, Long time, Throwable e) {
+        MQDataDTO mqDataDTO = MonitorUtils.builderConsumerMqDataDTO(data.topic(), data.key(), data.partition() + "", data.offset(), data.value(), status, time, e);
         MonitorSendProducer.sendMsg(data.topic(), mqDataDTO);
     }
 

+ 1 - 1
elab-kafka/src/main/java/com/elab/core/kafka/sender/KafkaMonitorProducer.java

@@ -44,7 +44,7 @@ public class KafkaMonitorProducer implements ProducerListener<String, String>, I
             CatCrossProcess.createRemoteMQMsg(defaultType, topic, (msgIdMap) -> {
                 logger.debug("topic :" + topic + " 分区 : " + partition + " key : " + key + " value : " + value);
                 logger.error("发送失败", exception);
-                MQDataDTO mq = MonitorUtils.builderProducerMqDataDTO(topic, key, null + "", null, value, 1);
+                MQDataDTO mq = MonitorUtils.builderProducerMqDataDTO(topic, key, null, null, value, 1, exception);
                 MonitorSendProducer.sendMsg(topic, mq);
                 return null;
             });

+ 3 - 3
elab-log/src/main/java/com/elab/log/ext/CatIdMonitorRule.java

@@ -26,10 +26,10 @@ public class CatIdMonitorRule implements MonitorRuleCallback {
                 if (catCrossIdModel.get_catRootMessageId() != null) {
                     tranceLogData.setRootLogId(catCrossIdModel.get_catRootMessageId());
                     tranceLogData.setParentLogId(catCrossIdModel.get_catParentMessageId());
-                    // 这里不用get_catChildMessageId的原因是因为生产者是不确定下游的消费者是谁的。
-                    // 这里还是用当前线程产生的LogId。这个id非常重要。
-                    tranceLogData.setLogId(Cat.getCurrentMessageId());
                 }
+                // 这里不用get_catChildMessageId的原因是因为生产者是不确定下游的消费者是谁的。
+                // 这里还是用当前线程产生的LogId。这个id非常重要。
+                tranceLogData.setLogId(Cat.getCurrentMessageId());
             }
         });
     }

+ 34 - 0
elab-log/src/main/java/com/elab/log/ext/CatSupplier.java

@@ -0,0 +1,34 @@
+package com.elab.log.ext;
+
+import com.elab.log.utils.CatCrossProcess;
+import com.elab.log.utils.CatMsgConstants;
+
+import java.util.Map;
+import java.util.function.Supplier;
+
+/**
+ * @Module 异步线程
+ * @Description
+ * @Author liukaixiong
+ * @Date 2021/1/22 15:55
+ */
+public class CatSupplier<T> implements Supplier<T> {
+
+    private Supplier<T> supplier;
+
+    private Map<String, String> msgContextMap;
+
+    private final String name = "supplier_thread";
+
+    public CatSupplier(Supplier<T> supplier) {
+        this.msgContextMap = CatCrossProcess.getMsgContextMap();
+        this.supplier = supplier;
+    }
+
+    @Override
+    public T get() {
+        return CatCrossProcess.buildRemoteMsg(CatMsgConstants.LOCAL_THREAD_SERVER, name, this.msgContextMap, () -> {
+            return this.supplier.get();
+        });
+    }
+}

+ 2 - 2
elab-mq/src/main/java/com/elab/mq/listener/ConsumerInterceptor.java

@@ -3,8 +3,8 @@ package com.elab.mq.listener;
 import com.elab.mq.model.MessageModel;
 
 /**
- * @Module TODO
- * @Description TODO
+ * @Module 拦截器
+ * @Description 消费者拦截器
  * @Author liukaixiong
  * @Date 2020/12/30 14:57
  */

+ 6 - 68
elab-mq/src/main/java/com/elab/mq/listener/MessageListenerWrapper.java

@@ -4,19 +4,19 @@ import com.aliyun.openservices.ons.api.Action;
 import com.aliyun.openservices.ons.api.ConsumeContext;
 import com.aliyun.openservices.ons.api.Message;
 import com.aliyun.openservices.ons.api.MessageListener;
-import com.dianping.cat.Cat;
 import com.elab.log.utils.CatCrossProcess;
 import com.elab.mq.model.MessageModel;
+import com.elab.mq.utils.RocketMonitorUtils;
 import com.google.common.base.Splitter;
-import com.jay.monitor.data.client.MonitorSendProducer;
-import com.jay.monitor.data.client.utils.MonitorUtils;
-import com.jay.monitor.data.core.model.serializable.MQDataDTO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.*;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 /**
  * 订阅组件适配器
@@ -56,13 +56,12 @@ public class MessageListenerWrapper implements MessageListener {
                             Action actionResult = abstractMessageListener.consume(message, consumeContext);
                             if (actionResult == null || Action.ReconsumeLater == actionResult) {
                                 logger.warn(" MQ 消费失败 : " + abstractMessageListener);
-                                sendMonitorData(message, msgMap, -1, (System.currentTimeMillis() - start));
                                 return Action.ReconsumeLater;
                             }
                         }
                     }
                     long time = System.currentTimeMillis() - start;
-                    sendMonitorData(message, msgMap, 1, time);
+                    RocketMonitorUtils.sendConsumerMonitorData(message, 1, time);
                     return Action.CommitMessage;
                 });
             } catch (Exception e) {
@@ -96,50 +95,6 @@ public class MessageListenerWrapper implements MessageListener {
         return flag;
     }
 
-    private void sendMonitorData(Message data, Map<String, String> msgMap, Integer status, long time) {
-        MessageModel messageModel = new MessageModel(data);
-        String content = (String) messageModel.getObject(String.class);
-        MQDataDTO mqDataDTO = MonitorUtils.builderConsumerRMQDataDTO(data.getTopic(), data.getKey(), data.getTag(), data.getMsgID(), content, status, time);
-
-        builderRemoteId(messageModel, mqDataDTO);
-
-        MonitorSendProducer.sendMsg(data.getTopic(), mqDataDTO);
-    }
-
-    /**
-     * 构建远程编号
-     *
-     * @param data
-     * @param mqDataDTO
-     */
-    private void builderRemoteId(MessageModel data, MQDataDTO mqDataDTO) {
-        String rootId = data.getUserProperties(Cat.Context.ROOT);
-        String parentId = data.getUserProperties(Cat.Context.PARENT);
-
-        mqDataDTO.setParentLogId(parentId);
-        mqDataDTO.setRootLogId(rootId);
-        mqDataDTO.setLogId(Cat.getCurrentMessageId());
-
-        /////////////////// 默认的关键索引线索 ///////////////////////
-
-        if (mqDataDTO.getGroupKeyName() == null) {
-            mqDataDTO.setGroupKeyName(data.getKey());
-        }
-
-        if (mqDataDTO.getGroupName() == null) {
-            mqDataDTO.setGroupName(data.getModuleName());
-        }
-
-        if (mqDataDTO.getDataId() == null) {
-            mqDataDTO.setDataId(data.getProducerId());
-        }
-
-        if (mqDataDTO.getSourceTime() == null && data.getConsumerTime() != null) {
-            mqDataDTO.setSourceTime(new Date(data.getConsumerTime()));
-        }
-
-    }
-
     private Map<String, String> conversionPropertyToMap(Properties userProperties) {
         if (userProperties == null) {
             return null;
@@ -151,21 +106,4 @@ public class MessageListenerWrapper implements MessageListener {
         return msgMap;
     }
 
-//    public static void main(String[] args) {
-//        String text = "LOGIN || AUTHORIZATION_MOBILE || SHARE_XCX || BAOBEI || BAOBEI_SHOUDONG || GZXM || IM_VIDEO ||" +
-//                " SPKF || QIANYUE || DAOFANG || LIUDIAN || RENGOU";
-//        String tag = "Test";
-//        List<String> tagList = Splitter.on("||").trimResults().omitEmptyStrings().splitToList(text);
-//        List<String> tags = Splitter.on("||").trimResults().omitEmptyStrings().splitToList(tag);
-//
-//        if (isContainsTags(text, tag)) {
-//            System.out.println("yes");
-//        } else {
-//            System.out.println("no");
-//        }
-//
-//        System.out.println(tagList);
-//
-//
-//    }
 }

+ 4 - 1
elab-mq/src/main/java/com/elab/mq/msg/impl/MsgProducerImpl.java

@@ -49,7 +49,7 @@ public class MsgProducerImpl extends ProducerBean implements IMsgProducerFacade
             logger.warn("请填相应的key,方便定位该数据");
         }
 
-        CatCrossProcess.createRemoteMQMsg(MQ_PRODUCER, topic + "_" + tag + "_" + getClass().getSimpleName(), (idMap) -> {
+        Object msgResult = CatCrossProcess.createRemoteMQMsg(MQ_PRODUCER, topic + "_" + tag + "_" + getClass().getSimpleName(), (idMap) -> {
             logger.debug(" 发送一条消息 " + message.getMsgID() + " -> " + message.toString());
 
             // 提前插入消息,为了让消息编号能够带过去,如果发送失败,则根据编号更改为-1状态。
@@ -82,6 +82,9 @@ public class MsgProducerImpl extends ProducerBean implements IMsgProducerFacade
                 throw e;
             }
         });
+        if (msgResult != null) {
+            return (SendResultModel) msgResult;
+        }
         return null;
     }
 

+ 85 - 0
elab-mq/src/main/java/com/elab/mq/utils/RocketMonitorUtils.java

@@ -0,0 +1,85 @@
+package com.elab.mq.utils;
+
+import com.aliyun.openservices.ons.api.Message;
+import com.dianping.cat.Cat;
+import com.elab.mq.model.MessageModel;
+import com.jay.monitor.data.client.MonitorSendProducer;
+import com.jay.monitor.data.client.utils.MonitorUtils;
+import com.jay.monitor.data.core.enums.MQTypeEnum;
+import com.jay.monitor.data.core.model.serializable.MQDataDTO;
+
+import java.util.Date;
+
+/**
+ * @Module 工具类
+ * @Description 监控工具类
+ * @Author liukaixiong
+ * @Date 2021/1/19 10:53
+ */
+public class RocketMonitorUtils {
+
+    public static void sendConsumerMonitorData(Message data, Integer status, Throwable e) {
+        sendConsumerMonitorData(data, status, -1L, e);
+    }
+
+    public static void sendConsumerMonitorData(Message data, Integer status, Long requestTime) {
+        sendConsumerMonitorData(data, status, requestTime, null);
+    }
+
+    public static void sendProducerMonitorData(MessageModel data, Integer status, Long requestTime, Throwable e) {
+        String content = (String) data.getObject(String.class);
+        MQDataDTO mqDataDTO = MonitorUtils.builderProducerMqDataDTO(data.getTopic(), data.getKey(), data.getTag(), data.getMsgID(), content, status, e);
+
+        mqDataDTO.setMqType(MQTypeEnum.rocketMQ.name());
+
+        builderRemoteId(data, mqDataDTO);
+
+        MonitorSendProducer.sendMsg(data.getTopic(), mqDataDTO);
+    }
+
+    public static void sendConsumerMonitorData(Message data, Integer status, Long requestTime, Throwable e) {
+        MessageModel messageModel = new MessageModel(data);
+
+        String content = (String) messageModel.getObject(String.class);
+
+        MQDataDTO mqDataDTO = MonitorUtils.builderConsumerRMQDataDTO(data.getTopic(), data.getKey(), data.getTag(), data.getMsgID(), content, status, requestTime, e);
+
+        builderRemoteId(messageModel, mqDataDTO);
+
+        MonitorSendProducer.sendMsg(data.getTopic(), mqDataDTO);
+    }
+
+    /**
+     * 构建远程编号
+     *
+     * @param data
+     * @param mqDataDTO
+     */
+    private static void builderRemoteId(MessageModel data, MQDataDTO mqDataDTO) {
+        String rootId = data.getUserProperties(Cat.Context.ROOT);
+        String parentId = data.getUserProperties(Cat.Context.PARENT);
+
+        mqDataDTO.setParentLogId(parentId);
+        mqDataDTO.setRootLogId(rootId);
+        mqDataDTO.setLogId(Cat.getCurrentMessageId());
+
+        /////////////////// 默认的关键索引线索 ///////////////////////
+
+        if (mqDataDTO.getGroupKeyName() == null) {
+            mqDataDTO.setGroupKeyName(data.getKey());
+        }
+
+        if (mqDataDTO.getGroupName() == null) {
+            mqDataDTO.setGroupName(data.getModuleName());
+        }
+
+        if (mqDataDTO.getDataId() == null) {
+            mqDataDTO.setDataId(data.getProducerId());
+        }
+
+        if (mqDataDTO.getSourceTime() == null && data.getConsumerTime() != null) {
+            mqDataDTO.setSourceTime(new Date(data.getConsumerTime()));
+        }
+
+    }
+}

+ 5 - 0
elab-redis/src/main/java/com/elab/redis/annotation/CacheLoopSubmit.java

@@ -2,6 +2,11 @@ package com.elab.redis.annotation;
 
 import java.lang.annotation.*;
 
+/**
+ * 防重复提交
+ *
+ * @author liukx
+ */
 @Target({ElementType.METHOD, ElementType.TYPE})
 @Retention(RetentionPolicy.RUNTIME)
 @Inherited

+ 2 - 2
elab-redis/src/main/java/com/elab/redis/config/CacheAutoConfiguration.java

@@ -1,6 +1,5 @@
 package com.elab.redis.config;
 
-import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
 import com.elab.redis.CacheTemplate;
 import com.elab.redis.annotation.CacheLoopSubmit;
 import com.elab.redis.annotation.CacheReadLock;
@@ -9,6 +8,7 @@ import com.elab.redis.interceptor.LockCacheAttributeSourceAdvisor;
 import com.elab.redis.interceptor.LockCacheAttributeSourcePointcut;
 import com.elab.redis.interceptor.LockCacheInterceptor;
 import com.elab.redis.redisson.DefaultRedissonSpringCacheManager;
+import com.elab.redis.serializers.CompatibilityJsonRedisSerializer;
 import com.elab.redis.spring.data.RedisTemplateDecorator;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -52,7 +52,7 @@ public class CacheAutoConfiguration {
         RedisTemplate<String, Object> template = new RedisTemplateDecorator<>();
         template.setConnectionFactory(redisConnectionFactory);
         template.setKeySerializer(new StringRedisSerializer());
-        template.setValueSerializer(new GenericFastJsonRedisSerializer());
+        template.setValueSerializer(new CompatibilityJsonRedisSerializer());
         template.setHashKeySerializer(new StringRedisSerializer());
         template.setHashValueSerializer(new StringRedisSerializer());
         return template;

+ 29 - 0
elab-redis/src/main/java/com/elab/redis/serializers/CompatibilityJsonRedisSerializer.java

@@ -0,0 +1,29 @@
+package com.elab.redis.serializers;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+
+/**
+ * @Module redis序列化
+ * @Description 通用的序列化类,兼容fastjson、jackson两个版本
+ * @Author liukaixiong
+ * @Date 2021/1/18 15:33
+ */
+public class CompatibilityJsonRedisSerializer extends GenericFastJsonRedisSerializer {
+
+    private GenericJackson2JsonRedisSerializer redisSerializer = new GenericJackson2JsonRedisSerializer();
+
+    @Override
+    public Object deserialize(byte[] bytes) throws SerializationException {
+        Object deserialize = super.deserialize(bytes);
+        if (deserialize != null && deserialize instanceof JSONObject) {
+            String clazz = ((JSONObject) deserialize).getString("@class");
+            if (clazz != null) {
+                return redisSerializer.deserialize(bytes);
+            }
+        }
+        return deserialize;
+    }
+}

+ 522 - 0
elab-redis/src/test/java/com/elab/marketing/auth/service/response/organize/OrganizeInfoModel.java

@@ -0,0 +1,522 @@
+package com.elab.marketing.auth.service.response.organize;
+
+import java.util.Date;
+
+/**用户的组织信息
+ * @author liyx
+ * @create 2019/11/8 15:08
+ * @email liyx@elab-plus.com
+ * @Description:
+ **/
+public class OrganizeInfoModel {
+
+	/**
+	 * 组织id
+	 */
+	private Integer organizeId;
+	/**
+	 * 组织用户id
+	 */
+	private Integer organizeUserId;
+	/**
+	 * 性别  0:女,1:男
+	 */
+	private Integer organizeUserSex;
+	/**
+	 * 组织用户姓名
+	 */
+	private String organizeUserName;
+	/**
+	 * 组织名称
+	 */
+	private String organizeName;
+
+	/**
+	 * 组织类别  1:案场顾问,2:分销经济人,3:代理公司,4:老业主,5自建渠道
+	 */
+	private Integer organizeType;
+	/**
+	 * 是否IM保护  0:关闭,1:组织保护,2:个人保护
+	 */
+	private Integer safeIm;
+	/**
+	 * 是否开启授权   0:否, 1:是
+	 */
+	private Integer openAuthorize;
+	/**
+	 * 是否自动报备:1:是  0:否
+	 */
+	private Integer autoRecord;
+	/**
+	 * 渠道码
+	 */
+	private String code;
+	/**
+	 * 是否开启裂变数据   0:否, 1:是
+	 */
+	private Integer openFission;
+
+	/**
+	 * 组织服务类型   1:渠道拓客,2:跟进客户
+	 */
+	private Integer serveType;
+	/**
+	 * 是否开启跟进保护期 0:否, 1:是
+	 */
+	private Integer openFollowProtectPeriod;
+	/**
+	 * 跟进保护期天数
+	 */
+	private Integer followProtectPeriod;
+	/**
+	 * 是否开启跟进结佣 0:否,1:是
+	 */
+	private Integer openFollowCommission;
+	/**
+	 * 跟进结佣条件 1:已签约,2:已结首付,3:已结全款
+	 */
+	private Integer followCommissionCondition;
+	/**
+	 * 是否开启报备保护期 0:否,1:是
+	 */
+	private Integer openRecordProtectPeriod;
+	/**
+	 * 报备保护期天数
+	 */
+	private Integer recordProtectPeriod;
+	/**
+	 * 是否开启防截客保护 0:否,1:是
+	 */
+	private Integer openInterceptProtectPeriod;
+	/**
+	 * 防截客保护期小时
+	 */
+	private Float interceptProtectPeriod;
+	/**
+	 * 是否开启拓客结佣条件 0:否,1:是
+	 */
+	private Integer openTokeCommission;
+	/**
+	 * 拓客结佣条件  1:已签约,2:已结首付,3:已结全款
+	 */
+	private Integer tokeCommissionCondition;
+	/**
+	 * 是否开启成交保护期   1:是  0:否
+	 */
+	private Integer openDealProtectionPeriod;
+	/**
+	 * 成交保护期
+	 */
+	private Integer dealProtectionPeriod;
+	/**
+	 * 继承逻辑  1:不继承,2:自动继承,3:手动继承,4:优先自动继承,提供手动选项
+	 */
+	private Integer inheritLogic;
+	/**
+	 * 是否开启手动报备  1:是,0:否
+	 */
+	private Integer manualRecord;
+	/**
+	 * 是否IM顾问  1:是,0:否
+	 */
+	private Integer imAdviser;
+	/**
+	 * 是否视频顾问 1:是,0:否
+	 */
+	private Integer videoAdviser;
+
+	/**
+	 * 组织领导人姓名(多个用逗号隔开)
+	 */
+	private String leaderName;
+
+	private String photo;
+
+	private String email;
+	private String honor;
+
+	/**
+	 * 关系人开关  0:关闭,1:开启
+	 */
+	private Integer relatedPersonSwitch;
+	private String remark;
+
+	private Integer followService;
+
+	private String organizeAvatarUrl;
+	private Integer verificationRole;
+	private Date verificationTime;
+	private Long verificationId;
+	
+	private Integer organizeUserRlatId;
+	
+	private Integer organizeHouseRlatId;
+	
+	private Integer openTwiceReport;
+	
+	private Integer twiceReportCondition;
+	
+	private Integer twiceReportOverdueDays;
+	
+	private Integer canReport;
+
+	public Integer getOrganizeId() {
+		return organizeId;
+	}
+
+	public void setOrganizeId(Integer organizeId) {
+		this.organizeId = organizeId;
+	}
+
+	public Integer getOrganizeUserId() {
+		return organizeUserId;
+	}
+
+	public void setOrganizeUserId(Integer organizeUserId) {
+		this.organizeUserId = organizeUserId;
+	}
+
+	public Integer getOrganizeUserSex() {
+		return organizeUserSex;
+	}
+
+	public void setOrganizeUserSex(Integer organizeUserSex) {
+		this.organizeUserSex = organizeUserSex;
+	}
+
+	public String getOrganizeUserName() {
+		return organizeUserName;
+	}
+
+	public void setOrganizeUserName(String organizeUserName) {
+		this.organizeUserName = organizeUserName;
+	}
+
+	public String getOrganizeName() {
+		return organizeName;
+	}
+
+	public void setOrganizeName(String organizeName) {
+		this.organizeName = organizeName;
+	}
+
+	public Integer getOrganizeType() {
+		return organizeType;
+	}
+
+	public void setOrganizeType(Integer organizeType) {
+		this.organizeType = organizeType;
+	}
+
+	public Integer getSafeIm() {
+		return safeIm;
+	}
+
+	public void setSafeIm(Integer safeIm) {
+		this.safeIm = safeIm;
+	}
+
+	public Integer getOpenAuthorize() {
+		return openAuthorize;
+	}
+
+	public void setOpenAuthorize(Integer openAuthorize) {
+		this.openAuthorize = openAuthorize;
+	}
+
+	public Integer getAutoRecord() {
+		return autoRecord;
+	}
+
+	public void setAutoRecord(Integer autoRecord) {
+		this.autoRecord = autoRecord;
+	}
+
+	public String getCode() {
+		return code;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public Integer getOpenFission() {
+		return openFission;
+	}
+
+	public void setOpenFission(Integer openFission) {
+		this.openFission = openFission;
+	}
+
+	public Integer getServeType() {
+		return serveType;
+	}
+
+	public void setServeType(Integer serveType) {
+		this.serveType = serveType;
+	}
+
+	public Integer getOpenFollowProtectPeriod() {
+		return openFollowProtectPeriod;
+	}
+
+	public void setOpenFollowProtectPeriod(Integer openFollowProtectPeriod) {
+		this.openFollowProtectPeriod = openFollowProtectPeriod;
+	}
+
+	public Integer getFollowProtectPeriod() {
+		return followProtectPeriod;
+	}
+
+	public void setFollowProtectPeriod(Integer followProtectPeriod) {
+		this.followProtectPeriod = followProtectPeriod;
+	}
+
+	public Integer getOpenFollowCommission() {
+		return openFollowCommission;
+	}
+
+	public void setOpenFollowCommission(Integer openFollowCommission) {
+		this.openFollowCommission = openFollowCommission;
+	}
+
+	public Integer getFollowCommissionCondition() {
+		return followCommissionCondition;
+	}
+
+	public void setFollowCommissionCondition(Integer followCommissionCondition) {
+		this.followCommissionCondition = followCommissionCondition;
+	}
+
+	public Integer getOpenRecordProtectPeriod() {
+		return openRecordProtectPeriod;
+	}
+
+	public void setOpenRecordProtectPeriod(Integer openRecordProtectPeriod) {
+		this.openRecordProtectPeriod = openRecordProtectPeriod;
+	}
+
+	public Integer getRecordProtectPeriod() {
+		return recordProtectPeriod;
+	}
+
+	public void setRecordProtectPeriod(Integer recordProtectPeriod) {
+		this.recordProtectPeriod = recordProtectPeriod;
+	}
+
+	public Integer getOpenInterceptProtectPeriod() {
+		return openInterceptProtectPeriod;
+	}
+
+	public void setOpenInterceptProtectPeriod(Integer openInterceptProtectPeriod) {
+		this.openInterceptProtectPeriod = openInterceptProtectPeriod;
+	}
+
+	public Float getInterceptProtectPeriod() {
+		return interceptProtectPeriod;
+	}
+
+	public void setInterceptProtectPeriod(Float interceptProtectPeriod) {
+		this.interceptProtectPeriod = interceptProtectPeriod;
+	}
+
+	public Integer getOpenTokeCommission() {
+		return openTokeCommission;
+	}
+
+	public void setOpenTokeCommission(Integer openTokeCommission) {
+		this.openTokeCommission = openTokeCommission;
+	}
+
+	public Integer getTokeCommissionCondition() {
+		return tokeCommissionCondition;
+	}
+
+	public void setTokeCommissionCondition(Integer tokeCommissionCondition) {
+		this.tokeCommissionCondition = tokeCommissionCondition;
+	}
+
+	public Integer getOpenDealProtectionPeriod() {
+		return openDealProtectionPeriod;
+	}
+
+	public void setOpenDealProtectionPeriod(Integer openDealProtectionPeriod) {
+		this.openDealProtectionPeriod = openDealProtectionPeriod;
+	}
+
+	public Integer getDealProtectionPeriod() {
+		return dealProtectionPeriod;
+	}
+
+	public void setDealProtectionPeriod(Integer dealProtectionPeriod) {
+		this.dealProtectionPeriod = dealProtectionPeriod;
+	}
+
+	public Integer getInheritLogic() {
+		return inheritLogic;
+	}
+
+	public void setInheritLogic(Integer inheritLogic) {
+		this.inheritLogic = inheritLogic;
+	}
+
+	public Integer getManualRecord() {
+		return manualRecord;
+	}
+
+	public void setManualRecord(Integer manualRecord) {
+		this.manualRecord = manualRecord;
+	}
+
+	public Integer getImAdviser() {
+		return imAdviser;
+	}
+
+	public void setImAdviser(Integer imAdviser) {
+		this.imAdviser = imAdviser;
+	}
+
+	public Integer getVideoAdviser() {
+		return videoAdviser;
+	}
+
+	public void setVideoAdviser(Integer videoAdviser) {
+		this.videoAdviser = videoAdviser;
+	}
+
+	public String getLeaderName() {
+		return leaderName;
+	}
+
+	public void setLeaderName(String leaderName) {
+		this.leaderName = leaderName;
+	}
+
+	public String getPhoto() {
+		return photo;
+	}
+
+	public void setPhoto(String photo) {
+		this.photo = photo;
+	}
+
+	public String getEmail() {
+		return email;
+	}
+
+	public void setEmail(String email) {
+		this.email = email;
+	}
+
+	public String getHonor() {
+		return honor;
+	}
+
+	public void setHonor(String honor) {
+		this.honor = honor;
+	}
+
+	public Integer getRelatedPersonSwitch() {
+		return relatedPersonSwitch;
+	}
+
+	public void setRelatedPersonSwitch(Integer relatedPersonSwitch) {
+		this.relatedPersonSwitch = relatedPersonSwitch;
+	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
+
+	public Integer getFollowService() {
+		return followService;
+	}
+
+	public void setFollowService(Integer followService) {
+		this.followService = followService;
+	}
+
+	public String getOrganizeAvatarUrl() {
+		return organizeAvatarUrl;
+	}
+
+	public void setOrganizeAvatarUrl(String organizeAvatarUrl) {
+		this.organizeAvatarUrl = organizeAvatarUrl;
+	}
+
+	public Integer getVerificationRole() {
+		return verificationRole;
+	}
+
+	public void setVerificationRole(Integer verificationRole) {
+		this.verificationRole = verificationRole;
+	}
+
+	public Date getVerificationTime() {
+		return verificationTime;
+	}
+
+	public void setVerificationTime(Date verificationTime) {
+		this.verificationTime = verificationTime;
+	}
+
+	public Long getVerificationId() {
+		return verificationId;
+	}
+
+	public void setVerificationId(Long verificationId) {
+		this.verificationId = verificationId;
+	}
+
+	public Integer getOrganizeUserRlatId() {
+		return organizeUserRlatId;
+	}
+
+	public void setOrganizeUserRlatId(Integer organizeUserRlatId) {
+		this.organizeUserRlatId = organizeUserRlatId;
+	}
+
+	public Integer getOrganizeHouseRlatId() {
+		return organizeHouseRlatId;
+	}
+
+	public void setOrganizeHouseRlatId(Integer organizeHouseRlatId) {
+		this.organizeHouseRlatId = organizeHouseRlatId;
+	}
+
+	public Integer getOpenTwiceReport() {
+		return openTwiceReport;
+	}
+
+	public void setOpenTwiceReport(Integer openTwiceReport) {
+		this.openTwiceReport = openTwiceReport;
+	}
+
+	public Integer getTwiceReportCondition() {
+		return twiceReportCondition;
+	}
+
+	public void setTwiceReportCondition(Integer twiceReportCondition) {
+		this.twiceReportCondition = twiceReportCondition;
+	}
+
+	public Integer getTwiceReportOverdueDays() {
+		return twiceReportOverdueDays;
+	}
+
+	public void setTwiceReportOverdueDays(Integer twiceReportOverdueDays) {
+		this.twiceReportOverdueDays = twiceReportOverdueDays;
+	}
+
+	public Integer getCanReport() {
+		return canReport;
+	}
+
+	public void setCanReport(Integer canReport) {
+		this.canReport = canReport;
+	}
+}

+ 14 - 4
elab-redis/src/test/java/com/elab/redis/cache/CacheTest.java

@@ -2,6 +2,7 @@ package com.elab.redis.cache;
 
 import com.alibaba.fastjson.JSONObject;
 import com.elab.core.componts.ConcurrentTool;
+import com.elab.core.utils.RandomUtils;
 import com.elab.redis.RedisSpringBoot;
 import com.elab.redis.redisson.doc.model.SomeObject;
 import com.elab.redis.service.IDemoService;
@@ -58,10 +59,19 @@ public class CacheTest extends RedisSpringBoot {
 
     @Test
     public void testCacheObject() throws Exception {
-        SomeObject someObject = new SomeObject();
-        someObject.setText("asdfasdf");
-        someObject.setName("lkx");
-        demoService.submit(someObject);
+        ConcurrentTool concurrentTool = new ConcurrentTool(10);
+        concurrentTool.process(() -> {
+            SomeObject someObject = new SomeObject();
+            someObject.setText("asdfasdf");
+            someObject.setName("lkx_" + RandomUtils.randomNum(2));
+            try {
+                demoService.submit(someObject);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            return null;
+        });
+        System.in.read();
     }
 
     @Test

+ 1 - 1
elab-redis/src/test/java/com/elab/redis/service/impl/DemoServiceImpl.java

@@ -36,7 +36,7 @@ public class DemoServiceImpl implements IDemoService {
     }
 
     @Override
-    @CacheLoopSubmit(unionKey = {"[0]{text}", "[0]{name}"}, cacheName = "demo", timeOut = 10)
+    @CacheLoopSubmit(unionKey = {"[0]{text},[0]{name}"}, cacheName = "demo", timeOut = 10)
     public String submit(SomeObject text) throws Exception {
         count--;
         Thread.sleep(500);

+ 61 - 21
elab-redis/src/test/java/com/elab/redis/spring/SpringDataTest.java

@@ -1,16 +1,16 @@
 package com.elab.redis.spring;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
+import com.elab.marketing.auth.service.response.organize.OrganizeInfoModel;
 import com.elab.redis.CacheTemplate;
 import com.elab.redis.RedisSpringBoot;
+import com.elab.redis.serializers.CompatibilityJsonRedisSerializer;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
 
 import java.io.IOException;
-import java.util.List;
 
 /**
  * springData
@@ -29,9 +29,49 @@ public class SpringDataTest extends RedisSpringBoot {
     @Autowired
     private StringRedisTemplate stringRedisTemplate;
 
+
+    @Test
+    public void serializerTest() {
+        RedisTemplate<String, Object> redisTemplate = cacheTemplate.getRedisTemplate();
+//        Set<Object> lyx =
+//                setOperations.members("lyx");
+//        List<String> collect = lyx.stream().map(String::valueOf).collect(Collectors.toList());
+//        redisTemplate.delete(collect);
+        String typeKey = "user:organize:userInfo:10018:13602651614";
+        String classKey = "user:organize:userInfo:10018:18154115526";
+
+        // 默认当前版本是 [GenericFastJsonRedisSerializer]
+        Object classObject = redisTemplate.opsForValue().get(classKey);
+        Object typeObject = redisTemplate.opsForValue().get(typeKey);
+        String tmpKey = "user:organize:userInfo:10018:testKey2";
+        redisTemplate.opsForValue().set(tmpKey, "1");
+        redisTemplate.opsForValue().increment(tmpKey, 10);
+        // 之前版本是 [GenericJackson2JsonRedisSerializer]
+        redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
+        Object classObject1 = redisTemplate.opsForValue().get(classKey);
+        Object typeObject1 = redisTemplate.opsForValue().get(typeKey);
+        tmpKey = "user:organize:userInfo:10018:testKey";
+        redisTemplate.opsForValue().set(tmpKey, "1");
+        redisTemplate.opsForValue().increment(tmpKey, 10);
+        // 兼容版本
+        redisTemplate.setValueSerializer(new CompatibilityJsonRedisSerializer());
+        Object classObject2 = redisTemplate.opsForValue().get(classKey);
+        Object typeObject2 = redisTemplate.opsForValue().get(typeKey);
+
+        if (classObject instanceof OrganizeInfoModel) {
+            System.out.println(true);
+        }
+    }
+
     @Test
     public void set() throws IOException {
 
+        RedisTemplate<String, Object> redisTemplate = cacheTemplate.getRedisTemplate();
+//        Set<Object> lyx =
+//                setOperations.members("lyx");
+//        List<String> collect = lyx.stream().map(String::valueOf).collect(Collectors.toList());
+//        redisTemplate.delete(collect);
+
 //        cacheTemplate.set().add("aaa","a","b","c");
 //
 //
@@ -59,24 +99,24 @@ public class SpringDataTest extends RedisSpringBoot {
 //        String val = (String) cacheTemplate.map().get("aaa", "d-key");
 //        String val = (String) cacheTemplate.map().get("aaa", "fff");
 
-        String key = "data_center:material_labels_key:1";
-        Object value = cacheTemplate.string().get(key);
-
-        List<JSONObject> jsonObjects = JSON.parseArray(value.toString(), JSONObject.class);
-        jsonObjects.forEach((str) -> {
-            String materialsId = str.getString("materialsId");
-            cacheTemplate.map().put("data_center:material_labels_key:1111", materialsId, str.toJSONString());
-        });
-
-        System.out.println(jsonObjects.toArray());
-
-        // 获取hash的key的所有值
-//        Map<String, Object> dataMap = cacheTemplate.map().entries("data_center:material_labels_key:1");
-//        System.out.println(dataMap.toString());
-//        System.out.println(val);
-
-        System.out.println("OK");
-        System.in.read();
+//        String key = "data_center:material_labels_key:1";
+//        Object value = cacheTemplate.string().get(key);
+//
+//        List<JSONObject> jsonObjects = JSON.parseArray(value.toString(), JSONObject.class);
+//        jsonObjects.forEach((str) -> {
+//            String materialsId = str.getString("materialsId");
+//            cacheTemplate.map().put("data_center:material_labels_key:1111", materialsId, str.toJSONString());
+//        });
+//
+//        System.out.println(jsonObjects.toArray());
+//
+//        // 获取hash的key的所有值
+////        Map<String, Object> dataMap = cacheTemplate.map().entries("data_center:material_labels_key:1");
+////        System.out.println(dataMap.toString());
+////        System.out.println(val);
+//
+//        System.out.println("OK");
+//        System.in.read();
 
     }
 }

+ 81 - 0
elab-spring/README.md

@@ -220,3 +220,84 @@ spring:
       scheduling-interval-second: 30 # 调度间隔时长(秒)
 ```
 
+#### 并行处理
+
+该框架的使用方式和`CompletableFuture`基本保持一致,只是仅仅涵盖了链路串联功能。
+希望大家能够统一使用框架封装的,好处就是在修改的时候能统一修改,调优也是。
+
+- 单个请求
+```java
+CompletableFuture<String> stringCompletableFuture = ThreadProcessUtils.supplyAsync(() -> {
+    logger.info("任务开始之前:" + Cat.getCurrentMessageId());
+    try {
+        Thread.sleep(3000);
+    } catch (Exception e) {
+    }
+    logger.info("任务开始之后:" + Cat.getCurrentMessageId());
+    return "ABC";
+});
+
+// 在此期间可以执行其他业务操作
+
+// 需要注意的是到这一步是阻塞的。
+String s = stringCompletableFuture.get();
+```
+
+- 多个请求,按照顺序返回结果
+```java
+// 这里需要注意的是第一个参数,true代表是等所有结果加载完了才返回,false是先提交任务执行,这个过程不一定能拿到结果。
+CompletableFuture<String>[] completableFutures = ThreadProcessUtils.supplyAsync(true,() -> {
+    logger.info("任务1 - 开始" + Cat.getCurrentMessageId());
+    Thread.sleep(3000);
+    logger.info("任务1 - 结束" + Cat.getCurrentMessageId());
+    return "ABC1";
+}, () -> {
+    logger.info("任务2 - 开始:" + Cat.getCurrentMessageId());
+    logger.info("任务2 - 结束" + Cat.getCurrentMessageId());
+    return "ABC2";
+});
+
+// 如果上面是true表示结果加载完了才会执行到这里,如果是false的话,就需要这里阻塞去拿结果.
+for (int i = 0; i < completableFutures.length; i++) {
+    String s = completableFutures[i].get();
+    logger.info("结果:" + s);
+}
+```
+
+- 多个请求,按照提交的key拿到结果
+```java
+
+Map<String, Supplier<String>> taskMap = new LinkedHashMap<>();
+taskMap.put("A", () -> {
+    logger.info("A 开始" + Cat.getCurrentMessageId());
+    sleep(1000);
+    logger.info("A 结束" + Cat.getCurrentMessageId());
+    return "A-result";
+});
+
+taskMap.put("B", () -> {
+    logger.info("B 开始" + Cat.getCurrentMessageId());
+    sleep(1000);
+    logger.info("B 结束" + Cat.getCurrentMessageId());
+    return "B-result";
+});
+
+taskMap.put("C", () -> {
+    logger.info("C 开始" + Cat.getCurrentMessageId());
+    sleep(1000);
+    logger.info("C 结束" + Cat.getCurrentMessageId());
+    return "C-result";
+});
+
+Map<String, CompletableFuture<String>> completableFutureMap = ThreadProcessUtils.supplyAsync(taskMap);
+
+
+// 根据提交的key,获取对应的值
+String a = completableFutureMap.get("A").get();
+String b = completableFutureMap.get("B").get();
+String c = completableFutureMap.get("C").get();
+
+logger.info("获取对应的结果:" + a);
+logger.info("获取对应的结果:" + b);
+logger.info("获取对应的结果:" + c);
+```

+ 29 - 0
elab-spring/src/main/java/com/elab/spring/anno/MQOperation.java

@@ -0,0 +1,29 @@
+package com.elab.spring.anno;
+
+import com.elab.annotation.Author;
+import com.elab.annotation.Description;
+import org.springframework.core.annotation.AliasFor;
+
+import java.lang.annotation.*;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2021/1/22 19:41
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+@Author
+@Description
+public @interface MQOperation {
+
+    @AliasFor(annotation = Author.class, attribute = "nickname")
+    String[] nickname() default {};
+
+    @AliasFor(annotation = Description.class, attribute = "remark")
+    String remark() default "";
+
+}

+ 47 - 0
elab-spring/src/main/java/com/elab/spring/config/prop/ThreadPoolProperties.java

@@ -0,0 +1,47 @@
+package com.elab.spring.config.prop;
+
+/**
+ * @Module 配置文件
+ * @Description 线程池配置
+ * @Author liukaixiong
+ * @Date 2021/1/26 17:24
+ */
+public class ThreadPoolProperties {
+
+    /**
+     * 核心线程数
+     */
+    private int corePoolSize = Runtime.getRuntime().availableProcessors() * 2;
+    /**
+     * 最大线程数
+     */
+    private int maximumPoolSize = Runtime.getRuntime().availableProcessors() * 4;
+    /**
+     * 线程存活时间(秒)
+     */
+    private int keepAliveTime = 0;
+
+    public int getCorePoolSize() {
+        return corePoolSize;
+    }
+
+    public void setCorePoolSize(int corePoolSize) {
+        this.corePoolSize = corePoolSize;
+    }
+
+    public int getMaximumPoolSize() {
+        return maximumPoolSize;
+    }
+
+    public void setMaximumPoolSize(int maximumPoolSize) {
+        this.maximumPoolSize = maximumPoolSize;
+    }
+
+    public int getKeepAliveTime() {
+        return keepAliveTime;
+    }
+
+    public void setKeepAliveTime(int keepAliveTime) {
+        this.keepAliveTime = keepAliveTime;
+    }
+}

+ 13 - 0
elab-spring/src/main/java/com/elab/spring/config/prop/ThreadProperties.java

@@ -21,6 +21,19 @@ public class ThreadProperties {
      */
     private Integer realQueueSize = 1000;
 
+    /**
+     * 核心线程池
+     */
+    private ThreadPoolProperties threadPool = new ThreadPoolProperties();
+
+    public ThreadPoolProperties getThreadPool() {
+        return threadPool;
+    }
+
+    public void setThreadPool(ThreadPoolProperties threadPool) {
+        this.threadPool = threadPool;
+    }
+
     public Integer getSchedulingIntervalSecond() {
         return schedulingIntervalSecond;
     }

+ 3 - 0
elab-spring/src/main/java/com/elab/spring/intercept/RMQCacheConsumerInterceptor.java

@@ -3,6 +3,7 @@ package com.elab.spring.intercept;
 import com.elab.mq.consts.MqConstants;
 import com.elab.mq.listener.ConsumerInterceptor;
 import com.elab.mq.model.MessageModel;
+import com.elab.mq.utils.RocketMonitorUtils;
 import com.elab.redis.config.ElabRedisProperties;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -134,6 +135,8 @@ public class RMQCacheConsumerInterceptor implements ConsumerInterceptor {
         if (currentStatus <= 1) {
             redisTemplate.opsForValue().set(key, 2);
         }
+        RocketMonitorUtils.sendConsumerMonitorData(messageModel, -1, e);
     }
 
+
 }

+ 2 - 51
elab-spring/src/main/java/com/elab/spring/intercept/RMQCacheProducerInterceptor.java

@@ -1,19 +1,14 @@
 package com.elab.spring.intercept;
 
 import com.aliyun.openservices.ons.api.SendResult;
-import com.dianping.cat.Cat;
 import com.elab.mq.model.MessageModel;
 import com.elab.mq.msg.ProducerInterceptor;
+import com.elab.mq.utils.RocketMonitorUtils;
 import com.elab.redis.CacheTemplate;
-import com.jay.monitor.data.client.MonitorSendProducer;
-import com.jay.monitor.data.client.utils.MonitorUtils;
-import com.jay.monitor.data.core.model.serializable.MQDataDTO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.util.Date;
-
 /**
  * @Module rmq拦截器
  * @Description 基于缓存实现
@@ -43,59 +38,15 @@ public class RMQCacheProducerInterceptor implements ProducerInterceptor {
 
     @Override
     public void success(MessageModel messageModel, String groupName, SendResult result) {
-        sendMonitorData(messageModel, 1);
         logger.debug("业务处理成功,携带的消息唯一编号:" + messageModel.getProducerId());
     }
 
     @Override
     public void error(MessageModel messageModel, String groupName, Throwable e) {
-        sendMonitorData(messageModel, -1);
+        RocketMonitorUtils.sendProducerMonitorData(messageModel, -1, -1L, e);
         logger.debug("业务处理失败,携带的消息唯一编号:" + messageModel.getProducerId());
     }
 
-    private void sendMonitorData(MessageModel data, Integer status) {
-        String content = (String) data.getObject(String.class);
-        MQDataDTO mqDataDTO = MonitorUtils.builderProducerRMQDataDTO(data.getTopic(), data.getKey(), data.getTag(), data.getMsgID(), content, status);
-
-        builderRemoteId(data, mqDataDTO);
-
-        MonitorSendProducer.sendMsg(data.getTopic(), mqDataDTO);
-    }
-
-    /**
-     * 构建远程编号,留下相应线索
-     *
-     * @param data
-     * @param mqDataDTO
-     */
-    private void builderRemoteId(MessageModel data, MQDataDTO mqDataDTO) {
-        ///////////////// 上下文链路编号 ////////////////////
-        String rootId = data.getUserProperties(Cat.Context.ROOT);
-        String parentId = data.getUserProperties(Cat.Context.PARENT);
-
-        mqDataDTO.setParentLogId(parentId);
-        mqDataDTO.setRootLogId(rootId);
-        mqDataDTO.setLogId(parentId);
-
-        /////////////////// 默认的关键索引线索 ///////////////////////
-        if (mqDataDTO.getGroupKeyName() == null) {
-            mqDataDTO.setGroupKeyName(data.getKey());
-        }
-
-        if (mqDataDTO.getGroupName() == null) {
-            mqDataDTO.setGroupName(data.getModuleName());
-        }
-
-        if (mqDataDTO.getDataId() == null) {
-            mqDataDTO.setDataId(data.getProducerId());
-        }
-
-        if (mqDataDTO.getSourceTime() == null) {
-            mqDataDTO.setSourceTime(new Date());
-        }
-
-    }
-
     private String getCacheKey() {
         return defaultPrefix;
     }

+ 2 - 0
elab-spring/src/main/java/com/elab/spring/intercept/RMQMsgTableConsumerInterceptor.java

@@ -7,6 +7,7 @@ import com.elab.mq.consts.MqConstants;
 import com.elab.mq.listener.ConsumerInterceptor;
 import com.elab.mq.model.MessageModel;
 import com.elab.mq.model.MqConsumerLogEntity;
+import com.elab.mq.utils.RocketMonitorUtils;
 import com.elab.spring.dao.IConsumerDao;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,6 +49,7 @@ public class RMQMsgTableConsumerInterceptor implements ConsumerInterceptor {
     @Override
     public void error(MessageModel messageModel,String groupName, Throwable e) {
         saveConsumerStatus(messageModel, MqConstants.MSG_NO, messageModel.getInvokeTime());
+        RocketMonitorUtils.sendConsumerMonitorData(messageModel, -1, e);
     }
 
     /**

+ 6 - 14
elab-spring/src/main/java/com/elab/spring/intercept/RMQMsgTableProducerInterceptor.java

@@ -8,10 +8,8 @@ import com.elab.core.utils.StringUtils;
 import com.elab.mq.model.MessageModel;
 import com.elab.mq.model.MqProducerLogEntity;
 import com.elab.mq.msg.ProducerInterceptor;
+import com.elab.mq.utils.RocketMonitorUtils;
 import com.elab.spring.dao.IProducerDao;
-import com.jay.monitor.data.client.MonitorSendProducer;
-import com.jay.monitor.data.client.utils.MonitorUtils;
-import com.jay.monitor.data.core.model.serializable.MQDataDTO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,21 +36,21 @@ public class RMQMsgTableProducerInterceptor implements ProducerInterceptor {
     private String groupId;
 
     @Override
-    public boolean check(MessageModel messageModel,String groupName) {
+    public boolean check(MessageModel messageModel, String groupName) {
         int id = insertRecordProducer(messageModel);
         messageModel.setProducerId(id + "");
         return true;
     }
 
     @Override
-    public void success(MessageModel messageModel,String groupName, SendResult result) {
-        sendMonitorData(messageModel, 1);
+    public void success(MessageModel messageModel, String groupName, SendResult result) {
+        RocketMonitorUtils.sendProducerMonitorData(messageModel, 1, -1L, null);
     }
 
     @Override
-    public void error(MessageModel messageModel,String groupName, Throwable e) {
+    public void error(MessageModel messageModel, String groupName, Throwable e) {
         updateRecordProducer(Integer.valueOf(messageModel.getProducerId()), -1, e.getMessage());
-        sendMonitorData(messageModel, -1);
+        RocketMonitorUtils.sendProducerMonitorData(messageModel, -1, -1L, e);
     }
 
     /**
@@ -113,10 +111,4 @@ public class RMQMsgTableProducerInterceptor implements ProducerInterceptor {
         }
     }
 
-    private void sendMonitorData(MessageModel data, Integer status) {
-        String content = (String) data.getObject(String.class);
-        MQDataDTO mqDataDTO = MonitorUtils.builderProducerRMQDataDTO(data.getTopic(), data.getKey(), data.getTag(), data.getMsgID(), content, status);
-        MonitorSendProducer.sendMsg(data.getTopic(), mqDataDTO);
-    }
-
 }

+ 34 - 2
elab-spring/src/main/java/com/elab/spring/utils/RestTemplateUtils.java

@@ -209,6 +209,34 @@ public class RestTemplateUtils {
         return responseData;
     }
 
+    /**
+     * delete 删除请求
+     *
+     * @param url
+     * @param httpHeaders
+     * @param reqParam
+     * @param clazz
+     * @param <T>
+     * @return
+     */
+    public <T> T delete(String url, HttpHeaders httpHeaders, Object reqParam, Class<T> clazz) {
+        return exchange(url, HttpMethod.DELETE, reqParam, clazz, httpHeaders, null);
+    }
+
+    /**
+     * 修改请求
+     *
+     * @param url
+     * @param httpHeaders
+     * @param reqParam
+     * @param clazz
+     * @param <T>
+     * @return
+     */
+    public <T> T put(String url, HttpHeaders httpHeaders, Object reqParam, Class<T> clazz) {
+        return exchange(url, HttpMethod.PUT, reqParam, clazz, httpHeaders, null);
+    }
+
     private <T> void requestAfter(String url, HttpHeaders httpHeaders, Object reqParam, Class<T> clazz, IRestFallback<?> restFallback) throws Exception {
         if (restFallback != null) {
             restFallback.requestAfter(url, httpHeaders, reqParam, clazz);
@@ -308,6 +336,10 @@ public class RestTemplateUtils {
      * @return
      */
     public <T> T get(String url, Object body, Class<T> clazz, HttpHeaders httpHeaders, IRestFallback restFallback) {
+        return exchange(url, HttpMethod.GET, body, clazz, httpHeaders, restFallback);
+    }
+
+    private <T> T exchange(String url, HttpMethod httpMethod, Object body, Class<T> clazz, HttpHeaders httpHeaders, IRestFallback restFallback) {
         String newUrl = getUrl(url);
         Transaction t = Cat.getProducer().newTransaction(CatMsgConstants.THIRD_PARTY, newUrl);
         logger.debug(" URL : " + url);
@@ -321,9 +353,9 @@ public class RestTemplateUtils {
             ResponseEntity<T> result = null;
             if (body == null) {
                 logger.debug(" DATA :" + body);
-                result = restTemplate.exchange(url, HttpMethod.GET, entity, clazz);
+                result = restTemplate.exchange(url, httpMethod, entity, clazz);
             } else {
-                result = getRestTemplate.exchange(url, HttpMethod.GET, entity, clazz);
+                result = getRestTemplate.exchange(url, httpMethod, entity, clazz);
             }
             responseData = result.getBody();
             t.setStatus(Transaction.SUCCESS);

+ 138 - 0
elab-spring/src/main/java/com/elab/spring/utils/ThreadProcessUtils.java

@@ -4,11 +4,19 @@ import com.elab.core.async.RealTaskExecutor;
 import com.elab.core.async.SchedulingTaskExecutor;
 import com.elab.core.async.model.TaskStoreData;
 import com.elab.core.async.pruducer.ITaskProducer;
+import com.elab.log.ext.CatSupplier;
+import com.elab.spring.config.prop.ThreadPoolProperties;
+import com.elab.spring.config.prop.ThreadProperties;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.*;
+import java.util.function.Supplier;
+
 /**
  * @Module 工具类
  * @Description 线程执行工具类
@@ -16,10 +24,30 @@ import org.springframework.context.ApplicationContextAware;
  * @Date 2020/11/18 15:51
  */
 public class ThreadProcessUtils implements ApplicationContextAware, InitializingBean {
+
     private ApplicationContext applicationContext;
 
     private static ITaskProducer taskProducer;
 
+    private ThreadProperties threadProperties;
+
+    private static ExecutorService executorService;
+
+    private Long defaultTimeOut = 10000L;
+
+    static ExecutorService getExecutorService() {
+        return executorService;
+    }
+
+    /**
+     * 设置线程池
+     *
+     * @param executorService
+     */
+    static void setExecutorService(ExecutorService executorService) {
+        ThreadProcessUtils.executorService = executorService;
+    }
+
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         this.applicationContext = applicationContext;
@@ -31,6 +59,106 @@ public class ThreadProcessUtils implements ApplicationContextAware, Initializing
         }
     }
 
+    /**
+     * 支持异步并串联日志
+     *
+     * @param supplier 提交任务
+     * @param <U>
+     * @return
+     */
+    public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier) {
+        return CompletableFuture.supplyAsync(new CatSupplier<>(supplier), getExecutorService());
+    }
+
+    /**
+     * 并行任务执行
+     *
+     * @param supplier 任务列表
+     * @param <U>
+     * @return
+     * @throws Exception
+     */
+    public static <U> CompletableFuture<U>[] supplyAsync(Supplier<U>... supplier) throws Exception {
+        return supplyAsync(true, null, supplier);
+    }
+
+    /**
+     * 多任务并行处理,最终按照提交顺序返回
+     *
+     * @param isBlockResult 是否阻塞返回结果
+     * @param supplier      提交任务
+     * @param <U>
+     * @return 阻塞
+     * @throws Exception
+     */
+    public static <U> CompletableFuture<U>[] supplyAsync(boolean isBlockResult, Long timeOutMs, Supplier<U>... supplier) throws Exception {
+        CompletableFuture<U>[] result = new CompletableFuture[supplier.length];
+        for (int i = 0; i < supplier.length; i++) {
+            CompletableFuture<U> completableFuture = supplyAsync(supplier[i]);
+            result[i] = completableFuture;
+        }
+
+        allOf(isBlockResult, timeOutMs, result);
+
+        return result;
+    }
+
+
+    public static <U> Map<String, CompletableFuture<U>> supplyAsync(Map<String, Supplier<U>> taskGroupMap) throws Exception {
+        return supplyAsync(true, taskGroupMap);
+    }
+
+    /**
+     * 多任务并行处理,并按照key分组后返回结果
+     *
+     * @param isBlockResult 是否阻塞返回结果集
+     * @param taskGroupMap  任务分组map
+     * @param <U>
+     * @return
+     * @throws Exception
+     */
+    public static <U> Map<String, CompletableFuture<U>> supplyAsync(boolean isBlockResult, Map<String, Supplier<U>> taskGroupMap) throws Exception {
+        return supplyAsync(isBlockResult, taskGroupMap, null);
+    }
+
+    /**
+     * 异步调用
+     *
+     * @param isBlockResult
+     * @param taskGroupMap
+     * @param timeOutMs
+     * @param <U>
+     * @return
+     * @throws Exception
+     */
+    public static <U> Map<String, CompletableFuture<U>> supplyAsync(boolean isBlockResult, Map<String, Supplier<U>> taskGroupMap, Long timeOutMs) throws Exception {
+        CompletableFuture<U>[] result = new CompletableFuture[taskGroupMap.size()];
+
+        Map<String, CompletableFuture<U>> resultMap = new HashMap<>();
+        int i = 0;
+        for (Map.Entry<String, Supplier<U>> entry : taskGroupMap.entrySet()) {
+            CompletableFuture<U> completableFuture = supplyAsync(entry.getValue());
+            result[i] = completableFuture;
+            resultMap.put(entry.getKey(), completableFuture);
+            i++;
+        }
+
+        allOf(isBlockResult, timeOutMs, result);
+
+        return resultMap;
+    }
+
+    private static <U> void allOf(boolean isBlockResult, Long timeOutMs, CompletableFuture<U>[] result) throws InterruptedException, ExecutionException, TimeoutException {
+        if (isBlockResult) {
+            CompletableFuture<Void> completableFuture = CompletableFuture.allOf(result);
+            if (timeOutMs != null) {
+                completableFuture.get(timeOutMs, TimeUnit.MILLISECONDS);
+            } else {
+                completableFuture.get();
+            }
+        }
+    }
+
     public static void addSchedulingList(SchedulingTaskExecutor schedulingTaskExecutor) {
         if (taskProducer != null) {
             taskProducer.sendSchedulingList(schedulingTaskExecutor);
@@ -41,5 +169,15 @@ public class ThreadProcessUtils implements ApplicationContextAware, Initializing
     @Override
     public void afterPropertiesSet() throws Exception {
         taskProducer = this.applicationContext.getBean(ITaskProducer.class);
+        this.threadProperties = this.applicationContext.getBean(ThreadProperties.class);
+        if (this.threadProperties != null && this.threadProperties.getThreadPool() != null) {
+            ThreadPoolProperties threadPool = this.threadProperties.getThreadPool();
+            ExecutorService executorService = new ThreadPoolExecutor(threadPool.getCorePoolSize(), threadPool.getMaximumPoolSize(), threadPool.getKeepAliveTime(), TimeUnit.SECONDS, new ArrayBlockingQueue(100));
+            setExecutorService(executorService);
+        } else {
+            ThreadPoolProperties threadPool = new ThreadPoolProperties();
+            ExecutorService executorService = new ThreadPoolExecutor(threadPool.getCorePoolSize(), threadPool.getMaximumPoolSize(), threadPool.getKeepAliveTime(), TimeUnit.SECONDS, new ArrayBlockingQueue(100));
+            setExecutorService(executorService);
+        }
     }
 }

+ 32 - 0
elab-spring/src/test/java/com/elab/spring/anno/TestAnnotation.java

@@ -0,0 +1,32 @@
+package com.elab.spring.anno;
+
+import com.elab.annotation.Author;
+import org.junit.Test;
+import org.springframework.core.annotation.AnnotatedElementUtils;
+
+import java.lang.reflect.Method;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2021/1/22 19:44
+ */
+
+public class TestAnnotation {
+
+    @MQOperation(nickname = {"liukx", "lkx"}, remark = "abc")
+    public void test1() {
+
+    }
+
+    @Test
+    public void test() throws Exception {
+        Method test1 = TestAnnotation.class.getDeclaredMethod("test1", null);
+        Author mergedAnnotation = AnnotatedElementUtils.findMergedAnnotation(test1, Author.class);
+
+        System.out.println(mergedAnnotation);
+
+    }
+
+}

+ 13 - 1
elab-spring/src/test/java/com/elab/spring/utils/RestTemplateUtilsTest.java

@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.elab.core.aop.annotations.EnableElabDB;
 import com.elab.core.utils.GzipUtils;
-import com.elab.core.utils.StringUtils;
 import com.elab.spring.callback.IRestFallback;
 import com.elab.spring.callback.impl.DefaultRestFallBack;
 import com.elab.spring.dao.MngHttpFailureDataDao;
@@ -20,6 +19,8 @@ import org.springframework.web.client.RestTemplate;
 import java.io.*;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.zip.GZIPInputStream;
 
 @RunWith(SpringRunner.class)
@@ -74,6 +75,17 @@ public class RestTemplateUtilsTest {
         Assert.assertNotNull(get);
     }
 
+
+    @Test
+    public void delete() {
+        String url = "http://localhost:5800/test";
+        Map<String, String> req = new HashMap<>();
+        req.put("abc", "asdsfd");
+        JSONObject get = restTemplateUtils.delete(url, null, req, JSONObject.class);
+        System.out.println("--->" + get);
+        Assert.assertNotNull(get);
+    }
+
     @Test
     public void getBody() {
         String url = "https://api-test-e.source3g.com/third-face-detect/foreign/face/customer/detail";

+ 103 - 1
elab-spring/src/test/java/com/elab/spring/utils/ThreadProcessUtilsTest.java

@@ -11,6 +11,11 @@ import org.slf4j.LoggerFactory;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Supplier;
+
 /**
  * @Module TODO
  * @Description TODO
@@ -39,10 +44,107 @@ public class ThreadProcessUtilsTest extends TestCase {
     @Test
     public void testAddSchedulingList() throws Exception {
         logger.info("sadfasdfsdfsad:::" + Cat.getCurrentMessageId());
-        ThreadProcessUtils.addSchedulingList(()->{
+        ThreadProcessUtils.addSchedulingList(() -> {
             System.out.println("这是一个调度操作" + Cat.getCurrentMessageId());
         });
         System.in.read();
     }
 
+    @Test
+    public void testSupplyAsync() throws Exception {
+        Transaction transaction = Cat.newTransaction("test", "msg");
+        CompletableFuture<String> stringCompletableFuture = ThreadProcessUtils.supplyAsync(() -> {
+            logger.info("哈哈哈之前:" + Cat.getCurrentMessageId());
+            try {
+                Thread.sleep(3000);
+            } catch (Exception e) {
+            }
+            logger.info("哈哈之后..." + Cat.getCurrentMessageId());
+            return "ABC";
+        });
+        String s = stringCompletableFuture.get();
+        logger.info("结果:" + s);
+        transaction.setSuccessStatus();
+        transaction.complete();
+        System.in.read();
+    }
+
+    @Test
+    public void testBatchSupplyAsync() throws Exception {
+        Transaction transaction = Cat.newTransaction("test", "msg");
+        CompletableFuture<String>[] completableFutures = ThreadProcessUtils.supplyAsync(() -> {
+            logger.info("任务1 - 开始" + Cat.getCurrentMessageId());
+            try {
+                Thread.sleep(3000);
+            } catch (Exception e) {
+            }
+            logger.info("任务1 - 结束" + Cat.getCurrentMessageId());
+            return "ABC1";
+        }, () -> {
+            logger.info("任务2 - 开始:" + Cat.getCurrentMessageId());
+            try {
+                Thread.sleep(3000);
+            } catch (Exception e) {
+            }
+            logger.info("任务2 - 结束" + Cat.getCurrentMessageId());
+            return "ABC2";
+        });
+
+        for (int i = 0; i < completableFutures.length; i++) {
+            String s = completableFutures[i].get();
+            logger.info("结果:" + s);
+        }
+
+        transaction.setSuccessStatus();
+        transaction.complete();
+        System.in.read();
+    }
+
+    @Test
+    public void testSupplyAsyncMap() throws Exception {
+        Transaction transaction = Cat.newTransaction("test", "msg");
+
+
+        Map<String, Supplier<String>> taskMap = new LinkedHashMap<>();
+        taskMap.put("A", () -> {
+            logger.info("A 开始" + Cat.getCurrentMessageId());
+            sleep(1000);
+            logger.info("A 结束" + Cat.getCurrentMessageId());
+            return "A-result";
+        });
+        taskMap.put("B", () -> {
+            logger.info("B 开始" + Cat.getCurrentMessageId());
+            sleep(1000);
+            logger.info("B 结束" + Cat.getCurrentMessageId());
+            return "B-result";
+        });
+        taskMap.put("C", () -> {
+            logger.info("C 开始" + Cat.getCurrentMessageId());
+            sleep(1000);
+            logger.info("C 结束" + Cat.getCurrentMessageId());
+            return "C-result";
+        });
+
+        Map<String, CompletableFuture<String>> completableFutureMap = ThreadProcessUtils.supplyAsync(taskMap);
+        String a = completableFutureMap.get("A").get();
+        String b = completableFutureMap.get("B").get();
+        String c = completableFutureMap.get("C").get();
+
+        logger.info("获取对应的结果:" + a);
+        logger.info("获取对应的结果:" + b);
+        logger.info("获取对应的结果:" + c);
+
+        transaction.setSuccessStatus();
+        transaction.complete();
+        System.in.read();
+    }
+
+    private void sleep(int ms) {
+        try {
+            Thread.sleep(ms);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
 }