数据开发模块

pull/3/head
chenbingxuan 2023-12-24 22:30:04 +08:00
parent 4169100ce2
commit 579a4dc7f3
10 changed files with 36 additions and 64 deletions

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import net.srt.api.module.data.governance.dto.quality.QulaityColumn; import net.srt.api.module.data.governance.dto.quality.QulaityColumn;
import net.srt.convert.QualityTaskTableConvert; import net.srt.convert.QualityTaskTableConvert;
import net.srt.dao.QualityTaskColumnDao; import net.srt.dao.QualityTaskColumnDao;
@ -34,11 +35,13 @@ import java.util.stream.Collectors;
@AllArgsConstructor @AllArgsConstructor
public class QualityTaskTableServiceimpl extends BaseServiceImpl<QualityTaskTableDao,QualityTaskTableEntity> implements QualityTaskTableService { public class QualityTaskTableServiceimpl extends BaseServiceImpl<QualityTaskTableDao,QualityTaskTableEntity> implements QualityTaskTableService {
@SneakyThrows
@Override @Override
public PageResult<QualityTaskTableVo> page(QualityTableQuery query) { public PageResult<QualityTaskTableVo> page(QualityTableQuery query) {
IPage<QualityTaskTableEntity> page=baseMapper.selectPage(getPage(query),getWrapper(query)); IPage<QualityTaskTableEntity> page=baseMapper.selectPage(getPage(query),getWrapper(query));
List<QualityTaskTableVo> taskTableVos= QualityTaskTableConvert.INSTANCE.convertList(page.getRecords()); List<QualityTaskTableVo> taskTableVos= QualityTaskTableConvert.INSTANCE.convertList(page.getRecords());
for (QualityTaskTableVo taskTableVo : taskTableVos) { taskTableVo.setColumnInfo(SingletonObject.OBJECT_MAPPER.readValue(SingletonObject.OBJECT_MAPPER.writeValueAsString(taskTableVo.getColumnInfo()), new TypeReference<List<QulaityColumn>>() { for (QualityTaskTableVo taskTableVo : taskTableVos) {
taskTableVo.setColumnInfo(SingletonObject.OBJECT_MAPPER.readValue(SingletonObject.OBJECT_MAPPER.writeValueAsString(taskTableVo.getColumnInfo()), new TypeReference<List<QulaityColumn>>() {
})); }));
taskTableVo.setCheckColumns(taskTableVo.getColumnInfo().stream().map(QulaityColumn::getColumnName).collect(Collectors.joining(","))); taskTableVo.setCheckColumns(taskTableVo.getColumnInfo().stream().map(QulaityColumn::getColumnName).collect(Collectors.joining(",")));

View File

@ -1,10 +1,19 @@
package net.srt; package net.srt;
import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.parser.SQLParserUtils;
import com.alibaba.druid.sql.parser.SQLStatementParser;
import jdk.nashorn.internal.runtime.ParserException;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import java.util.List;
import static com.alibaba.druid.sql.SQLUtils.toSQLString;
@EnableDiscoveryClient @EnableDiscoveryClient
@SpringBootApplication @SpringBootApplication
@MapperScan("net.srt.Fink.mapper") @MapperScan("net.srt.Fink.mapper")
@ -12,6 +21,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@MapperScan("net.srt.disposition.mapper") @MapperScan("net.srt.disposition.mapper")
public class DevelopmentApp { public class DevelopmentApp {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DevelopmentApp.class); SpringApplication.run(DevelopmentApp.class);
System.out.println("数据开发已启动===========>"); System.out.println("数据开发已启动===========>");
} }

View File

@ -1,13 +1,13 @@
package net.srt.disposition.controller; package net.srt.disposition.controller;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import net.srt.api.module.data.integrate.dto.DataDatabaseDto;
import net.srt.disposition.dto.DataProductionTreeDto; import net.srt.disposition.dto.DataProductionTreeDto;
import net.srt.disposition.dto.DispositionDto; import net.srt.disposition.dto.DispositionDto;
import net.srt.disposition.service.DataProductionService; import net.srt.disposition.service.DataProductionService;
import net.srt.disposition.vo.DataProductionTreeVo; import net.srt.disposition.vo.DataProductionTreeVo;
import net.srt.disposition.vo.DispositionVo; import net.srt.disposition.vo.DispositionVo;
import net.srt.framework.common.utils.Result; import net.srt.framework.common.utils.Result;
import net.srt.framework.common.utils.TreeNodeVo;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -20,8 +20,8 @@ public class DataProductionTreeController {
private DataProductionService dataProductionService; private DataProductionService dataProductionService;
@GetMapping @GetMapping
public Result<List<DataProductionTreeVo>> listResult(){ public Result<List<TreeNodeVo>> listResult(){
List<DataProductionTreeVo> dispositionVos=dataProductionService.dataTreeList(); List<TreeNodeVo> dispositionVos=dataProductionService.dataTreeList();
return Result.ok(dispositionVos); return Result.ok(dispositionVos);
} }

View File

@ -8,24 +8,13 @@ import java.util.Date;
@Data @Data
public class DataProductionTreeDto { public class DataProductionTreeDto {
private Integer id; private String description;
private Integer parentId; private Long id;
private Integer ifLeaf; private Integer ifLeaf;
private Long taskId; private String name;
private String taskType; private Integer orderNo;
private Long parentId;
private String parentPath; private String parentPath;
private String path; private String path;
private Integer orderNo; private Integer taskType;
private String label;
private Long metamodelId;
private String name;
private String icon;
private String code;
private Boolean builtin;
private String description;
private Long projectId;
private Integer creator;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date creatTime;
} }

View File

@ -13,11 +13,11 @@ import java.util.Date;
@TableName("data_production_tree") @TableName("data_production_tree")
public class DataProductionTreeEntity { public class DataProductionTreeEntity {
@TableId("id") @TableId("id")
private Integer id; private Long id;
private Integer parentId; private Long parentId;
private Integer ifLeaf; private Integer ifLeaf;
private Long taskId; private Long taskId;
private String taskType; private Integer taskType;
private String parentPath; private String parentPath;
private String path; private String path;
private Integer orderNo; private Integer orderNo;

View File

@ -1,16 +1,16 @@
package net.srt.disposition.service; package net.srt.disposition.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import net.srt.api.module.data.integrate.dto.DataDatabaseDto;
import net.srt.disposition.dto.DataProductionTreeDto; import net.srt.disposition.dto.DataProductionTreeDto;
import net.srt.disposition.dto.DispositionDto; import net.srt.disposition.dto.DispositionDto;
import net.srt.disposition.entity.DataProductionTreeEntity; import net.srt.disposition.entity.DataProductionTreeEntity;
import net.srt.disposition.vo.DataProductionTreeVo; import net.srt.disposition.vo.DataProductionTreeVo;
import net.srt.framework.common.utils.TreeNodeVo;
import java.util.List; import java.util.List;
public interface DataProductionService extends IService<DataProductionTreeEntity> { public interface DataProductionService extends IService<DataProductionTreeEntity> {
List<DataProductionTreeVo> dataTreeList(); List<TreeNodeVo> dataTreeList();
void add(DataProductionTreeDto dataProductionTreeDto); void add(DataProductionTreeDto dataProductionTreeDto);

View File

@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import net.srt.Fink.entity.FinkEntity; import net.srt.Fink.entity.FinkEntity;
import net.srt.api.module.data.integrate.dto.DataDatabaseDto;
import net.srt.disposition.convert.DataProductionTreeConvert; import net.srt.disposition.convert.DataProductionTreeConvert;
import net.srt.disposition.dto.DataProductionTreeDto; import net.srt.disposition.dto.DataProductionTreeDto;
import net.srt.disposition.dto.DispositionDto; import net.srt.disposition.dto.DispositionDto;
@ -27,51 +26,22 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
public class DataProductionServiceImpl extends BaseServiceImpl<DataProductionMapper, DataProductionTreeEntity> implements DataProductionService { public class DataProductionServiceImpl extends BaseServiceImpl<DataProductionMapper, DataProductionTreeEntity> implements DataProductionService {
@Override @Override
public List<DataProductionTreeVo> dataTreeList() { public List<TreeNodeVo> dataTreeList() {
LambdaQueryWrapper<DataProductionTreeEntity> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DataProductionTreeEntity> wrapper = new LambdaQueryWrapper<>();
dataScopeWithoutOrgId(wrapper);
wrapper.orderByAsc(DataProductionTreeEntity::getOrderNo); wrapper.orderByAsc(DataProductionTreeEntity::getOrderNo);
List<DataProductionTreeEntity> dataFileCategoryEntities = baseMapper.selectList(wrapper); List<DataProductionTreeEntity> dataFileCategoryEntities = baseMapper.selectList(wrapper);
List<DataProductionTreeVo> treeNodeVos = BeanUtil.copyListProperties(dataFileCategoryEntities, DataProductionTreeVo::new, (oldItem, newItem) -> { List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(dataFileCategoryEntities, TreeNodeVo::new, (oldItem, newItem) -> {
newItem.setLabel(oldItem.getName()); newItem.setLabel(oldItem.getName());
newItem.setValue(oldItem.getId());
if (oldItem.getTaskType()!=null){
newItem.setTaskType(oldItem.getTaskType());
}
if (newItem.getPath().contains("/")) { if (newItem.getPath().contains("/")) {
newItem.setParentPath(newItem.getPath().substring(0, newItem.getPath().lastIndexOf("/"))); newItem.setParentPath(newItem.getPath().substring(0, newItem.getPath().lastIndexOf("/")));
} }
}); });
return buildTree(treeNodeVos); return BuildTreeUtils.buildTree(treeNodeVos);
}
public static List<DataProductionTreeVo> buildTree(List<DataProductionTreeVo> nodeVos) {
List<DataProductionTreeVo> resultVos = new ArrayList<>(10);
for (DataProductionTreeVo node : nodeVos) {
// 一级菜单parentId为0
if (node.getParentId() == 0) {
resultVos.add(node);
}
}
// 为一级菜单设置子菜单getChild是递归调用的
for (DataProductionTreeVo node : resultVos) {
node.setDataProductionTreeVos(getChild(node.getId(), nodeVos));
}
return resultVos;
}
private static List<DataProductionTreeVo> getChild(Integer id, List<DataProductionTreeVo> nodeVos) {
// 子菜单
List<DataProductionTreeVo> childList = new ArrayList<>(10);
for (DataProductionTreeVo node : nodeVos) {
// 遍历所有节点将父菜单id与传过来的id比较
if (node.getParentId() != 0) {
if (node.getParentId().equals(id)) {
childList.add(node);
}
}
}
// 把子菜单的子菜单再循环一遍
for (DataProductionTreeVo node : childList) {
node.setDataProductionTreeVos(getChild(node.getId(), nodeVos));
}
return childList;
} }
@Override @Override