|
@@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -87,6 +88,69 @@ public class CwWorkClientService extends ServiceImpl<CwWorkClientBaseMapper, CwW
|
|
return cwWorkClientBaseMapper.findList(page, queryWrapper);
|
|
return cwWorkClientBaseMapper.findList(page, queryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public IPage<CwWorkClientBaseDTO> findListTree(Page<CwWorkClientBaseDTO> page, CwWorkClientBaseDTO cwWorkClientBaseDTO) throws Exception{
|
|
|
|
+ QueryWrapper<CwWorkClientBase> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("cw_wcb.del_flag","0");
|
|
|
|
+ queryWrapper.orderByDesc("cw_wcb.create_date");
|
|
|
|
+ if (ObjectUtil.isNotEmpty(cwWorkClientBaseDTO)) {
|
|
|
|
+ if (StringUtils.isNotBlank(cwWorkClientBaseDTO.getName()) ||
|
|
|
|
+ StringUtils.isNotBlank(cwWorkClientBaseDTO.getNo()) ||
|
|
|
|
+ StringUtils.isNotBlank(cwWorkClientBaseDTO.getType()) ||
|
|
|
|
+ StringUtils.isNotBlank(cwWorkClientBaseDTO.getIndustry())) {
|
|
|
|
+ List<String> ids = new ArrayList<>();
|
|
|
|
+ List<CwWorkClientBase> list = this.list(new QueryWrapper<CwWorkClientBase>().lambda()
|
|
|
|
+ .like(StringUtils.isNotBlank(cwWorkClientBaseDTO.getName()),CwWorkClientBase::getName, cwWorkClientBaseDTO.getName())
|
|
|
|
+ .like(StringUtils.isNotBlank(cwWorkClientBaseDTO.getNo()),CwWorkClientBase::getNo, cwWorkClientBaseDTO.getNo())
|
|
|
|
+ .eq(StringUtils.isNotBlank(cwWorkClientBaseDTO.getType()),CwWorkClientBase::getType, cwWorkClientBaseDTO.getType())
|
|
|
|
+ .eq(StringUtils.isNotBlank(cwWorkClientBaseDTO.getIndustry()),CwWorkClientBase::getIndustry, cwWorkClientBaseDTO.getIndustry())
|
|
|
|
+ );
|
|
|
|
+ list.stream().forEach(item->{
|
|
|
|
+ ids.add(item.getId());
|
|
|
|
+ if (StringUtils.isNotBlank(item.getOneUpCompany())) {
|
|
|
|
+ String parentId = item.getOneUpCompany();
|
|
|
|
+ while (true) {
|
|
|
|
+ CwWorkClientBase byId = this.getOne(new QueryWrapper<CwWorkClientBase>().lambda().eq(CwWorkClientBase::getId, parentId));
|
|
|
|
+ if (ObjectUtil.isNotEmpty(byId)) {
|
|
|
|
+ ids.add(byId.getId());
|
|
|
|
+ if (StringUtils.isBlank(byId.getOneUpCompany())) {
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ parentId = byId.getOneUpCompany();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<String> childIdList = this.list(new QueryWrapper<CwWorkClientBase>().lambda().eq(CwWorkClientBase::getOneUpCompany, item.getId())).stream().map(CwWorkClientBase::getId).collect(Collectors.toList());
|
|
|
|
+ while (true) {
|
|
|
|
+ if (CollectionUtil.isNotEmpty(childIdList)) {
|
|
|
|
+ childIdList.stream().forEach(childId->{
|
|
|
|
+ ids.add(childId);
|
|
|
|
+ });
|
|
|
|
+ List<String> childIdS = this.list(new QueryWrapper<CwWorkClientBase>().lambda().in(CwWorkClientBase::getOneUpCompany, childIdList)).stream().map(CwWorkClientBase::getId).collect(Collectors.toList());
|
|
|
|
+ if (CollectionUtil.isNotEmpty(childIdS)) {
|
|
|
|
+ childIdList = childIdS;
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ List<String> lastIdList = ids.stream().distinct().collect(Collectors.toList());
|
|
|
|
+ if (CollectionUtil.isNotEmpty(lastIdList)){
|
|
|
|
+ queryWrapper.in("cw_wcb.id",lastIdList);
|
|
|
|
+ } else {
|
|
|
|
+ return new Page<>();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(cwWorkClientBaseDTO.getStatus())) {
|
|
|
|
+ queryWrapper.eq("cw_wcb.status",cwWorkClientBaseDTO.getStatus());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return cwWorkClientBaseMapper.findList(page, queryWrapper);
|
|
|
|
+ }
|
|
|
|
+
|
|
public CwWorkClientBaseDTO queryById(String id) {
|
|
public CwWorkClientBaseDTO queryById(String id) {
|
|
|
|
|
|
CwWorkClientBaseDTO cwWorkClientBaseDTO = cwWorkClientBaseMapper.queryById(id);
|
|
CwWorkClientBaseDTO cwWorkClientBaseDTO = cwWorkClientBaseMapper.queryById(id);
|