Browse Source

1. 升级底层

liukx 4 years ago
parent
commit
8676d666c7

+ 1 - 1
elab-alert/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>elab-parent</artifactId>
         <groupId>com.elab.core</groupId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>elab-alert</artifactId>

+ 1 - 1
elab-annotation/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>elab-parent</artifactId>
         <groupId>com.elab.core</groupId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
elab-cache/pom.xml

@@ -6,7 +6,7 @@
     <parent>
         <groupId>com.elab.core</groupId>
         <artifactId>elab-parent</artifactId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <groupId>com.elab.cache</groupId>
     <artifactId>elab-cache</artifactId>

+ 1 - 1
elab-core/pom.xml

@@ -7,7 +7,7 @@
     <parent>
         <groupId>com.elab.core</groupId>
         <artifactId>elab-parent</artifactId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
 
     <groupId>com.elab.core</groupId>

+ 1 - 1
elab-db/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <groupId>com.elab.core</groupId>
         <artifactId>elab-parent</artifactId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>elab-db</artifactId>

+ 153 - 89
elab-db/src/main/java/com/elab/core/dao/BasicBaseDao.java

@@ -4,16 +4,14 @@ import com.alibaba.fastjson.JSON;
 import com.elab.core.bean.PageModel;
 import com.elab.core.dao.model.JdbcParamsModel;
 import com.elab.core.dao.model.ListDynamicSearch;
+import com.elab.core.dao.model.SqlResult;
 import com.elab.core.dao.params.BeanSqlParameterSource;
 import com.elab.core.dao.params.MapDataSqlParameterSource;
 import com.elab.core.dao.params.NamedParameterUtils2;
 import com.elab.core.dao.params.ParsedSql2;
 import com.elab.core.dao.row.ThirdRowMapper;
 import com.elab.core.exception.CoreException;
-import com.elab.core.spring.method.BatchPreparedStatementCreator;
-import com.elab.core.spring.method.CheckSqlProcess;
-import com.elab.core.spring.method.DefaultCheckSQLProcess;
-import com.elab.core.spring.method.SQLEventHandler;
+import com.elab.core.spring.method.*;
 import com.elab.core.sql.config.SqlCommandType;
 import com.elab.core.utils.BeanPropertyUtils;
 import com.google.common.collect.Sets;
@@ -45,8 +43,7 @@ import java.util.*;
  * @create 2018-04-20 15:36
  * @email liukx@elab-plus.com
  **/
-public class BasicBaseDao implements ApplicationContextAware,
-        InitializingBean {
+public class BasicBaseDao implements ApplicationContextAware, InitializingBean {
 
     private Logger logger = LoggerFactory.getLogger(BasicBaseDao.class);
 
@@ -56,13 +53,15 @@ public class BasicBaseDao implements ApplicationContextAware,
 
     private List<SQLEventHandler> sqlEventHandlerList;
 
+    private List<SQLPostProcess> sqlPostProcessorList;
+
     private ApplicationContext applicationContext;
 
     /**
      * 默认的基础类型
      */
-    private Set<Class> basicTypes = Sets.newHashSet(String.class, Integer.class, Double.class, Long.class, Float.class, Date.class);
-
+    private Set<Class> basicTypes =
+        Sets.newHashSet(String.class, Integer.class, Double.class, Long.class, Float.class, Date.class);
 
     @Override
     public void afterPropertiesSet() throws Exception {
@@ -74,24 +73,32 @@ public class BasicBaseDao implements ApplicationContextAware,
                 this.sqlEventHandlerList.add(V);
             });
         }
+
+        Map<String, SQLPostProcess> sqlPostProcessMap = this.applicationContext.getBeansOfType(SQLPostProcess.class);
+        if (sqlPostProcessMap != null && sqlPostProcessMap.size() > 0) {
+            this.sqlPostProcessorList = new ArrayList<>();
+            sqlPostProcessMap.forEach((K, V) -> {
+                this.sqlPostProcessorList.add(V);
+            });
+        }
     }
 
-//    @Override
-//    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
-//
-//    }
+    //    @Override
+    //    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
+    //
+    //    }
 
-//    @Override
-//    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
-//        Map<String, CheckSqlProcess> beansOfType = this.applicationContext.getBeansOfType(CheckSqlProcess.class);
-//        Map<String, SQLEventHandler> SQLEventHandlerMap = this.applicationContext.getBeansOfType(SQLEventHandler.class);
-//        if (SQLEventHandlerMap != null && SQLEventHandlerMap.size() > 0) {
-//            this.sqlEventHandlerList = new ArrayList<>();
-//            SQLEventHandlerMap.forEach((K, V) -> {
-//                this.sqlEventHandlerList.add(V);
-//            });
-//        }
-//    }
+    //    @Override
+    //    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
+    //        Map<String, CheckSqlProcess> beansOfType = this.applicationContext.getBeansOfType(CheckSqlProcess.class);
+    //        Map<String, SQLEventHandler> SQLEventHandlerMap = this.applicationContext.getBeansOfType(SQLEventHandler.class);
+    //        if (SQLEventHandlerMap != null && SQLEventHandlerMap.size() > 0) {
+    //            this.sqlEventHandlerList = new ArrayList<>();
+    //            SQLEventHandlerMap.forEach((K, V) -> {
+    //                this.sqlEventHandlerList.add(V);
+    //            });
+    //        }
+    //    }
 
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
@@ -134,12 +141,12 @@ public class BasicBaseDao implements ApplicationContextAware,
 
     @SuppressWarnings("serial")
     private final Map<String, ParsedSql2> parsedSqlCache =
-            new LinkedHashMap<String, ParsedSql2>(cacheLimit, 0.75f, true) {
-                @Override
-                protected boolean removeEldestEntry(Map.Entry<String, ParsedSql2> eldest) {
-                    return size() > getCacheLimit();
-                }
-            };
+        new LinkedHashMap<String, ParsedSql2>(cacheLimit, 0.75f, true) {
+            @Override
+            protected boolean removeEldestEntry(Map.Entry<String, ParsedSql2> eldest) {
+                return size() > getCacheLimit();
+            }
+        };
 
     /**
      * 参数转换 , 参数类型分别为 Map,Model
@@ -150,7 +157,7 @@ public class BasicBaseDao implements ApplicationContextAware,
     private SqlParameterSource getSqlParameterSource(Object params) {
         SqlParameterSource sqlParameterSource = null;
         if (params instanceof Map) {
-            sqlParameterSource = new MapSqlParameterSource((Map) params);
+            sqlParameterSource = new MapSqlParameterSource((Map)params);
         } else {
             sqlParameterSource = new BeanPropertySqlParameterSource(params);
         }
@@ -178,7 +185,6 @@ public class BasicBaseDao implements ApplicationContextAware,
         }
     }
 
-
     /**
      * 通用sql处理方式
      *
@@ -244,7 +250,8 @@ public class BasicBaseDao implements ApplicationContextAware,
     public <T> List<T> executeQueryList(String sql, Object o, Class<T> elementType) throws Exception {
         JdbcParamsModel jdbcParamsModel = commonParseSql(sql, o);
         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(new ThirdRowMapper<T>(elementType)));
         long time = System.currentTimeMillis() - start;
         logger.debug(" SQL 执行耗时 : " + time);
         return ts;
@@ -253,7 +260,8 @@ public class BasicBaseDao implements ApplicationContextAware,
     public <T> List<T> executeQueryBasicTypeList(String sql, Object o, Class<T> elementType) throws Exception {
         JdbcParamsModel jdbcParamsModel = commonParseSql(sql, o);
         long start = System.currentTimeMillis();
-        List<T> ts = (List<T>) this.jdbcTemplate.query(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), new SingleColumnRowMapper<>(elementType));
+        List<T> ts = (List<T>)this.jdbcTemplate
+            .query(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), new SingleColumnRowMapper<>(elementType));
         long time = System.currentTimeMillis() - start;
         logger.debug(" SQL 执行耗时 : " + time);
         return ts;
@@ -270,8 +278,8 @@ public class BasicBaseDao implements ApplicationContextAware,
      * @return
      * @throws Exception
      */
