|
@@ -1,5 +1,6 @@
|
|
|
package com.jeeplus.test.cw.reimbursementApproval.approvalType.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -15,14 +16,13 @@ import com.jeeplus.test.cw.reimbursementApproval.approvalType.domain.CwReimburse
|
|
|
import com.jeeplus.test.cw.reimbursementApproval.approvalType.domain.OfficeDomain;
|
|
|
import com.jeeplus.test.cw.reimbursementApproval.approvalType.mapper.CwReimbursementTypeMapper;
|
|
|
import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientContact;
|
|
|
+import com.jeeplus.test.materialManagement.materialType.domain.MaterialTypeInfo;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author: 王强
|
|
@@ -36,17 +36,67 @@ public class CwReimbursementTypeService {
|
|
|
|
|
|
public List<CwReimbursementTypeInfo> bxList2(CwReimbursementTypeInfo info) {
|
|
|
LambdaQueryWrapper<CwReimbursementTypeInfo> wrapper = new LambdaQueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(info.getName())) {
|
|
|
- wrapper.like(CwReimbursementTypeInfo::getName, info.getName());
|
|
|
+ if(StringUtils.isNotBlank(info.getName())){
|
|
|
+ //根据type模糊查询
|
|
|
+ List<CwReimbursementTypeInfo> cwReimbursementTypeInfoList = mapper.selectList(new QueryWrapper<CwReimbursementTypeInfo>().lambda()
|
|
|
+ .like(StringUtils.isNotBlank(info.getName()), CwReimbursementTypeInfo::getName, info.getName())
|
|
|
+ );
|
|
|
+ List<String> collect = cwReimbursementTypeInfoList.stream().map(CwReimbursementTypeInfo::getId).collect(Collectors.toList());
|
|
|
+ //materialTypeInfoList的父级id全部获取
|
|
|
+ List<String> cupIdList = cwReimbursementTypeInfoList.stream().map(CwReimbursementTypeInfo::getParentId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
|
|
|
+ //获取materialTypeInfoList的父级id的父级id
|
|
|
+ List<String> cupIdPList = new ArrayList<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(cupIdList)) {
|
|
|
+ cupIdList.stream().forEach(item -> {
|
|
|
+ CwReimbursementTypeInfo byId = mapper.selectById(item);
|
|
|
+ if (ObjectUtil.isNotEmpty(byId)) {
|
|
|
+ if (StringUtils.isNotBlank(byId.getParentId())) {
|
|
|
+ cupIdPList.add(byId.getParentId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //获取collect的下级id
|
|
|
+ List<String> childIdList = new ArrayList<>();
|
|
|
+ collect.stream().forEach(item -> {
|
|
|
+ List<CwReimbursementTypeInfo> list = mapper.selectList(new LambdaQueryWrapper<CwReimbursementTypeInfo>().eq(CwReimbursementTypeInfo::getParentId, item));
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ List<String> collect1 = list.stream().map(CwReimbursementTypeInfo::getId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(collect1)) {
|
|
|
+ childIdList.addAll(collect1);
|
|
|
+ //获取collect的下级的下级的id
|
|
|
+ collect1.stream().forEach(i -> {
|
|
|
+ List<CwReimbursementTypeInfo> l = mapper.selectList(new LambdaQueryWrapper<CwReimbursementTypeInfo>().eq(CwReimbursementTypeInfo::getParentId, i));
|
|
|
+ if (CollectionUtil.isNotEmpty(l)) {
|
|
|
+ List<String> collect2 = l.stream().map(CwReimbursementTypeInfo::getId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(collect2)) {
|
|
|
+ childIdList.addAll(collect2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //将获取到的这几个id集合融合到一起并去重,然后根据id查询,即可得到结果
|
|
|
+ collect.addAll(cupIdList);
|
|
|
+ collect.addAll(cupIdPList);
|
|
|
+ collect.addAll(childIdList);
|
|
|
+
|
|
|
+ List<String> idList = collect.stream().distinct().collect(Collectors.toList());
|
|
|
+ if(CollectionUtil.isNotEmpty(idList)){
|
|
|
+ wrapper.in(CwReimbursementTypeInfo::getId,idList);
|
|
|
+ }else{
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
}
|
|
|
if (ObjectUtil.isNotEmpty(info)) {
|
|
|
if (StringUtils.isNotBlank(info.getLike())){
|
|
|
wrapper.likeRight(CwReimbursementTypeInfo::getSort,info.getLike());
|
|
|
}
|
|
|
}
|
|
|
- if (info.getSort() != null) {
|
|
|
- wrapper.like(CwReimbursementTypeInfo::getSort, info.getSort());
|
|
|
- }
|
|
|
+// if (info.getSort() != null) {
|
|
|
+// wrapper.like(CwReimbursementTypeInfo::getSort, info.getSort());
|
|
|
+// }
|
|
|
|
|
|
wrapper.eq(BaseEntity::getDelFlag, 0);
|
|
|
wrapper.orderByAsc(CwReimbursementTypeInfo::getSort);
|
|
@@ -76,11 +126,58 @@ public class CwReimbursementTypeService {
|
|
|
|
|
|
public List<CwReimbursementTypeInfo> list(CwReimbursementTypeInfo info) {
|
|
|
QueryWrapper<CwReimbursementTypeInfo> wrapper = new QueryWrapper<>();
|
|
|
- if (StringUtils.isNotEmpty(info.getName())) {
|
|
|
- wrapper.like("a.name", info.getName());
|
|
|
- }
|
|
|
- if (info.getSort() != null) {
|
|
|
- wrapper.like("a.sort", info.getSort());
|
|
|
+ if(StringUtils.isNotBlank(info.getName())){
|
|
|
+ //根据type模糊查询
|
|
|
+ List<CwReimbursementTypeInfo> cwReimbursementTypeInfoList = mapper.selectList(new QueryWrapper<CwReimbursementTypeInfo>().lambda()
|
|
|
+ .like(StringUtils.isNotBlank(info.getName()), CwReimbursementTypeInfo::getName, info.getName())
|
|
|
+ );
|
|
|
+ List<String> collect = cwReimbursementTypeInfoList.stream().map(CwReimbursementTypeInfo::getId).collect(Collectors.toList());
|
|
|
+ //materialTypeInfoList的父级id全部获取
|
|
|
+ List<String> cupIdList = cwReimbursementTypeInfoList.stream().map(CwReimbursementTypeInfo::getParentId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
|
|
|
+ //获取materialTypeInfoList的父级id的父级id
|
|
|
+ List<String> cupIdPList = new ArrayList<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(cupIdList)) {
|
|
|
+ cupIdList.stream().forEach(item -> {
|
|
|
+ CwReimbursementTypeInfo byId = mapper.selectById(item);
|
|
|
+ if (ObjectUtil.isNotEmpty(byId)) {
|
|
|
+ if (StringUtils.isNotBlank(byId.getParentId())) {
|
|
|
+ cupIdPList.add(byId.getParentId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //获取collect的下级id
|
|
|
+ List<String> childIdList = new ArrayList<>();
|
|
|
+ collect.stream().forEach(item -> {
|
|
|
+ List<CwReimbursementTypeInfo> list = mapper.selectList(new LambdaQueryWrapper<CwReimbursementTypeInfo>().eq(CwReimbursementTypeInfo::getParentId, item));
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ List<String> collect1 = list.stream().map(CwReimbursementTypeInfo::getId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(collect1)) {
|
|
|
+ childIdList.addAll(collect1);
|
|
|
+ //获取collect的下级的下级的id
|
|
|
+ collect1.stream().forEach(i -> {
|
|
|
+ List<CwReimbursementTypeInfo> l = mapper.selectList(new LambdaQueryWrapper<CwReimbursementTypeInfo>().eq(CwReimbursementTypeInfo::getParentId, i));
|
|
|
+ if (CollectionUtil.isNotEmpty(l)) {
|
|
|
+ List<String> collect2 = l.stream().map(CwReimbursementTypeInfo::getId).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(collect2)) {
|
|
|
+ childIdList.addAll(collect2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //将获取到的这几个id集合融合到一起并去重,然后根据id查询,即可得到结果
|
|
|
+ collect.addAll(cupIdList);
|
|
|
+ collect.addAll(cupIdPList);
|
|
|
+ collect.addAll(childIdList);
|
|
|
+
|
|
|
+ List<String> idList = collect.stream().distinct().collect(Collectors.toList());
|
|
|
+ if(CollectionUtil.isNotEmpty(idList)){
|
|
|
+ wrapper.in("a.id",idList);
|
|
|
+ }else{
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
}
|
|
|
// wrapper.eq(CwReimbursementTypeInfo::getBusinessType, "1");
|
|
|
|