fase()远程调用测试
parent
bf01b893c7
commit
6044eaa915
|
@ -21,5 +21,6 @@ public class ServiceNameConstants {
|
||||||
*/
|
*/
|
||||||
public static final String FILE_SERVICE = "muyu-file";
|
public static final String FILE_SERVICE = "muyu-file";
|
||||||
|
|
||||||
public static final String EDITION_MUYU = "muyu-edition";
|
public static final String EDITION_MUYU = "muyu-rule";
|
||||||
|
public static final String System_MUYU = "muyu-system";
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-data-ranges</artifactId>
|
<artifactId>muyu-data-range</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>muyu-data-ranges-clinet</artifactId>
|
<artifactId>muyu-data-range-clinet</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-data-ranges-common</artifactId>
|
<artifactId>muyu-data-range-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.data.ranges.clinet.config;
|
package muyu.data.range.config;
|
||||||
|
|
||||||
import com.muyu.data.ranges.clinet.config.runner.DataGoodsConfigRunner;
|
import muyu.data.range.config.runner.DataGoodsConfigRunner;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎客户端配置类
|
||||||
|
*/
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
@Import(value = DataGoodsConfigRunner.class)
|
@Import(value = DataGoodsConfigRunner.class)
|
||||||
public class DataGoodsConfig {
|
public class DataGoodsConfig {
|
|
@ -1,6 +1,6 @@
|
||||||
package com.data.ranges.clinet.config;
|
package muyu.data.range.config;
|
||||||
|
|
||||||
import com.muyu.data.ranges.clinet.config.runner.DataRangeConfigRunner;
|
import muyu.data.range.config.runner.DataRangeConfigRunner;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.data.ranges.clinet.config.runner;
|
package muyu.data.range.config.runner;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
@ -22,8 +22,8 @@ public class DataGoodsConfigRunner implements ApplicationRunner {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
Result<TableDataInfo<RuleEngine>> list = remoteDataManagerService.list(null);
|
Result<List<RuleEngine>> list = remoteDataManagerService.list();
|
||||||
List<RuleEngine> rows = list.getData().getRows();
|
List<RuleEngine> rows = list.getData();
|
||||||
log.info("远程调用成功:{}",rows);
|
log.info("远程调用成功:{}",rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package muyu.data.range.config.runner;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.edition.dataSoutce.DataSourceConfig;
|
||||||
|
import com.muyu.system.domain.DataAccess;
|
||||||
|
import com.muyu.system.remote.RemoteSystemManageService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化加载
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
public class DataRangeConfigRunner implements ApplicationRunner {
|
||||||
|
@Autowired
|
||||||
|
private RemoteSystemManageService remoteSystemManageService;// 远程调用
|
||||||
|
@Autowired
|
||||||
|
private DataSourceConfig dataSourceConfig;
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
//远程调用
|
||||||
|
Result<List<DataAccess>> lists = remoteSystemManageService.lists();
|
||||||
|
//判断非空
|
||||||
|
if (lists.getData() == null || lists.getData().isEmpty()){
|
||||||
|
log.error("数据为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//获取数据源集合
|
||||||
|
List<DataAccess> listResultData = lists.getData();
|
||||||
|
// log.info("远程调用:{}",listResultData);
|
||||||
|
//存入map
|
||||||
|
//创建map
|
||||||
|
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
||||||
|
//遍历循环存入map
|
||||||
|
listResultData.forEach(res -> {
|
||||||
|
frimaryVoHashMap.put(res.getId(),res);
|
||||||
|
});
|
||||||
|
//遍历添加到hashMap
|
||||||
|
for (DataAccess listResultDatum : listResultData) {
|
||||||
|
if (listResultDatum.getType() == "MySql"){
|
||||||
|
//记录线程池
|
||||||
|
dataSourceConfig.index(listResultDatum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//连接上线程池
|
||||||
|
DataAccess dataAccess = listResultData.get(0);
|
||||||
|
System.out.println(dataAccess);
|
||||||
|
dataSourceConfig.verify(dataAccess.getId());
|
||||||
|
//获取一个线程池
|
||||||
|
Connection connection = dataSourceConfig.getConnection(dataAccess.getId());
|
||||||
|
log.info("获取线程:{}",connection);
|
||||||
|
//查看线程
|
||||||
|
System.out.println("查看线程");
|
||||||
|
dataSourceConfig.verify(dataAccess.getId());
|
||||||
|
//归还线程池
|
||||||
|
System.out.println("归还线程池");
|
||||||
|
dataSourceConfig.returnConnection(connection);
|
||||||
|
//查看线程
|
||||||
|
System.out.println("查看线程");
|
||||||
|
dataSourceConfig.verify(dataAccess.getId());
|
||||||
|
//将对象传入Spring
|
||||||
|
//SpringHashMap(hashMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public HashMap<Long, DruidDataSource> SpringHashMap(HashMap<Long,DruidDataSource> hashMap) {
|
||||||
|
return hashMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
muyu.data.range.config.DataGoodsConfig
|
||||||
|
muyu.data.range.config.DataRangeConfig
|
|
@ -5,17 +5,18 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-data-ranges</artifactId>
|
<artifactId>muyu-data-range</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>muyu-data-ranges-common</artifactId>
|
<artifactId>muyu-data-range-common</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
|
@ -25,6 +26,8 @@
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-modules-system</artifactId>
|
<artifactId>muyu-modules-system</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,4 +1,4 @@
|
||||||
package muyu.data.ranges.common.domain.dataSoutce;
|
package muyu.data.range.common.domain.dataSoutce;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
import com.alibaba.druid.pool.DruidPooledConnection;
|
|
@ -5,11 +5,11 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-data-ranges</artifactId>
|
<artifactId>muyu-data-range</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>muyu-data-ranges-server</artifactId>
|
<artifactId>muyu-data-range-server</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
@ -17,11 +17,6 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu-data-ranges-common</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
@ -95,9 +90,8 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>muyu-data-range-clinet</artifactId>
|
<artifactId>muyu-goods-edition-clinet</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.data.test;
|
package muyu.data.range;
|
||||||
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
|
@ -8,16 +8,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试启动类
|
|
||||||
*/
|
|
||||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
public class MuyuGoodsUnitApplication {
|
public class DataRangesApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(MuyuGoodsUnitApplication.class);
|
SpringApplication.run(DataRangesApplication.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package muyu.data.range.controller;
|
||||||
|
|
||||||
|
import com.data.ranges.clinet.config.runner.DataGoodsConfigRunner;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/range")
|
||||||
|
@Log4j2
|
||||||
|
public class RangesController {
|
||||||
|
|
||||||
|
@PostMapping("sel")
|
||||||
|
private static void sel(){
|
||||||
|
DataGoodsConfigRunner dataGoodsConfigRunner = new DataGoodsConfigRunner();
|
||||||
|
System.out.println(dataGoodsConfigRunner.toString());
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,12 +10,12 @@
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>muyu-data-ranges</artifactId>
|
<artifactId>muyu-data-range</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<modules>
|
<modules>
|
||||||
<module>muyu-data-ranges-clinet</module>
|
<module>muyu-data-range-server</module>
|
||||||
<module>muyu-data-ranges-common</module>
|
<module>muyu-data-range-common</module>
|
||||||
<module>muyu-data-ranges-server</module>
|
<module>muyu-data-range-clinet</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
|
@ -1,2 +0,0 @@
|
||||||
com.data.ranges.clinet.config.DataGoodsConfig
|
|
||||||
com.data.ranges.clinet.config.DataRangeConfig
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.muyu.data.ranges;
|
|
||||||
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
|
||||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
@EnableCustomConfig
|
|
||||||
@EnableCustomSwagger2
|
|
||||||
@EnableMyFeignClients
|
|
||||||
@SpringBootApplication
|
|
||||||
public class DataRangeApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(DataRangeApplication.class,args);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
|
||||||
<!-- 日志存放路径 -->
|
|
||||||
<property name="log.path" value="logs/muyu-visual-monitor"/>
|
|
||||||
<!-- 日志输出格式 -->
|
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
|
||||||
|
|
||||||
<!-- 控制台输出 -->
|
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统日志输出 -->
|
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/info.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>INFO</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/error.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>ERROR</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统模块日志级别控制 -->
|
|
||||||
<logger name="com.muyu" level="info"/>
|
|
||||||
<!-- Spring日志级别控制 -->
|
|
||||||
<logger name="org.springframework" level="warn"/>
|
|
||||||
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="console"/>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="file_info"/>
|
|
||||||
<appender-ref ref="file_error"/>
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
|
@ -10,6 +10,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试启动类
|
* 测试启动类
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.efition.clinet.config;
|
package com.muyu.efition.clinet.config;
|
||||||
|
|
||||||
|
import com.muyu.efition.clinet.config.runner.AccessConfigRunner;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
|
|
@ -1,129 +0,0 @@
|
||||||
package com.muyu.efition.clinet.config;
|
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
|
||||||
import com.muyu.edition.domain.RuleEngine;
|
|
||||||
import com.muyu.edition.domain.vo.UnitVo;
|
|
||||||
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
|
||||||
import com.muyu.system.domain.DataAccess;
|
|
||||||
import com.muyu.system.domain.vo.FrimaryVo;
|
|
||||||
import com.muyu.system.remote.RemoteSystemManageService;
|
|
||||||
import com.muyu.system.remote.factory.DataMangSystemFactory;
|
|
||||||
import lombok.SneakyThrows;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
|
||||||
import org.springframework.boot.ApplicationRunner;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化加载
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
@Component
|
|
||||||
@Configuration
|
|
||||||
public class AccessConfigRunner implements ApplicationRunner {
|
|
||||||
@Autowired
|
|
||||||
private RemoteSystemManageService remoteSystemManageService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
|
||||||
//远程调用
|
|
||||||
Result<TableDataInfo<DataAccess>> listed = remoteSystemManageService.list(null);
|
|
||||||
//判断非空
|
|
||||||
if (listed.getData().getRows() == null || listed.getData().getRows().isEmpty()){
|
|
||||||
log.error("数据为空");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//获取数据源集合
|
|
||||||
List<DataAccess> listResultData = listed.getData().getRows();
|
|
||||||
//存入map
|
|
||||||
//创建map
|
|
||||||
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
|
||||||
//遍历循环存入map
|
|
||||||
listResultData.forEach(res -> {
|
|
||||||
frimaryVoHashMap.put(res.getId(),res);
|
|
||||||
});
|
|
||||||
HashMap<String, UnitVo> hashMap = new HashMap<>();
|
|
||||||
//遍历添加到hashMap
|
|
||||||
for (DataAccess listResultDatum : listResultData) {
|
|
||||||
if (listResultDatum.getType() == "MySql"){
|
|
||||||
//主机地址
|
|
||||||
String host = listResultDatum.getHost();
|
|
||||||
//端口号
|
|
||||||
String port = listResultDatum.getPort();
|
|
||||||
//数据库名
|
|
||||||
String databaseName = listResultDatum.getDatabaseName();
|
|
||||||
// url
|
|
||||||
String url = String.format("jdbc:mysql://"+ host+":"+port+":"+databaseName);
|
|
||||||
log.info("集成化的url:{}",url);
|
|
||||||
//连接对象 url/用户名/密码
|
|
||||||
Connection connection = DriverManager.getConnection(url,listResultDatum.getUsername(),listResultDatum.getPassword());
|
|
||||||
log.info("连接对象:{}",connection);
|
|
||||||
DruidDataSource dataSource = new DruidDataSource();
|
|
||||||
//初始化链接池数量
|
|
||||||
dataSource.setInitialSize(listResultDatum.getInitNum().intValue());
|
|
||||||
//最大线程池
|
|
||||||
dataSource.setMaxActive(listResultDatum.getMaxNum().intValue());
|
|
||||||
//最大等待时间
|
|
||||||
dataSource.setMaxWait(listResultDatum.getMaxWaitTime());
|
|
||||||
//配置数据库的基本信息
|
|
||||||
dataSource.setDriverClassName("com.mysql/jdbc.Driver");
|
|
||||||
//数据库连接池
|
|
||||||
dataSource.setUrl("jdbc:mysql://"+
|
|
||||||
listResultDatum.getHost()+":"+listResultDatum.getPort()+":"+listResultDatum.getDatabaseName());
|
|
||||||
//数据库用户名
|
|
||||||
dataSource.setUsername(listResultDatum.getUsername());
|
|
||||||
//数据库密码
|
|
||||||
dataSource.setPassword(listResultDatum.getPassword());
|
|
||||||
log.info("获取连接池对象:{}",dataSource);
|
|
||||||
//封装对象
|
|
||||||
//SuperBuilder方法
|
|
||||||
UnitVo build = UnitVo.builder()
|
|
||||||
.connection(connection)
|
|
||||||
.dataSource(dataSource)
|
|
||||||
.build();
|
|
||||||
//存入map
|
|
||||||
hashMap.put(host+"_"+port+"_"+databaseName,build);
|
|
||||||
//查看连接池
|
|
||||||
DataAccess dataAccess = listResultData.get(0);
|
|
||||||
UnitVo unitVo = hashMap.get(dataAccess.getHost() + "_" + dataAccess.getPort() + "_" + dataAccess.getDatabaseName());
|
|
||||||
log.info("存在的连接池有:--{}",unitVo);
|
|
||||||
//取出连接池
|
|
||||||
|
|
||||||
//返回连接池
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//将对象传入Spring
|
|
||||||
SpringHashMap(hashMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public HashMap<String,UnitVo> SpringHashMap(HashMap<String,UnitVo> hashMap) {
|
|
||||||
return hashMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.muyu.efition.clinet.config;
|
||||||
|
|
||||||
|
import com.muyu.efition.clinet.config.runner.DataGoodsConfigRunner;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎客户端配置类
|
||||||
|
*/
|
||||||
|
@ComponentScan
|
||||||
|
@Import(value = DataGoodsConfigRunner.class)
|
||||||
|
public class DataGoodsConfig {
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.muyu.efition.clinet.config;
|
||||||
|
|
||||||
|
import com.muyu.efition.clinet.config.runner.DataRangeConfigRunner;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎客户端配置类
|
||||||
|
*/
|
||||||
|
@ComponentScan
|
||||||
|
@Import(value = DataRangeConfigRunner.class)
|
||||||
|
public class DataRangeConfig {
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
package com.muyu.efition.clinet.config.runner;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.edition.domain.RuleEngine;
|
||||||
|
import com.muyu.edition.domain.vo.RuleEngineVO;
|
||||||
|
import com.muyu.edition.domain.vo.UnitVo;
|
||||||
|
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
||||||
|
import com.muyu.system.domain.DataAccess;
|
||||||
|
import com.muyu.system.domain.vo.FrimaryVo;
|
||||||
|
import com.muyu.system.remote.RemoteSystemManageService;
|
||||||
|
import com.muyu.system.remote.factory.DataMangSystemFactory;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化加载
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
public class AccessConfigRunner implements ApplicationRunner {
|
||||||
|
// @Autowired
|
||||||
|
// private RemoteSystemManageService remoteSystemManageService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
//远程调用
|
||||||
|
System.out.println("远程调用");
|
||||||
|
// Result<List<DataAccess>> list = remoteSystemManageService.lists();
|
||||||
|
// //判断非空
|
||||||
|
// if (list.getData() == null || list.getData().isEmpty()){
|
||||||
|
// log.error("数据为空");
|
||||||
|
// return;
|
||||||
|
// }else{
|
||||||
|
// log.info("远程调用:",list);
|
||||||
|
// }
|
||||||
|
// //获取数据源集合
|
||||||
|
// List<DataAccess> listResultData = list.getData();
|
||||||
|
// log.info("远程调用成功:{}",listResultData);
|
||||||
|
// //存入map
|
||||||
|
// //创建map
|
||||||
|
// HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
||||||
|
// //遍历循环存入map
|
||||||
|
// listResultData.forEach(res -> {
|
||||||
|
// frimaryVoHashMap.put(res.getId(),res);
|
||||||
|
// });
|
||||||
|
// log.info("map:{}",frimaryVoHashMap);
|
||||||
|
// HashMap<String, UnitVo> hashMap = new HashMap<>();
|
||||||
|
// //遍历添加到hashMap
|
||||||
|
// for (DataAccess listResultDatum : listResultData) {
|
||||||
|
// if (listResultDatum.getType() == "MySql"){
|
||||||
|
// //主机地址
|
||||||
|
// String host = listResultDatum.getHost();
|
||||||
|
// //端口号
|
||||||
|
// String port = listResultDatum.getPort();
|
||||||
|
// //数据库名
|
||||||
|
// String databaseName = listResultDatum.getDatabaseName();
|
||||||
|
// // url
|
||||||
|
// String url = String.format("jdbc:mysql://"+ host+":"+port+":"+databaseName);
|
||||||
|
// log.info("集成化的url:{}",url);
|
||||||
|
// //连接对象 url/用户名/密码
|
||||||
|
// Connection connection = DriverManager.getConnection(url,listResultDatum.getUsername(),listResultDatum.getPassword());
|
||||||
|
// log.info("连接对象:{}",connection);
|
||||||
|
// DruidDataSource dataSource = new DruidDataSource();
|
||||||
|
// //初始化链接池数量
|
||||||
|
// dataSource.setInitialSize(listResultDatum.getInitNum().intValue());
|
||||||
|
// //最大线程池
|
||||||
|
// dataSource.setMaxActive(listResultDatum.getMaxNum().intValue());
|
||||||
|
// //最大等待时间
|
||||||
|
// dataSource.setMaxWait(listResultDatum.getMaxWaitTime());
|
||||||
|
// //配置数据库的基本信息
|
||||||
|
// dataSource.setDriverClassName("com.mysql/jdbc.Driver");
|
||||||
|
// //数据库连接池
|
||||||
|
// dataSource.setUrl("jdbc:mysql://"+
|
||||||
|
// listResultDatum.getHost()+":"+listResultDatum.getPort()+":"+listResultDatum.getDatabaseName());
|
||||||
|
// //数据库用户名
|
||||||
|
// dataSource.setUsername(listResultDatum.getUsername());
|
||||||
|
// //数据库密码
|
||||||
|
// dataSource.setPassword(listResultDatum.getPassword());
|
||||||
|
// log.info("获取连接池对象:{}",dataSource);
|
||||||
|
// //封装对象
|
||||||
|
// //SuperBuilder方法
|
||||||
|
// UnitVo build = UnitVo.builder()
|
||||||
|
// .connection(connection)
|
||||||
|
// .dataSource(dataSource)
|
||||||
|
// .build();
|
||||||
|
// //存入map
|
||||||
|
// hashMap.put(host+"_"+port+"_"+databaseName,build);
|
||||||
|
// //查看连接池
|
||||||
|
// DataAccess dataAccess = listResultData.get(0);
|
||||||
|
// UnitVo unitVo = hashMap.get(dataAccess.getHost() + "_" + dataAccess.getPort() + "_" + dataAccess.getDatabaseName());
|
||||||
|
// log.info("存在的连接池有:--{}",unitVo);
|
||||||
|
// //取出连接池
|
||||||
|
//
|
||||||
|
// //返回连接池
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //将对象传入Spring
|
||||||
|
// SpringHashMap(hashMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Bean
|
||||||
|
// public HashMap<String,UnitVo> SpringHashMap(HashMap<String,UnitVo> hashMap) {
|
||||||
|
// return hashMap;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.efition.clinet.config.runner;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.edition.domain.RuleEngine;
|
||||||
|
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
public class DataGoodsConfigRunner implements ApplicationRunner {
|
||||||
|
@Autowired
|
||||||
|
private RemoteDataManagerService remoteDataManagerService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
Result<List<RuleEngine>> list = remoteDataManagerService.list();
|
||||||
|
List<RuleEngine> rows = list.getData();
|
||||||
|
// log.info("引擎远程调用成功:{}",rows);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package com.data.ranges.clinet.config.runner;
|
package com.muyu.efition.clinet.config.runner;
|
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.edition.dataSoutce.DataSourceConfig;
|
||||||
import com.muyu.system.domain.DataAccess;
|
import com.muyu.system.domain.DataAccess;
|
||||||
import com.muyu.system.remote.RemoteSystemManageService;
|
import com.muyu.system.remote.RemoteSystemManageService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import muyu.data.range.common.domain.Unit;
|
|
||||||
import muyu.data.range.common.domain.dataSoutce.DataSourceConfig;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
@ -32,14 +32,16 @@ public class DataRangeConfigRunner implements ApplicationRunner {
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
//远程调用
|
//远程调用
|
||||||
Result<TableDataInfo<DataAccess>> listed = remoteSystemManageService.list(null);
|
Result<List<DataAccess>> lists = remoteSystemManageService.lists();
|
||||||
|
log.info("数据源调用状态:{}",lists);
|
||||||
//判断非空
|
//判断非空
|
||||||
if (listed.getData().getRows() == null || listed.getData().getRows().isEmpty()){
|
if (lists.getData() == null || lists.getData().isEmpty()){
|
||||||
log.error("数据为空");
|
log.error("数据为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//获取数据源集合
|
//获取数据源集合
|
||||||
List<DataAccess> listResultData = listed.getData().getRows();
|
List<DataAccess> listResultData = lists.getData();
|
||||||
|
log.info("远程调用:{}",listResultData);
|
||||||
//存入map
|
//存入map
|
||||||
//创建map
|
//创建map
|
||||||
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
||||||
|
@ -49,7 +51,7 @@ public class DataRangeConfigRunner implements ApplicationRunner {
|
||||||
});
|
});
|
||||||
//遍历添加到hashMap
|
//遍历添加到hashMap
|
||||||
for (DataAccess listResultDatum : listResultData) {
|
for (DataAccess listResultDatum : listResultData) {
|
||||||
if (listResultDatum.getType() == "MySql"){
|
if (listResultDatum.getType().equals("MySql")){
|
||||||
//记录线程池
|
//记录线程池
|
||||||
dataSourceConfig.index(listResultDatum);
|
dataSourceConfig.index(listResultDatum);
|
||||||
}
|
}
|
||||||
|
@ -59,16 +61,19 @@ public class DataRangeConfigRunner implements ApplicationRunner {
|
||||||
dataSourceConfig.verify(dataAccess.getId());
|
dataSourceConfig.verify(dataAccess.getId());
|
||||||
//获取一个线程池
|
//获取一个线程池
|
||||||
Connection connection = dataSourceConfig.getConnection(dataAccess.getId());
|
Connection connection = dataSourceConfig.getConnection(dataAccess.getId());
|
||||||
|
log.info("获取一个线程:{}",connection);
|
||||||
|
dataSourceConfig.verify(dataAccess.getId());
|
||||||
//归还线程池
|
//归还线程池
|
||||||
dataSourceConfig.returnConnection(connection);
|
dataSourceConfig.returnConnection(connection);
|
||||||
|
dataSourceConfig.verify(dataAccess.getId());
|
||||||
//将对象传入Spring
|
//将对象传入Spring
|
||||||
// SpringHashMap(hashMap);
|
//SpringHashMap(hashMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
// @Bean
|
||||||
public HashMap<Long,Unit> SpringHashMap(HashMap<Long,Unit> hashMap) {
|
// public HashMap<Long, DruidDataSource> SpringHashMap(HashMap<Long,DruidDataSource> hashMap) {
|
||||||
return hashMap;
|
// return hashMap;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
com.muyu.efition.clinet.config.AccessConfig
|
com.muyu.efition.clinet.config.AccessConfig
|
||||||
|
com.muyu.efition.clinet.config.DataGoodsConfig
|
||||||
|
com.muyu.efition.clinet.config.DataRangeConfig
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.muyu.edition.domain.vo;
|
||||||
|
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则引擎对象 rule_engine
|
||||||
|
*
|
||||||
|
* @author goods
|
||||||
|
* @date 2024-05-02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RuleEngineVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long ruleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "规则名称")
|
||||||
|
private String ruleName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引擎编码
|
||||||
|
*/
|
||||||
|
@Excel(name = "引擎编码")
|
||||||
|
private String ruleCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则级别
|
||||||
|
*/
|
||||||
|
@Excel(name = "规则级别")
|
||||||
|
private Integer ruleLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则类型
|
||||||
|
*/
|
||||||
|
@Excel(name = "规则类型")
|
||||||
|
private Integer ruleType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否激活
|
||||||
|
*/
|
||||||
|
@Excel(name = "是否激活")
|
||||||
|
private String ruleIsActivate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则状态
|
||||||
|
*/
|
||||||
|
@Excel(name = "规则状态")
|
||||||
|
private String ruleStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则描述
|
||||||
|
*/
|
||||||
|
@Excel(name = "规则描述")
|
||||||
|
private String description;
|
||||||
|
}
|
|
@ -2,12 +2,10 @@ package com.muyu.goods.edition.remote;
|
||||||
|
|
||||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
|
||||||
import com.muyu.edition.domain.RuleEngine;
|
import com.muyu.edition.domain.RuleEngine;
|
||||||
import com.muyu.goods.edition.remote.factory.DataMangFacrory;
|
import com.muyu.goods.edition.remote.factory.DataMangFacrory;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -15,13 +13,12 @@ import java.util.List;
|
||||||
* 远程调用
|
* 远程调用
|
||||||
*/
|
*/
|
||||||
@FeignClient(
|
@FeignClient(
|
||||||
contextId = "RemoteSys",
|
contextId = "engineSel",
|
||||||
value = ServiceNameConstants.EDITION_MUYU,
|
value = ServiceNameConstants.EDITION_MUYU,
|
||||||
fallbackFactory = DataMangFacrory.class,
|
fallbackFactory = DataMangFacrory.class,
|
||||||
path = "/engine"
|
path = "/engine"
|
||||||
)
|
)
|
||||||
public interface RemoteDataManagerService {
|
public interface RemoteDataManagerService {
|
||||||
@GetMapping("/list")
|
@PostMapping("/lists")
|
||||||
public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine);
|
public Result<List<RuleEngine>> list();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class DataMangFacrory implements FallbackFactory<RemoteDataManagerService
|
||||||
public RemoteDataManagerService create(Throwable cause) {
|
public RemoteDataManagerService create(Throwable cause) {
|
||||||
return new RemoteDataManagerService() {
|
return new RemoteDataManagerService() {
|
||||||
@Override
|
@Override
|
||||||
public Result<TableDataInfo<RuleEngine>> list(RuleEngine ruleEngine) {
|
public Result<List<RuleEngine>> list() {
|
||||||
return Result.error(cause.getMessage());
|
return Result.error(cause.getMessage());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,11 +5,13 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableAsync
|
||||||
public class MuYuGoodsEditionApplication {
|
public class MuYuGoodsEditionApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(MuYuGoodsEditionApplication.class, args);
|
SpringApplication.run(MuYuGoodsEditionApplication.class, args);
|
||||||
|
|
|
@ -37,6 +37,11 @@ public class RuleEngineController extends BaseController {
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/lists")
|
||||||
|
public Result<List<RuleEngine>> lists(){
|
||||||
|
return success(ruleEngineService.lists());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出规则引擎列表
|
* 导出规则引擎列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -65,4 +65,6 @@ public interface RuleEngineMapper {
|
||||||
void updateRuleIsActivate(@Param("ruleId") Long ruleId, @Param("ruleIsActivate") String ruleIsActivate);
|
void updateRuleIsActivate(@Param("ruleId") Long ruleId, @Param("ruleIsActivate") String ruleIsActivate);
|
||||||
|
|
||||||
void updateRuleStatus(@Param("ruleId") Long ruleId, @Param("ruleStatus") String ruleStatus);
|
void updateRuleStatus(@Param("ruleId") Long ruleId, @Param("ruleStatus") String ruleStatus);
|
||||||
|
|
||||||
|
List<RuleEngine> lists();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public interface IRuleEngineService {
|
||||||
*/
|
*/
|
||||||
public RuleEngine selectRuleEngineByRuleId(Long ruleId);
|
public RuleEngine selectRuleEngineByRuleId(Long ruleId);
|
||||||
|
|
||||||
|
List<RuleEngine> lists();
|
||||||
/**
|
/**
|
||||||
* 规则详情
|
* 规则详情
|
||||||
*
|
*
|
||||||
|
@ -75,4 +76,5 @@ public interface IRuleEngineService {
|
||||||
void updateRuleStatus(RuleEngine ruleEngine);
|
void updateRuleStatus(RuleEngine ruleEngine);
|
||||||
|
|
||||||
Result spliceNameToCode(String name, String code, Integer level);
|
Result spliceNameToCode(String name, String code, Integer level);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,11 @@ public class RuleEngineServiceImpl implements IRuleEngineService {
|
||||||
return ruleEngineMapper.selectRuleEngineByRuleId(ruleId);
|
return ruleEngineMapper.selectRuleEngineByRuleId(ruleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RuleEngine> lists() {
|
||||||
|
return ruleEngineMapper.lists();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规则引擎详情
|
* 规则引擎详情
|
||||||
*
|
*
|
||||||
|
|
|
@ -49,6 +49,9 @@
|
||||||
from rule_engine
|
from rule_engine
|
||||||
where rule_id = #{ruleId};
|
where rule_id = #{ruleId};
|
||||||
</select>
|
</select>
|
||||||
|
<select id="lists" resultType="com.muyu.edition.domain.RuleEngine">
|
||||||
|
<include refid="selectRuleEngineVo"/>
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertRuleEngine" parameterType="com.muyu.edition.domain.RuleEngine" useGeneratedKeys="true"
|
<insert id="insertRuleEngine" parameterType="com.muyu.edition.domain.RuleEngine" useGeneratedKeys="true"
|
||||||
keyProperty="ruleId">
|
keyProperty="ruleId">
|
||||||
|
|
|
@ -1,124 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>muyu-goods-unit</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu-modules-system</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu-goods-edition</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos Config -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Sentinel -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringBoot Actuator -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Swagger UI -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
|
||||||
<version>${swagger.fox.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Mysql Connector -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common DataSource -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu-common-datasource</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common DataScope -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu-common-datascope</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common Log -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu-common-log</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common Swagger -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>muyu-common-swagger</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skip>true</skip>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.muyu.goods.unit;
|
|
||||||
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
|
||||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试启动类
|
|
||||||
*/
|
|
||||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
|
||||||
@EnableCustomConfig
|
|
||||||
@EnableCustomSwagger2
|
|
||||||
@EnableMyFeignClients
|
|
||||||
@EnableAsync
|
|
||||||
public class MuyuGoodsUnitApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(MuyuGoodsUnitApplication.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 9515
|
|
||||||
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: muyu-test
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: 129.211.23.219:8848
|
|
||||||
config:
|
|
||||||
# 配置中心地址
|
|
||||||
server-addr: 129.211.23.219:8848
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.muyu.edition.mapper: DEBUG
|
|
|
@ -1,74 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
|
||||||
<!-- 日志存放路径 -->
|
|
||||||
<property name="log.path" value="logs/muyu-visual-monitor"/>
|
|
||||||
<!-- 日志输出格式 -->
|
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
|
||||||
|
|
||||||
<!-- 控制台输出 -->
|
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统日志输出 -->
|
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/info.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>INFO</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/error.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>ERROR</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统模块日志级别控制 -->
|
|
||||||
<logger name="com.muyu" level="info"/>
|
|
||||||
<!-- Spring日志级别控制 -->
|
|
||||||
<logger name="org.springframework" level="warn"/>
|
|
||||||
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="console"/>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="file_info"/>
|
|
||||||
<appender-ref ref="file_error"/>
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
|
@ -3,6 +3,7 @@ package com.muyu.system.controller;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
import com.muyu.system.domain.*;
|
import com.muyu.system.domain.*;
|
||||||
|
import com.muyu.system.domain.table.Status;
|
||||||
import com.muyu.system.domain.table.TableShow;
|
import com.muyu.system.domain.table.TableShow;
|
||||||
import com.muyu.system.domain.table.ToTalNum;
|
import com.muyu.system.domain.table.ToTalNum;
|
||||||
import com.muyu.system.domain.vo.DeptVO;
|
import com.muyu.system.domain.vo.DeptVO;
|
||||||
|
@ -188,6 +189,13 @@ public class AccreditController extends BaseController {
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/selStatus")
|
||||||
|
public Result<Status> selStatus(String databaseName, String tableName) {
|
||||||
|
return success(service.selStatus(databaseName,tableName));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门
|
* 获取部门
|
||||||
*
|
*
|
||||||
|
@ -295,5 +303,15 @@ public class AccreditController extends BaseController {
|
||||||
return success(toTalNum);
|
return success(toTalNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看局部
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("selTotal/{name}")
|
||||||
|
public Result<ToTalNum> selTotal(@PathVariable String name) {
|
||||||
|
ToTalNum toTalNum = service.selTotal(name);
|
||||||
|
return success(toTalNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,11 @@ public class DataAccessController extends BaseController {
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/lists")
|
||||||
|
public Result<List<DataAccess>> lists() {
|
||||||
|
return success(dataAccessService.lists());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出数据接入列表
|
* 导出数据接入列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.muyu.system.domain.table;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Status {
|
||||||
|
private String tableName;
|
||||||
|
private String asas;
|
||||||
|
private Integer dataTotal;
|
||||||
|
}
|
|
@ -33,8 +33,6 @@ public interface AccreditMapper {
|
||||||
|
|
||||||
TableList selNameTableList(@Param("databaseName") String databaseName, @Param("name") String name);
|
TableList selNameTableList(@Param("databaseName") String databaseName, @Param("name") String name);
|
||||||
|
|
||||||
List<ListStructure> selNameListStructure(@Param("tableName") String tableName, @Param("databaseName") String databaseName);
|
|
||||||
|
|
||||||
int selectOneTableList(@Param("databaseName") String databaseName, @Param("s") String s);
|
int selectOneTableList(@Param("databaseName") String databaseName, @Param("s") String s);
|
||||||
|
|
||||||
int selectOneSqlJdbc(@Param("databaseName") String databaseName, @Param("s") String s);
|
int selectOneSqlJdbc(@Param("databaseName") String databaseName, @Param("s") String s);
|
||||||
|
|
|
@ -86,4 +86,6 @@ public interface DataAccessMapper {
|
||||||
void deleteTableList(DataAccess dataAccess);
|
void deleteTableList(DataAccess dataAccess);
|
||||||
|
|
||||||
Integer selectAccessMapper(DataAccess dataAccess);
|
Integer selectAccessMapper(DataAccess dataAccess);
|
||||||
|
|
||||||
|
List<DataAccess> lists();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,9 @@ package com.muyu.system.remote;
|
||||||
|
|
||||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
|
||||||
import com.muyu.system.domain.DataAccess;
|
import com.muyu.system.domain.DataAccess;
|
||||||
import com.muyu.system.domain.vo.FrimaryVo;
|
|
||||||
import com.muyu.system.remote.factory.DataMangSystemFactory;
|
import com.muyu.system.remote.factory.DataMangSystemFactory;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -18,12 +14,11 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@FeignClient(
|
@FeignClient(
|
||||||
contextId = "RemoteSys",
|
contextId = "RemoteSys",
|
||||||
value = ServiceNameConstants.SYSTEM_SERVICE,
|
value = ServiceNameConstants.System_MUYU,
|
||||||
fallbackFactory = DataMangSystemFactory.class,
|
fallbackFactory = DataMangSystemFactory.class,
|
||||||
path = "/access"
|
path = "/access"
|
||||||
)
|
)
|
||||||
@Service
|
|
||||||
public interface RemoteSystemManageService {
|
public interface RemoteSystemManageService {
|
||||||
@GetMapping("/list")
|
@PostMapping("/lists")
|
||||||
public Result<TableDataInfo<DataAccess>> list(DataAccess dataAccess);
|
public Result<List<DataAccess>> lists();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,8 @@ public class DataMangSystemFactory implements FallbackFactory<RemoteSystemManage
|
||||||
@Override
|
@Override
|
||||||
public RemoteSystemManageService create(Throwable cause) {
|
public RemoteSystemManageService create(Throwable cause) {
|
||||||
return new RemoteSystemManageService() {
|
return new RemoteSystemManageService() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<TableDataInfo<DataAccess>> list(DataAccess dataAccess) {
|
public Result<List<DataAccess>> lists() {
|
||||||
return Result.error(cause.getMessage());
|
return Result.error(cause.getMessage());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.service;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.system.domain.*;
|
import com.muyu.system.domain.*;
|
||||||
|
import com.muyu.system.domain.table.Status;
|
||||||
import com.muyu.system.domain.table.TableShow;
|
import com.muyu.system.domain.table.TableShow;
|
||||||
import com.muyu.system.domain.table.ToTalNum;
|
import com.muyu.system.domain.table.ToTalNum;
|
||||||
import com.muyu.system.domain.vo.FrimaryVo;
|
import com.muyu.system.domain.vo.FrimaryVo;
|
||||||
|
@ -33,6 +34,7 @@ public interface AccreditService {
|
||||||
|
|
||||||
List<FrimaryVo> selectFrimary();
|
List<FrimaryVo> selectFrimary();
|
||||||
|
|
||||||
|
Status selStatus(String databaseName, String tableName);
|
||||||
List<Middle> listMiddle(String tableName, String databaseName);
|
List<Middle> listMiddle(String tableName, String databaseName);
|
||||||
|
|
||||||
List<Middle> listMiddle2(String databaseName);
|
List<Middle> listMiddle2(String databaseName);
|
||||||
|
@ -50,4 +52,8 @@ public interface AccreditService {
|
||||||
Integer selJDBCStream2(DataAccess dataAccess);
|
Integer selJDBCStream2(DataAccess dataAccess);
|
||||||
|
|
||||||
ToTalNum selTotalNum();
|
ToTalNum selTotalNum();
|
||||||
|
|
||||||
|
ToTalNum selTotal(String name);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public interface IDataAccessService {
|
||||||
* @return 数据接入集合
|
* @return 数据接入集合
|
||||||
*/
|
*/
|
||||||
public List<DataAccess> selectDataAccessList(DataAccess dataAccess);
|
public List<DataAccess> selectDataAccessList(DataAccess dataAccess);
|
||||||
|
List<DataAccess> lists();
|
||||||
/**
|
/**
|
||||||
* 新增数据接入
|
* 新增数据接入
|
||||||
*
|
*
|
||||||
|
@ -65,4 +65,5 @@ public interface IDataAccessService {
|
||||||
Integer synchronization(DataAccess dataAccess) throws Exception;
|
Integer synchronization(DataAccess dataAccess) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.service.impl;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.system.domain.*;
|
import com.muyu.system.domain.*;
|
||||||
|
import com.muyu.system.domain.table.Status;
|
||||||
import com.muyu.system.domain.table.TableShow;
|
import com.muyu.system.domain.table.TableShow;
|
||||||
import com.muyu.system.domain.table.ToTalNum;
|
import com.muyu.system.domain.table.ToTalNum;
|
||||||
import com.muyu.system.domain.vo.FrimaryVo;
|
import com.muyu.system.domain.vo.FrimaryVo;
|
||||||
|
@ -17,6 +18,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AccreditServiceImpl implements AccreditService {
|
public class AccreditServiceImpl implements AccreditService {
|
||||||
|
@ -118,7 +120,8 @@ public class AccreditServiceImpl implements AccreditService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ListStructure> selNameListStructure(String tableName, String databaseName) {
|
public List<ListStructure> selNameListStructure(String tableName, String databaseName) {
|
||||||
return mapper.selNameListStructure(tableName, databaseName);
|
List<ListStructure> collect = listListstructure().stream().filter(a -> a.getCatalogName().equals(databaseName)).filter(b -> b.getTableName().equals(tableName)).collect(Collectors.toList());
|
||||||
|
return collect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,55 +159,6 @@ public class AccreditServiceImpl implements AccreditService {
|
||||||
public Integer selJDBCStream2(DataAccess dataAccess) {
|
public Integer selJDBCStream2(DataAccess dataAccess) {
|
||||||
Integer id = 0;
|
Integer id = 0;
|
||||||
List<String> stringList = new ArrayList<>();
|
List<String> stringList = new ArrayList<>();
|
||||||
// 连接数据
|
|
||||||
// try {
|
|
||||||
// Class<?> aClass = Class.forName("com.mysql.cj.jdbc.Driver");
|
|
||||||
// Driver driver = (Driver) aClass.newInstance();
|
|
||||||
//// //获取数据库连接
|
|
||||||
// Connection connection = DriverManager.getConnection("jdbc:mysql://" + dataAccess.getHost() + ":" + dataAccess.getPort() + "/" + dataAccess.getDatabaseName() + "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8", dataAccess.getUsername(), dataAccess.getPassword());
|
|
||||||
//// //获取数据库名
|
|
||||||
//// //获取数据库的元数据
|
|
||||||
// DatabaseMetaData metaData = connection.getMetaData();
|
|
||||||
// //获取全部表名
|
|
||||||
// Statement statement = connection.createStatement();
|
|
||||||
// ResultSet rst = statement.executeQuery("select TABLE_NAME from INFORMATION_SCHEMA.Tables where table_schema = '" + dataAccess.getDatabaseName() + "'");
|
|
||||||
// mapper.deleteTableShow(dataAccess.getName());
|
|
||||||
// while (rst.next()) {
|
|
||||||
// stringList.add(rst.getString(1));
|
|
||||||
// }
|
|
||||||
// for (String s : stringList) {
|
|
||||||
// // 执行查询
|
|
||||||
// ResultSet rs = statement.executeQuery("select * from " + s);
|
|
||||||
// PreparedStatement pst = connection.prepareCall("select * from " + s);
|
|
||||||
// ResultSetMetaData rsd = pst.getMetaData();
|
|
||||||
// // 获取查询的结果集
|
|
||||||
// ResultSetMetaData md = rs.getMetaData();
|
|
||||||
// System.out.println(md);
|
|
||||||
// int columnCount = md.getColumnCount();
|
|
||||||
// System.out.println(columnCount);
|
|
||||||
// //获取结果集的元数据
|
|
||||||
// //遍历结果集
|
|
||||||
// while (rs.next()) {
|
|
||||||
// for (int i = 1; i <= columnCount; i++) {
|
|
||||||
// //获取列名
|
|
||||||
// String fields = md.getColumnName(i);
|
|
||||||
// System.out.println(fields);
|
|
||||||
// //获取表名
|
|
||||||
// String tableName = md.getTableName(i);
|
|
||||||
// System.out.println(tableName);
|
|
||||||
// //获取字段值
|
|
||||||
// Object val = rs.getObject(i);
|
|
||||||
// System.out.println(val);
|
|
||||||
// //获取java映射字段类型
|
|
||||||
// String columnClassName = md.getColumnClassName(i);
|
|
||||||
// mapper.indexTableShow(dataAccess.getName() + "." + tableName + "." + fields, columnClassName, val.toString());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// id =1;
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// id = 0;
|
|
||||||
// }
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +173,20 @@ public class AccreditServiceImpl implements AccreditService {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Status selStatus(String databaseName, String tableName) {
|
||||||
|
List<FrimaryVo> collect = selectFrimary().stream().filter(a -> a.getDatabaseName().equals(databaseName)).collect(Collectors.toList());
|
||||||
|
FrimaryVo frimaryVo = collect.get(0);
|
||||||
|
List<TableList> tableLists = frimaryVo.getTableLists().stream().filter(b -> b.getTableName().equals(tableName)).collect(Collectors.toList());
|
||||||
|
TableList tableList = tableLists.get(0);
|
||||||
|
Status build = Status.builder()
|
||||||
|
.asas(tableList.getAsas())
|
||||||
|
.tableName(tableList.getTableName())
|
||||||
|
.dataTotal(tableList.getDataTotal())
|
||||||
|
.build();
|
||||||
|
return build;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Middle> listMiddle(String tableName, String databaseName) {
|
public List<Middle> listMiddle(String tableName, String databaseName) {
|
||||||
return mapper.listMiddle(tableName, databaseName);
|
return mapper.listMiddle(tableName, databaseName);
|
||||||
|
@ -271,6 +239,21 @@ public class AccreditServiceImpl implements AccreditService {
|
||||||
return toTalNum;
|
return toTalNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ToTalNum selTotal(String name) {
|
||||||
|
System.out.println(name);
|
||||||
|
ToTalNum toTalNum = new ToTalNum();
|
||||||
|
System.out.println(selectFrimary());
|
||||||
|
List<FrimaryVo> collect = selectFrimary().stream().filter(c -> c.getDatabaseName().equals(name)).collect(Collectors.toList());
|
||||||
|
System.out.println(collect);
|
||||||
|
FrimaryVo frimaryVo = collect.get(0);
|
||||||
|
toTalNum.setSwitchOns(1);
|
||||||
|
toTalNum.setAssetsNum(frimaryVo.getTableNameNum());
|
||||||
|
toTalNum.setFieldsNum(frimaryVo.getDataTotal());
|
||||||
|
System.out.println(toTalNum);
|
||||||
|
return toTalNum;
|
||||||
|
}
|
||||||
|
|
||||||
//获取字段注解
|
//获取字段注解
|
||||||
private Map<String, String> getColumnComments(DatabaseMetaData metaData, String typeName) {
|
private Map<String, String> getColumnComments(DatabaseMetaData metaData, String typeName) {
|
||||||
Map<String, String> columnComents = new HashMap<>();
|
Map<String, String> columnComents = new HashMap<>();
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.muyu.system.mapper.SysDeptMapper;
|
||||||
import com.muyu.system.mapper.SysUserMapper;
|
import com.muyu.system.mapper.SysUserMapper;
|
||||||
import com.muyu.system.service.AccreditService;
|
import com.muyu.system.service.AccreditService;
|
||||||
import com.muyu.system.service.IDataAccessService;
|
import com.muyu.system.service.IDataAccessService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
* @date 2024-04-21
|
* @date 2024-04-21
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Log4j2
|
||||||
public class DataAccessServiceImpl implements IDataAccessService {
|
public class DataAccessServiceImpl implements IDataAccessService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataAccessMapper dataAccessMapper;
|
private DataAccessMapper dataAccessMapper;
|
||||||
|
@ -66,6 +68,11 @@ public class DataAccessServiceImpl implements IDataAccessService {
|
||||||
return dataAccessMapper.selectDataAccessList(dataAccess);
|
return dataAccessMapper.selectDataAccessList(dataAccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DataAccess> lists() {
|
||||||
|
return dataAccessMapper.lists();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增数据接入
|
* 新增数据接入
|
||||||
*
|
*
|
||||||
|
@ -125,18 +132,7 @@ public class DataAccessServiceImpl implements IDataAccessService {
|
||||||
public Integer synchronization(DataAccess dataAccess) throws Exception {
|
public Integer synchronization(DataAccess dataAccess) throws Exception {
|
||||||
Integer id = 0;
|
Integer id = 0;
|
||||||
List<String> stringList = new ArrayList<>();
|
List<String> stringList = new ArrayList<>();
|
||||||
// 连接数据
|
|
||||||
// Class<?> aClass = Class.forName("com.mysql.cj.jdbc.Driver");
|
|
||||||
// Driver driver = (Driver) aClass.newInstance();
|
|
||||||
//// //获取数据库连接
|
|
||||||
// Connection connection = DriverManager.getConnection("jdbc:mysql://" + dataAccess.getHost() + ":"+ dataAccess.getPort() +"/"+ dataAccess.getDatabaseName() +"?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8",dataAccess.getUsername(),dataAccess.getPassword());
|
|
||||||
//// //获取数据库名
|
|
||||||
//// //获取数据库的元数据
|
|
||||||
// DatabaseMetaData metaData = connection.getMetaData();
|
|
||||||
// //获取全部表名
|
|
||||||
// Statement statement = connection.createStatement();
|
|
||||||
//开启多线程池
|
//开启多线程池
|
||||||
// ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 50, 10, TimeUnit.MINUTES, new LinkedBlockingDeque<>(10));
|
|
||||||
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(Integer.valueOf(dataAccess.getInitNum().toString()), Integer.valueOf(dataAccess.getMaxNum().toString()), Integer.valueOf(dataAccess.getMaxWaitTime().toString()), TimeUnit.SECONDS, new LinkedBlockingDeque<>(Integer.valueOf(dataAccess.getMaxWaitSize().toString())));
|
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(Integer.valueOf(dataAccess.getInitNum().toString()), Integer.valueOf(dataAccess.getMaxNum().toString()), Integer.valueOf(dataAccess.getMaxWaitTime().toString()), TimeUnit.SECONDS, new LinkedBlockingDeque<>(Integer.valueOf(dataAccess.getMaxWaitSize().toString())));
|
||||||
|
|
||||||
//第一个 树形表
|
//第一个 树形表
|
||||||
|
@ -153,7 +149,7 @@ public class DataAccessServiceImpl implements IDataAccessService {
|
||||||
Class<?> aClass = Class.forName("com.mysql.cj.jdbc.Driver");
|
Class<?> aClass = Class.forName("com.mysql.cj.jdbc.Driver");
|
||||||
Driver driver = (Driver) aClass.newInstance();
|
Driver driver = (Driver) aClass.newInstance();
|
||||||
// //获取数据库连接
|
// //获取数据库连接
|
||||||
Connection connection = DriverManager.getConnection("jdbc:mysql://" + dataAccess.getHost() + ":" + dataAccess.getPort() + "/" + dataAccess.getDatabaseName() + "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8", dataAccess.getUsername(), dataAccess.getPassword());
|
Connection connection = DriverManager.getConnection("jdbc:mysql://" + dataAccess.getHost() + ":" + dataAccess.getPort() + "/" + dataAccess.getDatabaseName(), dataAccess.getUsername(), dataAccess.getPassword());
|
||||||
// //获取数据库名
|
// //获取数据库名
|
||||||
// //获取数据库的元数据
|
// //获取数据库的元数据
|
||||||
DatabaseMetaData metaData = connection.getMetaData();
|
DatabaseMetaData metaData = connection.getMetaData();
|
||||||
|
@ -264,34 +260,33 @@ public class DataAccessServiceImpl implements IDataAccessService {
|
||||||
Map<String, String> columnComments = getColumnComments(metaData, s);
|
Map<String, String> columnComments = getColumnComments(metaData, s);
|
||||||
//添加数据结构
|
//添加数据结构
|
||||||
for (int i = 0; i < rsd.getColumnCount(); i++) {
|
for (int i = 0; i < rsd.getColumnCount(); i++) {
|
||||||
System.out.println("java类型" + rsd.getColumnClassName(i + 1));
|
// System.out.println("java类型" + rsd.getColumnClassName(i + 1));
|
||||||
System.out.println("数据库类型" + rsd.getColumnTypeName(i + 1));
|
// System.out.println("数据库类型" + rsd.getColumnTypeName(i + 1));
|
||||||
System.out.println("字段名称" + rsd.getColumnName(i + 1));
|
// System.out.println("字段名称" + rsd.getColumnName(i + 1));
|
||||||
System.out.println("表名" + rsd.getTableName(i + 1));
|
// System.out.println("表名" + rsd.getTableName(i + 1));
|
||||||
System.out.println("数据库名" + rsd.getCatalogName(i + 1));
|
// System.out.println("数据库名" + rsd.getCatalogName(i + 1));
|
||||||
System.out.println("模式名" + rsd.getSchemaName(i + 1));
|
// System.out.println("模式名" + rsd.getSchemaName(i + 1));
|
||||||
System.out.println("列数" + rsd.getColumnCount());
|
// System.out.println("列数" + rsd.getColumnCount());
|
||||||
System.out.println("列类型" + rsd.getColumnType(i + 1));
|
// System.out.println("列类型" + rsd.getColumnType(i + 1));
|
||||||
System.out.println("列标签" + rsd.getColumnLabel(i + 1));
|
// System.out.println("列标签" + rsd.getColumnLabel(i + 1));
|
||||||
System.out.println("列显示大小" + rsd.getColumnDisplaySize(i + 1));
|
// System.out.println("列显示大小" + rsd.getColumnDisplaySize(i + 1));
|
||||||
System.out.println("精度" + rsd.getPrecision(i + 1));
|
// System.out.println("精度" + rsd.getPrecision(i + 1));
|
||||||
System.out.println("规模" + rsd.getScale(i + 1));
|
// System.out.println("规模" + rsd.getScale(i + 1));
|
||||||
System.out.println("自增" + rsd.isAutoIncrement(i + 1));
|
// System.out.println("自增" + rsd.isAutoIncrement(i + 1));
|
||||||
System.out.println("是否为空" + rsd.isNullable(i + 1));
|
// System.out.println("是否为空" + rsd.isNullable(i + 1));
|
||||||
System.out.println("区分大小写" + rsd.isCaseSensitive(i + 1));
|
// System.out.println("区分大小写" + rsd.isCaseSensitive(i + 1));
|
||||||
System.out.println("是否是货币" + rsd.isCurrency(i + 1));
|
// System.out.println("是否是货币" + rsd.isCurrency(i + 1));
|
||||||
System.out.println("可搜索" + rsd.isSearchable(i + 1));
|
// System.out.println("可搜索" + rsd.isSearchable(i + 1));
|
||||||
System.out.println("签署" + rsd.isSigned(i + 1));
|
// System.out.println("签署" + rsd.isSigned(i + 1));
|
||||||
System.out.println("绝对可以写" + rsd.isDefinitelyWritable(i + 1));
|
// System.out.println("绝对可以写" + rsd.isDefinitelyWritable(i + 1));
|
||||||
System.out.println("只读" + rsd.isReadOnly(i + 1));
|
// System.out.println("只读" + rsd.isReadOnly(i + 1));
|
||||||
System.out.println("是可写的" + rsd.isWritable(i + 1));
|
// System.out.println("是可写的" + rsd.isWritable(i + 1));
|
||||||
System.out.println("注解" + columnComments.get(rsd.getColumnName(i + 1)));
|
// System.out.println("注解" + columnComments.get(rsd.getColumnName(i + 1)));
|
||||||
ListStructure listStructure = new ListStructure();
|
ListStructure listStructure = new ListStructure();
|
||||||
//获取数据库名
|
//获取数据库名
|
||||||
listStructure.setCatalogName(rsd.getCatalogName(i + 1));
|
listStructure.setCatalogName(rsd.getCatalogName(i + 1));
|
||||||
//获取表名
|
//获取表名
|
||||||
listStructure.setTableName(rsd.getTableName(i + 1));
|
listStructure.setTableName(rsd.getTableName(i + 1));
|
||||||
|
|
||||||
//获取映射类型
|
//获取映射类型
|
||||||
listStructure.setColumnTypeName(rsd.getColumnTypeName(i + 1));
|
listStructure.setColumnTypeName(rsd.getColumnTypeName(i + 1));
|
||||||
//获取字段名称
|
//获取字段名称
|
||||||
|
@ -315,26 +310,25 @@ public class DataAccessServiceImpl implements IDataAccessService {
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}, threadPoolExecutor);
|
}, threadPoolExecutor);
|
||||||
|
// 第四个
|
||||||
CompletableFuture<Integer> completable4 = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Integer> completable4 = CompletableFuture.supplyAsync(() -> {
|
||||||
// 连接数据
|
// 连接数据
|
||||||
try {
|
try {
|
||||||
// //获取数据库连接
|
//获取数据库连接
|
||||||
Connection connection = DriverManager.getConnection("jdbc:mysql://" + dataAccess.getHost() + ":" + dataAccess.getPort() + "/" + dataAccess.getDatabaseName() + "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8", dataAccess.getUsername(), dataAccess.getPassword());
|
Connection connection = DriverManager.getConnection("jdbc:mysql://" + dataAccess.getHost() + ":" + dataAccess.getPort() + "/" + dataAccess.getDatabaseName() + "?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8", dataAccess.getUsername(), dataAccess.getPassword());
|
||||||
// //获取数据库名
|
//获取数据库名
|
||||||
// //获取数据库的元数据
|
//获取数据库的元数据
|
||||||
DatabaseMetaData metaData = connection.getMetaData();
|
DatabaseMetaData metaData = connection.getMetaData();
|
||||||
//获取全部表名
|
//获取全部表名
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
ResultSet rst = statement.executeQuery("select TABLE_NAME from INFORMATION_SCHEMA.Tables where table_schema = '" + dataAccess.getDatabaseName() + "'");
|
ResultSet rst = statement.executeQuery("select TABLE_NAME from INFORMATION_SCHEMA.Tables where table_schema = '" + dataAccess.getDatabaseName() + "'");
|
||||||
accreditMapper.deleteTableShow(dataAccess.getName());
|
accreditMapper.deleteTableShow(dataAccess.getName()+"."+dataAccess.getDatabaseName());
|
||||||
//所有表名
|
//所有表名
|
||||||
ArrayList<String> strings = new ArrayList<>();
|
ArrayList<String> strings = new ArrayList<>();
|
||||||
while (rst.next()) {
|
while (rst.next()) {
|
||||||
strings.add(rst.getString(1));
|
strings.add(rst.getString(1));
|
||||||
System.out.println(rst.getString(1));
|
System.out.println(rst.getString(1));
|
||||||
}
|
}
|
||||||
System.out.println(strings);
|
|
||||||
for (String string : strings) {
|
for (String string : strings) {
|
||||||
// 执行查询
|
// 执行查询
|
||||||
ResultSet rs = statement.executeQuery("select * from " + string);
|
ResultSet rs = statement.executeQuery("select * from " + string);
|
||||||
|
@ -355,15 +349,21 @@ public class DataAccessServiceImpl implements IDataAccessService {
|
||||||
String tableName = md.getTableName(i);
|
String tableName = md.getTableName(i);
|
||||||
System.out.println(tableName);
|
System.out.println(tableName);
|
||||||
//字段值
|
//字段值
|
||||||
Object val = rs.getObject(i);
|
Object val = null;
|
||||||
|
if (rs.getObject(i) == null){
|
||||||
|
val = "null";
|
||||||
|
}else{
|
||||||
|
val = rs.getObject(i);
|
||||||
|
}
|
||||||
System.out.println(val);
|
System.out.println(val);
|
||||||
//字段类型
|
//字段类型
|
||||||
String columnClassName = md.getColumnClassName(i);
|
String columnClassName = md.getColumnClassName(i);
|
||||||
accreditMapper.indexTableShow(dataAccess.getName() + "." + tableName + "." + columnName, columnClassName, val.toString());
|
accreditMapper.indexTableShow(dataAccess.getName() + "."+dataAccess.getDatabaseName() + "." + tableName + "." + columnName, columnClassName, val.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -376,6 +376,7 @@ public class DataAccessServiceImpl implements IDataAccessService {
|
||||||
if (completable1.join() + completable2.join() + completable3.join() + completable4.join() == 4) {
|
if (completable1.join() + completable2.join() + completable3.join() + completable4.join() == 4) {
|
||||||
id = 1;
|
id = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
id = 0;
|
id = 0;
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
com.muyu.system.remote.factory.DataMangSystemFactory
|
|
@ -91,12 +91,6 @@
|
||||||
where name = #{name}
|
where name = #{name}
|
||||||
and database_name = #{databaseName}
|
and database_name = #{databaseName}
|
||||||
</select>
|
</select>
|
||||||
<select id="selNameListStructure" resultType="com.muyu.system.domain.ListStructure">
|
|
||||||
select *
|
|
||||||
from list_structure
|
|
||||||
where table_name = #{tableName}
|
|
||||||
and catalog_name = #{databaseName}
|
|
||||||
</select>
|
|
||||||
<select id="selectOneTableList" resultType="java.lang.Integer">
|
<select id="selectOneTableList" resultType="java.lang.Integer">
|
||||||
select count(name)
|
select count(name)
|
||||||
from tableList
|
from tableList
|
||||||
|
|
|
@ -91,6 +91,9 @@
|
||||||
from tableList
|
from tableList
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="lists" resultType="com.muyu.system.domain.DataAccess">
|
||||||
|
<include refid="selectDataAccessVo"/>
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertDataAccess" parameterType="com.muyu.system.domain.DataAccess" useGeneratedKeys="true"
|
<insert id="insertDataAccess" parameterType="com.muyu.system.domain.DataAccess" useGeneratedKeys="true"
|
||||||
keyProperty="id">
|
keyProperty="id">
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -218,6 +218,7 @@
|
||||||
<module>muyu-modules/muyu-goods-edition</module>
|
<module>muyu-modules/muyu-goods-edition</module>
|
||||||
<module>muyu-modules/muyu-data-test</module>
|
<module>muyu-modules/muyu-data-test</module>
|
||||||
<module>muyu-modules/muyu-data-ranges</module>
|
<module>muyu-modules/muyu-data-ranges</module>
|
||||||
|
<module>muyu-modules/muyu-data-range</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue