资产更新版本2.0豪华版优化字段名称查询
parent
0ca04cc481
commit
a1dea3a085
|
@ -72,6 +72,11 @@ public class TableFie{
|
||||||
// @TableField(exist = false)
|
// @TableField(exist = false)
|
||||||
private String dataMapping;
|
private String dataMapping;
|
||||||
|
|
||||||
|
public TableFie(Integer id, String field) {
|
||||||
|
this.id = id;
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
public static TableFie customerBuild(TableFie tableFie, Supplier<TableFie> function) {
|
public static TableFie customerBuild(TableFie tableFie, Supplier<TableFie> function) {
|
||||||
return TableFie.builder()
|
return TableFie.builder()
|
||||||
.id(tableFie.getId())
|
.id(tableFie.getId())
|
||||||
|
|
|
@ -22,8 +22,6 @@ import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:yang
|
* @Author:yang
|
||||||
|
@ -246,12 +244,14 @@ public class DataRunNameServiceImpl implements DataRunNameService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询值
|
* 查询值
|
||||||
|
*
|
||||||
* @param dataDame
|
* @param dataDame
|
||||||
* @param tableName
|
* @param tableName
|
||||||
* @param field
|
* @param field
|
||||||
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String tableFySelect(String dataDame, String tableName, String field) {
|
private List<TableFie> tableFySelect(String dataDame, String tableName, String field, Integer id) {
|
||||||
|
|
||||||
// 从连接池获取数据库连接
|
// 从连接池获取数据库连接
|
||||||
DruidDataSource conn = JdbcHelper.getConnRs(dataDame);
|
DruidDataSource conn = JdbcHelper.getConnRs(dataDame);
|
||||||
|
@ -259,20 +259,21 @@ public class DataRunNameServiceImpl implements DataRunNameService {
|
||||||
try {
|
try {
|
||||||
DruidPooledConnection connection = conn.getConnection();
|
DruidPooledConnection connection = conn.getConnection();
|
||||||
// 准备SQL查询语句
|
// 准备SQL查询语句
|
||||||
PreparedStatement ps = connection.prepareStatement("select " + field + " FROM " + tableName);
|
List<TableFie> fieArrayList = new ArrayList<>();
|
||||||
|
PreparedStatement ps = connection.prepareStatement("select " +id+","+ field + " FROM " + tableName);
|
||||||
ResultSet resultSet = ps.executeQuery();
|
ResultSet resultSet = ps.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
|
int ids = resultSet.getInt(id);
|
||||||
String fields = resultSet.getString(field);
|
String fields = resultSet.getString(field);
|
||||||
// 返回包含数据值的列表
|
// 返回包含数据值的列表
|
||||||
return fields;
|
fieArrayList.add(new TableFie(id,fields));
|
||||||
}
|
}
|
||||||
|
return fieArrayList;
|
||||||
// 释放数据库连接
|
// 释放数据库连接
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// 如果发生SQL异常,抛出运行时异常
|
// 如果发生SQL异常,抛出运行时异常
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -469,8 +470,13 @@ public class DataRunNameServiceImpl implements DataRunNameService {
|
||||||
List<DataValue> tableValue = this.findTableValue(String.valueOf(dataName.getId()), tableNames.getName());
|
List<DataValue> tableValue = this.findTableValue(String.valueOf(dataName.getId()), tableNames.getName());
|
||||||
tableFieList.forEach(tableFy -> {
|
tableFieList.forEach(tableFy -> {
|
||||||
//查询字段映射信息
|
//查询字段映射信息
|
||||||
String str = this.tableFySelect(dataName.getName(), tableNames.getName(), tableFy.getField());
|
List<TableFie> str = this.tableFySelect(dataName.getName(), tableNames.getName(), tableFy.getField(),tableFy.getId());
|
||||||
tableFy.setDataValue(str);
|
str.forEach(s -> {
|
||||||
|
if (s.getId()==tableFy.getId()){
|
||||||
|
tableFy.setDataValue(s.getField());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
log.info("字段数据对象:{}", tableFy);
|
log.info("字段数据对象:{}", tableFy);
|
||||||
|
|
||||||
for (DataValue dataValue : tableValue) {
|
for (DataValue dataValue : tableValue) {
|
||||||
|
|
Loading…
Reference in New Issue