fase()链路追踪
parent
f49fd448e5
commit
596dd3544f
|
@ -9,7 +9,6 @@ import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规则引擎客户端配置类
|
* 规则引擎客户端配置类
|
||||||
|
@ -18,7 +17,7 @@ import java.util.List;
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
@Import(value = AccessConfigRunner.class)
|
@Import(value = AccessConfigRunner.class)
|
||||||
public class AccessConfig {
|
public class AccessConfig {
|
||||||
public List<DataModel> getRabdomData(Long id, String tableName,Integer ruleLevel) {
|
public List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) {
|
||||||
List<List<DataModel>> listList = new ArrayList<>();
|
List<List<DataModel>> listList = new ArrayList<>();
|
||||||
Connection connection = DataSourceConfig.getConnection(id);
|
Connection connection = DataSourceConfig.getConnection(id);
|
||||||
String sql = "select * from " + tableName;
|
String sql = "select * from " + tableName;
|
||||||
|
@ -27,27 +26,27 @@ public class AccessConfig {
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
ResultSet resultSet = statement.executeQuery(sql);
|
ResultSet resultSet = statement.executeQuery(sql);
|
||||||
PreparedStatement pst = connection.prepareStatement("select * from " + tableName);
|
PreparedStatement pst = connection.prepareStatement("select * from " + tableName);
|
||||||
log.info("元数据1:{}",resultSet);
|
log.info("元数据1:{}", resultSet);
|
||||||
// ResultSet resultSet1 = pst.executeQuery();
|
// ResultSet resultSet1 = pst.executeQuery();
|
||||||
//元数据信息
|
//元数据信息
|
||||||
ResultSetMetaData metaData = pst.getMetaData();
|
ResultSetMetaData metaData = pst.getMetaData();
|
||||||
//元数据数量
|
//元数据数量
|
||||||
int columnCount = metaData.getColumnCount();
|
int columnCount = metaData.getColumnCount();
|
||||||
while (resultSet.next()){
|
while (resultSet.next()) {
|
||||||
List<DataModel> list = new ArrayList<>();
|
List<DataModel> list = new ArrayList<>();
|
||||||
for (int i = 1; i <= columnCount; i++) {
|
for (int i = 1; i <= columnCount; i++) {
|
||||||
String columnName = metaData.getColumnName(i);
|
String columnName = metaData.getColumnName(i);
|
||||||
log.info("字段名:{}",columnName);
|
log.info("字段名:{}", columnName);
|
||||||
String tableName1 = metaData.getTableName(i);
|
String tableName1 = metaData.getTableName(i);
|
||||||
log.info("表名:{}",tableName1);
|
log.info("表名:{}", tableName1);
|
||||||
String columnClassName = metaData.getColumnClassName(i);
|
String columnClassName = metaData.getColumnClassName(i);
|
||||||
log.info("java类型:{}",columnClassName);
|
log.info("java类型:{}", columnClassName);
|
||||||
String columnTypeName = metaData.getColumnTypeName(i);
|
String columnTypeName = metaData.getColumnTypeName(i);
|
||||||
log.info("原类型:{}",columnTypeName);
|
log.info("原类型:{}", columnTypeName);
|
||||||
String catalogName = metaData.getCatalogName(i);
|
String catalogName = metaData.getCatalogName(i);
|
||||||
log.info("数据库名:{}",catalogName);
|
log.info("数据库名:{}", catalogName);
|
||||||
Object object = resultSet.getObject(i);
|
Object object = resultSet.getObject(i);
|
||||||
log.info("字段值:{}",object);
|
log.info("字段值:{}", object);
|
||||||
DataModel build = DataModel.builder()
|
DataModel build = DataModel.builder()
|
||||||
.key(columnName)
|
.key(columnName)
|
||||||
.val(object)
|
.val(object)
|
||||||
|
@ -55,19 +54,19 @@ public class AccessConfig {
|
||||||
.processType(columnClassName)
|
.processType(columnClassName)
|
||||||
.processClass(Class.forName(columnClassName))
|
.processClass(Class.forName(columnClassName))
|
||||||
.build();
|
.build();
|
||||||
log.info("测试内容:{}",build);
|
log.info("测试内容:{}", build);
|
||||||
list.add(build);
|
list.add(build);
|
||||||
}
|
}
|
||||||
listList.add(list);
|
listList.add(list);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
log.info("长度:{}",listList.size());
|
log.info("长度:{}", listList.size());
|
||||||
log.info("列表:{}",listList);
|
log.info("列表:{}", listList);
|
||||||
if (listList.size() == 0){
|
if (listList.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (List<DataModel> list : listList) {
|
for (List<DataModel> list : listList) {
|
||||||
|
@ -87,12 +86,12 @@ public class AccessConfig {
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
ResultSet resultSet = statement.executeQuery(sql);
|
ResultSet resultSet = statement.executeQuery(sql);
|
||||||
PreparedStatement pst = connection.prepareStatement("select * from " + tableName);
|
PreparedStatement pst = connection.prepareStatement("select * from " + tableName);
|
||||||
log.info("元数据1:{}",resultSet);
|
log.info("元数据1:{}", resultSet);
|
||||||
//元数据信息
|
//元数据信息
|
||||||
ResultSetMetaData metaData = pst.getMetaData();
|
ResultSetMetaData metaData = pst.getMetaData();
|
||||||
//元数据数量
|
//元数据数量
|
||||||
int columnCount = metaData.getColumnCount();
|
int columnCount = metaData.getColumnCount();
|
||||||
while (resultSet.next()){
|
while (resultSet.next()) {
|
||||||
List<DataModel> list = new ArrayList<>();
|
List<DataModel> list = new ArrayList<>();
|
||||||
for (int i = 1; i <= columnCount; i++) {
|
for (int i = 1; i <= columnCount; i++) {
|
||||||
String columnName = metaData.getColumnName(i);
|
String columnName = metaData.getColumnName(i);
|
||||||
|
@ -118,6 +117,7 @@ public class AccessConfig {
|
||||||
}
|
}
|
||||||
return listList;
|
return listList;
|
||||||
}
|
}
|
||||||
|
|
||||||
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<>();
|
||||||
try (ResultSet colums = metaData.getColumns(null, null, typeName, null)) {
|
try (ResultSet colums = metaData.getColumns(null, null, typeName, null)) {
|
||||||
|
|
|
@ -2,12 +2,8 @@ package muyu.data.test.clinet.config;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.exception.ServiceException;
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
import com.muyu.edition.constant.RuleOperationConstants;
|
|
||||||
import com.muyu.edition.domain.Config;
|
|
||||||
import com.muyu.edition.domain.Edition;
|
import com.muyu.edition.domain.Edition;
|
||||||
import com.muyu.edition.domain.RuleEngine;
|
|
||||||
import com.muyu.goods.edition.remote.EditionDataRemoteService;
|
import com.muyu.goods.edition.remote.EditionDataRemoteService;
|
||||||
import com.muyu.goods.edition.remote.RemoteDataManagerService;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import muyu.data.test.clinet.config.runner.DataEditionConfigRunner;
|
import muyu.data.test.clinet.config.runner.DataEditionConfigRunner;
|
||||||
import muyu.data.test.common.context.DataModelContextHolder;
|
import muyu.data.test.common.context.DataModelContextHolder;
|
||||||
|
@ -37,8 +33,9 @@ import java.util.stream.Collectors;
|
||||||
public class DataEditionConfig {
|
public class DataEditionConfig {
|
||||||
@Autowired
|
@Autowired
|
||||||
private EditionDataRemoteService editionDataRemoteService;
|
private EditionDataRemoteService editionDataRemoteService;
|
||||||
|
|
||||||
public Object setColumn(TestDataModelReq testDataModelReq) {
|
public Object setColumn(TestDataModelReq testDataModelReq) {
|
||||||
switch (testDataModelReq.getRuleLevel()){
|
switch (testDataModelReq.getRuleLevel()) {
|
||||||
case 2:
|
case 2:
|
||||||
//先获取一个记录列
|
//先获取一个记录列
|
||||||
List<RecordModel> dataModels = new ArrayList<>();
|
List<RecordModel> dataModels = new ArrayList<>();
|
||||||
|
@ -90,7 +87,7 @@ public class DataEditionConfig {
|
||||||
mainMethod.invoke(o);
|
mainMethod.invoke(o);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ServiceException("异常"+e.getMessage());
|
throw new ServiceException("异常" + e.getMessage());
|
||||||
}
|
}
|
||||||
return "正常,无需返回";
|
return "正常,无需返回";
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.springframework.boot.ApplicationRunner;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -31,7 +30,7 @@ public class AccessConfigRunner implements ApplicationRunner {
|
||||||
Result<List<DataAccess>> lists = remoteSystemManageService.lists();
|
Result<List<DataAccess>> lists = remoteSystemManageService.lists();
|
||||||
// log.info("数据源调用状态:{}",lists);
|
// log.info("数据源调用状态:{}",lists);
|
||||||
//判断非空
|
//判断非空
|
||||||
if (lists.getData() == null || lists.getData().isEmpty()){
|
if (lists.getData() == null || lists.getData().isEmpty()) {
|
||||||
log.error("数据为空");
|
log.error("数据为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -43,11 +42,11 @@ public class AccessConfigRunner implements ApplicationRunner {
|
||||||
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
|
||||||
//遍历循环存入map
|
//遍历循环存入map
|
||||||
listResultData.forEach(res -> {
|
listResultData.forEach(res -> {
|
||||||
frimaryVoHashMap.put(res.getId(),res);
|
frimaryVoHashMap.put(res.getId(), res);
|
||||||
});
|
});
|
||||||
//遍历添加到hashMap
|
//遍历添加到hashMap
|
||||||
for (DataAccess listResultDatum : listResultData) {
|
for (DataAccess listResultDatum : listResultData) {
|
||||||
if (listResultDatum.getType().equals("MySql")){
|
if (listResultDatum.getType().equals("MySql")) {
|
||||||
//记录线程池
|
//记录线程池
|
||||||
DataSourceConfig.index(listResultDatum);
|
DataSourceConfig.index(listResultDatum);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +54,4 @@ public class AccessConfigRunner implements ApplicationRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.stream.Collectors;
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Component
|
@Component
|
||||||
@Configuration
|
@Configuration
|
||||||
public class DataEditionConfigRunner implements ApplicationRunner , ApplicationContextAware {
|
public class DataEditionConfigRunner implements ApplicationRunner, ApplicationContextAware {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteDataManagerService remoteDataManagerService;
|
private RemoteDataManagerService remoteDataManagerService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -32,6 +32,7 @@ public class DataEditionConfigRunner implements ApplicationRunner , ApplicationC
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据环境变量来决定是否执行
|
* 根据环境变量来决定是否执行
|
||||||
|
*
|
||||||
* @param applicationContext the ApplicationContext object to be used by this object
|
* @param applicationContext the ApplicationContext object to be used by this object
|
||||||
* @throws BeansException
|
* @throws BeansException
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +40,7 @@ public class DataEditionConfigRunner implements ApplicationRunner , ApplicationC
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
System.out.println("1");
|
System.out.println("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
//获取引擎
|
//获取引擎
|
||||||
|
@ -55,7 +57,7 @@ public class DataEditionConfigRunner implements ApplicationRunner , ApplicationC
|
||||||
List<Edition> editions = editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList());
|
List<Edition> editions = editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList());
|
||||||
EditionSoutceConfig.indexByte(editions);
|
EditionSoutceConfig.indexByte(editions);
|
||||||
for (Edition edition : editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList())) {
|
for (Edition edition : editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList())) {
|
||||||
EditionSoutceConfig.index(listResultDatum.getRuleId(),edition);
|
EditionSoutceConfig.index(listResultDatum.getRuleId(), edition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Long ruleId = listResultData.get(0).getRuleId();
|
Long ruleId = listResultData.get(0).getRuleId();
|
||||||
|
@ -65,8 +67,8 @@ public class DataEditionConfigRunner implements ApplicationRunner , ApplicationC
|
||||||
|
|
||||||
HashMap<Long, Map<String, byte[]>> even = EditionSoutceConfig.even();
|
HashMap<Long, Map<String, byte[]>> even = EditionSoutceConfig.even();
|
||||||
Map<String, byte[]> aByte = EditionSoutceConfig.getByte(id);
|
Map<String, byte[]> aByte = EditionSoutceConfig.getByte(id);
|
||||||
log.info("总表:{}",even);
|
log.info("总表:{}", even);
|
||||||
log.info("第一个:{}",aByte);
|
log.info("第一个:{}", aByte);
|
||||||
String versionClass = editionList.get(0).getVersionClass();
|
String versionClass = editionList.get(0).getVersionClass();
|
||||||
byte[] bytes = aByte.get(versionClass);
|
byte[] bytes = aByte.get(versionClass);
|
||||||
String s = new String(bytes);
|
String s = new String(bytes);
|
||||||
|
|
|
@ -7,18 +7,19 @@ import muyu.data.test.common.model.process.DataModelProcessModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型上下文
|
* 数据模型上下文
|
||||||
|
*
|
||||||
* @ClassName DataModelContextHolder
|
* @ClassName DataModelContextHolder
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class DataModelContextHolder{
|
public class DataModelContextHolder {
|
||||||
|
|
||||||
private static final ThreadLocal<DataModelProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
private static final ThreadLocal<DataModelProcessModel> THREAD_LOCAL = new ThreadLocal<>();
|
||||||
|
|
||||||
private RecordContextHolder recordContextHolder;
|
private RecordContextHolder recordContextHolder;
|
||||||
|
|
||||||
public static DataModelContextHolder build(RecordContextHolder recordContextHolder){
|
public static DataModelContextHolder build(RecordContextHolder recordContextHolder) {
|
||||||
return DataModelContextHolder.builder()
|
return DataModelContextHolder.builder()
|
||||||
.recordContextHolder(recordContextHolder)
|
.recordContextHolder(recordContextHolder)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -6,18 +6,19 @@ import muyu.data.test.common.model.process.DataSetProcessModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据集上下文
|
* 数据集上下文
|
||||||
|
*
|
||||||
* @ClassName DataSetContextHolder
|
* @ClassName DataSetContextHolder
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class DataSetContextHolder{
|
public class DataSetContextHolder {
|
||||||
|
|
||||||
private static final ThreadLocal<DataSetProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
private static final ThreadLocal<DataSetProcessModel> THREAD_LOCAL = new ThreadLocal<>();
|
||||||
|
|
||||||
private TaskContextHolder taskContextHolder;
|
private TaskContextHolder taskContextHolder;
|
||||||
|
|
||||||
public static DataSetContextHolder build(TaskContextHolder taskContextHolder){
|
public static DataSetContextHolder build(TaskContextHolder taskContextHolder) {
|
||||||
return DataSetContextHolder.builder()
|
return DataSetContextHolder.builder()
|
||||||
.taskContextHolder(taskContextHolder)
|
.taskContextHolder(taskContextHolder)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -6,18 +6,19 @@ import muyu.data.test.common.model.process.RecordProcessModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录上下文
|
* 记录上下文
|
||||||
|
*
|
||||||
* @ClassName RecordContextHolder
|
* @ClassName RecordContextHolder
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class RecordContextHolder{
|
public class RecordContextHolder {
|
||||||
|
|
||||||
private static final ThreadLocal<RecordProcessModel> THREAD_LOCAL=new ThreadLocal<>();
|
private static final ThreadLocal<RecordProcessModel> THREAD_LOCAL = new ThreadLocal<>();
|
||||||
|
|
||||||
private DataSetContextHolder dataSetContextHolder;
|
private DataSetContextHolder dataSetContextHolder;
|
||||||
|
|
||||||
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder){
|
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder) {
|
||||||
return RecordContextHolder.builder()
|
return RecordContextHolder.builder()
|
||||||
.dataSetContextHolder(dataSetContextHolder)
|
.dataSetContextHolder(dataSetContextHolder)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -2,12 +2,13 @@ package muyu.data.test.common.context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务上下文
|
* 任务上下文
|
||||||
|
*
|
||||||
* @ClassName TaskContextHolder
|
* @ClassName TaskContextHolder
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
*/
|
*/
|
||||||
public class TaskContextHolder {
|
public class TaskContextHolder {
|
||||||
|
|
||||||
public static TaskContextHolder build(){
|
public static TaskContextHolder build() {
|
||||||
return new TaskContextHolder();
|
return new TaskContextHolder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@ import java.util.HashMap;
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class DataSourceConfig {
|
public class DataSourceConfig {
|
||||||
|
|
||||||
private static HashMap<Long,DruidDataSource> hashMap = new HashMap<>();
|
private static HashMap<Long, DruidDataSource> hashMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加线程池
|
* 添加线程池
|
||||||
* 线程池初始化
|
* 线程池初始化
|
||||||
|
@ -34,7 +35,7 @@ public class DataSourceConfig {
|
||||||
//数据库名
|
//数据库名
|
||||||
String databaseName = dataAccess.getDatabaseName();
|
String databaseName = dataAccess.getDatabaseName();
|
||||||
// url
|
// url
|
||||||
String url = String.format("jdbc:mysql://"+ host+":"+port+"/"+databaseName);
|
String url = String.format("jdbc:mysql://" + host + ":" + port + "/" + databaseName);
|
||||||
DruidDataSource dataSource = new DruidDataSource();
|
DruidDataSource dataSource = new DruidDataSource();
|
||||||
//初始化链接池数量
|
//初始化链接池数量
|
||||||
dataSource.setInitialSize(dataAccess.getInitNum().intValue());
|
dataSource.setInitialSize(dataAccess.getInitNum().intValue());
|
||||||
|
@ -51,14 +52,14 @@ public class DataSourceConfig {
|
||||||
//数据库密码
|
//数据库密码
|
||||||
dataSource.setPassword(dataAccess.getPassword());
|
dataSource.setPassword(dataAccess.getPassword());
|
||||||
dataSource.init();// 初始化
|
dataSource.init();// 初始化
|
||||||
hashMap.put(dataAccess.getId(),dataSource);
|
hashMap.put(dataAccess.getId(), dataSource);
|
||||||
// log.info("储存线程池:{}",hashMap);
|
// log.info("储存线程池:{}",hashMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取出线程池
|
* 取出线程池
|
||||||
*/
|
*/
|
||||||
public static Connection getConnection(Long key){
|
public static Connection getConnection(Long key) {
|
||||||
DruidDataSource dataSource = hashMap.get(key);
|
DruidDataSource dataSource = hashMap.get(key);
|
||||||
try {
|
try {
|
||||||
DruidPooledConnection connection = dataSource.getConnection();
|
DruidPooledConnection connection = dataSource.getConnection();
|
||||||
|
@ -67,16 +68,18 @@ public class DataSourceConfig {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 归还线程池
|
* 归还线程池
|
||||||
*/
|
*/
|
||||||
public static void returnConnection(Connection connection){
|
public static void returnConnection(Connection connection) {
|
||||||
try {
|
try {
|
||||||
connection.close();
|
connection.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 连接线程池
|
* 连接线程池
|
||||||
* 验证线程池
|
* 验证线程池
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
package muyu.data.test.common.dataSoutce;
|
package muyu.data.test.common.dataSoutce;
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
import com.muyu.edition.constant.RuleOperationConstants;
|
import com.muyu.edition.constant.RuleOperationConstants;
|
||||||
import com.muyu.edition.domain.Edition;
|
import com.muyu.edition.domain.Edition;
|
||||||
import com.muyu.edition.domain.RuleEngine;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import muyu.data.test.common.dymamicLoad.DynamicLoader;
|
import muyu.data.test.common.dymamicLoad.DynamicLoader;
|
||||||
import org.bouncycastle.pqc.crypto.newhope.NHSecretKeyProcessor;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -23,31 +20,31 @@ public class EditionSoutceConfig {
|
||||||
private static HashMap<Long, HashMap<Long, Edition>> hashMap = new HashMap<>();
|
private static HashMap<Long, HashMap<Long, Edition>> hashMap = new HashMap<>();
|
||||||
private static HashMap<Long, Map<String, byte[]>> longHashMapHashMap = new HashMap<>();
|
private static HashMap<Long, Map<String, byte[]>> longHashMapHashMap = new HashMap<>();
|
||||||
|
|
||||||
public static void index(Long ruleId, Edition edition){
|
public static void index(Long ruleId, Edition edition) {
|
||||||
HashMap<Long, Edition> editionHashMap = new HashMap<>();
|
HashMap<Long, Edition> editionHashMap = new HashMap<>();
|
||||||
editionHashMap.put(edition.getId(),edition);
|
editionHashMap.put(edition.getId(), edition);
|
||||||
hashMap.put(ruleId,editionHashMap);
|
hashMap.put(ruleId, editionHashMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void indexByte(List<Edition> list){
|
public static void indexByte(List<Edition> list) {
|
||||||
list.stream().forEach(engine -> {
|
list.stream().forEach(engine -> {
|
||||||
//获取版本内容
|
//获取版本内容
|
||||||
String content = engine.getRuleContent().replaceAll("\r\n", "");
|
String content = engine.getRuleContent().replaceAll("\r\n", "");
|
||||||
//编译生成class文件存放到Map中
|
//编译生成class文件存放到Map中
|
||||||
Map<String, byte[]> compile = DynamicLoader.compile( engine.getVersionClass() + RuleOperationConstants.FILE_SUFFIX, content);
|
Map<String, byte[]> compile = DynamicLoader.compile(engine.getVersionClass() + RuleOperationConstants.FILE_SUFFIX, content);
|
||||||
longHashMapHashMap.put(engine.getId(),compile);
|
longHashMapHashMap.put(engine.getId(), compile);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Long,Edition> get(Long ruleId){
|
public static HashMap<Long, Edition> get(Long ruleId) {
|
||||||
return hashMap.get(ruleId);
|
return hashMap.get(ruleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String,byte[]> getByte(Long id){
|
public static Map<String, byte[]> getByte(Long id) {
|
||||||
return longHashMapHashMap.get(id);
|
return longHashMapHashMap.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Long , Map<String, byte[]>> even(){
|
public static HashMap<Long, Map<String, byte[]>> even() {
|
||||||
return longHashMapHashMap;
|
return longHashMapHashMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package muyu.data.test.common.domain.model;
|
package muyu.data.test.common.domain.model;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.annotation.NacosProperties;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package muyu.data.test.common.engine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 引擎
|
* 引擎
|
||||||
|
*
|
||||||
* @ClassName Engine
|
* @ClassName Engine
|
||||||
* @Author: 森静若林
|
* @Author: 森静若林
|
||||||
* @Date: 2024/5/6 13:48
|
* @Date: 2024/5/6 13:48
|
||||||
|
|
|
@ -6,6 +6,7 @@ import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录动作
|
* 记录动作
|
||||||
|
*
|
||||||
* @ClassName ActionRecords
|
* @ClassName ActionRecords
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
* @Date 2024/5/13 22:31
|
* @Date 2024/5/13 22:31
|
||||||
|
@ -13,11 +14,11 @@ import lombok.extern.log4j.Log4j2;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class ActionRecords extends RuntimeException{
|
public class ActionRecords extends RuntimeException {
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
private String name="记录";
|
private String name = "记录";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型
|
* 数据模型
|
||||||
|
@ -28,7 +29,7 @@ public class ActionRecords extends RuntimeException{
|
||||||
this.object = object;
|
this.object = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void records(){
|
public void records() {
|
||||||
log.info("记录的数据是:{}",this.object);
|
log.info("记录的数据是:{}", this.object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,18 @@ import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除动作
|
* 移除动作
|
||||||
|
*
|
||||||
* @ClassName ActionRemove
|
* @ClassName ActionRemove
|
||||||
* @Author: 森静若林
|
* @Author: 森静若林
|
||||||
* @Date: 2024/5/6 13:48
|
* @Date: 2024/5/6 13:48
|
||||||
*/
|
*/
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
public class ActionRemove extends RuntimeException{
|
public class ActionRemove extends RuntimeException {
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
private String name="移除";
|
private String name = "移除";
|
||||||
/**
|
/**
|
||||||
* 数据模型
|
* 数据模型
|
||||||
*/
|
*/
|
||||||
|
@ -26,7 +27,7 @@ public class ActionRemove extends RuntimeException{
|
||||||
this.dataModel = dataModel;
|
this.dataModel = dataModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(){
|
public void remove() {
|
||||||
this.dataModel.setValue(null);
|
this.dataModel.setValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,17 +6,18 @@ import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换动作
|
* 替换动作
|
||||||
|
*
|
||||||
* @ClassName ActionReplace
|
* @ClassName ActionReplace
|
||||||
* @Author: 森静若林
|
* @Author: 森静若林
|
||||||
* @Date: 2024/5/6 13:48
|
* @Date: 2024/5/6 13:48
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class ActionReplace extends RuntimeException{
|
public class ActionReplace extends RuntimeException {
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
private String name="替换";
|
private String name = "替换";
|
||||||
/**
|
/**
|
||||||
* 新值
|
* 新值
|
||||||
*/
|
*/
|
||||||
|
@ -26,7 +27,7 @@ public class ActionReplace extends RuntimeException{
|
||||||
*/
|
*/
|
||||||
private DataModel dataModel;
|
private DataModel dataModel;
|
||||||
|
|
||||||
public ActionReplace(String newValue,DataModel dataModel) {
|
public ActionReplace(String newValue, DataModel dataModel) {
|
||||||
super();
|
super();
|
||||||
this.newValue = newValue;
|
this.newValue = newValue;
|
||||||
this.dataModel = dataModel;
|
this.dataModel = dataModel;
|
||||||
|
@ -36,7 +37,7 @@ public class ActionReplace extends RuntimeException{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(){
|
public void replace() {
|
||||||
this.dataModel.setValue(this.newValue);
|
this.dataModel.setValue(this.newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package muyu.data.test.common.engine.scope;
|
package muyu.data.test.common.engine.scope;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import muyu.data.test.common.context.DataModelContextHolder;
|
import muyu.data.test.common.context.DataModelContextHolder;
|
||||||
import muyu.data.test.common.engine.Engine;
|
import muyu.data.test.common.engine.Engine;
|
||||||
import muyu.data.test.common.model.DataModel;
|
import muyu.data.test.common.model.DataModel;
|
||||||
|
@ -9,6 +8,7 @@ import muyu.data.test.common.model.process.DataModelProcessModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型引擎
|
* 数据模型引擎
|
||||||
|
*
|
||||||
* @ClassName DataModelEngine
|
* @ClassName DataModelEngine
|
||||||
* @Author: 森静若林
|
* @Author: 森静若林
|
||||||
* @Date: 2024/5/6 13:48
|
* @Date: 2024/5/6 13:48
|
||||||
|
@ -16,32 +16,32 @@ import muyu.data.test.common.model.process.DataModelProcessModel;
|
||||||
public abstract class DataModelEngine implements Engine<DataModelProcessModel> {
|
public abstract class DataModelEngine implements Engine<DataModelProcessModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataModelProcessModel get (){
|
public DataModelProcessModel get() {
|
||||||
return DataModelContextHolder.get();
|
return DataModelContextHolder.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataModel getModel(){
|
public DataModel getModel() {
|
||||||
return get().getDataModel();
|
return get().getDataModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getKey () {
|
public String getKey() {
|
||||||
return getModel().getKey();
|
return getModel().getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getValue () {
|
public Object getValue() {
|
||||||
return getModel().getVal();
|
return getModel().getVal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSourceType () {
|
public String getSourceType() {
|
||||||
return getModel().getSourceType();
|
return getModel().getSourceType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProcessType () {
|
public String getProcessType() {
|
||||||
return getModel().getProcessType();
|
return getModel().getProcessType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<?> getProcessClass () {
|
public Class<?> getProcessClass() {
|
||||||
return getModel().getProcessClass();
|
return getModel().getProcessClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据集引擎
|
* 数据集引擎
|
||||||
|
*
|
||||||
* @ClassName DataSetEngine
|
* @ClassName DataSetEngine
|
||||||
* @Author: 森静若林
|
* @Author: 森静若林
|
||||||
* @Date: 2024/5/6 13:48
|
* @Date: 2024/5/6 13:48
|
||||||
|
@ -17,15 +18,15 @@ import java.util.List;
|
||||||
public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
|
public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSetProcessModel get (){
|
public DataSetProcessModel get() {
|
||||||
return DataSetContextHolder.get();
|
return DataSetContextHolder.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataSetModel getModel(){
|
public DataSetModel getModel() {
|
||||||
return get().getDataSetModel();
|
return get().getDataSetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RecordModel> getRecordModels () {
|
public List<RecordModel> getRecordModels() {
|
||||||
return getModel().getRecordModels();
|
return getModel().getRecordModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package muyu.data.test.common.engine.scope;
|
package muyu.data.test.common.engine.scope;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import muyu.data.test.common.context.RecordContextHolder;
|
import muyu.data.test.common.context.RecordContextHolder;
|
||||||
import muyu.data.test.common.engine.Engine;
|
import muyu.data.test.common.engine.Engine;
|
||||||
import muyu.data.test.common.model.DataModel;
|
import muyu.data.test.common.model.DataModel;
|
||||||
|
@ -12,6 +11,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录引擎
|
* 记录引擎
|
||||||
|
*
|
||||||
* @ClassName RecordEngine
|
* @ClassName RecordEngine
|
||||||
* @Author: 森静若林
|
* @Author: 森静若林
|
||||||
* @Date: 2024/5/6 13:48
|
* @Date: 2024/5/6 13:48
|
||||||
|
@ -19,19 +19,19 @@ import java.util.List;
|
||||||
public abstract class RecordEngine implements Engine<RecordProcessModel> {
|
public abstract class RecordEngine implements Engine<RecordProcessModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecordProcessModel get (){
|
public RecordProcessModel get() {
|
||||||
return RecordContextHolder.get();
|
return RecordContextHolder.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getKeys(){
|
public List<String> getKeys() {
|
||||||
return get().getKeys();
|
return get().getKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordModel getModel(){
|
public RecordModel getModel() {
|
||||||
return get().getRecordModel();
|
return get().getRecordModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DataModel> getDataModels () {
|
public List<DataModel> getDataModels() {
|
||||||
return getModel().getDataModels();
|
return getModel().getDataModels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型
|
* 数据模型
|
||||||
|
*
|
||||||
* @ClassName DataModel
|
* @ClassName DataModel
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
* @Date 2024/5/5 18:48
|
* @Date 2024/5/5 18:48
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据集模型
|
* 数据集模型
|
||||||
|
*
|
||||||
* @ClassName DataSetModel
|
* @ClassName DataSetModel
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
* @Date 2024/5/5 18:48
|
* @Date 2024/5/5 18:48
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录模型
|
* 记录模型
|
||||||
|
*
|
||||||
* @ClassName RecordModel
|
* @ClassName RecordModel
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
* @Date 2024/5/5 18:48
|
* @Date 2024/5/5 18:48
|
||||||
|
|
|
@ -7,6 +7,7 @@ import muyu.data.test.common.model.DataModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据模型处理模型
|
* 数据模型处理模型
|
||||||
|
*
|
||||||
* @ClassName DataModelProcessModel
|
* @ClassName DataModelProcessModel
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
* @Date 2024/5/5 18:37
|
* @Date 2024/5/5 18:37
|
||||||
|
|
|
@ -7,6 +7,7 @@ import muyu.data.test.common.model.DataSetModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据集处理模型
|
* 数据集处理模型
|
||||||
|
*
|
||||||
* @ClassName DataSetProcessModel
|
* @ClassName DataSetProcessModel
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
* @Date 2024/5/5 18:37
|
* @Date 2024/5/5 18:37
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录处理模型
|
* 记录处理模型
|
||||||
|
*
|
||||||
* @ClassName RecordProcessModel
|
* @ClassName RecordProcessModel
|
||||||
* @Author 森静若林
|
* @Author 森静若林
|
||||||
* @Date 2024/5/5 18:37
|
* @Date 2024/5/5 18:37
|
||||||
|
|
|
@ -5,7 +5,6 @@ import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import muyu.data.test.common.model.DataModel;
|
import muyu.data.test.common.model.DataModel;
|
||||||
import org.w3c.dom.stylesheets.LinkStyle;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ 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.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@ -15,6 +14,6 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
public class DataTestApplication {
|
public class DataTestApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(DataTestApplication.class,args);
|
SpringApplication.run(DataTestApplication.class, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,11 @@ import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import muyu.data.test.common.model.DataModel;
|
import muyu.data.test.common.model.DataModel;
|
||||||
import muyu.data.test.common.model.DataModel;
|
|
||||||
import muyu.data.test.common.req.TestDataModelReq;
|
import muyu.data.test.common.req.TestDataModelReq;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
|
@ -19,18 +18,21 @@ import java.util.List;
|
||||||
public class TestController extends BaseController {
|
public class TestController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private TestService service;
|
private TestService service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 随机字段
|
* 随机字段
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("getRabdomData")
|
@GetMapping("getRabdomData")
|
||||||
public Result<List<DataModel>> getRabdomData(Long id, String tableName,Integer ruleLevel) throws SQLException {
|
public Result<List<DataModel>> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException {
|
||||||
return success(service.getRabdomData(id,tableName,ruleLevel));
|
return success(service.getRabdomData(id, tableName, ruleLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 展示队列
|
* 展示队列
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param tableName
|
* @param tableName
|
||||||
* @param ruleLevel
|
* @param ruleLevel
|
||||||
|
@ -39,16 +41,16 @@ public class TestController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("getColumn")
|
@GetMapping("getColumn")
|
||||||
public Result<List<List<DataModel>>> getColumn(Long id, String tableName, Integer ruleLevel) throws Exception {
|
public Result<List<List<DataModel>>> getColumn(Long id, String tableName, Integer ruleLevel) throws Exception {
|
||||||
return success(service.getColumn(id,tableName,ruleLevel));
|
return success(service.getColumn(id, tableName, ruleLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("setColumn")
|
@PostMapping("setColumn")
|
||||||
public Result setColumn(@RequestBody TestDataModelReq testDataModelReq){
|
public Result setColumn(@RequestBody TestDataModelReq testDataModelReq) {
|
||||||
return success(service.setColumn(testDataModelReq));
|
return success(service.setColumn(testDataModelReq));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("editionInitialize")
|
@PostMapping("editionInitialize")
|
||||||
public void editionInitialize(){
|
public void editionInitialize() {
|
||||||
service.editionInitialize();
|
service.editionInitialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,19 +10,20 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class Consumer {
|
public class Consumer {
|
||||||
@Autowired
|
|
||||||
private TestController testController;
|
|
||||||
//队列名称
|
//队列名称
|
||||||
public static final String QueueName = "edition";
|
public static final String QueueName = "edition";
|
||||||
|
@Autowired
|
||||||
|
private TestController testController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听队列
|
* 监听队列
|
||||||
*/
|
*/
|
||||||
@RabbitListener(queuesToDeclare = {@Queue("edition")})
|
@RabbitListener(queuesToDeclare = {@Queue("edition")})
|
||||||
public void testEdition(Integer id){
|
public void testEdition(Integer id) {
|
||||||
if (id>0){
|
if (id > 0) {
|
||||||
testController.editionInitialize();
|
testController.editionInitialize();
|
||||||
log.info("初始化");
|
log.info("初始化");
|
||||||
}else{
|
} else {
|
||||||
log.info("等待");
|
log.info("等待");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.data.test.server;
|
package com.data.test.server;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import muyu.data.test.common.model.DataModel;
|
import muyu.data.test.common.model.DataModel;
|
||||||
import muyu.data.test.common.req.TestDataModelReq;
|
import muyu.data.test.common.req.TestDataModelReq;
|
||||||
|
|
||||||
|
@ -8,7 +7,7 @@ import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface TestService {
|
public interface TestService {
|
||||||
List<DataModel> getRabdomData(Long id, String tableName,Integer ruleLevel) throws SQLException;
|
List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException;
|
||||||
|
|
||||||
List<List<DataModel>> getColumn(Long id, String tableName, Integer ruleLevel);
|
List<List<DataModel>> getColumn(Long id, String tableName, Integer ruleLevel);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.data.test.server.impl;
|
package com.data.test.server.impl;
|
||||||
|
|
||||||
import com.data.test.server.TestService;
|
import com.data.test.server.TestService;
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import muyu.data.test.clinet.config.AccessConfig;
|
import muyu.data.test.clinet.config.AccessConfig;
|
||||||
import muyu.data.test.clinet.config.DataEditionConfig;
|
import muyu.data.test.clinet.config.DataEditionConfig;
|
||||||
import muyu.data.test.common.model.DataModel;
|
import muyu.data.test.common.model.DataModel;
|
||||||
|
@ -18,14 +17,15 @@ public class TestServiceImpl implements TestService {
|
||||||
private AccessConfig accessConfig;
|
private AccessConfig accessConfig;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataEditionConfig dataEditionConfig;
|
private DataEditionConfig dataEditionConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException {
|
public List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException {
|
||||||
return accessConfig.getRabdomData(id,tableName,ruleLevel);
|
return accessConfig.getRabdomData(id, tableName, ruleLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<List<DataModel>> getColumn(Long id, String tableName, Integer ruleLevel) {
|
public List<List<DataModel>> getColumn(Long id, String tableName, Integer ruleLevel) {
|
||||||
return accessConfig.getColumn(id,tableName,ruleLevel);
|
return accessConfig.getColumn(id, tableName, ruleLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,5 +29,14 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-logging</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.muyu.edition.DCL;
|
||||||
|
|
||||||
|
import org.slf4j.MDC;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class MDCTraceUtil {
|
||||||
|
/**
|
||||||
|
* 追踪id的名称
|
||||||
|
*/
|
||||||
|
public static final String KEY_TRACE_ID = "traceId";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志链路追踪id信息头
|
||||||
|
*/
|
||||||
|
public static final String TRACE_ID_HEADER = "x-traceId-header";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建traceId并赋值MDC
|
||||||
|
*/
|
||||||
|
public static void addTrace() {
|
||||||
|
String traceId = createTraceId();
|
||||||
|
// MDC(Mapped Diagnostic Context)诊断上下文映射,是@Slf4j提供的一个支持动态打印日志信息的工具。
|
||||||
|
MDC.put(KEY_TRACE_ID, traceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 赋值MDC
|
||||||
|
*/
|
||||||
|
public static void putTrace(String traceId) {
|
||||||
|
MDC.put(KEY_TRACE_ID, traceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取MDC中的traceId值
|
||||||
|
*/
|
||||||
|
public static String getTraceId() {
|
||||||
|
return MDC.get(KEY_TRACE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除MDC的值
|
||||||
|
*/
|
||||||
|
public static void removeTrace() {
|
||||||
|
MDC.remove(KEY_TRACE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建traceId
|
||||||
|
*/
|
||||||
|
public static String createTraceId() {
|
||||||
|
return UUID.randomUUID().toString().replace("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muyu.edition.config;
|
||||||
|
|
||||||
|
import com.muyu.edition.config.LogInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class LogWebMvcConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
// 添加拦截器
|
||||||
|
registry.addInterceptor(mvcInterceptor())
|
||||||
|
// 拦截所有请求的路径
|
||||||
|
.addPathPatterns("/**");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LogInterceptor mvcInterceptor() {
|
||||||
|
return new LogInterceptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.edition.config;
|
||||||
|
|
||||||
|
import com.alibaba.druid.util.StringUtils;
|
||||||
|
import com.muyu.edition.DCL.MDCTraceUtil;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
public class LogInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
// 客户端可以传入链路ID,需要唯一性
|
||||||
|
String traceId = request.getHeader(MDCTraceUtil.TRACE_ID_HEADER);
|
||||||
|
if (!StringUtils.isEmpty(traceId)) {
|
||||||
|
MDCTraceUtil.putTrace(request.getHeader(MDCTraceUtil.TRACE_ID_HEADER));
|
||||||
|
} else {
|
||||||
|
MDCTraceUtil.addTrace();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||||
|
MDCTraceUtil.removeTrace();
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,3 +31,4 @@ spring:
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.muyu.edition.mapper: DEBUG
|
com.muyu.edition.mapper: DEBUG
|
||||||
|
config: classpath:logback-spring.xml
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
|
||||||
|
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
|
||||||
|
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
|
||||||
|
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||||
|
<configuration scan="true" scanPeriod="10 seconds">
|
||||||
|
<contextName>logback</contextName>
|
||||||
|
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
|
||||||
|
<springProperty scope="context" name="log.path" source="log.path"/>
|
||||||
|
<!-- 彩色日志 -->
|
||||||
|
<!-- 彩色日志依赖的渲染类 -->
|
||||||
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
|
||||||
|
<conversionRule conversionWord="wex"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
|
||||||
|
<conversionRule conversionWord="wEx"
|
||||||
|
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
|
||||||
|
<!-- 彩色日志格式 -->
|
||||||
|
<property name="CONSOLE_LOG_PATTERN"
|
||||||
|
value="[traceId:%X{traceId}] ${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||||
|
|
||||||
|
<property name="PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"/>
|
||||||
|
<!--输出到控制台-->
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>debug</level>
|
||||||
|
</filter>
|
||||||
|
<encoder>
|
||||||
|
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
||||||
|
<!-- 设置字符集 -->
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
<!-- 滚动文件输出日志 -->
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/log.log</file>
|
||||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 每天日志归档路径以及格式 -->
|
||||||
|
<fileNamePattern>${log.path}/log-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||||
|
<maxFileSize>10MB</maxFileSize>
|
||||||
|
</timeBasedFileNamingAndTriggeringPolicy>
|
||||||
|
<!--日志文件保留天数-->
|
||||||
|
<maxHistory>15</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${PATTERN}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<!-- 配置日志输出的方式,可以同时输出到控制台和文件 -->
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class Stream {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List<String> list = Arrays.asList("dsf", "psd", "qw3", "dfq332", "dgw4thn","dps","dps");
|
||||||
|
//遍历转换成大写
|
||||||
|
List<String> collect1 = list.stream().map(String::toUpperCase).collect(Collectors.toList());
|
||||||
|
System.out.println(collect1);
|
||||||
|
//过滤
|
||||||
|
List<String> collect2 = list.stream().filter(e -> !e.contains("d")).collect(Collectors.toList());
|
||||||
|
System.out.println(collect2);
|
||||||
|
// 10个随机数
|
||||||
|
Random random = new Random();
|
||||||
|
// random.ints().limit(3).forEach(System.out::println);
|
||||||
|
// random.ints().limit(3).sorted().forEach(System.out::println);
|
||||||
|
//使用map输出元数对应的平方数且去重
|
||||||
|
List<Integer> integerList = Arrays.asList(1,3,5,7,9,2,4,6,8,10);
|
||||||
|
integerList.stream().map(i -> i * i).distinct().collect(Collectors.toList());
|
||||||
|
//取集合数据
|
||||||
|
List<Users> usersList = new ArrayList<>();
|
||||||
|
usersList.add(new Users("张三","男",15));
|
||||||
|
usersList.add(new Users("李四","男",23));
|
||||||
|
usersList.add(new Users("王五","男",18));
|
||||||
|
Map<String, Users> hashMap = new HashMap<>();
|
||||||
|
List<Map<String,Users>> list1 = new ArrayList<>();
|
||||||
|
for (int i = 1; i <= usersList.size(); i++) {
|
||||||
|
hashMap.put(i+"",usersList.get(i-1));
|
||||||
|
list1.add(hashMap);
|
||||||
|
}
|
||||||
|
System.out.println(list1);
|
||||||
|
List<Users> collect = list1.stream().map(item -> item.get("1")).collect(Collectors.toList());
|
||||||
|
System.out.println(collect.get(0));
|
||||||
|
//将一个对象的集合转换为另一个对象的集合
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
public class Users {
|
||||||
|
private String name;
|
||||||
|
private String sex;
|
||||||
|
private Integer age;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSex() {
|
||||||
|
return sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSex(String sex) {
|
||||||
|
this.sex = sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Users{" +
|
||||||
|
"name='" + name + '\'' +
|
||||||
|
", sex='" + sex + '\'' +
|
||||||
|
", age=" + age +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAge() {
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAge(Integer age) {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Users(String name, String sex, int age) {
|
||||||
|
this.name = name;
|
||||||
|
this.sex = sex;
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
}
|
8
pom.xml
8
pom.xml
|
@ -206,7 +206,15 @@
|
||||||
<version>${muyu.version}</version>
|
<version>${muyu.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- lombko配置-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.28</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|
Loading…
Reference in New Issue