09040919:修改同步资产结构的逻辑
parent
51fdd1f6c1
commit
c4a9063516
|
@ -30,8 +30,7 @@ public class DataValueController {
|
|||
/**
|
||||
* 根据基础表ID和SQL语句查询数据
|
||||
*
|
||||
* @param basicId 基础表ID
|
||||
* @param sql SQL语句
|
||||
* @param dataValueModel 基础表ID和sql语句
|
||||
* @return DataValue{kltv}
|
||||
*/
|
||||
@PostMapping("/findTableValue")
|
||||
|
|
|
@ -258,6 +258,4 @@ public class TableInfoController {
|
|||
}
|
||||
return Result.success(tableInfoList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.source.domain.AssetAuthorization;
|
||||
import com.muyu.source.domain.DataSource;
|
||||
import com.muyu.source.domain.Structure;
|
||||
import com.muyu.source.domain.TableInfo;
|
||||
|
@ -46,6 +47,8 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
private TableInfoService tableInfoService;
|
||||
@Resource
|
||||
private StructureService structureService;
|
||||
@Resource
|
||||
private AssetAuthorizationService assetAuthorizationService;
|
||||
|
||||
private static final Long PARENTID = 0L;
|
||||
private static final String DRIVERNAME = "com.mysql.cj.jdbc.Driver";
|
||||
|
@ -160,11 +163,33 @@ public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSou
|
|||
*/
|
||||
@Override
|
||||
public Integer syncAssetStructure(DataSource etlDataScore) {
|
||||
|
||||
try {
|
||||
if (etlDataScore.getDataType().equals(MYSQL)) {
|
||||
MysqlPool mysqlPool = new MysqlPool(etlDataScore);
|
||||
mysqlPool.init();
|
||||
Connection conn = mysqlPool.getConn();
|
||||
TableInfo tableInfoServiceOne = tableInfoService.getOne(new LambdaQueryWrapper<>() {{
|
||||
eq(TableInfo::getBasicId, etlDataScore.getId());
|
||||
}});
|
||||
//如果存在就删除
|
||||
if(StringUtils.isNotNull(tableInfoServiceOne)){
|
||||
List<TableInfo> list = tableInfoService.list(new LambdaQueryWrapper<>() {{
|
||||
eq(TableInfo::getBasicId, etlDataScore.getId());
|
||||
}});
|
||||
list.forEach(tableInfo -> {
|
||||
structureService.remove(new LambdaQueryWrapper<>(){{
|
||||
eq(Structure::getTableId, tableInfo.getId());
|
||||
}});
|
||||
});
|
||||
tableInfoService.remove(new LambdaQueryWrapper<>(){{
|
||||
eq(TableInfo::getBasicId, etlDataScore.getId());
|
||||
}});
|
||||
assetAuthorizationService.remove(new LambdaQueryWrapper<>(){{
|
||||
eq(AssetAuthorization::getTableId, tableInfoServiceOne.getId())
|
||||
.eq(AssetAuthorization::getBasicId, etlDataScore.getId());
|
||||
}});
|
||||
}
|
||||
|
||||
TableInfo tableInfoInsert = TableInfo.builder()
|
||||
.basicId(etlDataScore.getId())
|
||||
|
|
Loading…
Reference in New Issue