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