-    public <T> List<T> executeQueryList(String sql, Object obj, ListDynamicSearch search, Class<T> elementType) throws
-            Exception {
+    public <T> List<T> executeQueryList(String sql, Object obj, ListDynamicSearch search, Class<T> elementType)
+        throws Exception {
         JdbcParamsModel jdbcParamsModel = commonParseSql(sql, obj, search);
         List<T> ts = findForList(elementType, jdbcParamsModel);
         return ts;
@@ -279,7 +287,8 @@ 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(getRowMapper(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;
@@ -303,10 +312,12 @@ public class BasicBaseDao implements ApplicationContextAware,
      * @param <T>
      * @return
      */
-    public <T> List<T> executeQueryPage(PageModel pageModel, String sql, Object o, Class<T> elementType) throws Exception {
+    public <T> List<T> executeQueryPage(PageModel pageModel, String sql, Object o, Class<T> elementType)
+        throws Exception {
         JdbcParamsModel jdbcParamsModel = commonParseSql(sql, o);
         long start = System.currentTimeMillis();
-        List<T> ts = this.jdbcTemplate.query(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), new ThirdRowMapper<T>(elementType));
+        List<T> ts = this.jdbcTemplate
+            .query(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), new ThirdRowMapper<T>(elementType));
         long time = System.currentTimeMillis() - start;
         logger.debug(" SQL 执行耗时 : " + time);
         return ts;
@@ -336,7 +347,8 @@ public class BasicBaseDao implements ApplicationContextAware,
     public int executeQueryCount(String sql, Object arg) throws Exception {
         JdbcParamsModel jdbcParamsModel = commonParseSql(sql, arg);
         long start = System.currentTimeMillis();
-        Integer count = this.jdbcTemplate.queryForObject(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), Integer.class);
+        Integer count =
+            this.jdbcTemplate.queryForObject(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), Integer.class);
         long time = System.currentTimeMillis() - start;
         logger.debug(" SQL 执行耗时 : " + time);
         logger.debug(" 获取到的总数 : " + count);
@@ -350,10 +362,12 @@ public class BasicBaseDao implements ApplicationContextAware,
      * @param o   参数
      * @return
      */
-    public List<Map<String, Object>> executeQueryForListMap(String sql, Object o, ListDynamicSearch dynamicSearch) throws Exception {
+    public List<Map<String, Object>> executeQueryForListMap(String sql, Object o, ListDynamicSearch dynamicSearch)
+        throws Exception {
         JdbcParamsModel jdbcParamsModel = commonParseSql(sql, o, dynamicSearch);
         long start = System.currentTimeMillis();
-        List<Map<String, Object>> maps = this.jdbcTemplate.queryForList(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects());
+        List<Map<String, Object>> maps =
+            this.jdbcTemplate.queryForList(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects());
         long time = System.currentTimeMillis() - start;
         logger.debug(" SQL 执行耗时 : " + time);
         return maps;
@@ -386,7 +400,8 @@ public class BasicBaseDao implements ApplicationContextAware,
      */
     public <T> List<T> queryBigDataForList(String sql, Object[] args, Class<T> elementType) throws DataAccessException {
         long start = System.currentTimeMillis();
-        List<T> query = (List<T>) this.jdbcTemplate.query(sql, args, new TimeRowMapperResultSetExtractor(new ThirdRowMapper<T>(elementType)));
+        List<T> query = (List<T>)this.jdbcTemplate
+            .query(sql, args, new TimeRowMapperResultSetExtractor(new ThirdRowMapper<T>(elementType)));
         long time = System.currentTimeMillis() - start;
         logger.debug(" SQL 执行耗时 : " + time);
         return query;
@@ -421,7 +436,8 @@ public class BasicBaseDao implements ApplicationContextAware,
      * @return
      * @throws Exception
      */
-    public <T> T executeQueryCount(String sql, Object o, ListDynamicSearch search, Class<T> elementType) throws Exception {
+    public <T> T executeQueryCount(String sql, Object o, ListDynamicSearch search, Class<T> elementType)
+        throws Exception {
         JdbcParamsModel jdbcParamsModel = commonParseSql(sql, o, search);
         long start = System.currentTimeMillis();
         T ts = executorQuerySingleObject(elementType, jdbcParamsModel);
@@ -440,7 +456,8 @@ public class BasicBaseDao implements ApplicationContextAware,
      */
     private <T> T executorQuerySingleObject(Class<T> elementType, JdbcParamsModel jdbcParamsModel) {
         try {
-            return this.jdbcTemplate.queryForObject(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), elementType);
+            return this.jdbcTemplate
+                .queryForObject(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects(), elementType);
         } catch (EmptyResultDataAccessException e) {
             return null;
         } catch (IncorrectResultSizeDataAccessException e) {
@@ -449,7 +466,6 @@ public class BasicBaseDao implements ApplicationContextAware,
         }
     }
 
-
     /**
      * 查询一个数据集合对象,根据自定义的数据转换器返回
      *
@@ -528,30 +544,38 @@ public class BasicBaseDao implements ApplicationContextAware,
     /**
      * 添加数据操作
      *
-     * @param sql SQL语句
-     * @param o   参数对象
+     * @param sql     SQL语句
+     * @param request 参数对象
      * @return
      */
-    public int insert(String sqlId, String table, String sql, Object o) throws Exception {
+    public int insert(String sqlId, String table, String sql, Object request) throws Exception {
         int result = 0;
-        SqlParameterSource sqlParameterSource = getSqlParameterSource(o);
-        GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
-        sqlInvokeBefore(SqlCommandType.INSERT, sqlId, table, sql, o);
-        long start = System.currentTimeMillis();
-        logger.debug("sql : " + sql + "\r\n" + JSON.toJSONString(o));
-        this.getNamedParameterJdbcTemplate().update(sql, sqlParameterSource, keyHolder);
-        // 如果存在自动生成的主键,不存在那么表示参数中已经涵盖了,不需要返回。
-        if (keyHolder.getKey() != null) {
-            result = keyHolder.getKey().intValue();
+        boolean isOk = false;
+        try {
+            SqlParameterSource sqlParameterSource = getSqlParameterSource(request);
+            GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
+            sqlInvokeBefore(SqlCommandType.INSERT, sqlId, table, sql, request);
+            long start = System.currentTimeMillis();
+            logger.debug("sql : " + sql + "\r\n" + JSON.toJSONString(request));
+            this.getNamedParameterJdbcTemplate().update(sql, sqlParameterSource, keyHolder);
+            // 如果存在自动生成的主键,不存在那么表示参数中已经涵盖了,不需要返回。
+            if (keyHolder.getKey() != null) {
+                result = keyHolder.getKey().intValue();
+            }
+            logger.debug(" 得到主键 : " + result);
+            long time = System.currentTimeMillis() - start;
+            logger.debug(" SQL 执行耗时 : " + time);
+            sqlInvokeAfter(SqlCommandType.INSERT, sqlId, table, sql, request, result);
+            sqlPostCallBack(SqlCommandType.INSERT, sqlId, table, sql, request, result, time, 1);
+            isOk = true;
+        } finally {
+            if (!isOk) {
+                sqlPostCallBack(SqlCommandType.INSERT, sqlId, table, sql, request, result, -1L, -1);
+            }
         }
-        logger.debug(" 得到主键 : " + result);
-        long time = System.currentTimeMillis() - start;
-        logger.debug(" SQL 执行耗时 : " + time);
-        sqlInvokeAfter(SqlCommandType.INSERT, sqlId, table, sql, o, result);
         return result;
     }
 
-
     /**
      * 将内部参数转换成对应的属性器
      *
@@ -562,16 +586,15 @@ public class BasicBaseDao implements ApplicationContextAware,
     private SqlParameterSource getConvertSqlParameterSource(Object bean, Map<String, String> nameMap) {
         SqlParameterSource sqlParameterSource = null;
         if (bean instanceof Map) {
-            sqlParameterSource = new MapDataSqlParameterSource((Map<String, ?>) bean);
+            sqlParameterSource = new MapDataSqlParameterSource((Map<String, ?>)bean);
         } else {
             sqlParameterSource = new BeanSqlParameterSource(bean);
-            ((BeanSqlParameterSource) sqlParameterSource).setPropertyMap(nameMap);
+            ((BeanSqlParameterSource)sqlParameterSource).setPropertyMap(nameMap);
         }
         return sqlParameterSource;
     }
 
-    public int[] batchOperation(SqlCommandType sqlCommandType, String sql, List list)
-            throws Exception {
+    public int[] batchOperation(SqlCommandType sqlCommandType, String sql, List list) throws Exception {
         return batchOperation(sqlCommandType, "", "", sql, list);
     }
 
@@ -583,8 +606,8 @@ public class BasicBaseDao implements ApplicationContextAware,
      * @param list           数据集合
      * @return
      */
-    public int[] batchOperation(SqlCommandType sqlCommandType, String sqlId, String table, String sql, List list) throws
-            Exception {
+    public int[] batchOperation(SqlCommandType sqlCommandType, String sqlId, String table, String sql, List list)
+        throws Exception {
         if (list != null && list.size() > 0) {
             long start = System.currentTimeMillis();
             logger.debug("sql : " + sql);
@@ -616,6 +639,7 @@ public class BasicBaseDao implements ApplicationContextAware,
             logger.debug(" params size : " + list.size());
             long time = System.currentTimeMillis() - start;
             logger.debug(" SQL 执行耗时 : " + time);
+            sqlPostCallBack(SqlCommandType.UPDATE, sqlId, table, sql, list, results, time, 1);
             return results;
         } else {
             throw new CoreException("批量操作数据不能为空 ...");
@@ -633,7 +657,8 @@ public class BasicBaseDao implements ApplicationContextAware,
     private int[] batchInsert(String sql, SqlParameterSource[] parameterSource) throws SQLException {
         ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
         String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, parameterSource[0]);
-        List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql, parameterSource[0]);
+        List<SqlParameter> declaredParameters =
+            NamedParameterUtils.buildSqlParameterList(parsedSql, parameterSource[0]);
         PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse, declaredParameters);
         /**
          * 参数执行处理
@@ -656,14 +681,14 @@ public class BasicBaseDao implements ApplicationContextAware,
          * 创建Statement对象的时候,加上Statement.RETURN_GENERATED_KEYS参数
          */
         BatchPreparedStatementCreator batchPreparedStatementCreator = new BatchPreparedStatementCreator(sqlToUse);
-        return jdbcTemplate.execute(batchPreparedStatementCreator, (PreparedStatementCallback<int[]>) ps -> {
+        return jdbcTemplate.execute(batchPreparedStatementCreator, (PreparedStatementCallback<int[]>)ps -> {
             try {
                 int batchSize = pss.getBatchSize();
                 int[] keys = new int[batchSize];
 
                 InterruptibleBatchPreparedStatementSetter ipss =
-                        (pss instanceof InterruptibleBatchPreparedStatementSetter ?
-                                (InterruptibleBatchPreparedStatementSetter) pss : null);
+                    (pss instanceof InterruptibleBatchPreparedStatementSetter ?
+                        (InterruptibleBatchPreparedStatementSetter)pss : null);
                 if (JdbcUtils.supportsBatchUpdates(ps.getConnection())) {
                     for (int i = 0; i < batchSize; i++) {
                         pss.setValues(ps, i);
@@ -698,14 +723,14 @@ public class BasicBaseDao implements ApplicationContextAware,
                 }
             } finally {
                 if (pss instanceof ParameterDisposer) {
-                    ((ParameterDisposer) pss).cleanupParameters();
+                    ((ParameterDisposer)pss).cleanupParameters();
                 }
             }
         });
     }
 
-    protected PreparedStatementCreatorFactory getPreparedStatementCreatorFactory(
-            ParsedSql parsedSql, SqlParameterSource paramSource) {
+    protected PreparedStatementCreatorFactory getPreparedStatementCreatorFactory(ParsedSql parsedSql,
+        SqlParameterSource paramSource) {
         String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
         List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql, paramSource);
         return new PreparedStatementCreatorFactory(sqlToUse, declaredParameters);
@@ -720,8 +745,8 @@ public class BasicBaseDao implements ApplicationContextAware,
         }
     }
 
-    private void sqlInvokeAfter(SqlCommandType event, String sqlId, String table, String sql, Object request, Object
-            result) {
+    private void sqlInvokeAfter(SqlCommandType event, String sqlId, String table, String sql, Object request,
+        Object result) {
         if (this.sqlEventHandlerList != null && this.sqlEventHandlerList.size() > 0) {
             for (int i = 0; i < sqlEventHandlerList.size(); i++) {
                 SQLEventHandler sqlEventHandler = sqlEventHandlerList.get(i);
@@ -730,6 +755,37 @@ public class BasicBaseDao implements ApplicationContextAware,
         }
     }
 
+    private void sqlPostCallBack(SqlCommandType event, String sqlId, String table, String sql, Object request,
+        Object result, Long time, Integer status) {
+        if (this.sqlPostProcessorList != null && this.sqlPostProcessorList.size() > 0) {
+            for (int i = 0; i < sqlPostProcessorList.size(); i++) {
+                SqlResult sqlResult = new SqlResult();
+                sqlResult.setCommandType(event.name());
+                sqlResult.setSqlId(sqlId);
+                sqlResult.setTable(table);
+                sqlResult.setSql(sql);
+                sqlResult.setRequestParams(request);
+                sqlResult.setResult(result);
+                sqlResult.setTime(time);
+                if (result != null) {
+                    if (result instanceof int[]) {
+                        sqlResult.setAffectRows(((int[])result).length);
+                        sqlResult.setCommandType("batch_" + event.name());
+                    } else if (result instanceof Number) {
+                        if (event == SqlCommandType.INSERT) {
+                            sqlResult.setAffectRows(1);
+                        } else {
+                            sqlResult.setAffectRows((Integer)result);
+                        }
+                    }
+                }
+                sqlResult.setStatus(status);
+                SQLPostProcess sqlPostProcess = sqlPostProcessorList.get(i);
+                sqlPostProcess.callback(sqlResult);
+            }
+        }
+    }
+
     /**
      * 执行修改
      *
@@ -745,20 +801,28 @@ public class BasicBaseDao implements ApplicationContextAware,
     /**
      * 修改数据操作
      *
-     * @param sql SQL语句
-     * @param o   对象
+     * @param sql     SQL语句
+     * @param request 对象
      * @return
      */
-    public int update(String sqlId, String table, String sql, Object o) throws Exception {
-        JdbcParamsModel jdbcParamsModel = commonParseSql(sql, o);
-        sqlInvokeBefore(SqlCommandType.UPDATE, sqlId, table, sql, o);
-        long start = System.currentTimeMillis();
-        int update = this.jdbcTemplate.update(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects());
-        long time = System.currentTimeMillis() - start;
-        sqlInvokeAfter(SqlCommandType.UPDATE, sqlId, table, sql, o, update);
-        logger.debug(" SQL 执行耗时 : " + time);
-        return update;
+    public int update(String sqlId, String table, String sql, Object request) throws Exception {
+        boolean isOk = false;
+        try {
+            JdbcParamsModel jdbcParamsModel = commonParseSql(sql, request);
+            sqlInvokeBefore(SqlCommandType.UPDATE, sqlId, table, sql, request);
+            long start = System.currentTimeMillis();
+            int update = this.jdbcTemplate.update(jdbcParamsModel.getSql(), jdbcParamsModel.getObjects());
+            long time = System.currentTimeMillis() - start;
+            sqlInvokeAfter(SqlCommandType.UPDATE, sqlId, table, sql, request, update);
+            logger.debug(" SQL 执行耗时 : " + time);
+            sqlPostCallBack(SqlCommandType.UPDATE, sqlId, table, sql, request, update, time, 1);
+            isOk = true;
+            return update;
+        } finally {
+            if (!isOk) {
+                sqlPostCallBack(SqlCommandType.UPDATE, sqlId, table, sql, request, null, -1L, -1);
+            }
+        }
     }
 
-
 }

+ 115 - 0
elab-db/src/main/java/com/elab/core/dao/model/SqlResult.java

@@ -0,0 +1,115 @@
+package com.elab.core.dao.model;
+
+import com.elab.core.sql.config.SqlCommandType;
+
+public class SqlResult {
+    /**
+     * 执行命令
+     */
+    private String commandType;
+    /**
+     * sql编号
+     */
+    private String sqlId;
+    /**
+     * 表名称
+     */
+    private String table;
+    /**
+     * SQL 语句
+     */
+    private String sql;
+    /**
+     * 请求参数
+     */
+    private Object requestParams;
+    /**
+     * 影响行数
+     */
+    private Integer affectRows;
+    /**
+     * 结果返回
+     */
+    private Object result;
+    /**
+     * 耗时
+     */
+    private Long time;
+
+    /**
+     * SQL执行状态
+     */
+    private Integer status;
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public String getCommandType() {
+        return commandType;
+    }
+
+    public void setCommandType(String commandType) {
+        this.commandType = commandType;
+    }
+
+    public String getSqlId() {
+        return sqlId;
+    }
+
+    public void setSqlId(String sqlId) {
+        this.sqlId = sqlId;
+    }
+
+    public String getTable() {
+        return table;
+    }
+
+    public void setTable(String table) {
+        this.table = table;
+    }
+
+    public String getSql() {
+        return sql;
+    }
+
+    public void setSql(String sql) {
+        this.sql = sql;
+    }
+
+    public Object getRequestParams() {
+        return requestParams;
+    }
+
+    public void setRequestParams(Object requestParams) {
+        this.requestParams = requestParams;
+    }
+
+    public Object getResult() {
+        return result;
+    }
+
+    public void setResult(Object result) {
+        this.result = result;
+    }
+
+    public Long getTime() {
+        return time;
+    }
+
+    public void setTime(Long time) {
+        this.time = time;
+    }
+
+    public Integer getAffectRows() {
+        return affectRows;
+    }
+
+    public void setAffectRows(Integer affectRows) {
+        this.affectRows = affectRows;
+    }
+}

+ 21 - 14
elab-db/src/main/java/com/elab/core/spring/config/DataSourceConfigBean.java

@@ -26,9 +26,9 @@ import java.util.List;
 @Configuration
 public class DataSourceConfigBean {
 
-
     @Bean(name = "default")
-    public DataSource getDefaultDataSource(@Autowired Environment env) throws Exception {
+    public DataSource getDefaultDataSource(@Autowired Environment env,
+        @Autowired(required = false) List<Filter> filters) throws Exception {
         DruidDataSource dataSource = new DruidDataSource();
         dataSource.setDriverClassName(env.getProperty("default.driverClassName", "com.mysql.jdbc.Driver"));
         dataSource.setUrl(env.getProperty("default.url"));
@@ -40,18 +40,25 @@ public class DataSourceConfigBean {
         dataSource.setMaxActive(Integer.parseInt(env.getProperty("default.maxActive", "50")));
         dataSource.setValidationQuery(env.getProperty("default.validationQuery", "SELECT 1"));
         dataSource.setMaxWait(Integer.parseInt(env.getProperty("default.maxWait", "60000")));
-        dataSource.setPoolPreparedStatements(Boolean.valueOf(env.getProperty("default.poolPreparedStatements", "true")));
+        dataSource
+            .setPoolPreparedStatements(Boolean.valueOf(env.getProperty("default.poolPreparedStatements", "true")));
         dataSource.setTestOnBorrow(Boolean.valueOf(env.getProperty("default.testOnBorrow", "false")));
         dataSource.setTestWhileIdle(Boolean.valueOf(env.getProperty("default.testWhileIdle", "true")));
         dataSource.setRemoveAbandoned(Boolean.valueOf(env.getProperty("default.removeAbandoned", "true")));
-        dataSource.setRemoveAbandonedTimeout(Integer.valueOf(env.getProperty("default.removeAbandonedTimeout", "3600")));
-        dataSource.setMinEvictableIdleTimeMillis(Integer.valueOf(env.getProperty("default.minEvictableIdleTimeMillis", "300000")));
-        dataSource.setTimeBetweenEvictionRunsMillis(Integer.valueOf(env.getProperty("default.timeBetweenEvictionRunsMillis", "60000")));
+        dataSource
+            .setRemoveAbandonedTimeout(Integer.valueOf(env.getProperty("default.removeAbandonedTimeout", "3600")));
+        dataSource.setMinEvictableIdleTimeMillis(
+            Integer.valueOf(env.getProperty("default.minEvictableIdleTimeMillis", "300000")));
+        dataSource.setTimeBetweenEvictionRunsMillis(
+            Integer.valueOf(env.getProperty("default.timeBetweenEvictionRunsMillis", "60000")));
         dataSource.setTestOnReturn(Boolean.valueOf(env.getProperty("default.testOnReturn", "false")));
         dataSource.setQueryTimeout(Integer.valueOf(env.getProperty("default.queryTimeout", "2400")));
 
         List<Filter> filterList = new ArrayList<>();
         filterList.add(getStatFilter());
+        if (filters != null) {
+            filterList.addAll(filters);
+        }
         dataSource.setProxyFilters(filterList);
         return dataSource;
     }
@@ -64,13 +71,13 @@ public class DataSourceConfigBean {
         return filter;
     }
 
-//    public Log4jFilter getLog4jFilter() {
-//        Log4jFilter log4jFilter = new Log4jFilter();
-//        log4jFilter.setConnectionLogEnabled(false);
-//        log4jFilter.setStatementLogEnabled(false);
-//        log4jFilter.setResultSetLogEnabled(false);
-//        log4jFilter.setStatementExecutableSqlLogEnable(true);
-//        return log4jFilter;
-//    }
+    //    public Log4jFilter getLog4jFilter() {
+    //        Log4jFilter log4jFilter = new Log4jFilter();
+    //        log4jFilter.setConnectionLogEnabled(false);
+    //        log4jFilter.setStatementLogEnabled(false);
+    //        log4jFilter.setResultSetLogEnabled(false);
+    //        log4jFilter.setStatementExecutableSqlLogEnable(true);
+    //        return log4jFilter;
+    //    }
 
 }

+ 11 - 1
elab-db/src/main/java/com/elab/core/spring/method/SQLEventHandler.java

@@ -12,7 +12,17 @@ public interface SQLEventHandler {
 
     public void sqlInvokeBefore(SqlCommandType sqlCommandType, String sqlId, String table, String sql, Object params);
 
+    /**
+     * DMLSQL被执行之后触发的方法
+     *
+     * @param sqlCommandType
+     * @param sqlId
+     * @param table
+     * @param sql
+     * @param params
+     * @param result
+     */
     public void sqlInvokeAfter(SqlCommandType sqlCommandType, String sqlId, String table, String sql, Object params,
-                               Object result);
+        Object result);
 
 }

+ 17 - 0
elab-db/src/main/java/com/elab/core/spring/method/SQLPostProcess.java

@@ -0,0 +1,17 @@
+package com.elab.core.spring.method;
+
+import com.elab.core.dao.model.SqlResult;
+
+/**
+ * SQL 后置处理器
+ */
+public interface SQLPostProcess {
+
+    /**
+     * 回调方法
+     *
+     * @param sqlResult
+     */
+    public void callback(SqlResult sqlResult);
+
+}

+ 1 - 1
elab-es/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>elab-parent</artifactId>
         <groupId>com.elab.core</groupId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
elab-kafka/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>elab-parent</artifactId>
         <groupId>com.elab.core</groupId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
elab-log/pom.xml

@@ -7,7 +7,7 @@
     <parent>
         <groupId>com.elab.core</groupId>
         <artifactId>elab-parent</artifactId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
 
     <groupId>com.elab.log</groupId>

+ 1 - 1
elab-mongodb/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>elab-parent</artifactId>
         <groupId>com.elab.core</groupId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
elab-mq/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>elab-parent</artifactId>
         <groupId>com.elab.core</groupId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
elab-redis/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>elab-parent</artifactId>
         <groupId>com.elab.core</groupId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

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

@@ -53,8 +53,8 @@ public class CacheAutoConfiguration {
         template.setConnectionFactory(redisConnectionFactory);
         template.setKeySerializer(new StringRedisSerializer());
         template.setValueSerializer(new CompatibilityJsonRedisSerializer());
-        template.setHashKeySerializer(new StringRedisSerializer());
-        template.setHashValueSerializer(new StringRedisSerializer());
+//        template.setHashKeySerializer(new StringRedisSerializer());
+//        template.setHashValueSerializer(new StringRedisSerializer());
         return template;
     }
 

+ 98 - 86
elab-redis/src/test/java/com/elab/redis/spring/SpringDataTest.java

@@ -8,9 +8,9 @@ import com.elab.redis.serializers.CompatibilityJsonRedisSerializer;
 import com.google.common.base.Splitter;
 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.core.*;
 import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializer;
 
 import java.io.IOException;
 import java.util.*;
@@ -32,94 +32,99 @@ 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);
+        //        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);
-        }
+        //        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);
+        //        }
+
+        //        redisTemplate.setHashKeySerializer(new GenericJackson2JsonRedisSerializer());
+        //        redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
+        redisTemplate.opsForHash().put("aaaa", 10, 1000L);
+        Object aaaa = redisTemplate.opsForHash().get("aaaa", 10);
+        System.out.println("=================" + aaaa);
     }
 
     @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");
-//
-//
-//        RLock xxx = cacheTemplate.getRedissonClient().getLock("xxx");
-//        cacheTemplate.string().set("abc", "cccc");
-//        Object abc = cacheTemplate.string().get("abc");
-//        System.out.println("--->" + abc);
-//
-//        redisTemplate.opsForValue().set("kkx", "abc");
-//
-//        Map<String, String> map = new HashMap<>();
-//        map.put("lkx", "xxx");
-//        map.put("xxx", "sss");
-//        redisTemplate.opsForValue().set("obj", map);
-//        Map<String, String> xiong = (Map<String, String>) redisTemplate.opsForValue().get("obj");
-//        System.out.println(xiong);
-
-//        // 存储值
-//        cacheTemplate.map().put("aaa", "a-key", "v-value");
-//        cacheTemplate.map().put("aaa", "b-key", "b-value");
-//        cacheTemplate.map().put("aaa", "c-key", "c-value");
-//        cacheTemplate.map().put("aaa", "d-key", "d-value");
-//
-//        // 获取key的hashkey的值
-//        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();
+        //        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");
+        //
+        //
+        //        RLock xxx = cacheTemplate.getRedissonClient().getLock("xxx");
+        //        cacheTemplate.string().set("abc", "cccc");
+        //        Object abc = cacheTemplate.string().get("abc");
+        //        System.out.println("--->" + abc);
+        //
+        //        redisTemplate.opsForValue().set("kkx", "abc");
+        //
+        //        Map<String, String> map = new HashMap<>();
+        //        map.put("lkx", "xxx");
+        //        map.put("xxx", "sss");
+        //        redisTemplate.opsForValue().set("obj", map);
+        //        Map<String, String> xiong = (Map<String, String>) redisTemplate.opsForValue().get("obj");
+        //        System.out.println(xiong);
+
+        //        // 存储值
+        //        cacheTemplate.map().put("aaa", "a-key", "v-value");
+        //        cacheTemplate.map().put("aaa", "b-key", "b-value");
+        //        cacheTemplate.map().put("aaa", "c-key", "c-value");
+        //        cacheTemplate.map().put("aaa", "d-key", "d-value");
+        //
+        //        // 获取key的hashkey的值
+        //        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();
     }
 
     @Test
@@ -129,22 +134,22 @@ public class SpringDataTest extends RedisSpringBoot {
         Set<String> keys = redisTemplate.keys(prefKey);
         redisTemplate.delete(keys);
         System.out.println(keys);
-//        List<String> delKey = new ArrayList<>();
-//
-//        redisTemplate.delete(Arrays.asList(""));
+        //        List<String> delKey = new ArrayList<>();
+        //
+        //        redisTemplate.delete(Arrays.asList(""));
     }
 
     @Test
     public void delToken() {
-        String mobiles = "15123317643,18423586949,15730080319,13330396258,15683552125,13996022227,13896140216,18580429360,\n" +
-                "    18696697989,13436008391,15025446540,13436020926,15025634510,17754989043,17723039715,15123224136,\n" +
-                "    13789996159,15023632596,17708327136,15213163035,15002377412,18702366654,18623383017,13637911168,\n" +
-                "    18716287371,15683169135,18696760033,18608003962,15555044400";
+        String mobiles =
+            "15123317643,18423586949,15730080319,13330396258,15683552125,13996022227,13896140216,18580429360,\n"
+                + "    18696697989,13436008391,15025446540,13436020926,15025634510,17754989043,17723039715,15123224136,\n"
+                + "    13789996159,15023632596,17708327136,15213163035,15002377412,18702366654,18623383017,13637911168,\n"
+                + "    18716287371,15683169135,18696760033,18608003962,15555044400";
 
         String prefixKey = "gateway:LOGIN:UID:token:";
         String prefixTokenKey = "gateway:LOGIN:TOKEN:token:";
         List<String> mobileList = Splitter.on(",").trimResults().splitToList(mobiles);
-
         Set<String> delKey = new HashSet<>();
         for (int i = 0; i < mobileList.size(); i++) {
             System.out.println(mobileList.get(i));
@@ -154,7 +159,6 @@ public class SpringDataTest extends RedisSpringBoot {
         }
         List<Object> tokenKeys = redisTemplate.opsForValue().multiGet(delKey);
 
-
         List<String> tokenName = new ArrayList<>();
 
         tokenKeys.forEach((key) -> {
@@ -166,4 +170,12 @@ public class SpringDataTest extends RedisSpringBoot {
         Long delete = redisTemplate.delete(tokenName);
         System.out.println("删除key个数:" + tokenName.size() + " 删除总数:" + delete);
     }
+
+    private Cursor<String> scan(String match, int count) {
+        ScanOptions scanOptions = ScanOptions.scanOptions().match(match).count(count).build();
+        RedisSerializer<?> keySerializer = redisTemplate.getKeySerializer();
+        return (Cursor)redisTemplate.executeWithStickyConnection(
+            (RedisCallback)redisConnection -> new ConvertingCursor<>(redisConnection.scan(scanOptions),
+                keySerializer::deserialize));
+    }
 }

+ 1 - 1
elab-redis/src/test/resources/application.yml

@@ -1,6 +1,6 @@
 spring:
   redis:
-    database: 10
+    database: 0
     host: r-uf6e60u5cmlj0sx563pd.redis.rds.aliyuncs.com
     password: xcGm4kTks6
     port: 6379

+ 1 - 1
elab-rocketMQ/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>elab-parent</artifactId>
         <groupId>com.elab.core</groupId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
elab-spring/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>elab-parent</artifactId>
         <groupId>com.elab.core</groupId>
-        <version>2.0.5.2-SNAPSHOT</version>
+        <version>2.0.5.3-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 7 - 0
elab-spring/src/main/java/com/elab/spring/config/SpringMvcConfig.java

@@ -1,6 +1,7 @@
 package com.elab.spring.config;
 
 import com.elab.spring.intercept.SQLMonitorEventHandler;
+import com.elab.spring.intercept.SQLMonitorPostCallback;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -37,4 +38,10 @@ public class SpringMvcConfig {
         sqlMonitorEventHandler.setAffectNumber(Integer.valueOf(env.getProperty("default.affectNumber", "100")));
         return sqlMonitorEventHandler;
     }
+
+    @Bean
+    public SQLMonitorPostCallback sqlMonitorPostCallback(@Autowired Environment env) {
+        SQLMonitorPostCallback sqlMonitorPostCallback = new SQLMonitorPostCallback();
+        return sqlMonitorPostCallback;
+    }
 }

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

@@ -20,6 +20,18 @@ public class ThreadPoolProperties {
      * 线程存活时间(秒)
      */
     private int keepAliveTime = 0;
+    /**
+     * 队列大小
+     */
+    private Integer queueSize = 100;
+
+    public Integer getQueueSize() {
+        return queueSize;
+    }
+
+    public void setQueueSize(Integer queueSize) {
+        this.queueSize = queueSize;
+    }
 
     public int getCorePoolSize() {
         return corePoolSize;

+ 53 - 0
elab-spring/src/main/java/com/elab/spring/intercept/SQLMonitorPostCallback.java

@@ -0,0 +1,53 @@
+package com.elab.spring.intercept;
+
+import com.alibaba.fastjson.JSON;
+import com.dianping.cat.Cat;
+import com.elab.core.dao.model.SqlResult;
+import com.elab.core.spring.method.SQLPostProcess;
+import com.elab.core.sql.config.SqlCommandType;
+import com.elab.core.utils.DataUtils;
+import com.jay.monitor.data.client.MonitorSendProducer;
+import com.jay.monitor.data.core.model.serializable.SQLMonitorDTO;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Date;
+
+/**
+ * SQL 监控回调借口
+ * <p>
+ * author lkx
+ */
+public class SQLMonitorPostCallback implements SQLPostProcess {
+
+    @Override
+    public void callback(SqlResult sqlResult) {
+        SQLMonitorDTO sqlMonitorDTO = new SQLMonitorDTO();
+
+        BeanUtils.copyProperties(sqlResult, sqlMonitorDTO);
+
+        if (SqlCommandType.INSERT.name().equals(sqlMonitorDTO.getCommandType())) {
+            sqlMonitorDTO.setDataId(sqlResult.getResult() + "");
+            sqlMonitorDTO.setAffectedRows(1);
+        } else if (SqlCommandType.UPDATE.name().equals(sqlMonitorDTO.getCommandType())) {
+            // 从请求参数中抓取可靠信息
+            Object requestParams = sqlResult.getRequestParams();
+            try {
+                String id = org.apache.commons.beanutils.BeanUtils.getProperty(requestParams, "id");
+                sqlMonitorDTO.setDataId(id);
+                sqlMonitorDTO.setAffectedRows(DataUtils.getDefaultValue(sqlResult.getResult(), 0));
+            } catch (Exception e) {
+
+            }
+        }
+
+        sqlMonitorDTO.setJsonContent(JSON.toJSONString(sqlResult.getRequestParams()));
+        sqlMonitorDTO.setResult(sqlResult.getResult());
+        sqlMonitorDTO.setLogId(Cat.getCurrentMessageId());
+        sqlMonitorDTO.setCreateDate(new Date());
+        sqlMonitorDTO.setCommandType(sqlResult.getCommandType());
+        sqlMonitorDTO.setRequestTime(sqlResult.getTime());
+        MonitorSendProducer.sendMsg(sqlMonitorDTO);
+    }
+}

+ 7 - 0
elab-spring/src/test/java/com/elab/spring/intercept/SQLMonitorPostCallbackTest.java

@@ -0,0 +1,7 @@
+package com.elab.spring.intercept;
+
+import junit.framework.TestCase;
+
+public class SQLMonitorPostCallbackTest extends TestCase {
+
+}

+ 2 - 2
pom.xml

@@ -7,7 +7,7 @@
     <groupId>com.elab.core</groupId>
     <artifactId>elab-parent</artifactId>
     <packaging>pom</packaging>
-    <version>2.0.5.2-SNAPSHOT</version>
+    <version>2.0.5.3-SNAPSHOT</version>
     <modules>
         <module>elab-core</module>
         <module>elab-cache</module>
@@ -392,7 +392,7 @@
     </build>
 
     <!--mvn -DnewVersion=1.0.0-RELEASE -DgenerateBackupPoms=false versions:set-->
-    <!--mvn -DnewVersion=1.0.0-SNAPSHOT -DgenerateBackupPoms=false versions:set-->
+    <!--mvn -DnewVersion=2.0.5.3-SNAPSHOT -DgenerateBackupPoms=false versions:set-->
     <distributionManagement>
         <!--<repository>-->
         <!--<id>releases</id>-->