fix:修改了数据接入同步功能

master
Jiang Peng 2024-04-26 09:29:24 +08:00
parent 4185897de1
commit 639cb8159e
2 changed files with 8 additions and 45 deletions

View File

@ -53,33 +53,6 @@ public class DataSourceServiceImpl implements DataSourceService{
@Override @Override
public List<DataSource> selectDataSourceList(DataSource dataSource) { public List<DataSource> selectDataSourceList(DataSource dataSource) {
List<DataSource> dataSources = dataSourceMapper.selectDataSourceList(dataSource); List<DataSource> dataSources = dataSourceMapper.selectDataSourceList(dataSource);
// dataSources.stream()
// .map(source -> {
// String user = source.getUsername();
// String password = source.getPassword();
// String jdbcDriver = "com.mysql.cj.jdbc.Driver";
// String jdbcUrl = "jdbc:mysql://"+source.getLinkAddress()+":"+source.getPort()+"/"+source.getDatabaseName();
// Connection conn = null;
// Result result = this.test(source);
// if (result.getCode()==200){
// try {
// Class.forName(jdbcDriver);
// conn = DriverManager.getConnection(jdbcUrl, user, password);
// List<TableDetail> tableNames = new ArrayList<>();
// String sql="SELECT table_name FROM information_schema.tables WHERE table_schema = '"+source.getDatabaseName()+"'";
// PreparedStatement ps = conn.prepareStatement(sql);
// ResultSet resultSet = ps.executeQuery();
// while (resultSet.next()){
// tableNames.add(resultSet.getString("table_name"));
// }
// source.setTableList(tableNames);
// ps.close();
// } catch (ClassNotFoundException | SQLException e) {
// throw new RuntimeException(e);
// }
// }
// return null;
// }).toList();
return dataSources; return dataSources;
} }
@ -227,6 +200,8 @@ public class DataSourceServiceImpl implements DataSourceService{
case "blob": case "blob":
case "longblob": case "longblob":
return "byte[]"; return "byte[]";
case "longtext":
return "Clob";
// ... 其他类型映射包括日期、时间、字符串、二进制、Blob、枚举、集合等 // ... 其他类型映射包括日期、时间、字符串、二进制、Blob、枚举、集合等
default: default:
throw new IllegalArgumentException("Unsupported data type: " + mappingType); throw new IllegalArgumentException("Unsupported data type: " + mappingType);
@ -262,7 +237,6 @@ public class DataSourceServiceImpl implements DataSourceService{
ResultSet resultSet = preparedStatement.executeQuery(); ResultSet resultSet = preparedStatement.executeQuery();
// 遍历查询结果,创建并填充资产模型列表 // 遍历查询结果,创建并填充资产模型列表
while (resultSet.next()){ while (resultSet.next()){
AssetModel assetModel = new AssetModel(); AssetModel assetModel = new AssetModel();
assetModel.setComment(resultSet.getString("COLUMN_COMMENT")); assetModel.setComment(resultSet.getString("COLUMN_COMMENT"));

View File

@ -130,25 +130,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- <if test="item.createTime != null">#{item.createTime},</if>--> <!-- <if test="item.createTime != null">#{item.createTime},</if>-->
<!-- </trim>--> <!-- </trim>-->
<!-- </foreach>--> <!-- </foreach>-->
<!-- </insert>-->
<!-- </insert>-->
<insert id="batchInsert" parameterType="com.muyu.etl.domain.AssetModel" useGeneratedKeys="true" keyProperty="id"> <insert id="batchInsert" parameterType="com.muyu.etl.domain.AssetModel" useGeneratedKeys="true" keyProperty="id">
insert into `asset_model_copy1` ( INSERT INTO `asset_model_copy1` (
`data_asset_id`, `data_asset_id`, `name`, `comment`, `is_primary_key`, `type`, `mapping_type`,
`name`, `length`, `decimal_places`, `is_null`, `is_dict`, `default_value`, `dict_key`,
comment, `create_by`, `create_time`
is_primary_key, ) VALUES
`type`,
mapping_type,
`length`,
decimal_places,
is_null,
is_dict,
default_value,
dict_key,
create_by,
create_time
) values
<foreach collection="tableAssets" item="item" separator=","> <foreach collection="tableAssets" item="item" separator=",">
( (
#{item.dataAssetId}, #{item.dataAssetId},