数据开发模块
parent
5095d6caf1
commit
8ff6be9ab4
|
@ -42,7 +42,7 @@ public class HadoopController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* 修改
|
||||
* @param HadoopAddDto
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
package net.srt.Hadoop.convert;
|
||||
|
||||
import net.srt.Fink.convert.FinkConvert;
|
||||
import net.srt.Fink.dto.FinkAddDto;
|
||||
import net.srt.Fink.entity.FinkEntity;
|
||||
import net.srt.Fink.vo.FinkVo;
|
||||
import net.srt.Hadoop.dto.HadoopAddDto;
|
||||
import net.srt.Hadoop.dto.HadoopDto;
|
||||
import net.srt.Hadoop.entity.HadoopEntity;
|
||||
import net.srt.Hadoop.vo.HadoopVo;
|
||||
import org.mapstruct.Mapper;
|
||||
|
|
|
@ -14,8 +14,12 @@ import net.srt.disposition.entity.DataProductionTreeEntity;
|
|||
import net.srt.disposition.mapper.DataProductionMapper;
|
||||
import net.srt.disposition.service.DataProductionService;
|
||||
import net.srt.disposition.vo.DataProductionTreeVo;
|
||||
import net.srt.framework.common.utils.BeanUtil;
|
||||
import net.srt.framework.common.utils.BuildTreeUtils;
|
||||
import net.srt.framework.common.utils.TreeNodeVo;
|
||||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -24,36 +28,70 @@ import java.util.List;
|
|||
public class DataProductionServiceImpl extends BaseServiceImpl<DataProductionMapper, DataProductionTreeEntity> implements DataProductionService {
|
||||
@Override
|
||||
public List<DataProductionTreeVo> dataTreeList() {
|
||||
ArrayList<DataProductionTreeVo> dataProductionTreeVoArrayList = new ArrayList<>();
|
||||
List<DataProductionTreeEntity> dataProductionTreeEntities = baseMapper.selectList(null);
|
||||
for (DataProductionTreeEntity dataProductionTreeEntity : dataProductionTreeEntities) {
|
||||
List<DataProductionTreeVo> dataProductionTreeVos=findDataProductTreeVoList(dataProductionTreeEntity);
|
||||
DataProductionTreeVo convert = DataProductionTreeConvert.INSTANCE.convert(dataProductionTreeEntity);
|
||||
convert.setDataProductionTreeVos(dataProductionTreeVos);
|
||||
dataProductionTreeVoArrayList.add(convert);
|
||||
}
|
||||
return dataProductionTreeVoArrayList;
|
||||
LambdaQueryWrapper<DataProductionTreeEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.orderByAsc(DataProductionTreeEntity::getOrderNo);
|
||||
List<DataProductionTreeEntity> dataFileCategoryEntities = baseMapper.selectList(wrapper);
|
||||
List<DataProductionTreeVo> treeNodeVos = BeanUtil.copyListProperties(dataFileCategoryEntities, DataProductionTreeVo::new, (oldItem, newItem) -> {
|
||||
newItem.setLabel(oldItem.getName());
|
||||
if (newItem.getPath().contains("/")) {
|
||||
newItem.setParentPath(newItem.getPath().substring(0, newItem.getPath().lastIndexOf("/")));
|
||||
}
|
||||
});
|
||||
return buildTree(treeNodeVos);
|
||||
}
|
||||
|
||||
private List<DataProductionTreeVo> findDataProductTreeVoList(DataProductionTreeEntity dataProductionTreeEntity) {
|
||||
QueryWrapper<DataProductionTreeEntity> dataProductionTreeEntityQueryWrapper = new QueryWrapper<>();
|
||||
dataProductionTreeEntityQueryWrapper.eq("parent_id",dataProductionTreeEntity.getId());
|
||||
List<DataProductionTreeEntity> dataProductionTreeEntities = baseMapper.selectList(dataProductionTreeEntityQueryWrapper);
|
||||
List<DataProductionTreeVo> convert = DataProductionTreeConvert.INSTANCE.convert(dataProductionTreeEntities);
|
||||
return convert;
|
||||
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
|
||||
public void add(DataProductionTreeDto dataProductionTreeDto) {
|
||||
DataProductionTreeEntity convert = DataProductionTreeConvert.INSTANCE.convert(dataProductionTreeDto);
|
||||
if (convert.getParentPath()!=null && !convert.getParentPath().equals("")){
|
||||
String path=convert.getParentPath()+"/"+convert.getName();
|
||||
convert.setPath(path);
|
||||
baseMapper.insert(convert);
|
||||
DataProductionTreeEntity entity = DataProductionTreeConvert.INSTANCE.convert(dataProductionTreeDto);
|
||||
entity.setPath(recursionPath(entity, null));
|
||||
entity.setProjectId(getProjectId());
|
||||
baseMapper.insert(entity);
|
||||
}
|
||||
|
||||
private String recursionPath(DataProductionTreeEntity categoryEntity, String path) {
|
||||
if (StringUtil.isBlank(path)) {
|
||||
path = categoryEntity.getName();
|
||||
}
|
||||
convert.setLabel(convert.getName());
|
||||
convert.setPath(convert.getName());
|
||||
baseMapper.insert(convert);
|
||||
if (categoryEntity.getParentId() != 0) {
|
||||
DataProductionTreeEntity parent = getById(categoryEntity.getParentId());
|
||||
path = parent.getName() + "/" + path;
|
||||
return recursionPath(parent, path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue