feat:数据统计组件

master
Saisai Liu 2024-04-23 20:41:09 +08:00
parent ed38fe8109
commit 606a05d68e
3 changed files with 76 additions and 15 deletions

View File

@ -0,0 +1,55 @@
package com.muyu.etl.domain.resp;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.etl.domain.Structure;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
/**
* table_info
*
* @author Saisai
* @date 2024-04-22
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class TableInfoStructureResp
{
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long basicId;
/** 表名称/数据库 */
@Excel(name = "表名称/数据库")
private String tableName;
/** 表备注 */
@Excel(name = "表备注")
private String tableRemark;
/** 数据量 */
@Excel(name = "数据量")
private Long dataNum;
/** 是否核心 'Y'是 'N'不是 */
@Excel(name = "是否核心 'Y'是 'N'不是")
private String center;
private String databaseType;
private List<Structure> structureList;
}

View File

@ -35,5 +35,5 @@ public class TableTreeResp {
/**
*
*/
private List<TableInfo> Children;
private List<TableInfoStructureResp> Children;
}

View File

@ -1,11 +1,13 @@
package com.muyu.etl.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.etl.domain.BasicConfigInfo;
import com.muyu.etl.domain.Structure;
import com.muyu.etl.domain.TableInfo;
import com.muyu.etl.domain.resp.TableInfoStructureResp;
import com.muyu.etl.domain.resp.TableTreeResp;
import com.muyu.etl.mapper.BasicConfigInfoMapper;
import com.muyu.etl.service.BasicConfigInfoService;
@ -196,7 +198,7 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
" COLUMN_NAME AS '字段', " +
" COLUMN_COMMENT AS '字段注释', " +
" CASE WHEN COLUMN_KEY = 'PRI' THEN '是' ELSE '否' END AS '是否主键'," +
" CASE \n" +
" CASE \n" +
" WHEN DATA_TYPE = 'int' THEN 'Integer' " +
" WHEN DATA_TYPE = 'bigint' THEN 'Long' " +
" WHEN DATA_TYPE = 'varchar' THEN 'String' " +
@ -229,7 +231,6 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
String NumericScale = String.valueOf(resultSet.getInt(8));
String isNullable = String.valueOf( resultSet.getObject(9));
String columnDefault = String.valueOf( resultSet.getObject(10));
Structure build = Structure.builder()
.tableId(table.getId())
.columnName(String.valueOf(columnName))
@ -243,11 +244,10 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
.isNull("YES".equals(isNullable) ? "Y" : "N")
.defaultValue( columnDefault)
.build();
log.info(build);
structureService.saveOrUpdate(build,new LambdaUpdateWrapper<Structure>(){{
eq(Structure::getTableId,build.getTableId());
eq(Structure::getColumnName,build.getColumnName());
eq(Structure::getRemark,build.getRemark());
eq(Structure::getColumnRemark,build.getColumnRemark());
}});
}
}
@ -308,22 +308,28 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMapp
public List<TableTreeResp> getTableTree() {
List<TableTreeResp> tableTreeRespList = tableInfoService.selectTableInfoList(new TableInfo(){{setParentId(0L);}}).stream().map(tableInfo ->{
BasicConfigInfo basicConfigInfo = this.selectBasicConfigInfoById(tableInfo.getBasicId());
List<TableInfo> tableInfoList = tableInfoService.selectTableInfoList(new TableInfo() {{
List<TableInfoStructureResp> tableInfoStructureRespList = tableInfoService.selectTableInfoList(new TableInfo() {{
setParentId(tableInfo.getId());
}});
}}).stream().map(info -> {
List<Structure> structureList = structureService.list(new LambdaQueryWrapper<Structure>().eq(Structure::getTableId,info.getId()));
return TableInfoStructureResp.builder()
.id(info.getId())
.tableName(info.getTableName())
.center(info.getCenter())
.tableRemark(info.getTableRemark())
.dataNum(info.getDataNum())
.databaseType(basicConfigInfo.getDatabaseType())
.structureList(structureList)
.basicId(info.getBasicId())
.build();
}).collect(Collectors.toList());
return TableTreeResp.builder()
.tableInfo(tableInfo)
.basicConfigInfo(basicConfigInfo)
.Children(tableInfoList)
.Children(tableInfoStructureRespList)
.build();
}).collect(Collectors.toList());
return tableTreeRespList;
}
//{
// label: '一级 1',
// children: [{
// label: '二级 1-1',
// data
// }]
// }
}