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