liukaixiong 4 lat temu
rodzic
commit
8bef8743f5
44 zmienionych plików z 4609 dodań i 369 usunięć
  1. 25 9
      jay-monitor-data-client/src/main/java/com/jay/monitor/data/client/MonitorDataClient.java
  2. 6 0
      jay-monitor-data-server/pom.xml
  3. 22 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/config/BeanConfig.java
  4. 51 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/config/props/MonitorProperties.java
  5. 130 130
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/controllers/RouteController.java
  6. 1 2
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/daos/BackstageRouteMapper.java
  7. 11 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/enums/DataSplitType.java
  8. 11 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/enums/StoreType.java
  9. 76 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/ext/mybatis/interceptor/SplitTableInterceptor.java
  10. 27 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/ext/springboot/EnumConfigurationPropertySource.java
  11. 35 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/ext/springboot/RunApplication.java
  12. 68 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/DataIdFactory.java
  13. 37 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/IdGenerateService.java
  14. 37 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/callback/DefaultIdChangeCallback.java
  15. 19 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/callback/IdChangeCallback.java
  16. 79 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/generate/DayIdGenerate.java
  17. 62 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/generate/HourIdGenerate.java
  18. 47 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/job/DefaultDataStoreBuilderService.java
  19. 12 3
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/job/ScheduledJob.java
  20. 224 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/models/entity/JayMonitorMq.java
  21. 1299 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/models/entity/JayMonitorMqExample.java
  22. 105 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/models/entity/JayMonitorMqLog.java
  23. 689 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/models/entity/JayMonitorMqLogExample.java
  24. 198 198
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/services/impl/DefaultBackstageRouteService.java
  25. 34 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/store/AbstractSplitDataProcess.java
  26. 80 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/store/SplitDataManager.java
  27. 82 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/store/mysql/MysqlDDLProcess.java
  28. 37 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/utils/MonitorPropertiesUtil.java
  29. 43 0
      jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/utils/SqlUtils.java
  30. 1 1
      jay-monitor-data-server/src/main/resources/application-com.yml
  31. 1 1
      jay-monitor-data-server/src/main/resources/application-dev.yml
  32. 7 22
      jay-monitor-data-server/src/main/resources/application.yml
  33. 1 3
      jay-monitor-data-server/src/main/resources/logback.xml
  34. 237 0
      jay-monitor-data-server/src/main/resources/mybatis/mapper/JayMonitorMqLogMapper.xml
  35. 380 0
      jay-monitor-data-server/src/main/resources/mybatis/mapper/JayMonitorMqMapper.xml
  36. 29 0
      jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/config/props/MonitorPropertiesTest.java
  37. 61 0
      jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/config/props/TestMonitorProperties.java
  38. 43 0
      jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/factory/DataIdFactoryTest.java
  39. 95 0
      jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/factory/DayIdGenerateTest.java
  40. 64 0
      jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/utils/SqlUtilsTest.java
  41. 46 0
      jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/utils/ThreadUtils.java
  42. 13 0
      jay-monitor-data-server/src/test/resources/application-dev.yml
  43. 81 0
      jay-monitor-data-server/src/test/resources/application.yml
  44. 3 0
      数据调度监控.md

+ 25 - 9
jay-monitor-data-client/src/main/java/com/jay/monitor/data/client/MonitorDataClient.java

@@ -12,6 +12,7 @@ import java.util.Queue;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.LongAdder;
 
 /**
  * 监控数据客户端传输列
@@ -21,6 +22,8 @@ import java.util.concurrent.Executors;
  */
 public class MonitorDataClient implements Runnable {
 
+    private LongAdder counter = new LongAdder();
+
     private Logger logger = LoggerFactory.getLogger(getClass());
 
     private String host;
@@ -97,7 +100,12 @@ public class MonitorDataClient implements Runnable {
     public void sendObjectMsg(BaseDTO data) {
         boolean isAdd = queueData.offer(data);
         if (!isAdd) {
-            logger.warn("容量不够,请及时扩容 queueSize:" + this.queueSize);
+            counter.increment();
+            long current = counter.longValue();
+            if (current % 1000 == 0) {
+                logger.warn("容量不够,请及时扩容 queueSize:" + this.queueSize);
+                counter.reset();
+            }
         }
     }
 
@@ -127,20 +135,28 @@ public class MonitorDataClient implements Runnable {
                 }
             } catch (Exception e) {
                 logger.warn("monitor consumer fail : " + e.getMessage());
-            } finally {
-                try {
-                    // 需要注意的是,这里休眠只是为了不让CPU飙百,避免没有数据来的情况下。
-                    // 当然这也意味着消费会受影响,每秒200条.
-                    Thread.sleep(5);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                    logger.error("数据传输线程失败", e);
+                // 当遇到连接问题的时候,尝试休眠等待.
+                if (e.getMessage().startsWith("Create connection failed.")) {
+                    sleep(30000);
                 }
+            } finally {
+                sleep(5);
             }
 
         }
     }
 
+    private void sleep(long ms) {
+        try {
+            // 需要注意的是,这里休眠只是为了不让CPU飙百,避免没有数据来的情况下。
+            // 当然这也意味着消费会受影响,每秒200条.
+            Thread.sleep(ms);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+            logger.error("数据传输线程失败", e);
+        }
+    }
+
     /**
      * 加速消费
      *

+ 6 - 0
jay-monitor-data-server/pom.xml

@@ -67,6 +67,12 @@
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+            <optional>true</optional>
+        </dependency>
+
 <!--        <dependency>-->
 <!--            <groupId>org.springframework.cloud</groupId>-->
 <!--            <artifactId>spring-cloud-starter-eureka</artifactId>-->

+ 22 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/config/BeanConfig.java

@@ -3,8 +3,17 @@ package com.jay.monitor.data.server.config;
 import com.alipay.remoting.rpc.protocol.UserProcessor;
 import com.jay.monitor.data.core.enums.MonitorDataConstants;
 import com.jay.monitor.data.server.MonitorDataServer;
+import com.jay.monitor.data.server.config.props.MonitorProperties;
+import com.jay.monitor.data.server.factory.DataIdFactory;
+import com.jay.monitor.data.server.factory.IdGenerateService;
+import com.jay.monitor.data.server.factory.callback.IdChangeCallback;
+import com.jay.monitor.data.server.store.AbstractSplitDataProcess;
+import com.jay.monitor.data.server.store.SplitDataManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
@@ -27,6 +36,7 @@ import java.util.List;
 @ComponentScan(basePackages = {"com.jay.monitor.data.server"}, excludeFilters = {
         @ComponentScan.Filter(type = FilterType.ANNOTATION, value = {Controller.class, ControllerAdvice.class})
 })
+@EnableConfigurationProperties({MonitorProperties.class, OAuth2ClientProperties.class})
 public class BeanConfig {
 
     private Logger logger = LoggerFactory.getLogger(getClass());
@@ -41,4 +51,16 @@ public class BeanConfig {
         return monitorDataServer;
     }
 
+    @Bean
+    @ConditionalOnBean({IdGenerateService.class})
+    public DataIdFactory dataIdFactory(List<IdGenerateService> idGenerateServices, IdChangeCallback idChangeCallback) {
+        return new DataIdFactory(idGenerateServices, idChangeCallback);
+    }
+
+    @Bean
+    @ConditionalOnBean({AbstractSplitDataProcess.class})
+    public SplitDataManager splitDataManager(List<AbstractSplitDataProcess> splitDataProcessList){
+        return new SplitDataManager(splitDataProcessList);
+    }
+
 }

+ 51 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/config/props/MonitorProperties.java

@@ -0,0 +1,51 @@
+package com.jay.monitor.data.server.config.props;
+
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.enums.StoreType;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Module 配置
+ * @Description 监控服务器配置属性
+ * @Author liukaixiong
+ * @Date 2020/11/5 13:52
+ */
+@ConfigurationProperties(prefix = "spring.monitor-server")
+public class MonitorProperties {
+
+    /**
+     * 存储配置规则
+     * key -> {@link com.jay.monitor.data.server.enums.StoreType}
+     */
+    private Map<StoreType, StoreInfo> storeInfo = new HashMap<>();
+
+    public Map<StoreType, StoreInfo> getStoreInfo() {
+        return storeInfo;
+    }
+
+    public void setStoreInfo(Map<StoreType, StoreInfo> storeInfo) {
+        this.storeInfo = storeInfo;
+    }
+
+    public static class StoreInfo {
+
+        /**
+         * 表的拆分配置规则
+         * Key -> 表名
+         */
+        private Map<String, DataSplitType> tableRule = new HashMap<>();
+
+        public Map<String, DataSplitType> getTableRule() {
+            return tableRule;
+        }
+
+        public void setTableRule(Map<String, DataSplitType> tableRule) {
+            this.tableRule = tableRule;
+        }
+    }
+
+
+}

+ 130 - 130
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/controllers/RouteController.java

