feat(DataAccessServiceImpl)重写同步
parent
c647dbf7fe
commit
43feb93e6a
|
@ -139,8 +139,8 @@ public class AccreditController extends BaseController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("/selNameListStructure")
|
||||
public Result<List<ListStructure>> selNameListStructure(@RequestParam String databaseName,@RequestParam String tableName){
|
||||
List<ListStructure> list = service.selNameListStructure(databaseName,tableName);
|
||||
public Result<List<ListStructure>> selNameListStructure(@RequestParam String tableName,@RequestParam String databaseName){
|
||||
List<ListStructure> list = service.selNameListStructure(tableName,databaseName);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,4 +127,6 @@ public class DataAccessController extends BaseController
|
|||
return error("同步失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class TableList {
|
|||
/**
|
||||
*备注
|
||||
*/
|
||||
private String as;
|
||||
private String asas;
|
||||
/**
|
||||
*数据
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,14 @@ public class FrimaryVo {
|
|||
* 数据库名称
|
||||
*/
|
||||
private String databaseName;
|
||||
/**
|
||||
* 表数量
|
||||
*/
|
||||
private Integer tableNameNum;
|
||||
/**
|
||||
* 总数数据
|
||||
*/
|
||||
private Integer dataTotal;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
|
|
|
@ -25,13 +25,12 @@ public interface AccreditMapper {
|
|||
|
||||
void insertListStructure(ListStructure listStructure);
|
||||
|
||||
void inserttableList(@Param("databaseName") String databaseName,@Param("s") String s);
|
||||
|
||||
List<ListStructure> listListstructure();
|
||||
|
||||
TableList selNameTableList(@Param("databaseName") String databaseName, @Param("name") String name);
|
||||
|
||||
List<ListStructure> selNameListStructure(@Param("databaseName") String databaseName, @Param("tableName") String tableName);
|
||||
List<ListStructure> selNameListStructure(@Param("tableName") String tableName, @Param("databaseName") String databaseName);
|
||||
|
||||
int selectOneTableList(@Param("databaseName") String databaseName, @Param("s") String s);
|
||||
|
||||
|
@ -59,4 +58,5 @@ public interface AccreditMapper {
|
|||
|
||||
|
||||
List<Middle> listMiddle2(@Param("databaseName") String databaseName);
|
||||
|
||||
}
|
||||
|
|
|
@ -69,8 +69,6 @@ public interface DataAccessMapper
|
|||
|
||||
void insertMiddle(@Param("deptId") Long deptId, @Param("id") Long id,@Param("databaseName") String databaseName, @Param("tableName") String tableName);
|
||||
|
||||
void indexFrimary(DataAccess dataAccess);
|
||||
|
||||
Integer oneSelFrimary(DataAccess dataAccess);
|
||||
|
||||
void insertUserMiddle(@Param("userId") Long userId, @Param("id") Long id,@Param("databaseName") String databaseName, @Param("tableName") String tableName);
|
||||
|
@ -80,4 +78,12 @@ public interface DataAccessMapper
|
|||
Integer selectOneUserMiddel(@Param("userId") Long userId, @Param("id") Long id, @Param("databaseName") String databaseName, @Param("tableName") String tableName);
|
||||
|
||||
void deleteFrimary(DataAccess dataAccess);
|
||||
|
||||
void indexFrimary(@Param("dataAccess") DataAccess dataAccess, @Param("num") Integer num, @Param("i") Integer i);
|
||||
|
||||
void inserttableList(@Param("dataAccess") DataAccess dataAccess, @Param("tableName") String tableName, @Param("annotation") String annotation, @Param("anInt") int anInt);
|
||||
|
||||
void deleteTableList(DataAccess dataAccess);
|
||||
|
||||
Integer selectAccessMapper(DataAccess dataAccess);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public interface AccreditService {
|
|||
|
||||
TableList selNameTableList(String databaseName,String name);
|
||||
|
||||
List<ListStructure> selNameListStructure(String databaseName,String tableName);
|
||||
List<ListStructure> selNameListStructure(String tableName,String databaseName);
|
||||
|
||||
Integer updateListStructure(ListStructure listStructure);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public interface IDataAccessService
|
|||
|
||||
DataAccess oneDataAccess();
|
||||
|
||||
Integer synchronization(DataAccess dataAccess);
|
||||
Integer synchronization(DataAccess dataAccess) throws Exception;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -115,8 +115,8 @@ public class AccreditServiceImpl implements AccreditService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ListStructure> selNameListStructure(String databaseName,String tableName) {
|
||||
return mapper.selNameListStructure(databaseName,tableName);
|
||||
public List<ListStructure> selNameListStructure(String tableName,String databaseName) {
|
||||
return mapper.selNameListStructure(tableName,databaseName);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ import java.sql.ResultSet;
|
|||
import java.sql.DriverManager;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -127,131 +131,216 @@ public class DataAccessServiceImpl implements IDataAccessService
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer synchronization(DataAccess dataAccess) {
|
||||
public Integer synchronization(DataAccess dataAccess) throws Exception {
|
||||
Integer id = 0;
|
||||
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 rs = statement.executeQuery("SHOW TABLES");
|
||||
ResultSet rst = statement.executeQuery("select TABLE_NAME, TABLE_COMMENT from INFORMATION_SCHEMA.Tables where table_schema = " + dataAccess.getDatabaseName());
|
||||
|
||||
//获取字段名
|
||||
// while (rs.next()){
|
||||
// stringList.add(rs.getString(1));
|
||||
// }
|
||||
// accreditMapper.delOneTableList(dataAccess.getDatabaseName(),);
|
||||
while (rst.next()){
|
||||
System.out.println("表名"+rst.getString(1)+",注释:"+rst.getString(2));
|
||||
//框架子类
|
||||
// accreditMapper.inserttableList(dataAccess,s);
|
||||
// 连接数据
|
||||
// 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())));
|
||||
|
||||
//第一个 树形表
|
||||
CompletableFuture<Integer> completable1 = CompletableFuture.supplyAsync(() -> {
|
||||
//先清除同数据库叶子表
|
||||
Integer ini = dataAccessMapper.selectAccessMapper(dataAccess);
|
||||
if (ini>0){
|
||||
dataAccessMapper.deleteTableList(dataAccess);
|
||||
}
|
||||
// accreditMapper.delListStructure(dataAccess.getDatabaseName());
|
||||
// 表介绍
|
||||
Integer num = 0;
|
||||
Integer i = 0;
|
||||
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, TABLE_COMMENT from INFORMATION_SCHEMA.Tables where table_schema = '" + dataAccess.getDatabaseName() + "'");
|
||||
while (rst.next()) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("select count(*) from " + rst.getString(1));
|
||||
ResultSet rls = preparedStatement.executeQuery();
|
||||
while (rls.next()) {
|
||||
int anInt = rls.getInt(1);
|
||||
// 叶子类增加
|
||||
num += anInt;
|
||||
i++;
|
||||
dataAccessMapper.inserttableList(dataAccess, rst.getString(1), rst.getString(2), anInt);
|
||||
System.out.println("表名" + rst.getString(1) + ",注释:" + rst.getString(2) + "数量:" + anInt);
|
||||
}
|
||||
}
|
||||
// 处理树表
|
||||
dataAccessMapper.deleteFrimary(dataAccess);
|
||||
dataAccessMapper.indexFrimary(dataAccess, num, i);
|
||||
rst.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return 1;
|
||||
}, threadPoolExecutor);
|
||||
//第二个 部门中间表 用户中间表
|
||||
CompletableFuture<Integer> completable2 = CompletableFuture.supplyAsync(() -> {
|
||||
//获取全部表名
|
||||
ResultSet rs = null;
|
||||
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();
|
||||
rs = statement.executeQuery("SHOW TABLES");
|
||||
//获取所有部门
|
||||
List<SysDept> list = sysDeptMapper.listDeptList();
|
||||
//获取所有用户
|
||||
List<SysUserVo> sysUserVos = sysUserMapper.listSelectSysUser();
|
||||
while (rs.next()) {
|
||||
/**
|
||||
*部门
|
||||
*/
|
||||
for (SysDept sysDept : list) {
|
||||
Integer sysDeptIds = dataAccessMapper.selectOneMiddel(sysDept.getDeptId(), dataAccess.getId(), dataAccess.getDatabaseName(), rs.getString(1));
|
||||
if (sysDeptIds == 0) {
|
||||
//添加中间件
|
||||
dataAccessMapper.insertMiddle(sysDept.getDeptId(), dataAccess.getId(), dataAccess.getDatabaseName(), rs.getString(1));
|
||||
}
|
||||
}
|
||||
//用户
|
||||
for (SysUserVo sysUserVo : sysUserVos) {
|
||||
Integer sysUserVoIds = dataAccessMapper.selectOneUserMiddel(sysUserVo.getUserId(), dataAccess.getId(), dataAccess.getDatabaseName(), rs.getString(1));
|
||||
if (sysUserVoIds == 0) {
|
||||
//添加中间件
|
||||
dataAccessMapper.insertUserMiddle(sysUserVo.getUserId(), dataAccess.getId(), dataAccess.getDatabaseName(), rs.getString(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
//获取字段名
|
||||
return 1;
|
||||
}, threadPoolExecutor);
|
||||
//第三个
|
||||
CompletableFuture<Integer> completable3 = CompletableFuture.supplyAsync(() -> {
|
||||
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 rs = statement.executeQuery("SHOW TABLES");
|
||||
|
||||
//处理表名
|
||||
// for (String s : stringList) {
|
||||
// int i1 = accreditMapper.selectOneSqlJdbc(dataAccess.getDatabaseName(),s);
|
||||
// if (i1>0){
|
||||
// }else{
|
||||
// PreparedStatement pst = connection.prepareCall("select * from " + s);
|
||||
// ResultSetMetaData rsd = pst.getMetaData();
|
||||
// //获取元数据
|
||||
// DatabaseMetaData metaData1 = connection.getMetaData();
|
||||
// Map<String,String> columnComments =getColumnComments(metaData,s);
|
||||
// //添加数据结构
|
||||
// for (int i = 0; i < rsd.getColumnCount(); i++) {
|
||||
// System.out.println("java类型" + rsd.getColumnClassName(i + 1));
|
||||
// System.out.println("数据库类型" + rsd.getColumnTypeName(i + 1));
|
||||
// System.out.println("字段名称" + rsd.getColumnName(i + 1));
|
||||
// System.out.println("表名" + rsd.getTableName(i + 1));
|
||||
// System.out.println("数据库名" + rsd.getCatalogName(i + 1));
|
||||
// System.out.println("模式名" + rsd.getSchemaName(i + 1));
|
||||
// System.out.println("列数" + rsd.getColumnCount());
|
||||
// System.out.println("列类型" + rsd.getColumnType(i + 1));
|
||||
// System.out.println("列标签" + rsd.getColumnLabel(i + 1));
|
||||
// System.out.println("列显示大小" + rsd.getColumnDisplaySize(i + 1));
|
||||
// System.out.println("精度" + rsd.getPrecision(i + 1));
|
||||
// System.out.println("规模" + rsd.getScale(i + 1));
|
||||
// System.out.println("自增" + rsd.isAutoIncrement(i + 1));
|
||||
// System.out.println("是否为空" + rsd.isNullable(i + 1));
|
||||
// System.out.println("区分大小写" + rsd.isCaseSensitive(i + 1));
|
||||
// System.out.println("是否是货币" + rsd.isCurrency(i + 1));
|
||||
// System.out.println("可搜索" + rsd.isSearchable(i + 1));
|
||||
// System.out.println("签署" + rsd.isSigned(i + 1));
|
||||
// System.out.println("绝对可以写" + rsd.isDefinitelyWritable(i + 1));
|
||||
// System.out.println("只读" + rsd.isReadOnly(i + 1));
|
||||
// System.out.println("是可写的" + rsd.isWritable(i + 1));
|
||||
// System.out.println("注解" + columnComments.get(rsd.getColumnName(i + 1)));
|
||||
// ListStructure listStructure = new ListStructure();
|
||||
// //获取数据库名
|
||||
// listStructure.setCatalogName(rsd.getCatalogName(i + 1));
|
||||
// //获取表名
|
||||
// listStructure.setTableName(rsd.getTableName(i + 1));
|
||||
// //获取java类型
|
||||
// listStructure.setColumnLassName(rsd.getColumnClassName(i + 1));
|
||||
// //获取映射类型
|
||||
// listStructure.setColumnTypeName(rsd.getColumnTypeName(i + 1));
|
||||
// //获取字段名称
|
||||
// listStructure.setColumnName(rsd.getColumnName(i + 1));
|
||||
// //获取长度
|
||||
// listStructure.setPrecisions(rsd.getPrecision(i + 1));
|
||||
// //获取小数
|
||||
// listStructure.setScale(rsd.getScale(i + 1));
|
||||
// //获取非空
|
||||
// listStructure.setIsNull(rsd.isNullable(i + 1));
|
||||
// //获取默认
|
||||
// listStructure.setSchemaName(rsd.getSchemaName(i + 1));
|
||||
// //获取注解
|
||||
// listStructure.setColumnComments(columnComments.get(rsd.getColumnName(i + 1)));
|
||||
// accreditMapper.insertListStructure(listStructure);
|
||||
// }
|
||||
// }
|
||||
// /**
|
||||
// * 获取所有的部门
|
||||
// */
|
||||
// List<SysDept> list = sysDeptMapper.listDeptList();
|
||||
// for (SysDept sysDept : list) {
|
||||
// Integer sysDeptIds = dataAccessMapper.selectOneMiddel(sysDept.getDeptId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
// if (sysDeptIds == 0){
|
||||
// //添加中间件
|
||||
// dataAccessMapper.insertMiddle(sysDept.getDeptId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
// }
|
||||
// }
|
||||
// //获取所有用户
|
||||
// List<SysUserVo> sysUserVos = sysUserMapper.listSelectSysUser();
|
||||
// for (SysUserVo sysUserVo : sysUserVos) {
|
||||
// Integer sysUserVoIds = dataAccessMapper.selectOneUserMiddel(sysUserVo.getUserId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
// if (sysUserVoIds == 0){
|
||||
// //添加中间件
|
||||
// dataAccessMapper.insertUserMiddle(sysUserVo.getUserId(),dataAccess.getId(),dataAccess.getDatabaseName(),s);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//关闭连接
|
||||
connection.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
//获取字段名
|
||||
while (rs.next()) {
|
||||
stringList.add(rs.getString(1));
|
||||
}
|
||||
//处理表名
|
||||
for (String s : stringList) {
|
||||
int i1 = accreditMapper.selectOneSqlJdbc(dataAccess.getDatabaseName(), s);
|
||||
if (i1 > 0) {
|
||||
} else {
|
||||
PreparedStatement pst = connection.prepareCall("select * from " + s);
|
||||
ResultSetMetaData rsd = pst.getMetaData();
|
||||
//获取元数据
|
||||
DatabaseMetaData metaData1 = connection.getMetaData();
|
||||
Map<String, String> columnComments = getColumnComments(metaData, s);
|
||||
//添加数据结构
|
||||
for (int i = 0; i < rsd.getColumnCount(); i++) {
|
||||
System.out.println("java类型" + rsd.getColumnClassName(i + 1));
|
||||
System.out.println("数据库类型" + rsd.getColumnTypeName(i + 1));
|
||||
System.out.println("字段名称" + rsd.getColumnName(i + 1));
|
||||
System.out.println("表名" + rsd.getTableName(i + 1));
|
||||
System.out.println("数据库名" + rsd.getCatalogName(i + 1));
|
||||
System.out.println("模式名" + rsd.getSchemaName(i + 1));
|
||||
System.out.println("列数" + rsd.getColumnCount());
|
||||
System.out.println("列类型" + rsd.getColumnType(i + 1));
|
||||
System.out.println("列标签" + rsd.getColumnLabel(i + 1));
|
||||
System.out.println("列显示大小" + rsd.getColumnDisplaySize(i + 1));
|
||||
System.out.println("精度" + rsd.getPrecision(i + 1));
|
||||
System.out.println("规模" + rsd.getScale(i + 1));
|
||||
System.out.println("自增" + rsd.isAutoIncrement(i + 1));
|
||||
System.out.println("是否为空" + rsd.isNullable(i + 1));
|
||||
System.out.println("区分大小写" + rsd.isCaseSensitive(i + 1));
|
||||
System.out.println("是否是货币" + rsd.isCurrency(i + 1));
|
||||
System.out.println("可搜索" + rsd.isSearchable(i + 1));
|
||||
System.out.println("签署" + rsd.isSigned(i + 1));
|
||||
System.out.println("绝对可以写" + rsd.isDefinitelyWritable(i + 1));
|
||||
System.out.println("只读" + rsd.isReadOnly(i + 1));
|
||||
System.out.println("是可写的" + rsd.isWritable(i + 1));
|
||||
System.out.println("注解" + columnComments.get(rsd.getColumnName(i + 1)));
|
||||
ListStructure listStructure = new ListStructure();
|
||||
//获取数据库名
|
||||
listStructure.setCatalogName(rsd.getCatalogName(i + 1));
|
||||
//获取表名
|
||||
listStructure.setTableName(rsd.getTableName(i + 1));
|
||||
//获取java类型
|
||||
listStructure.setColumnLassName(rsd.getColumnClassName(i + 1));
|
||||
//获取映射类型
|
||||
listStructure.setColumnTypeName(rsd.getColumnTypeName(i + 1));
|
||||
//获取字段名称
|
||||
listStructure.setColumnName(rsd.getColumnName(i + 1));
|
||||
//获取长度
|
||||
listStructure.setPrecisions(rsd.getPrecision(i + 1));
|
||||
//获取小数
|
||||
listStructure.setScale(rsd.getScale(i + 1));
|
||||
//获取非空
|
||||
listStructure.setIsNull(rsd.isNullable(i + 1));
|
||||
//获取默认
|
||||
listStructure.setSchemaName(rsd.getSchemaName(i + 1));
|
||||
//获取注解
|
||||
listStructure.setColumnComments(columnComments.get(rsd.getColumnName(i + 1)));
|
||||
accreditMapper.insertListStructure(listStructure);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}, threadPoolExecutor);
|
||||
|
||||
System.out.println(completable1.join());
|
||||
System.out.println(completable2.join());
|
||||
System.out.println(completable3.join());
|
||||
if (completable1.join()+completable2.join()+completable3.join() == 3){
|
||||
id = 1;
|
||||
}else{
|
||||
id = 0;
|
||||
}
|
||||
//获取结构父类比表
|
||||
// Integer in = dataAccessMapper.oneSelFrimary(dataAccess);
|
||||
// if (in<=0){
|
||||
// dataAccessMapper.indexFrimary(dataAccess);
|
||||
// }else{
|
||||
// dataAccessMapper.deleteFrimary(dataAccess);
|
||||
// dataAccessMapper.indexFrimary(dataAccess);
|
||||
// }
|
||||
id = 1;
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
insert into list_structure (catalog_name,table_name,column_lass_name,column_type_name,column_name,precisions,scale,is_null,schema_name,column_comments)
|
||||
values (#{catalogName},#{tableName},#{columnLassName},#{columnTypeName},#{columnName},#{precisions},#{scale},#{isNull},#{schemaName},#{columnComments});
|
||||
</insert>
|
||||
<insert id="inserttableList">
|
||||
insert into tableList (database_name,name)
|
||||
values (#{databaseName},#{s});
|
||||
</insert>
|
||||
<update id="updateListStructure">
|
||||
update list_structure
|
||||
set yes_or_no = #{yesOrNo},
|
||||
|
@ -67,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
<select id="tableNameList" resultType="com.muyu.system.domain.TableList">
|
||||
select *
|
||||
from tableList where database_name = #{databaseName}
|
||||
from tableList where databaseName = #{databaseName}
|
||||
</select>
|
||||
<select id="listListstructure" resultType="com.muyu.system.domain.ListStructure">
|
||||
select *
|
||||
|
|
|
@ -47,10 +47,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectDataAccessVo"/>
|
||||
order by id desc limit 1
|
||||
</select>
|
||||
<select id="indexFrimary">
|
||||
insert into frimary (id,name,systemName,databaseName)
|
||||
values (#{id},#{name},#{systemName},#{databaseName});
|
||||
</select>
|
||||
<select id="oneSelFrimary" resultType="java.lang.Integer">
|
||||
select count(id)
|
||||
from frimary where id = #{id} and databaseName = #{databaseName}
|
||||
|
@ -63,6 +59,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select count(id)
|
||||
from user_maiddle where id = #{id} and user_id = #{userId} and database_name = #{databaseName} and table_name = #{tableName}
|
||||
</select>
|
||||
<select id="selectAccessMapper" resultType="java.lang.Integer">
|
||||
select count(id)
|
||||
from tableList where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertDataAccess" parameterType="com.muyu.system.domain.DataAccess" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into data_access
|
||||
|
@ -107,6 +107,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
insert into user_maiddle (id,user_id,database_name,table_name,status_id)
|
||||
values (#{id},#{userId},#{databaseName},#{tableName},0);
|
||||
</insert>
|
||||
<insert id="indexFrimary">
|
||||
insert into frimary (id,name,systemName,databaseName,tableNameNum,dataTotal)
|
||||
values (#{dataAccess.id},#{dataAccess.name},#{dataAccess.systemName},#{dataAccess.databaseName},#{i},#{num});
|
||||
</insert>
|
||||
|
||||
<insert id="inserttableList">
|
||||
insert into tablelist (id,name,systemName,databaseName,tableName,asas,dataTotal)
|
||||
values (#{dataAccess.id},#{dataAccess.name},#{dataAccess.systemName},#{dataAccess.databaseName},#{tableName},#{annotation},#{anInt});
|
||||
</insert>
|
||||
|
||||
<update id="updateDataAccess" parameterType="com.muyu.system.domain.DataAccess">
|
||||
update data_access
|
||||
|
@ -142,6 +151,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<delete id="deleteFrimary">
|
||||
delete
|
||||
from frimary
|
||||
where id = #{id} and databaseName = #{databaseName}
|
||||
where id = #{id}
|
||||
</delete>
|
||||
<delete id="deleteTableList">
|
||||
delete
|
||||
from tablelist
|
||||
where id = #{id}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue