pull/3/head
zmyYYDS 2023-12-24 22:40:29 +08:00
commit c87c4a8bac
8 changed files with 42 additions and 52 deletions

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

@ -1,10 +1,20 @@
package net.srt.disposition.dto; package net.srt.disposition.dto;
/** import com.fasterxml.jackson.annotation.JsonFormat;
* @BelongsProject: srt_cloud import lombok.Data;
* @BelongsPackage: net.srt.disposition.dto import org.springframework.format.annotation.DateTimeFormat;
* @Author: jpz
* @CreateTime: 2023/12/23 9:09 import java.util.Date;
*/
@Data
public class DataProductionTreeDto { public class DataProductionTreeDto {
private String description;
private Long id;
private Integer ifLeaf;
private String name;
private Integer orderNo;
private Long parentId;
private String parentPath;
private String path;
private Integer taskType;
} }

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