@@ -1,130 +1,130 @@
-package com.jay.monitor.data.server.controllers;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.jay.monitor.data.core.utils.ResponseUtils;
-import com.jay.monitor.data.core.model.response.ListResponseModel;
-import com.jay.monitor.data.core.model.response.ObjectResponseModel;
-import com.jay.monitor.data.core.model.response.ResponseCommonModel;
-import com.jay.monitor.data.server.models.entity.BackstageRoute;
-import com.jay.monitor.data.server.models.request.route.BackstageRoutePageRequest;
-import com.jay.monitor.data.server.models.request.route.RouteDataRequest;
-import com.jay.monitor.data.server.services.impl.DefaultBackstageRouteService;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * 后台路由管理
- *
- * @author liukx
- * @Date 2019-02-28 15:16
- */
-@Controller
-@RequestMapping(value = "/backstageRoute")
-public class RouteController {
-
-    final static private String page = "/route/";
-    @Autowired
-    private DefaultBackstageRouteService routesService;
-
-
-    @RequestMapping(value = "/list.html", method = RequestMethod.GET)
-    public String list() throws Exception {
-        return page + "routeList";
-    }
-
-    @RequestMapping(value = "/update.html", method = RequestMethod.GET)
-    public String update(@RequestParam("id") Integer id, Model model) throws Exception {
-        ResponseUtils.checkParamNull(id, "id");
-        BackstageRoute entity = routesService.getById(id + "");
-        model.addAttribute("obj", entity);
-        return page + "update";
-    }
-
-
-    @RequestMapping(value = "/refresh.html", method = RequestMethod.GET)
-    public String refreshHtml(Model model) throws Exception {
-        List<String> routes = routesService.getRoutes();
-        model.addAttribute("routes", routes);
-        return page + "refresh";
-    }
-
-    /**
-     * 添加后台路由管理管理模块
-     *
-     * @param request 请求参数
-     * @return
-     * @throws Exception
-     */
-    @RequestMapping(value = "/insert", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
-    @ResponseBody
-    public ResponseCommonModel insertBackstageRoute(@RequestBody BackstageRoute request) throws Exception {
-        int result = routesService.insert(request);
-        ResponseCommonModel response = new ResponseCommonModel();
-        if (result < 0) {
-            response.setSuccess(false);
-        }
-        return response;
-    }
-
-    @RequestMapping(value = "/refresh", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
-    @ResponseBody
-    public ResponseCommonModel refresh(@RequestBody RouteDataRequest dataRequest) throws Exception {
-        ResponseCommonModel responseCommonModel = routesService.executeRefresh(dataRequest);
-        return responseCommonModel;
-    }
-
-    @RequestMapping(value = "/list", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
-    @ResponseBody
-    public ObjectResponseModel<BackstageRoute> findBackstageRouteList(@RequestBody BackstageRoutePageRequest request) throws Exception {
-        BackstageRoute entity = new BackstageRoute();
-        BeanUtils.copyProperties(request, entity);
-        // 将参数对应的全部匹配赋值
-        QueryWrapper queryWrapper = new QueryWrapper(entity);
-        Page<BackstageRoute> page = new Page<>(request.getPageNo(), request.getPageSize());
-        IPage pageInfo = routesService.page(page, queryWrapper);
-        ObjectResponseModel objectResponseModel = new ObjectResponseModel();
-        objectResponseModel.setSingle(pageInfo);
-        // 将查询出来的参数传递给对外的实体
-//        BeanUtils.copyProperties(backEntityPageModel, pageModel1);
-        return objectResponseModel;
-    }
-
-    @RequestMapping(value = "/getObjectById", method = RequestMethod.GET)
-    @ResponseBody
-    public ObjectResponseModel<BackstageRoute> getObjectById(@RequestParam("id") Integer id) throws Exception {
-        BackstageRoute result = routesService.getById(id + "");
-        ObjectResponseModel<BackstageRoute> model = new ObjectResponseModel<BackstageRoute>();
-        model.setSingle(result);
-        return model;
-    }
-
-    @RequestMapping(value = "/getObjectByList", method = RequestMethod.POST)
-    @ResponseBody
-    public ListResponseModel<BackstageRoute> getObjectByList(@RequestBody BackstageRoute request) throws Exception {
-        QueryWrapper queryWrapper = new QueryWrapper(request);
-        List<BackstageRoute> result = routesService.listObjs(queryWrapper);
-        ListResponseModel<BackstageRoute> model = new ListResponseModel<BackstageRoute>();
-        model.setList(result);
-        return model;
-    }
-
-    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
-    @ResponseBody
-    public ResponseCommonModel updateBackstageRouteInfo(@RequestBody BackstageRoute request) throws Exception {
-        request.setUpdated(new Date());
-        boolean b = routesService.updateById(request);
-        ResponseCommonModel response = new ResponseCommonModel();
-        if (b) {
-            response.setSuccess(false);
-        }
-        return response;
-    }
-}
+//package com.jay.monitor.data.server.controllers;
+//
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.baomidou.mybatisplus.core.metadata.IPage;
+//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+//import com.jay.monitor.data.core.utils.ResponseUtils;
+//import com.jay.monitor.data.core.model.response.ListResponseModel;
+//import com.jay.monitor.data.core.model.response.ObjectResponseModel;
+//import com.jay.monitor.data.core.model.response.ResponseCommonModel;
+//import com.jay.monitor.data.server.models.entity.BackstageRoute;
+//import com.jay.monitor.data.server.models.request.route.BackstageRoutePageRequest;
+//import com.jay.monitor.data.server.models.request.route.RouteDataRequest;
+////import com.jay.monitor.data.server.services.impl.DefaultBackstageRouteService;
+//import org.springframework.beans.BeanUtils;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Controller;
+//import org.springframework.ui.Model;
+//import org.springframework.web.bind.annotation.*;
+//
+//import java.util.Date;
+//import java.util.List;
+//
+///**
+// * 后台路由管理
+// *
+// * @author liukx
+// * @Date 2019-02-28 15:16
+// */
+//@Controller
+//@RequestMapping(value = "/backstageRoute")
+//public class RouteController {
+//
+//    final static private String page = "/route/";
+//    @Autowired
+//    private DefaultBackstageRouteService routesService;
+//
+//
+//    @RequestMapping(value = "/list.html", method = RequestMethod.GET)
+//    public String list() throws Exception {
+//        return page + "routeList";
+//    }
+//
+//    @RequestMapping(value = "/update.html", method = RequestMethod.GET)
+//    public String update(@RequestParam("id") Integer id, Model model) throws Exception {
+//        ResponseUtils.checkParamNull(id, "id");
+//        BackstageRoute entity = routesService.getById(id + "");
+//        model.addAttribute("obj", entity);
+//        return page + "update";
+//    }
+//
+//
+//    @RequestMapping(value = "/refresh.html", method = RequestMethod.GET)
+//    public String refreshHtml(Model model) throws Exception {
+//        List<String> routes = routesService.getRoutes();
+//        model.addAttribute("routes", routes);
+//        return page + "refresh";
+//    }
+//
+//    /**
+//     * 添加后台路由管理管理模块
+//     *
+//     * @param request 请求参数
+//     * @return
+//     * @throws Exception
+//     */
+//    @RequestMapping(value = "/insert", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
+//    @ResponseBody
+//    public ResponseCommonModel insertBackstageRoute(@RequestBody BackstageRoute request) throws Exception {
+//        int result = routesService.insert(request);
+//        ResponseCommonModel response = new ResponseCommonModel();
+//        if (result < 0) {
+//            response.setSuccess(false);
+//        }
+//        return response;
+//    }
+//
+//    @RequestMapping(value = "/refresh", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
+//    @ResponseBody
+//    public ResponseCommonModel refresh(@RequestBody RouteDataRequest dataRequest) throws Exception {
+//        ResponseCommonModel responseCommonModel = routesService.executeRefresh(dataRequest);
+//        return responseCommonModel;
+//    }
+//
+//    @RequestMapping(value = "/list", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
+//    @ResponseBody
+//    public ObjectResponseModel<BackstageRoute> findBackstageRouteList(@RequestBody BackstageRoutePageRequest request) throws Exception {
+//        BackstageRoute entity = new BackstageRoute();
+//        BeanUtils.copyProperties(request, entity);
+//        // 将参数对应的全部匹配赋值
+//        QueryWrapper queryWrapper = new QueryWrapper(entity);
+//        Page<BackstageRoute> page = new Page<>(request.getPageNo(), request.getPageSize());
+//        IPage pageInfo = routesService.page(page, queryWrapper);
+//        ObjectResponseModel objectResponseModel = new ObjectResponseModel();
+//        objectResponseModel.setSingle(pageInfo);
+//        // 将查询出来的参数传递给对外的实体
+////        BeanUtils.copyProperties(backEntityPageModel, pageModel1);
+//        return objectResponseModel;
+//    }
+//
+//    @RequestMapping(value = "/getObjectById", method = RequestMethod.GET)
+//    @ResponseBody
+//    public ObjectResponseModel<BackstageRoute> getObjectById(@RequestParam("id") Integer id) throws Exception {
+//        BackstageRoute result = routesService.getById(id + "");
+//        ObjectResponseModel<BackstageRoute> model = new ObjectResponseModel<BackstageRoute>();
+//        model.setSingle(result);
+//        return model;
+//    }
+//
+//    @RequestMapping(value = "/getObjectByList", method = RequestMethod.POST)
+//    @ResponseBody
+//    public ListResponseModel<BackstageRoute> getObjectByList(@RequestBody BackstageRoute request) throws Exception {
+//        QueryWrapper queryWrapper = new QueryWrapper(request);
+//        List<BackstageRoute> result = routesService.listObjs(queryWrapper);
+//        ListResponseModel<BackstageRoute> model = new ListResponseModel<BackstageRoute>();
+//        model.setList(result);
+//        return model;
+//    }
+//
+//    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
+//    @ResponseBody
+//    public ResponseCommonModel updateBackstageRouteInfo(@RequestBody BackstageRoute request) throws Exception {
+//        request.setUpdated(new Date());
+//        boolean b = routesService.updateById(request);
+//        ResponseCommonModel response = new ResponseCommonModel();
+//        if (b) {
+//            response.setSuccess(false);
+//        }
+//        return response;
+//    }
+//}

+ 1 - 2
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/daos/BackstageRouteMapper.java

@@ -1,6 +1,5 @@
 package com.jay.monitor.data.server.daos;
 
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jay.monitor.data.server.models.entity.BackstageRoute;
 import com.jay.monitor.data.server.models.entity.BackstageRouteExample;
 import org.apache.ibatis.annotations.Param;
@@ -8,7 +7,7 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 
-public interface BackstageRouteMapper extends BaseMapper<BackstageRoute> {
+public interface BackstageRouteMapper {
 
     int countByExample(BackstageRouteExample example);
 

+ 11 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/enums/DataSplitType.java

@@ -0,0 +1,11 @@
+package com.jay.monitor.data.server.enums;
+
+/**
+ * @Module 枚举
+ * @Description 数据拆分规则定义
+ * @Author liukaixiong
+ * @Date 2020/11/5 13:56
+ */
+public enum DataSplitType {
+    HOUR, DAY, WEEK, MONTH;
+}

+ 11 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/enums/StoreType.java

@@ -0,0 +1,11 @@
+package com.jay.monitor.data.server.enums;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2020/10/29 13:31
+ */
+public enum StoreType {
+    MYSQL
+}

+ 76 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/ext/mybatis/interceptor/SplitTableInterceptor.java

@@ -0,0 +1,76 @@
+package com.jay.monitor.data.server.ext.mybatis.interceptor;
+
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
+import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
+import com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler;
+import com.jay.monitor.data.server.config.props.MonitorProperties;
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.store.mysql.MysqlDDLProcess;
+import com.jay.monitor.data.server.utils.MonitorPropertiesUtil;
+import org.apache.ibatis.executor.statement.StatementHandler;
+import org.apache.ibatis.mapping.*;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.plugin.Intercepts;
+import org.apache.ibatis.plugin.Invocation;
+import org.apache.ibatis.plugin.Signature;
+import org.apache.ibatis.reflection.MetaObject;
+import org.apache.ibatis.reflection.SystemMetaObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Module 拦截器
+ * @Description 负责重写表名称的数据,按照拆分的规则找到对应的表。
+ * @Author liukaixiong
+ * @Date 2020/11/5 10:55
+ */
+@Component
+@Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
+public class SplitTableInterceptor extends AbstractSqlParserHandler implements Interceptor {
+
+    @Autowired
+    private MysqlDDLProcess ddlProcess;
+
+    @Autowired
+    private MonitorProperties monitorProperties;
+
+    @Override
+    public Object intercept(Invocation invocation) throws Throwable {
+
+        StatementHandler statementHandler = PluginUtils.realTarget(invocation.getTarget());
+        MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
+        // SQL 解析
+        this.sqlParser(metaObject);
+        MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement");
+
+        // 如果是查询方法
+        if (SqlCommandType.SELECT == mappedStatement.getSqlCommandType()
+                || StatementType.CALLABLE == mappedStatement.getStatementType()) {
+            return invocation.proceed();
+        }
+        // 针对定义了rowBounds,做为mapper接口方法的参数
+        BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql");
+        TableInfo tableInfo = TableInfoHelper.getTableInfo(boundSql.getParameterObject().getClass());
+        String tableName = tableInfo.getTableName();
+
+        // 从配置文件中获取对应的规则
+        Map<String, DataSplitType> tableRuleMap = MonitorPropertiesUtil.getMysqlTableRuleMap(monitorProperties);
+
+        if (tableRuleMap != null) {
+            DataSplitType dataSplitType = tableRuleMap.get(tableName);
+            String sql = boundSql.getSql();
+            String dataId = ddlProcess.getDataId(tableName,dataSplitType);
+            String newSql = sql.replace(tableName, dataId);
+            List<ParameterMapping> mappings = new ArrayList<>(boundSql.getParameterMappings());
+            metaObject.setValue("delegate.boundSql.sql", newSql);
+            metaObject.setValue("delegate.boundSql.parameterMappings", mappings);
+        }
+        return invocation.proceed();
+    }
+}

+ 27 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/ext/springboot/EnumConfigurationPropertySource.java

@@ -0,0 +1,27 @@
+//package com.jay.monitor.data.server.ext.springboot;
+//
+//import org.springframework.boot.context.properties.source.ConfigurationProperty;
+//import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
+//import org.springframework.boot.context.properties.source.IterableConfigurationPropertySource;
+//
+//import java.util.stream.Stream;
+//
+///**
+// * @Module TODO
+// * @Description TODO
+// * @Author liukaixiong
+// * @Date 2020/11/5 20:32
+// */
+//public class EnumConfigurationPropertySource implements IterableConfigurationPropertySource {
+//
+//    @Override
+//    public Stream<ConfigurationPropertyName> stream() {
+//        return null;
+//    }
+//
+//    @Override
+//    public ConfigurationProperty getConfigurationProperty(ConfigurationPropertyName name) {
+//        String s = name.toString();
+//        return ConfigurationProperty.of(name, null, null);
+//    }
+//}

+ 35 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/ext/springboot/RunApplication.java

@@ -0,0 +1,35 @@
+package com.jay.monitor.data.server.ext.springboot;
+
+import com.alipay.remoting.config.ConfigManager;
+import com.jay.monitor.data.server.store.SplitDataManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Module 启动
+ * @Description 启动时, 希望做某些事情
+ * @Author liukaixiong
+ * @Date 2020/11/6 16:52
+ */
+@Component
+public class RunApplication implements ApplicationRunner {
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private SplitDataManager splitDataManager;
+
+    @Override
+    public void run(ApplicationArguments args) throws Exception {
+        // 希望在启动的时候,能够尝试先创建一下表,即便已经存在。
+        splitDataManager.initFirstProcess();
+        logger.info("比较关键的一些性能参数:");
+        logger.info("核心线最小程池" + ConfigManager.default_tp_min_size());
+        logger.info("核心线最大程池大小" + ConfigManager.default_tp_max_size());
+        logger.info("等待队列大小" + ConfigManager.default_tp_queue_size());
+    }
+}

+ 68 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/DataIdFactory.java

@@ -0,0 +1,68 @@
+package com.jay.monitor.data.server.factory;
+
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.factory.callback.IdChangeCallback;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Module 生成器工厂
+ * @Description 将所有生成器规则统一由生成器管理, 对外引用
+ * @Author liukaixiong
+ * @Date 2020/11/5 15:03
+ */
+public class DataIdFactory implements InitializingBean {
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    private List<IdGenerateService> idGenerateServices;
+
+    private Map<DataSplitType, IdGenerateService> idGenerateServiceMap;
+
+    private IdChangeCallback idChangeCallback;
+
+    public DataIdFactory(List<IdGenerateService> idGenerateServices, IdChangeCallback idChangeCallback) {
+        this.idGenerateServices = idGenerateServices;
+        this.idChangeCallback = idChangeCallback;
+    }
+
+    /**
+     * 获取当前的生成id
+     *
+     * @param splitType
+     * @return
+     */
+    public String getCurrentId(DataSplitType splitType) {
+        if (idGenerateServiceMap != null) {
+            IdGenerateService idGenerateService = idGenerateServiceMap.get(splitType);
+            if (idGenerateService != null) {
+                return idGenerateService.getCurrentId((id) -> {
+                    try {
+                        if (idChangeCallback != null) {
+                            logger.info("触发id变更修改,ID的类型:" + splitType);
+                            idChangeCallback.onChange(splitType, id);
+                        }
+                    } catch (Exception e) {
+                        logger.error("数据生成失败", e);
+                    }
+                });
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        if (idGenerateServices != null) {
+            idGenerateServiceMap = new HashMap<>();
+            idGenerateServices.forEach((service) -> {
+                idGenerateServiceMap.put(service.splitType(), service);
+            });
+        }
+    }
+}

+ 37 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/IdGenerateService.java

@@ -0,0 +1,37 @@
+package com.jay.monitor.data.server.factory;
+
+import com.jay.monitor.data.server.enums.DataSplitType;
+
+import java.util.function.Consumer;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2020/11/5 15:27
+ */
+public interface IdGenerateService {
+
+    /**
+     * 分割类型
+     *
+     * @return
+     */
+    public DataSplitType splitType();
+
+    /**
+     * 获取当前标识
+     *
+     * @return
+     */
+    public String getCurrentId(Consumer<String> consumer);
+
+    /**
+     * 获取指定id的下一个标识
+     *
+     * @param id
+     * @return
+     */
+    public String getNextId(String id);
+
+}

+ 37 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/callback/DefaultIdChangeCallback.java

@@ -0,0 +1,37 @@
+package com.jay.monitor.data.server.factory.callback;
+
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.store.SplitDataManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Module 回调
+ * @Description 当生成编号发生改变的时候, 默认触发的事件
+ * @Author liukaixiong
+ * @Date 2020/11/6 16:14
+ */
+@Component
+public class DefaultIdChangeCallback implements IdChangeCallback, ApplicationContextAware {
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
+    private ApplicationContext applicationContext;
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        this.applicationContext = applicationContext;
+    }
+
+    @Override
+    public void onChange(DataSplitType splitType, String id) {
+        getDataManager().generateMysql(splitType);
+    }
+
+    private SplitDataManager getDataManager() {
+        return this.applicationContext.getBean(SplitDataManager.class);
+    }
+}

+ 19 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/callback/IdChangeCallback.java

@@ -0,0 +1,19 @@
+package com.jay.monitor.data.server.factory.callback;
+
+import com.jay.monitor.data.server.enums.DataSplitType;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2020/11/6 16:09
+ */
+public interface IdChangeCallback {
+    /**
+     * 发生改变事件
+     *
+     * @param splitType
+     * @param id
+     */
+    void onChange(DataSplitType splitType, String id);
+}

+ 79 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/generate/DayIdGenerate.java

@@ -0,0 +1,79 @@
+package com.jay.monitor.data.server.factory.generate;
+
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.factory.IdGenerateService;
+import org.springframework.stereotype.Component;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.function.Consumer;
+
+/**
+ * @Module 编号生成器
+ * @Description 根据天生成编号
+ * @Author liukaixiong
+ * @Date 2020/11/5 15:04
+ */
+@Component
+public class DayIdGenerate implements IdGenerateService {
+
+    public static final long DAY = 24 * 3600 * 1000L;
+
+    private SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+
+    private volatile long m_timestamp = getDayTimestamp();
+
+    private volatile String defaultId = resetCounter(m_timestamp);
+
+    public void setM_timestamp(long m_timestamp) {
+        this.m_timestamp = m_timestamp;
+    }
+
+    public void setDefaultId(String defaultId) {
+        this.defaultId = defaultId;
+    }
+
+    public long getM_timestamp() {
+        return m_timestamp;
+    }
+
+    public String getDefaultId() {
+        return defaultId;
+    }
+
+    protected long getDayTimestamp() {
+        long timestamp = System.currentTimeMillis();
+        return timestamp / DAY;
+    }
+
+    private String resetCounter(long timestamp) {
+        this.m_timestamp = timestamp;
+        this.defaultId = sdf.format(new Date(System.currentTimeMillis()));
+        return this.defaultId;
+    }
+
+    @Override
+    public DataSplitType splitType() {
+        return DataSplitType.DAY;
+    }
+
+    @Override
+    public String getCurrentId(Consumer<String> consumer) {
+        long timestamp = getDayTimestamp();
+        String id = defaultId;
+        if (timestamp != m_timestamp) {
+            synchronized (this) {
+                if (timestamp != m_timestamp) {
+                    id = resetCounter(timestamp);
+                    consumer.accept(id);
+                }
+            }
+        }
+        return id;
+    }
+
+    @Override
+    public String getNextId(String id) {
+        return null;
+    }
+}

+ 62 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/factory/generate/HourIdGenerate.java

@@ -0,0 +1,62 @@
+package com.jay.monitor.data.server.factory.generate;
+
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.factory.IdGenerateService;
+import org.springframework.stereotype.Component;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.function.Consumer;
+
+/**
+ * @Module 编号生成器
+ * @Description 根据小时生成
+ * @Author liukaixiong
+ * @Date 2020/11/5 19:13
+ */
+@Component
+public class HourIdGenerate implements IdGenerateService {
+
+    private SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHH");
+
+    public static final long HOUR = 3600 * 1000L;
+
+    private volatile long hourTimestamp = getHourTimestamp();
+
+    private volatile String defaultId = resetCounter(hourTimestamp);
+
+    protected long getHourTimestamp() {
+        long timestamp = System.currentTimeMillis();
+        return timestamp / HOUR;
+    }
+
+    private String resetCounter(long timestamp) {
+        hourTimestamp = timestamp;
+        return sdf.format(new Date(System.currentTimeMillis()));
+    }
+
+    @Override
+    public DataSplitType splitType() {
+        return DataSplitType.HOUR;
+    }
+
+    @Override
+    public String getCurrentId(Consumer<String> consumer) {
+        long timestamp = getHourTimestamp();
+        String id = defaultId;
+        if (timestamp != hourTimestamp) {
+            synchronized (this) {
+                if (timestamp != hourTimestamp) {
+                    id = resetCounter(timestamp);
+                    consumer.accept(id);
+                }
+            }
+        }
+        return id;
+    }
+
+    @Override
+    public String getNextId(String id) {
+        return null;
+    }
+}

+ 47 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/job/DefaultDataStoreBuilderService.java

@@ -0,0 +1,47 @@
+//package com.jay.monitor.data.server.job;
+//
+//import com.jay.monitor.data.server.config.props.MonitorProperties;
+//import com.jay.monitor.data.server.enums.DataSplitType;
+//import com.jay.monitor.data.server.enums.StoreType;
+//import com.jay.monitor.data.server.store.AbstractSplitDataProcess;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.List;
+//
+///**
+// * @Module TODO
+// * @Description TODO
+// * @Author liukaixiong
+// * @Date 2020/11/5 14:24
+// */
+//@Component
+//public class DefaultDataStoreBuilderService extends ScheduleJobServiceAdaptor {
+//
+//    @Autowired
+//    private MonitorProperties monitorProperties;
+//
+//    @Autowired(required = false)
+//    private List<AbstractSplitDataProcess> storeProcesses;
+//
+//    @Override
+//    public boolean isDayInvoke() {
+//        DataSplitType dataSplitType = monitorProperties.getDataSplitType();
+//        return DataSplitType.DAY == dataSplitType;
+//    }
+//
+//    @Override
+//    public void processDayJob() throws Exception {
+//        process(DataSplitType.DAY);
+//    }
+//
+//    private void process(DataSplitType splitType) {
+//        StoreType storeType = monitorProperties.getStoreType();
+//        storeProcesses.forEach(store -> {
+//            StoreType type = store.storeType();
+//            if (storeType == type) {
+//                store.invoke(splitType);
+//            }
+//        });
+//    }
+//}

+ 12 - 3
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/job/ScheduledJob.java

@@ -2,6 +2,7 @@ package com.jay.monitor.data.server.job;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -17,7 +18,7 @@ import java.util.concurrent.ArrayBlockingQueue;
  * @time : 2019/11/5 - 15:25
  */
 @Component
-public class ScheduledJob implements Runnable {
+public class ScheduledJob implements Runnable, InitializingBean {
 
     private Logger logger = LoggerFactory.getLogger(ScheduledJob.class);
 
@@ -38,6 +39,12 @@ public class ScheduledJob implements Runnable {
         dayJob();
     }
 
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        init();
+    }
+
     /**
      * 每天执行一次
      */
@@ -106,8 +113,10 @@ public class ScheduledJob implements Runnable {
             FailsQueueData queueData = null;
             try {
                 queueData = failQueue.poll();
-                ScheduleJobService jobService = queueData.getJobService();
-                processJobByType(jobService, queueData.getType());
+                if (queueData != null) {
+                    ScheduleJobService jobService = queueData.getJobService();
+                    processJobByType(jobService, queueData.getType());
+                }
             } catch (Throwable e) {
                 int count = queueData.getCount() + 1;
                 if (count > maxCount) {

+ 224 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/models/entity/JayMonitorMq.java

@@ -0,0 +1,224 @@
+package com.jay.monitor.data.server.models.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * jay_monitor_mq
+ * @author 
+ */
+public class JayMonitorMq implements Serializable {
+    /**
+     * 主键名称
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 应用名称
+     */
+    private String applicationName;
+
+    /**
+     * 应用地址
+     */
+    private String applicationIp;
+
+    /**
+     * mq类型 
+     */
+    private String mqType;
+
+    /**
+     * 执行类型  producer/consumer
+     */
+    private String invokeType;
+
+    /**
+     * 订阅主题
+     */
+    private String topic;
+
+    /**
+     * 分区名称
+     */
+    private String partitionName;
+
+    /**
+     * 消息编号
+     */
+    private String msgId;
+
+    /**
+     * 应用监控组
+     */
+    private String dataGroupName;
+
+    /**
+     * 应用监控key
+     */
+    private String dataGroupKey;
+
+    /**
+     * 数据编号
+     */
+    private String dataId;
+
+    /**
+     * 日志编号
+     */
+    private String logId;
+
+    /**
+     * 状态1:正常消息 -1异常消息
+     */
+    private Integer status;
+
+    /**
+     * 数据来源时间
+     */
+    private Date sourceTime;
+
+    /**
+     * 时间时间
+     */
+    private Date createdTime;
+
+    /**
+     * 日期
+     */
+    private Date createdDay;
+
+    private static final long serialVersionUID = 1L;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getApplicationName() {
+        return applicationName;
+    }
+
+    public void setApplicationName(String applicationName) {
+        this.applicationName = applicationName;
+    }
+
+    public String getApplicationIp() {
+        return applicationIp;
+    }
+
+    public void setApplicationIp(String applicationIp) {
+        this.applicationIp = applicationIp;
+    }
+
+    public String getMqType() {
+        return mqType;
+    }
+
+    public void setMqType(String mqType) {
+        this.mqType = mqType;
+    }
+
+    public String getInvokeType() {
+        return invokeType;
+    }
+
+    public void setInvokeType(String invokeType) {
+        this.invokeType = invokeType;
+    }
+
+    public String getTopic() {
+        return topic;
+    }
+
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    public String getPartitionName() {
+        return partitionName;
+    }
+
+    public void setPartitionName(String partitionName) {
+        this.partitionName = partitionName;
+    }
+
+    public String getMsgId() {
+        return msgId;
+    }
+
+    public void setMsgId(String msgId) {
+        this.msgId = msgId;
+    }
+
+    public String getDataGroupName() {
+        return dataGroupName;
+    }
+
+    public void setDataGroupName(String dataGroupName) {
+        this.dataGroupName = dataGroupName;
+    }
+
+    public String getDataGroupKey() {
+        return dataGroupKey;
+    }
+
+    public void setDataGroupKey(String dataGroupKey) {
+        this.dataGroupKey = dataGroupKey;
+    }
+
+    public String getDataId() {
+        return dataId;
+    }
+
+    public void setDataId(String dataId) {
+        this.dataId = dataId;
+    }
+
+    public String getLogId() {
+        return logId;
+    }
+
+    public void setLogId(String logId) {
+        this.logId = logId;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Date getSourceTime() {
+        return sourceTime;
+    }
+
+    public void setSourceTime(Date sourceTime) {
+        this.sourceTime = sourceTime;
+    }
+
+    public Date getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Date createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    public Date getCreatedDay() {
+        return createdDay;
+    }
+
+    public void setCreatedDay(Date createdDay) {
+        this.createdDay = createdDay;
+    }
+}

Plik diff jest za duży
+ 1299 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/models/entity/JayMonitorMqExample.java


+ 105 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/models/entity/JayMonitorMqLog.java

@@ -0,0 +1,105 @@
+package com.jay.monitor.data.server.models.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * jay_monitor_mq_log
+ * @author 
+ */
+public class JayMonitorMqLog implements Serializable {
+
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 监控来源编号
+     */
+    private Integer monitorId;
+
+    /**
+     * 根日志编号
+     */
+    private String rootLogId;
+
+    /**
+     * 上级日志编号
+     */
+    private String parentLogId;
+
+    /**
+     * 日志编号
+     */
+    private String logId;
+
+    /**
+     * 日志文本
+     */
+    private String logText;
+
+    /**
+     * 创建日期
+     */
+    private Date createDate;
+
+    private static final long serialVersionUID = 1L;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getMonitorId() {
+        return monitorId;
+    }
+
+    public void setMonitorId(Integer monitorId) {
+        this.monitorId = monitorId;
+    }
+
+    public String getRootLogId() {
+        return rootLogId;
+    }
+
+    public void setRootLogId(String rootLogId) {
+        this.rootLogId = rootLogId;
+    }
+
+    public String getParentLogId() {
+        return parentLogId;
+    }
+
+    public void setParentLogId(String parentLogId) {
+        this.parentLogId = parentLogId;
+    }
+
+    public String getLogId() {
+        return logId;
+    }
+
+    public void setLogId(String logId) {
+        this.logId = logId;
+    }
+
+    public String getLogText() {
+        return logText;
+    }
+
+    public void setLogText(String logText) {
+        this.logText = logText;
+    }
+
+    public Date getCreateDate() {
+        return createDate;
+    }
+
+    public void setCreateDate(Date createDate) {
+        this.createDate = createDate;
+    }
+}

+ 689 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/models/entity/JayMonitorMqLogExample.java

@@ -0,0 +1,689 @@
+package com.jay.monitor.data.server.models.entity;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+public class JayMonitorMqLogExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    public JayMonitorMqLogExample() {
+        oredCriteria = new ArrayList<>();
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        protected void addCriterionForJDBCDate(String condition, Date value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            addCriterion(condition, new java.sql.Date(value.getTime()), property);
+        }
+
+        protected void addCriterionForJDBCDate(String condition, List<Date> values, String property) {
+            if (values == null || values.size() == 0) {
+                throw new RuntimeException("Value list for " + property + " cannot be null or empty");
+            }
+            List<java.sql.Date> dateList = new ArrayList<>();
+            Iterator<Date> iter = values.iterator();
+            while (iter.hasNext()) {
+                dateList.add(new java.sql.Date(iter.next().getTime()));
+            }
+            addCriterion(condition, dateList, property);
+        }
+
+        protected void addCriterionForJDBCDate(String condition, Date value1, Date value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            addCriterion(condition, new java.sql.Date(value1.getTime()), new java.sql.Date(value2.getTime()), property);
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Integer value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Integer value) {
+            addCriterion("id <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Integer value) {
+            addCriterion("id >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Integer value) {
+            addCriterion("id >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Integer value) {
+            addCriterion("id <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Integer value) {
+            addCriterion("id <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Integer> values) {
+            addCriterion("id in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Integer> values) {
+            addCriterion("id not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Integer value1, Integer value2) {
+            addCriterion("id between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Integer value1, Integer value2) {
+            addCriterion("id not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdIsNull() {
+            addCriterion("monitor_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdIsNotNull() {
+            addCriterion("monitor_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdEqualTo(Integer value) {
+            addCriterion("monitor_id =", value, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdNotEqualTo(Integer value) {
+            addCriterion("monitor_id <>", value, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdGreaterThan(Integer value) {
+            addCriterion("monitor_id >", value, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdGreaterThanOrEqualTo(Integer value) {
+            addCriterion("monitor_id >=", value, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdLessThan(Integer value) {
+            addCriterion("monitor_id <", value, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdLessThanOrEqualTo(Integer value) {
+            addCriterion("monitor_id <=", value, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdIn(List<Integer> values) {
+            addCriterion("monitor_id in", values, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdNotIn(List<Integer> values) {
+            addCriterion("monitor_id not in", values, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdBetween(Integer value1, Integer value2) {
+            addCriterion("monitor_id between", value1, value2, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMonitorIdNotBetween(Integer value1, Integer value2) {
+            addCriterion("monitor_id not between", value1, value2, "monitorId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdIsNull() {
+            addCriterion("root_log_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdIsNotNull() {
+            addCriterion("root_log_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdEqualTo(String value) {
+            addCriterion("root_log_id =", value, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdNotEqualTo(String value) {
+            addCriterion("root_log_id <>", value, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdGreaterThan(String value) {
+            addCriterion("root_log_id >", value, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdGreaterThanOrEqualTo(String value) {
+            addCriterion("root_log_id >=", value, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdLessThan(String value) {
+            addCriterion("root_log_id <", value, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdLessThanOrEqualTo(String value) {
+            addCriterion("root_log_id <=", value, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdLike(String value) {
+            addCriterion("root_log_id like", value, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdNotLike(String value) {
+            addCriterion("root_log_id not like", value, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdIn(List<String> values) {
+            addCriterion("root_log_id in", values, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdNotIn(List<String> values) {
+            addCriterion("root_log_id not in", values, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdBetween(String value1, String value2) {
+            addCriterion("root_log_id between", value1, value2, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andRootLogIdNotBetween(String value1, String value2) {
+            addCriterion("root_log_id not between", value1, value2, "rootLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdIsNull() {
+            addCriterion("parent_log_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdIsNotNull() {
+            addCriterion("parent_log_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdEqualTo(String value) {
+            addCriterion("parent_log_id =", value, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdNotEqualTo(String value) {
+            addCriterion("parent_log_id <>", value, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdGreaterThan(String value) {
+            addCriterion("parent_log_id >", value, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdGreaterThanOrEqualTo(String value) {
+            addCriterion("parent_log_id >=", value, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdLessThan(String value) {
+            addCriterion("parent_log_id <", value, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdLessThanOrEqualTo(String value) {
+            addCriterion("parent_log_id <=", value, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdLike(String value) {
+            addCriterion("parent_log_id like", value, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdNotLike(String value) {
+            addCriterion("parent_log_id not like", value, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdIn(List<String> values) {
+            addCriterion("parent_log_id in", values, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdNotIn(List<String> values) {
+            addCriterion("parent_log_id not in", values, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdBetween(String value1, String value2) {
+            addCriterion("parent_log_id between", value1, value2, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andParentLogIdNotBetween(String value1, String value2) {
+            addCriterion("parent_log_id not between", value1, value2, "parentLogId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdIsNull() {
+            addCriterion("log_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdIsNotNull() {
+            addCriterion("log_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdEqualTo(String value) {
+            addCriterion("log_id =", value, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdNotEqualTo(String value) {
+            addCriterion("log_id <>", value, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdGreaterThan(String value) {
+            addCriterion("log_id >", value, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdGreaterThanOrEqualTo(String value) {
+            addCriterion("log_id >=", value, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdLessThan(String value) {
+            addCriterion("log_id <", value, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdLessThanOrEqualTo(String value) {
+            addCriterion("log_id <=", value, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdLike(String value) {
+            addCriterion("log_id like", value, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdNotLike(String value) {
+            addCriterion("log_id not like", value, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdIn(List<String> values) {
+            addCriterion("log_id in", values, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdNotIn(List<String> values) {
+            addCriterion("log_id not in", values, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdBetween(String value1, String value2) {
+            addCriterion("log_id between", value1, value2, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogIdNotBetween(String value1, String value2) {
+            addCriterion("log_id not between", value1, value2, "logId");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextIsNull() {
+            addCriterion("log_text is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextIsNotNull() {
+            addCriterion("log_text is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextEqualTo(String value) {
+            addCriterion("log_text =", value, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextNotEqualTo(String value) {
+            addCriterion("log_text <>", value, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextGreaterThan(String value) {
+            addCriterion("log_text >", value, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextGreaterThanOrEqualTo(String value) {
+            addCriterion("log_text >=", value, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextLessThan(String value) {
+            addCriterion("log_text <", value, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextLessThanOrEqualTo(String value) {
+            addCriterion("log_text <=", value, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextLike(String value) {
+            addCriterion("log_text like", value, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextNotLike(String value) {
+            addCriterion("log_text not like", value, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextIn(List<String> values) {
+            addCriterion("log_text in", values, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextNotIn(List<String> values) {
+            addCriterion("log_text not in", values, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextBetween(String value1, String value2) {
+            addCriterion("log_text between", value1, value2, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andLogTextNotBetween(String value1, String value2) {
+            addCriterion("log_text not between", value1, value2, "logText");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateIsNull() {
+            addCriterion("create_date is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateIsNotNull() {
+            addCriterion("create_date is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateEqualTo(Date value) {
+            addCriterionForJDBCDate("create_date =", value, "createDate");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateNotEqualTo(Date value) {
+            addCriterionForJDBCDate("create_date <>", value, "createDate");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateGreaterThan(Date value) {
+            addCriterionForJDBCDate("create_date >", value, "createDate");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateGreaterThanOrEqualTo(Date value) {
+            addCriterionForJDBCDate("create_date >=", value, "createDate");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateLessThan(Date value) {
+            addCriterionForJDBCDate("create_date <", value, "createDate");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateLessThanOrEqualTo(Date value) {
+            addCriterionForJDBCDate("create_date <=", value, "createDate");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateIn(List<Date> values) {
+            addCriterionForJDBCDate("create_date in", values, "createDate");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateNotIn(List<Date> values) {
+            addCriterionForJDBCDate("create_date not in", values, "createDate");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateBetween(Date value1, Date value2) {
+            addCriterionForJDBCDate("create_date between", value1, value2, "createDate");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateDateNotBetween(Date value1, Date value2) {
+            addCriterionForJDBCDate("create_date not between", value1, value2, "createDate");
+            return (Criteria) this;
+        }
+    }
+
+    /**
+     */
+    public static class Criteria extends GeneratedCriteria {
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 198 - 198
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/services/impl/DefaultBackstageRouteService.java

@@ -1,204 +1,204 @@
-package com.jay.monitor.data.server.services.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.jay.monitor.data.core.model.response.ResponseCommonModel;
-import com.jay.monitor.data.core.utils.ResponseUtils;
-import com.jay.monitor.data.server.daos.BackstageRouteMapper;
-import com.jay.monitor.data.server.models.entity.BackstageRoute;
-import com.jay.monitor.data.server.models.entity.BackstageRouteExample;
-import com.jay.monitor.data.server.models.request.route.RouteDataRequest;
-import com.jay.monitor.data.server.models.response.RouteDataResponse;
-import com.jay.monitor.data.server.services.IBackstageRouteService;
-import com.jay.monitor.data.server.services.IRouteDataService;
-import com.jay.monitor.data.server.services.IRoutesService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.*;
-
-/**
- * 后台路由管理Service
- *
- * @author liukx
- * @Date 2019-02-28 15:16
- */
-@Service("defaultBackstageRouteService")
-public class DefaultBackstageRouteService extends ServiceImpl<BackstageRouteMapper, BackstageRoute> implements IBackstageRouteService, IRoutesService {
-
-
-    private Logger logger = LoggerFactory.getLogger(DefaultBackstageRouteService.class);
-
-    @Autowired
-    private BackstageRouteMapper backstageRouteMapper;
-
-    @Value("${spring.application.name}")
-    private String domainName;
-
+//package com.jay.monitor.data.server.services.impl;
+//
+//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+//import com.jay.monitor.data.core.model.response.ResponseCommonModel;
+//import com.jay.monitor.data.core.utils.ResponseUtils;
+//import com.jay.monitor.data.server.daos.BackstageRouteMapper;
+//import com.jay.monitor.data.server.models.entity.BackstageRoute;
+//import com.jay.monitor.data.server.models.entity.BackstageRouteExample;
+//import com.jay.monitor.data.server.models.request.route.RouteDataRequest;
+//import com.jay.monitor.data.server.models.response.RouteDataResponse;
+//import com.jay.monitor.data.server.services.IBackstageRouteService;
+//import com.jay.monitor.data.server.services.IRouteDataService;
+//import com.jay.monitor.data.server.services.IRoutesService;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.stereotype.Service;
+//import org.springframework.transaction.annotation.Transactional;
+//
+//import java.util.*;
+//
+///**
+// * 后台路由管理Service
+// *
+// * @author liukx
+// * @Date 2019-02-28 15:16
+// */
+//@Service("defaultBackstageRouteService")
+//public class DefaultBackstageRouteService extends ServiceImpl<BackstageRouteMapper, BackstageRoute> implements IBackstageRouteService, IRoutesService {
+//
+//
+//    private Logger logger = LoggerFactory.getLogger(DefaultBackstageRouteService.class);
+//
 //    @Autowired
-//    private EurekaClient eurekaClient;
-
-    @Autowired
-    private List<IRouteDataService> routeDataServiceList;
-
-    @Autowired
-    private Map<String, IRouteDataService> routeDataServiceMap;
-
-    @Transactional
-    public int insert(BackstageRoute request) {
-        return 0;
-    }
-
-    public List<String> getRoutes() {
-//        List<String> routeList = getValidApplicationName();
-        return null;
-    }
-
-    /**
-     * 执行路由刷新的对象
-     *
-     * @param request
-     * @return
-     * @throws Exception
-     */
-    @Override
-    @Transactional
-    public ResponseCommonModel executeRefresh(RouteDataRequest request) throws Exception {
-        String projectName = request.getProjectName();
-        ResponseUtils.checkParamNull(projectName, "project");
-
-//        Application application = eurekaClient.getApplication(projectName);
-//        InstanceInfo applicationInfo = getApplicationInfo(application);
-
-        // 如果eureka拿不到该项目,表示该项目未存活
-//        ResponseUtils.checkNull(applicationInfo, CommonEnums.ROUTE_EUREKA_APP_ERROR);
-
-        // 根据服务注册的地址去指定的服务内去获取api的文档
-//        String homePageUrl = applicationInfo.getHomePageUrl();
-//        IRouteDataService routeDataService = routeDataServiceList.get(0);
-//        RouteDataRequest routeDataRequest = new RouteDataRequest();
-//        routeDataRequest.setUrl(homePageUrl);
-//        routeDataRequest.setProjectName(projectName);
-//        List<RouteDataResponse> data = routeDataService.getData(routeDataRequest);
-        List<RouteDataResponse> data = null;
-
-        StringBuffer sb = new StringBuffer();
-
-        // 拿到注册文档开始分析对比数据变化
-        BackstageRouteExample example = new BackstageRouteExample();
-        example.createCriteria().andProjectEqualTo(projectName);
-        List<BackstageRoute> backstageRouteEntityList = backstageRouteMapper.selectByExample(example);
-        if (backstageRouteEntityList != null && backstageRouteEntityList.size() > 0) {
-            logger.info(" 开始分析数据对比 ... ");
-            Map<String, BackstageRoute> urlMap = new HashMap<>();
-            for (int i = 0; i < backstageRouteEntityList.size(); i++) {
-                BackstageRoute backstageRoute = backstageRouteEntityList.get(i);
-                urlMap.put(backstageRoute.getUrl(), backstageRoute);
-            }
-
-            // 构建两个容器分别存放修改过的和需要新增的数据
-            List<BackstageRoute> updateEntityList = new ArrayList<>();
-            List<BackstageRoute> insertEntityList = new ArrayList<>();
-
-            for (int i = 0; i < data.size(); i++) {
-                RouteDataResponse response = data.get(i);
-                String url = response.getUrl();
-                BackstageRoute oldEntity = urlMap.get(url);
-                if (oldEntity == null) {
-                    insertRoute(projectName, response);
-                    insertEntityList.add(response);
-                } else {
-                    RouteDataResponse routeDataResponse = new RouteDataResponse(oldEntity);
-                    if (!response.equals(routeDataResponse)) {
-                        logger.info(oldEntity.getUrl() + " 触发修改 ... ");
-                        response.setId(oldEntity.getId());
-                        response.setUpdated(new Date());
-                        backstageRouteMapper.updateByPrimaryKey(response);
-                        updateEntityList.add(response);
-                    }
-                }
-            }
-            sb.append(" 新增 [" + insertEntityList.size() + "] 条 , 修改 [" + updateEntityList.size() + "] 条");
-            logger.info(sb.toString());
-
-        } else {
-            logger.info(" 直接执行添加操作 ... 数据大小 : " + data.size());
-            // 直接执行添加操作
-            for (int i = 0; i < data.size(); i++) {
-                RouteDataResponse response = data.get(i);
-                insertRoute(projectName, response);
-            }
-            sb.append(" 新增 [" + data.size() + "] 条 ");
-        }
-
-        ResponseCommonModel responseCommonModel = new ResponseCommonModel();
-        responseCommonModel.setSuccess(true);
-        responseCommonModel.setMessage(sb.toString());
-
-        return responseCommonModel;
-    }
-
-    /**
-     * 添加路由到数据库
-     *
-     * @param project
-     * @param response
-     * @throws Exception
-     */
-    private void insertRoute(String project, RouteDataResponse response) throws Exception {
-        response.setProject(project);
-        response.setCreated(new Date());
-        response.setIsValid(1);
-        response.setStatus(1);
-        backstageRouteMapper.insert(response);
-    }
-
-    /**
-     * 获取Eureka有效的应用名称
-     *
-     * @return
-     */
-//    private List<String> getValidApplicationName() {
-//        List<String> routeList = new ArrayList<>();
-//        Applications applications = eurekaClient.getApplications();
-//        List<Application> registeredApplications = applications.getRegisteredApplications();
-//        if (applications != null && registeredApplications.size() > 0) {
-//            for (int i = 0; i < registeredApplications.size(); i++) {
-//                Application application = registeredApplications.get(i);
-//                InstanceInfo applicationInfo = getApplicationInfo(application);
-//                String vipAddress = applicationInfo.getVIPAddress();
-//                if (applicationInfo != null && StringUtils.isNotEmpty(vipAddress) && filterApplication(vipAddress)) {
-//                    routeList.add(vipAddress);
-//                }
-//            }
-//        }
-//        return routeList;
+//    private BackstageRouteMapper backstageRouteMapper;
+//
+//    @Value("${spring.application.name}")
+//    private String domainName;
+//
+////    @Autowired
+////    private EurekaClient eurekaClient;
+//
+//    @Autowired
+//    private List<IRouteDataService> routeDataServiceList;
+//
+//    @Autowired
+//    private Map<String, IRouteDataService> routeDataServiceMap;
+//
+//    @Transactional
+//    public int insert(BackstageRoute request) {
+//        return 0;
+//    }
+//
+//    public List<String> getRoutes() {
+////        List<String> routeList = getValidApplicationName();
+//        return null;
 //    }
-
-    public boolean filterApplication(String applicationName) {
-        return !(applicationName.indexOf("eureka") > 0 || applicationName.equals(domainName));
-    }
-
-    /**
-     * 获取指定的应用对象信息
-     *
-     * @param application
-     * @return
-     */
-//    private InstanceInfo getApplicationInfo(Application application) {
-//        if (application != null && application.size() > 0) {
-//            for (int j = 0; j < application.size(); j++) {
-//                List<InstanceInfo> instances = application.getInstances();
-//                if (instances != null && instances.size() > 0) {
-//                    InstanceInfo instanceInfo = instances.get(0);
-//                    return instanceInfo;
+//
+//    /**
+//     * 执行路由刷新的对象
+//     *
+//     * @param request
+//     * @return
+//     * @throws Exception
+//     */
+//    @Override
+//    @Transactional
+//    public ResponseCommonModel executeRefresh(RouteDataRequest request) throws Exception {
+//        String projectName = request.getProjectName();
+//        ResponseUtils.checkParamNull(projectName, "project");
+//
+////        Application application = eurekaClient.getApplication(projectName);
+////        InstanceInfo applicationInfo = getApplicationInfo(application);
+//
+//        // 如果eureka拿不到该项目,表示该项目未存活
+////        ResponseUtils.checkNull(applicationInfo, CommonEnums.ROUTE_EUREKA_APP_ERROR);
+//
+//        // 根据服务注册的地址去指定的服务内去获取api的文档
+////        String homePageUrl = applicationInfo.getHomePageUrl();
+////        IRouteDataService routeDataService = routeDataServiceList.get(0);
+////        RouteDataRequest routeDataRequest = new RouteDataRequest();
+////        routeDataRequest.setUrl(homePageUrl);
+////        routeDataRequest.setProjectName(projectName);
+////        List<RouteDataResponse> data = routeDataService.getData(routeDataRequest);
+//        List<RouteDataResponse> data = null;
+//
+//        StringBuffer sb = new StringBuffer();
+//
+//        // 拿到注册文档开始分析对比数据变化
+//        BackstageRouteExample example = new BackstageRouteExample();
+//        example.createCriteria().andProjectEqualTo(projectName);
+//        List<BackstageRoute> backstageRouteEntityList = backstageRouteMapper.selectByExample(example);
+//        if (backstageRouteEntityList != null && backstageRouteEntityList.size() > 0) {
+//            logger.info(" 开始分析数据对比 ... ");
+//            Map<String, BackstageRoute> urlMap = new HashMap<>();
+//            for (int i = 0; i < backstageRouteEntityList.size(); i++) {
+//                BackstageRoute backstageRoute = backstageRouteEntityList.get(i);
+//                urlMap.put(backstageRoute.getUrl(), backstageRoute);
+//            }
+//
+//            // 构建两个容器分别存放修改过的和需要新增的数据
+//            List<BackstageRoute> updateEntityList = new ArrayList<>();
+//            List<BackstageRoute> insertEntityList = new ArrayList<>();
+//
+//            for (int i = 0; i < data.size(); i++) {
+//                RouteDataResponse response = data.get(i);
+//                String url = response.getUrl();
+//                BackstageRoute oldEntity = urlMap.get(url);
+//                if (oldEntity == null) {
+//                    insertRoute(projectName, response);
+//                    insertEntityList.add(response);
+//                } else {
+//                    RouteDataResponse routeDataResponse = new RouteDataResponse(oldEntity);
+//                    if (!response.equals(routeDataResponse)) {
+//                        logger.info(oldEntity.getUrl() + " 触发修改 ... ");
+//                        response.setId(oldEntity.getId());
+//                        response.setUpdated(new Date());
+//                        backstageRouteMapper.updateByPrimaryKey(response);
+//                        updateEntityList.add(response);
+//                    }
 //                }
 //            }
+//            sb.append(" 新增 [" + insertEntityList.size() + "] 条 , 修改 [" + updateEntityList.size() + "] 条");
+//            logger.info(sb.toString());
+//
+//        } else {
+//            logger.info(" 直接执行添加操作 ... 数据大小 : " + data.size());
+//            // 直接执行添加操作
+//            for (int i = 0; i < data.size(); i++) {
+//                RouteDataResponse response = data.get(i);
+//                insertRoute(projectName, response);
+//            }
+//            sb.append(" 新增 [" + data.size() + "] 条 ");
 //        }
-//        return null;
+//
+//        ResponseCommonModel responseCommonModel = new ResponseCommonModel();
+//        responseCommonModel.setSuccess(true);
+//        responseCommonModel.setMessage(sb.toString());
+//
+//        return responseCommonModel;
+//    }
+//
+//    /**
+//     * 添加路由到数据库
+//     *
+//     * @param project
+//     * @param response
+//     * @throws Exception
+//     */
+//    private void insertRoute(String project, RouteDataResponse response) throws Exception {
+//        response.setProject(project);
+//        response.setCreated(new Date());
+//        response.setIsValid(1);
+//        response.setStatus(1);
+//        backstageRouteMapper.insert(response);
+//    }
+//
+//    /**
+//     * 获取Eureka有效的应用名称
+//     *
+//     * @return
+//     */
+////    private List<String> getValidApplicationName() {
+////        List<String> routeList = new ArrayList<>();
+////        Applications applications = eurekaClient.getApplications();
+////        List<Application> registeredApplications = applications.getRegisteredApplications();
+////        if (applications != null && registeredApplications.size() > 0) {
+////            for (int i = 0; i < registeredApplications.size(); i++) {
+////                Application application = registeredApplications.get(i);
+////                InstanceInfo applicationInfo = getApplicationInfo(application);
+////                String vipAddress = applicationInfo.getVIPAddress();
+////                if (applicationInfo != null && StringUtils.isNotEmpty(vipAddress) && filterApplication(vipAddress)) {
+////                    routeList.add(vipAddress);
+////                }
+////            }
+////        }
+////        return routeList;
+////    }
+//
+//    public boolean filterApplication(String applicationName) {
+//        return !(applicationName.indexOf("eureka") > 0 || applicationName.equals(domainName));
 //    }
-
-}
+//
+//    /**
+//     * 获取指定的应用对象信息
+//     *
+//     * @param application
+//     * @return
+//     */
+////    private InstanceInfo getApplicationInfo(Application application) {
+////        if (application != null && application.size() > 0) {
+////            for (int j = 0; j < application.size(); j++) {
+////                List<InstanceInfo> instances = application.getInstances();
+////                if (instances != null && instances.size() > 0) {
+////                    InstanceInfo instanceInfo = instances.get(0);
+////                    return instanceInfo;
+////                }
+////            }
+////        }
+////        return null;
+////    }
+//
+//}

+ 34 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/store/AbstractSplitDataProcess.java

@@ -0,0 +1,34 @@
+package com.jay.monitor.data.server.store;
+
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.enums.StoreType;
+
+/**
+ * @Module 处理器
+ * @Description 数据分割处理器
+ * @Author liukaixiong
+ * @Date 2020/11/5 15:40
+ */
+public abstract class AbstractSplitDataProcess {
+
+
+    public abstract void splitDataInvoke(DataSplitType splitData);
+
+    /**
+     * 存储类型
+     *
+     * @return
+     */
+    public abstract StoreType storeType();
+
+    public void invoke(DataSplitType splitData) {
+        try {
+            splitDataInvoke(splitData);
+        } catch (Exception e) {
+
+        }
+    }
+
+    public abstract String getDataId(String tableName, DataSplitType dataSplitType);
+
+}

+ 80 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/store/SplitDataManager.java

@@ -0,0 +1,80 @@
+package com.jay.monitor.data.server.store;
+
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.enums.StoreType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @Module 管理器
+ * @Description 数据拆分管理器
+ * @Author liukaixiong
+ * @Date 2020/11/5 18:40
+ */
+public class SplitDataManager implements InitializingBean {
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    private List<AbstractSplitDataProcess> splitDataProcessList;
+
+    private Map<StoreType, AbstractSplitDataProcess> processMap = new ConcurrentHashMap<>();
+
+    private StoreType defaultStoreType = StoreType.MYSQL;
+
+    public SplitDataManager(List<AbstractSplitDataProcess> splitDataProcessList) {
+        this.splitDataProcessList = splitDataProcessList;
+    }
+
+    public void generateMysql(DataSplitType splitType) {
+        generate(StoreType.MYSQL, splitType);
+    }
+
+    /**
+     * 生成事件
+     *
+     * @param storeType 存储类型 (MYSQL)
+     * @param splitType 拆分类型
+     */
+    public void generate(StoreType storeType, DataSplitType splitType) {
+        AbstractSplitDataProcess storeProcess = processMap.get(storeType);
+        if (storeProcess != null) {
+            storeProcess.splitDataInvoke(splitType);
+        } else {
+            logger.warn("找不到对应的[" + splitType + "]");
+        }
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        if (this.splitDataProcessList != null) {
+            splitDataProcessList.forEach((bean) -> {
+                processMap.put(bean.storeType(), bean);
+            });
+            Assert.isTrue(processMap.size() > 0, "找不到对应的存储器");
+        }
+    }
+
+    /**
+     * 希望重启的时候,能够触发方法构建存储结构
+     */
+    public void initFirstProcess() {
+        try {
+            DataSplitType[] splitTypes = DataSplitType.values();
+            processMap.forEach((K, bean) -> {
+                for (int i = 0; i < splitTypes.length; i++) {
+                    DataSplitType dataSplitType = splitTypes[i];
+                    bean.splitDataInvoke(dataSplitType);
+                }
+            });
+        } catch (Exception e) {
+            logger.warn("初始化拆分数据结构失败:" + e.getMessage());
+        }
+    }
+
+}

+ 82 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/store/mysql/MysqlDDLProcess.java

@@ -0,0 +1,82 @@
+package com.jay.monitor.data.server.store.mysql;
+
+import com.jay.monitor.data.server.config.props.MonitorProperties;
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.enums.StoreType;
+import com.jay.monitor.data.server.factory.DataIdFactory;
+import com.jay.monitor.data.server.store.AbstractSplitDataProcess;
+import com.jay.monitor.data.server.utils.MonitorPropertiesUtil;
+import com.jay.monitor.data.server.utils.SqlUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.sql.DataSource;
+import java.util.Map;
+
+/**
+ * @Module 数据拆分
+ * @Description Mysql数据拆分
+ * @Author liukaixiong
+ * @Date 2020/11/5 15:47
+ */
+@Component
+public class MysqlDDLProcess extends AbstractSplitDataProcess {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private DataSource dataSource;
+
+    @Autowired
+    private DataIdFactory dataIdFactory;
+
+    @Autowired
+    private MonitorProperties monitorProperties;
+
+    @Override
+    public void splitDataInvoke(DataSplitType splitData) {
+
+        String currentId = dataIdFactory.getCurrentId(splitData);
+
+        if (currentId == null) {
+            return;
+        }
+
+        Map<String, DataSplitType> tableRule = MonitorPropertiesUtil.getMysqlTableRuleMap(monitorProperties);
+
+        if (tableRule == null) {
+            logger.info("MYSQL 找不到对应的数据拆分规则");
+            return;
+        }
+
+        // 遍历配置文件中的表,并根据当前的编号修改,去规则中进行匹配,然后创建
+        tableRule.forEach((tableName, V) -> {
+            if (V == splitData) {
+                try {
+                    String newTableName = getNewTableName(tableName, currentId);
+                    SqlUtils.createTable(dataSource.getConnection(), getNewTableName(tableName, currentId), tableName);
+                    logger.info("根据数据拆分规则:" + splitData + " 创建存储表名称: " + newTableName + " 参考表:" + tableName);
+                } catch (Exception e) {
+                    logger.error("获取链接失败", e);
+                }
+            }
+        });
+    }
+
+    @Override
+    public String getDataId(String tableName, DataSplitType dataSplitType) {
+        String currentId = dataIdFactory.getCurrentId(dataSplitType);
+        return getNewTableName(tableName, currentId);
+    }
+
+    protected String getNewTableName(String tableName, String id) {
+        return tableName + "_" + id;
+    }
+
+    @Override
+    public StoreType storeType() {
+        return StoreType.MYSQL;
+    }
+
+}

+ 37 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/utils/MonitorPropertiesUtil.java

@@ -0,0 +1,37 @@
+package com.jay.monitor.data.server.utils;
+
+import com.jay.monitor.data.server.config.props.MonitorProperties;
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.enums.StoreType;
+
+import java.util.Map;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2020/11/5 20:02
+ */
+public class MonitorPropertiesUtil {
+
+    public static Map<String, DataSplitType> getMysqlTableRuleMap(MonitorProperties properties) {
+        return getTableRuleMap(properties, StoreType.MYSQL);
+    }
+
+    public static Map<String, DataSplitType> getTableRuleMap(MonitorProperties properties, StoreType storeType) {
+        Map<StoreType, MonitorProperties.StoreInfo> storeInfoMap = properties.getStoreInfo();
+
+        if (properties.getStoreInfo() == null) {
+            return null;
+        }
+
+        MonitorProperties.StoreInfo storeInfo = storeInfoMap.get(storeType);
+
+        if (storeInfo == null) {
+            return null;
+        }
+
+        Map<String, DataSplitType> tableRule = storeInfo.getTableRule();
+        return tableRule;
+    }
+}

+ 43 - 0
jay-monitor-data-server/src/main/java/com/jay/monitor/data/server/utils/SqlUtils.java

@@ -0,0 +1,43 @@
+package com.jay.monitor.data.server.utils;
+
+import com.alibaba.druid.util.JdbcUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.Assert;
+
+import java.sql.Connection;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2020/11/5 11:38
+ */
+public class SqlUtils {
+
+    private static Logger logger = LoggerFactory.getLogger(SqlUtils.class);
+
+    /**
+     * 创建表
+     *
+     * @param connection    数据库连接
+     * @param tableName     要创建的表名
+     * @param likeTableName 复制的表名
+     */
+    public static void createTable(Connection connection, String tableName, String likeTableName) {
+        Assert.notNull(connection, "数据库连接不能为空");
+        Assert.notNull(tableName, "表名不能为空");
+        Assert.notNull(likeTableName, "表名不能为空");
+        try {
+            String sql = "create table " + tableName + " like " + likeTableName;
+            JdbcUtils.execute(connection, sql);
+        } catch (Exception e) {
+            if (e.getMessage().indexOf("already exists") > 0) {
+                logger.warn("表 " + tableName + " 已经创建!");
+            } else {
+                logger.error("创建表失败 : " + e.getMessage());
+            }
+        }
+    }
+
+}

+ 1 - 1
jay-monitor-data-server/src/main/resources/application-com.yml

@@ -4,4 +4,4 @@ spring:
     driver-class-name: com.mysql.jdbc.Driver
     url: jdbc:mysql://172.19.189.118/jay_monitor_prod?characterEncoding=UTF-8&connectTimeout=60000&socketTimeout=60000
     username: jay_monitor
-    password: jayzhou
+    password: jayzhou

+ 1 - 1
jay-monitor-data-server/src/main/resources/application-dev.yml

@@ -2,6 +2,6 @@ spring:
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
     driver-class-name: com.mysql.jdbc.Driver
-    url: jdbc:mysql://192.168.0.13:3306/elab_db?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior\
+    url: jdbc:mysql://192.168.0.13:3306/elab_db?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior
     username: root
     password: elab@123

+ 7 - 22
jay-monitor-data-server/src/main/resources/application.yml

@@ -14,6 +14,12 @@ spring:
       enabled: true
       force-request: true
       force: true
+  monitor-server:
+    store-info:
+      mysql:
+        table-rule:
+          jay_monitor_mq: day
+          jay_monitor_mq_log: day
   thymeleaf:
     cache: false
     prefix: classpath:/templates
@@ -40,25 +46,4 @@ swagger2:
   licenseUrl: http://127.0.0.1:5301/doc.html
   version: 1.0.0
   enable: true
-  docUrl: /v2/api-docs
-
-
-#sofa:
-#  middleware:
-#    log:
-#      com:
-#        alipay:
-#          remoting:
-#            console: true
-
-
-#sofa:
-#  middleware:
-#    log:
-#      com:
-#        alipay:
-#          remoting:
-#            console: true
-#  middleware:
-#    log:
-#      disable: true
+  docUrl: /v2/api-docs

+ 1 - 3
jay-monitor-data-server/src/main/resources/logback.xml

@@ -73,9 +73,7 @@
         <appender-ref ref="stdout"/>
     </logger>
 
-
-
-    <root level="ERROR">
+    <root level="INFO">
         <appender-ref ref="console"></appender-ref>
         <appender-ref ref="ASYNC_FILE"></appender-ref>
         <!--        <appender-ref ref="cat"/>-->

+ 237 - 0
jay-monitor-data-server/src/main/resources/mybatis/mapper/JayMonitorMqLogMapper.xml

@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jay.monitor.data.server.daos.JayMonitorMqLogMapper">
+  <resultMap id="BaseResultMap" type="com.jay.monitor.data.server.models.entity.JayMonitorMqLog">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="monitor_id" jdbcType="INTEGER" property="monitorId" />
+    <result column="root_log_id" jdbcType="VARCHAR" property="rootLogId" />
+    <result column="parent_log_id" jdbcType="VARCHAR" property="parentLogId" />
+    <result column="log_id" jdbcType="VARCHAR" property="logId" />
+    <result column="log_text" jdbcType="VARCHAR" property="logText" />
+    <result column="create_date" jdbcType="DATE" property="createDate" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, monitor_id, root_log_id, parent_log_id, log_id, log_text, create_date
+  </sql>
+  <select id="selectByExample" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqLogExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from jay_monitor_mq_log
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from jay_monitor_mq_log
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from jay_monitor_mq_log
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqLogExample">
+    delete from jay_monitor_mq_log
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqLog" useGeneratedKeys="true">
+    insert into jay_monitor_mq_log (monitor_id, root_log_id, parent_log_id, 
+      log_id, log_text, create_date
+      )
+    values (#{monitorId,jdbcType=INTEGER}, #{rootLogId,jdbcType=VARCHAR}, #{parentLogId,jdbcType=VARCHAR}, 
+      #{logId,jdbcType=VARCHAR}, #{logText,jdbcType=VARCHAR}, #{createDate,jdbcType=DATE}
+      )
+  </insert>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqLog" useGeneratedKeys="true">
+    insert into jay_monitor_mq_log
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="monitorId != null">
+        monitor_id,
+      </if>
+      <if test="rootLogId != null">
+        root_log_id,
+      </if>
+      <if test="parentLogId != null">
+        parent_log_id,
+      </if>
+      <if test="logId != null">
+        log_id,
+      </if>
+      <if test="logText != null">
+        log_text,
+      </if>
+      <if test="createDate != null">
+        create_date,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="monitorId != null">
+        #{monitorId,jdbcType=INTEGER},
+      </if>
+      <if test="rootLogId != null">
+        #{rootLogId,jdbcType=VARCHAR},
+      </if>
+      <if test="parentLogId != null">
+        #{parentLogId,jdbcType=VARCHAR},
+      </if>
+      <if test="logId != null">
+        #{logId,jdbcType=VARCHAR},
+      </if>
+      <if test="logText != null">
+        #{logText,jdbcType=VARCHAR},
+      </if>
+      <if test="createDate != null">
+        #{createDate,jdbcType=DATE},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqLogExample" resultType="java.lang.Long">
+    select count(*) from jay_monitor_mq_log
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update jay_monitor_mq_log
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=INTEGER},
+      </if>
+      <if test="record.monitorId != null">
+        monitor_id = #{record.monitorId,jdbcType=INTEGER},
+      </if>
+      <if test="record.rootLogId != null">
+        root_log_id = #{record.rootLogId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.parentLogId != null">
+        parent_log_id = #{record.parentLogId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.logId != null">
+        log_id = #{record.logId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.logText != null">
+        log_text = #{record.logText,jdbcType=VARCHAR},
+      </if>
+      <if test="record.createDate != null">
+        create_date = #{record.createDate,jdbcType=DATE},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update jay_monitor_mq_log
+    set id = #{record.id,jdbcType=INTEGER},
+      monitor_id = #{record.monitorId,jdbcType=INTEGER},
+      root_log_id = #{record.rootLogId,jdbcType=VARCHAR},
+      parent_log_id = #{record.parentLogId,jdbcType=VARCHAR},
+      log_id = #{record.logId,jdbcType=VARCHAR},
+      log_text = #{record.logText,jdbcType=VARCHAR},
+      create_date = #{record.createDate,jdbcType=DATE}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqLog">
+    update jay_monitor_mq_log
+    <set>
+      <if test="monitorId != null">
+        monitor_id = #{monitorId,jdbcType=INTEGER},
+      </if>
+      <if test="rootLogId != null">
+        root_log_id = #{rootLogId,jdbcType=VARCHAR},
+      </if>
+      <if test="parentLogId != null">
+        parent_log_id = #{parentLogId,jdbcType=VARCHAR},
+      </if>
+      <if test="logId != null">
+        log_id = #{logId,jdbcType=VARCHAR},
+      </if>
+      <if test="logText != null">
+        log_text = #{logText,jdbcType=VARCHAR},
+      </if>
+      <if test="createDate != null">
+        create_date = #{createDate,jdbcType=DATE},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqLog">
+    update jay_monitor_mq_log
+    set monitor_id = #{monitorId,jdbcType=INTEGER},
+      root_log_id = #{rootLogId,jdbcType=VARCHAR},
+      parent_log_id = #{parentLogId,jdbcType=VARCHAR},
+      log_id = #{logId,jdbcType=VARCHAR},
+      log_text = #{logText,jdbcType=VARCHAR},
+      create_date = #{createDate,jdbcType=DATE}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+</mapper>

+ 380 - 0
jay-monitor-data-server/src/main/resources/mybatis/mapper/JayMonitorMqMapper.xml

@@ -0,0 +1,380 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jay.monitor.data.server.daos.JayMonitorMqMapper">
+  <resultMap id="BaseResultMap" type="com.jay.monitor.data.server.models.entity.JayMonitorMq">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="application_name" jdbcType="VARCHAR" property="applicationName" />
+    <result column="application_ip" jdbcType="VARCHAR" property="applicationIp" />
+    <result column="mq_type" jdbcType="VARCHAR" property="mqType" />
+    <result column="invoke_type" jdbcType="VARCHAR" property="invokeType" />
+    <result column="topic" jdbcType="VARCHAR" property="topic" />
+    <result column="partition_name" jdbcType="VARCHAR" property="partitionName" />
+    <result column="msg_id" jdbcType="VARCHAR" property="msgId" />
+    <result column="data_group_name" jdbcType="VARCHAR" property="dataGroupName" />
+    <result column="data_group_key" jdbcType="VARCHAR" property="dataGroupKey" />
+    <result column="data_id" jdbcType="VARCHAR" property="dataId" />
+    <result column="log_id" jdbcType="VARCHAR" property="logId" />
+    <result column="status" jdbcType="INTEGER" property="status" />
+    <result column="source_time" jdbcType="TIMESTAMP" property="sourceTime" />
+    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
+    <result column="created_day" jdbcType="DATE" property="createdDay" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, application_name, application_ip, mq_type, invoke_type, topic, partition_name, 
+    msg_id, data_group_name, data_group_key, data_id, log_id, `status`, source_time, 
+    created_time, created_day
+  </sql>
+  <select id="selectByExample" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from jay_monitor_mq
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from jay_monitor_mq
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from jay_monitor_mq
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqExample">
+    delete from jay_monitor_mq
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMq" useGeneratedKeys="true">
+    insert into jay_monitor_mq (application_name, application_ip, mq_type, 
+      invoke_type, topic, partition_name, 
+      msg_id, data_group_name, data_group_key, 
+      data_id, log_id, `status`, 
+      source_time, created_time, created_day
+      )
+    values (#{applicationName,jdbcType=VARCHAR}, #{applicationIp,jdbcType=VARCHAR}, #{mqType,jdbcType=VARCHAR}, 
+      #{invokeType,jdbcType=VARCHAR}, #{topic,jdbcType=VARCHAR}, #{partitionName,jdbcType=VARCHAR}, 
+      #{msgId,jdbcType=VARCHAR}, #{dataGroupName,jdbcType=VARCHAR}, #{dataGroupKey,jdbcType=VARCHAR}, 
+      #{dataId,jdbcType=VARCHAR}, #{logId,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
+      #{sourceTime,jdbcType=TIMESTAMP}, #{createdTime,jdbcType=TIMESTAMP}, #{createdDay,jdbcType=DATE}
+      )
+  </insert>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMq" useGeneratedKeys="true">
+    insert into jay_monitor_mq
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="applicationName != null">
+        application_name,
+      </if>
+      <if test="applicationIp != null">
+        application_ip,
+      </if>
+      <if test="mqType != null">
+        mq_type,
+      </if>
+      <if test="invokeType != null">
+        invoke_type,
+      </if>
+      <if test="topic != null">
+        topic,
+      </if>
+      <if test="partitionName != null">
+        partition_name,
+      </if>
+      <if test="msgId != null">
+        msg_id,
+      </if>
+      <if test="dataGroupName != null">
+        data_group_name,
+      </if>
+      <if test="dataGroupKey != null">
+        data_group_key,
+      </if>
+      <if test="dataId != null">
+        data_id,
+      </if>
+      <if test="logId != null">
+        log_id,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="sourceTime != null">
+        source_time,
+      </if>
+      <if test="createdTime != null">
+        created_time,
+      </if>
+      <if test="createdDay != null">
+        created_day,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="applicationName != null">
+        #{applicationName,jdbcType=VARCHAR},
+      </if>
+      <if test="applicationIp != null">
+        #{applicationIp,jdbcType=VARCHAR},
+      </if>
+      <if test="mqType != null">
+        #{mqType,jdbcType=VARCHAR},
+      </if>
+      <if test="invokeType != null">
+        #{invokeType,jdbcType=VARCHAR},
+      </if>
+      <if test="topic != null">
+        #{topic,jdbcType=VARCHAR},
+      </if>
+      <if test="partitionName != null">
+        #{partitionName,jdbcType=VARCHAR},
+      </if>
+      <if test="msgId != null">
+        #{msgId,jdbcType=VARCHAR},
+      </if>
+      <if test="dataGroupName != null">
+        #{dataGroupName,jdbcType=VARCHAR},
+      </if>
+      <if test="dataGroupKey != null">
+        #{dataGroupKey,jdbcType=VARCHAR},
+      </if>
+      <if test="dataId != null">
+        #{dataId,jdbcType=VARCHAR},
+      </if>
+      <if test="logId != null">
+        #{logId,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="sourceTime != null">
+        #{sourceTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createdTime != null">
+        #{createdTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createdDay != null">
+        #{createdDay,jdbcType=DATE},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMqExample" resultType="java.lang.Long">
+    select count(*) from jay_monitor_mq
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update jay_monitor_mq
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=INTEGER},
+      </if>
+      <if test="record.applicationName != null">
+        application_name = #{record.applicationName,jdbcType=VARCHAR},
+      </if>
+      <if test="record.applicationIp != null">
+        application_ip = #{record.applicationIp,jdbcType=VARCHAR},
+      </if>
+      <if test="record.mqType != null">
+        mq_type = #{record.mqType,jdbcType=VARCHAR},
+      </if>
+      <if test="record.invokeType != null">
+        invoke_type = #{record.invokeType,jdbcType=VARCHAR},
+      </if>
+      <if test="record.topic != null">
+        topic = #{record.topic,jdbcType=VARCHAR},
+      </if>
+      <if test="record.partitionName != null">
+        partition_name = #{record.partitionName,jdbcType=VARCHAR},
+      </if>
+      <if test="record.msgId != null">
+        msg_id = #{record.msgId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.dataGroupName != null">
+        data_group_name = #{record.dataGroupName,jdbcType=VARCHAR},
+      </if>
+      <if test="record.dataGroupKey != null">
+        data_group_key = #{record.dataGroupKey,jdbcType=VARCHAR},
+      </if>
+      <if test="record.dataId != null">
+        data_id = #{record.dataId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.logId != null">
+        log_id = #{record.logId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.status != null">
+        `status` = #{record.status,jdbcType=INTEGER},
+      </if>
+      <if test="record.sourceTime != null">
+        source_time = #{record.sourceTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.createdTime != null">
+        created_time = #{record.createdTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.createdDay != null">
+        created_day = #{record.createdDay,jdbcType=DATE},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update jay_monitor_mq
+    set id = #{record.id,jdbcType=INTEGER},
+      application_name = #{record.applicationName,jdbcType=VARCHAR},
+      application_ip = #{record.applicationIp,jdbcType=VARCHAR},
+      mq_type = #{record.mqType,jdbcType=VARCHAR},
+      invoke_type = #{record.invokeType,jdbcType=VARCHAR},
+      topic = #{record.topic,jdbcType=VARCHAR},
+      partition_name = #{record.partitionName,jdbcType=VARCHAR},
+      msg_id = #{record.msgId,jdbcType=VARCHAR},
+      data_group_name = #{record.dataGroupName,jdbcType=VARCHAR},
+      data_group_key = #{record.dataGroupKey,jdbcType=VARCHAR},
+      data_id = #{record.dataId,jdbcType=VARCHAR},
+      log_id = #{record.logId,jdbcType=VARCHAR},
+      `status` = #{record.status,jdbcType=INTEGER},
+      source_time = #{record.sourceTime,jdbcType=TIMESTAMP},
+      created_time = #{record.createdTime,jdbcType=TIMESTAMP},
+      created_day = #{record.createdDay,jdbcType=DATE}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMq">
+    update jay_monitor_mq
+    <set>
+      <if test="applicationName != null">
+        application_name = #{applicationName,jdbcType=VARCHAR},
+      </if>
+      <if test="applicationIp != null">
+        application_ip = #{applicationIp,jdbcType=VARCHAR},
+      </if>
+      <if test="mqType != null">
+        mq_type = #{mqType,jdbcType=VARCHAR},
+      </if>
+      <if test="invokeType != null">
+        invoke_type = #{invokeType,jdbcType=VARCHAR},
+      </if>
+      <if test="topic != null">
+        topic = #{topic,jdbcType=VARCHAR},
+      </if>
+      <if test="partitionName != null">
+        partition_name = #{partitionName,jdbcType=VARCHAR},
+      </if>
+      <if test="msgId != null">
+        msg_id = #{msgId,jdbcType=VARCHAR},
+      </if>
+      <if test="dataGroupName != null">
+        data_group_name = #{dataGroupName,jdbcType=VARCHAR},
+      </if>
+      <if test="dataGroupKey != null">
+        data_group_key = #{dataGroupKey,jdbcType=VARCHAR},
+      </if>
+      <if test="dataId != null">
+        data_id = #{dataId,jdbcType=VARCHAR},
+      </if>
+      <if test="logId != null">
+        log_id = #{logId,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=INTEGER},
+      </if>
+      <if test="sourceTime != null">
+        source_time = #{sourceTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createdTime != null">
+        created_time = #{createdTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createdDay != null">
+        created_day = #{createdDay,jdbcType=DATE},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.jay.monitor.data.server.models.entity.JayMonitorMq">
+    update jay_monitor_mq
+    set application_name = #{applicationName,jdbcType=VARCHAR},
+      application_ip = #{applicationIp,jdbcType=VARCHAR},
+      mq_type = #{mqType,jdbcType=VARCHAR},
+      invoke_type = #{invokeType,jdbcType=VARCHAR},
+      topic = #{topic,jdbcType=VARCHAR},
+      partition_name = #{partitionName,jdbcType=VARCHAR},
+      msg_id = #{msgId,jdbcType=VARCHAR},
+      data_group_name = #{dataGroupName,jdbcType=VARCHAR},
+      data_group_key = #{dataGroupKey,jdbcType=VARCHAR},
+      data_id = #{dataId,jdbcType=VARCHAR},
+      log_id = #{logId,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=INTEGER},
+      source_time = #{sourceTime,jdbcType=TIMESTAMP},
+      created_time = #{createdTime,jdbcType=TIMESTAMP},
+      created_day = #{createdDay,jdbcType=DATE}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+</mapper>

+ 29 - 0
jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/config/props/MonitorPropertiesTest.java

@@ -0,0 +1,29 @@
+//package com.jay.monitor.data.server.config.props;
+//
+//import org.junit.Test;
+//import org.junit.runner.RunWith;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.boot.test.context.SpringBootTest;
+//import org.springframework.test.context.junit4.SpringRunner;
+//
+//import java.io.IOException;
+//
+///**
+// * @Module TODO
+// * @Description TODO
+// * @Author liukaixiong
+// * @Date 2020/11/6 13:01
+// */
+//@RunWith(SpringRunner.class)
+//@SpringBootTest(classes = {TestMonitorProperties.class})
+//public class MonitorPropertiesTest {
+//
+//    @Autowired
+//    private TestMonitorProperties testMonitorProperties;
+//
+//    @Test
+//    public void test() throws IOException {
+//        System.out.println("test");
+//    }
+//
+//}

+ 61 - 0
jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/config/props/TestMonitorProperties.java

@@ -0,0 +1,61 @@
+//package com.jay.monitor.data.server.config.props;
+//
+//import com.jay.monitor.data.server.enums.StoreType;
+//import org.springframework.boot.context.properties.ConfigurationProperties;
+//import org.springframework.boot.context.properties.EnableConfigurationProperties;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//
+///**
+// * @Module 配置
+// * @Description 监控服务器配置属性
+// * @Author liukaixiong
+// * @Date 2020/11/5 13:52
+// */
+//@EnableConfigurationProperties(TestMonitorProperties.class)
+//@ConfigurationProperties(prefix = "spring.monitor-server")
+//public class TestMonitorProperties {
+//
+//    private String testData;
+//    /**
+//     * 存储配置规则
+//     * key -> {@link com.jay.monitor.data.server.enums.StoreType}
+//     */
+//    private Map<StoreType, StoreInfo> storeInfo = new HashMap<>();
+//
+//    public Map<StoreType, StoreInfo> getStoreInfo() {
+//        return storeInfo;
+//    }
+//
+//    public void setStoreInfo(Map<StoreType, StoreInfo> storeInfo) {
+//        this.storeInfo = storeInfo;
+//    }
+//
+//    public String getTestData() {
+//        return testData;
+//    }
+//
+//    public void setTestData(String testData) {
+//        this.testData = testData;
+//    }
+//
+//    public static class StoreInfo {
+//
+//        /**
+//         * 表的拆分配置规则
+//         * Key -> 表名
+//         */
+//        private Map<String, String> tableRule = new HashMap<>();
+//
+//        public Map<String, String> getTableRule() {
+//            return tableRule;
+//        }
+//
+//        public void setTableRule(Map<String, String> tableRule) {
+//            this.tableRule = tableRule;
+//        }
+//    }
+//
+//
+//}

+ 43 - 0
jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/factory/DataIdFactoryTest.java

@@ -0,0 +1,43 @@
+package com.jay.monitor.data.server.factory;
+
+import com.jay.monitor.data.server.config.props.MonitorProperties;
+import com.jay.monitor.data.server.enums.DataSplitType;
+import com.jay.monitor.data.server.factory.callback.DefaultIdChangeCallback;
+import com.jay.monitor.data.server.factory.generate.DayIdGenerate;
+import com.jay.monitor.data.server.store.SplitDataManager;
+import com.jay.monitor.data.server.store.mysql.MysqlDDLProcess;
+import com.jay.monitor.data.server.utils.ThreadUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2020/11/9 10:59
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = {MonitorProperties.class, DataSourceAutoConfiguration.class, MysqlDDLProcess.class, SplitDataManager.class, DayIdGenerate.class, DataIdFactory.class, DefaultIdChangeCallback.class})
+public class DataIdFactoryTest {
+
+    @Autowired
+    private DataIdFactory dataIdFactory;
+
+    @Autowired
+    private DayIdGenerate dayIdGenerate;
+
+    @Test
+    public void getCurrentId() throws Exception {
+        ThreadUtils.concurrent(5, 10, 2000, () -> {
+            dayIdGenerate.setM_timestamp(11L);
+            dayIdGenerate.setDefaultId("201106");
+            String currentId = dataIdFactory.getCurrentId(DataSplitType.DAY);
+            return currentId;
+        });
+        System.in.read();
+    }
+}

+ 95 - 0
jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/factory/DayIdGenerateTest.java

@@ -0,0 +1,95 @@
+package com.jay.monitor.data.server.factory;
+
+import com.jay.monitor.data.server.config.props.MonitorProperties;
+import com.jay.monitor.data.server.factory.callback.DefaultIdChangeCallback;
+import com.jay.monitor.data.server.factory.generate.DayIdGenerate;
+import com.jay.monitor.data.server.store.SplitDataManager;
+import com.jay.monitor.data.server.store.mysql.MysqlDDLProcess;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.concurrent.CyclicBarrier;
+
+/**
+ * @Module 数据生成器
+ * @Description 根据天生层编号
+ * @Author liukaixiong
+ * @Date 2020/11/6 15:54
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = {MonitorProperties.class,DataSourceAutoConfiguration.class,MysqlDDLProcess.class, SplitDataManager.class, DayIdGenerate.class, DataIdFactory.class, DefaultIdChangeCallback.class})
+public class DayIdGenerateTest {
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
+    //    @Autowired
+//    private DataIdFactory idFactory;
+    @Autowired
+    private DayIdGenerate dayIdGenerate;
+
+    private CyclicBarrier barrier = new CyclicBarrier(10);
+
+    @Test
+    public void getConcurrentCurrentId() throws Exception {
+        //
+        dayIdGenerate.setM_timestamp(0L);
+
+        for (int i = 0; i < 10; i++) {
+            new Thread(() -> {
+                try {
+                    logger.info("开始等待");
+                    barrier.await();
+                    logger.info("抢占开始");
+//                    String currentId = idFactory.getCurrentId(DataSplitType.DAY);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }).start();
+        }
+        System.in.read();
+    }
+
+
+    @Test
+    public void testDayGenerate() throws Exception {
+
+        logger.info("程序初始化的数据:" + dayIdGenerate.getM_timestamp() + "\t" + dayIdGenerate.getDefaultId());
+
+        dayIdGenerate.setM_timestamp(0L);
+        dayIdGenerate.setDefaultId("201106");
+
+        logger.info("修改后的数据:" + dayIdGenerate.getM_timestamp() + "\t" + dayIdGenerate.getDefaultId());
+
+        for (int i = 0; i < 10; i++) {
+            new Thread(() -> {
+                try {
+                    logger.info("开始等待");
+                    barrier.await();
+                    logger.info("抢占开始");
+                    String currentId = dayIdGenerate.getCurrentId((id) -> {
+                        logger.info("------------------------->发生改变的编号:" + id);
+                    });
+                    logger.info("正常获取的编号:" + currentId);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }).start();
+        }
+
+        Thread.sleep(1000);
+        logger.info("最终的数据结果:" + dayIdGenerate.getM_timestamp() + "\t" + dayIdGenerate.getDefaultId());
+    }
+
+    @Test
+    public void testBatchDayGenerate() throws Exception {
+        testDayGenerate();
+        testDayGenerate();
+        testDayGenerate();
+        testDayGenerate();
+    }
+}

+ 64 - 0
jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/utils/SqlUtilsTest.java

@@ -0,0 +1,64 @@
+package com.jay.monitor.data.server.utils;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.util.JdbcUtils;
+import org.junit.Test;
+
+import javax.sql.DataSource;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2020/11/5 13:29
+ */
+public class SqlUtilsTest {
+
+    public static final long HOUR = 3600 * 1000L;
+    public static final long DAY = 24 * 3600 * 1000L;
+
+    @Test
+    public void test() throws Exception {
+        String sql = "create table jay_monitor_mq_20201105 like jay_monitor_mq;";
+        DataSource conn = dataSource();
+        JdbcUtils.execute(conn, sql);
+//        List<SQLStatement> sqlStatements = SQLUtils.parseStatements(sql, JdbcConstants.MYSQL);
+    }
+
+    public DataSource dataSource() {
+        DruidDataSource dataSource = new DruidDataSource();
+        dataSource.setUrl("jdbc:mysql://192.168.0.13:3306/elab_db?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior");
+        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
+        dataSource.setUsername("root");
+        dataSource.setPassword("elab@123");
+        return dataSource;
+    }
+
+    protected long getTimestamp() {
+        long timestamp = System.currentTimeMillis();
+        return timestamp / HOUR; // version 2
+    }
+
+    protected long getDayTimestamp() {
+        long timestamp = System.currentTimeMillis();
+        return timestamp / DAY; // version 2
+    }
+
+    @Test
+    public void testGetTime() {
+//        long timestamp = getTimestamp();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+        Date date = new Date(System.currentTimeMillis());
+        System.out.println(sdf.format(date));
+
+
+        for (int i = 0; i < 5; i++) {
+            long timestamp = getTimestamp();
+            long dayTimestamp = getDayTimestamp();
+            System.out.println(timestamp + "\t" + dayTimestamp);
+        }
+    }
+
+}

+ 46 - 0
jay-monitor-data-server/src/test/java/com/jay/monitor/data/server/utils/ThreadUtils.java

@@ -0,0 +1,46 @@
+package com.jay.monitor.data.server.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.CyclicBarrier;
+import java.util.function.Supplier;
+
+/**
+ * @Module TODO
+ * @Description TODO
+ * @Author liukaixiong
+ * @Date 2020/11/9 11:04
+ */
+public class ThreadUtils {
+
+    private static Logger logger = LoggerFactory.getLogger(ThreadUtils.class);
+
+    /**
+     * 压测工具类
+     *
+     * @param number       压测次数
+     * @param count        压测数量
+     * @param intervalTime 每个压测之间的间隔时间
+     * @param consumer     压测的具体内容
+     */
+    public static void concurrent(int number, int count, int intervalTime, Supplier consumer) {
+        CyclicBarrier barrier = new CyclicBarrier(count);
+        for (int i = 0; i < number; i++) {
+            logger.info("压测第[" + i + "]次");
+            for (int j = 0; j < 10; j++) {
+                new Thread(() -> {
+                    try {
+                        logger.info("开始等待");
+                        barrier.await();
+                        logger.info("抢占开始");
+                        Object o = consumer.get();
+                        logger.info("得到的结果:" + o);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }).start();
+            }
+        }
+    }
+}

+ 13 - 0
jay-monitor-data-server/src/test/resources/application-dev.yml

@@ -0,0 +1,13 @@
+spring:
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://192.168.0.13:3306/elab_db?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior
+    username: root
+    password: elab@123
+  monitor-server:
+    test-data: asdfsa
+    store-info:
+      mysql:
+        table-rule:
+          ffff: day

+ 81 - 0
jay-monitor-data-server/src/test/resources/application.yml

@@ -0,0 +1,81 @@
+server:
+  port: 5800
+  tomcat:
+    max-threads: 2000
+    uri-encoding: UTF-8
+spring:
+  profiles:
+    active: dev
+  application:
+    name: jay-monitor-server
+  http:
+    encoding:
+      charset: UTF-8
+      enabled: true
+      force-request: true
+      force: true
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://192.168.0.13:3306/elab_db?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior
+    username: root
+    password: elab@123
+    monitor-server:
+      test-data: asdfsa
+      store-info:
+        mysql:
+          table-rule:
+            ffff: day
+  thymeleaf:
+    cache: false
+    prefix: classpath:/templates
+    suffix: .html
+    mode: LEGACYHTML5
+    enabled: true
+    check-template: false
+  resources:
+    chain:
+      strategy:
+        content:
+          enabled: true
+          paths: /**
+mybatis-plus:
+  mapper-locations: classpath*:/mybatis/mapper/*.xml,classpath:mybatis/mapper/ext/*.xml
+  type-aliases-package: com.jay.monitor.data.server.daos
+  config-location: classpath:/mybatis/mybatis-config.xml
+
+  security:
+    oauth2:
+      client:
+        provider:
+          fff:
+            tokenUri: http
+swagger2:
+  basePackage: com.jay.monitor.data.server.controllers
+  title: backstage
+  description: 后台服务
+  termsOfServiceUrl: http://www.elab-plus.com
+  licenseUrl: http://127.0.0.1:5301/doc.html
+  version: 1.0.0
+  enable: true
+  docUrl: /v2/api-docs
+
+#sofa:
+#  middleware:
+#    log:
+#      com:
+#        alipay:
+#          remoting:
+#            console: true
+
+
+#sofa:
+#  middleware:
+#    log:
+#      com:
+#        alipay:
+#          remoting:
+#            console: true
+#  middleware:
+#    log:
+#      disable: true

+ 3 - 0
数据调度监控.md

@@ -72,3 +72,6 @@ URL 统计
 - 每周报告
 - 每月报告
 
+功能描述: 
+1. 支持数据按照纬度拆分 : 小时、天、周、月
+2.