|
@@ -2,17 +2,16 @@ package com.jeeplus.test.program.configuration.typeDict.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.jeeplus.aop.logging.annotation.ApiLog;
|
|
import com.jeeplus.aop.logging.annotation.ApiLog;
|
|
-import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
|
import com.jeeplus.sys.constant.enums.LogTypeEnum;
|
|
import com.jeeplus.sys.constant.enums.LogTypeEnum;
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
import com.jeeplus.test.program.configuration.typeDict.domain.ProgramTypeDict;
|
|
import com.jeeplus.test.program.configuration.typeDict.domain.ProgramTypeDict;
|
|
import com.jeeplus.test.program.configuration.typeDict.service.ProgramTypeDictService;
|
|
import com.jeeplus.test.program.configuration.typeDict.service.ProgramTypeDictService;
|
|
import com.jeeplus.test.program.configuration.typeDict.service.dto.ProgramTypeDictDTO;
|
|
import com.jeeplus.test.program.configuration.typeDict.service.dto.ProgramTypeDictDTO;
|
|
-import com.jeeplus.test.program.configuration.typeDict.service.mapstruct.ProgramTypeDictWrapper;
|
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
@@ -20,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -43,33 +43,45 @@ public class ProgramTypeDictController {
|
|
@PreAuthorize("hasAuthority('program:configuration:type:list')")
|
|
@PreAuthorize("hasAuthority('program:configuration:type:list')")
|
|
@GetMapping("list")
|
|
@GetMapping("list")
|
|
public ResponseEntity<IPage<ProgramTypeDictDTO>> data(ProgramTypeDictDTO programTypeDictDTO, Page<ProgramTypeDictDTO> page) throws Exception {
|
|
public ResponseEntity<IPage<ProgramTypeDictDTO>> data(ProgramTypeDictDTO programTypeDictDTO, Page<ProgramTypeDictDTO> page) throws Exception {
|
|
|
|
+ page.setSize(-1);
|
|
IPage<ProgramTypeDictDTO> result = new Page<ProgramTypeDictDTO>();
|
|
IPage<ProgramTypeDictDTO> result = new Page<ProgramTypeDictDTO>();
|
|
if(ObjectUtil.isNotEmpty(programTypeDictDTO)){
|
|
if(ObjectUtil.isNotEmpty(programTypeDictDTO)){
|
|
if(StringUtils.isNotBlank(programTypeDictDTO.getType())){
|
|
if(StringUtils.isNotBlank(programTypeDictDTO.getType())){
|
|
|
|
+ //根据type模糊查询
|
|
List<ProgramTypeDict> programTypeDictList = programTypeDictService.list(new QueryWrapper<ProgramTypeDict>().lambda()
|
|
List<ProgramTypeDict> programTypeDictList = programTypeDictService.list(new QueryWrapper<ProgramTypeDict>().lambda()
|
|
.like(StringUtils.isNotBlank(programTypeDictDTO.getType()), ProgramTypeDict::getType, programTypeDictDTO.getType())
|
|
.like(StringUtils.isNotBlank(programTypeDictDTO.getType()), ProgramTypeDict::getType, programTypeDictDTO.getType())
|
|
);
|
|
);
|
|
- List<String> pIdList = programTypeDictList.stream().distinct().filter(item->{
|
|
|
|
- if(!"0".equals(item.getParentId())){
|
|
|
|
|
|
+ //获取到其中不是一级项目类型的数据
|
|
|
|
+ List<ProgramTypeDict> childList = programTypeDictList.stream().distinct().filter(item -> {
|
|
|
|
+ if (!"0".equals(item.getParentId())) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
- }).map(ProgramTypeDict::getParentId).collect(Collectors.toList());
|
|
|
|
- List<String> IdList = programTypeDictList.stream().distinct().filter(item->{
|
|
|
|
- if("0".equals(item.getParentId())){
|
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ //childList的id全部获取
|
|
|
|
+ List<String> cIdList = childList.stream().distinct().map(ProgramTypeDict::getId).collect(Collectors.toList());
|
|
|
|
+ //childList的父级id全部获取
|
|
|
|
+ List<String> cupIdList = childList.stream().distinct().map(ProgramTypeDict::getParentId).collect(Collectors.toList());
|
|
|
|
+ //获取到其中一级项目类型的数据的id
|
|
|
|
+ List<String> pIdList = programTypeDictList.stream().distinct().filter(item -> {
|
|
|
|
+ if ("0".equals(item.getParentId())) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}).map(ProgramTypeDict::getId).collect(Collectors.toList());
|
|
}).map(ProgramTypeDict::getId).collect(Collectors.toList());
|
|
- pIdList.addAll(IdList);
|
|
|
|
- List<String> collect = pIdList.stream().distinct().collect(Collectors.toList());
|
|
|
|
- if(CollectionUtil.isNotEmpty(collect)){
|
|
|
|
- QueryWrapper<ProgramTypeDict> wrapper = new QueryWrapper<ProgramTypeDict>()
|
|
|
|
- .in("ptd.id",collect)
|
|
|
|
- .or()
|
|
|
|
- .in("ptd.parent_id",collect);
|
|
|
|
- result = programTypeDictService.findList (page,wrapper);
|
|
|
|
|
|
+ //获取pIdList下的所有子项目类型的id
|
|
|
|
+ if(CollectionUtil.isNotEmpty(pIdList)){
|
|
|
|
+ pIdList.addAll(programTypeDictService.list(new QueryWrapper<ProgramTypeDict>().lambda()
|
|
|
|
+ .in(ProgramTypeDict::getParentId,pIdList)).stream().map(ProgramTypeDict::getId).collect(Collectors.toList()));
|
|
}
|
|
}
|
|
|
|
+ //将获取到的这几个id集合融合到一起并去重,然后根据id查询,即可得到结果
|
|
|
|
+ cIdList.addAll(cupIdList);
|
|
|
|
+ cIdList.addAll(pIdList);
|
|
|
|
+ List<String> idList = cIdList.stream().distinct().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ QueryWrapper<ProgramTypeDict> wrapper = new QueryWrapper<ProgramTypeDict>()
|
|
|
|
+ .in("ptd.id",idList);
|
|
|
|
+ result = programTypeDictService.findList (page,wrapper);
|
|
}else{
|
|
}else{
|
|
result = programTypeDictService.findList (page,new QueryWrapper<ProgramTypeDict>());
|
|
result = programTypeDictService.findList (page,new QueryWrapper<ProgramTypeDict>());
|
|
}
|
|
}
|