|
@@ -1,5 +1,6 @@
|
|
package com.jeeplus.test.changes.dimission.controller;
|
|
package com.jeeplus.test.changes.dimission.controller;
|
|
|
|
|
|
|
|
+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.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -17,12 +18,14 @@ import com.jeeplus.test.changes.dimission.service.mapstruct.ChangesDimissionWrap
|
|
import com.jeeplus.test.roster.domain.RosterBase;
|
|
import com.jeeplus.test.roster.domain.RosterBase;
|
|
import com.jeeplus.test.roster.service.RosterBaseService;
|
|
import com.jeeplus.test.roster.service.RosterBaseService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
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.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -36,6 +39,25 @@ public class ChangesDimissionController {
|
|
@Resource
|
|
@Resource
|
|
private RosterBaseService rosterBaseService;
|
|
private RosterBaseService rosterBaseService;
|
|
|
|
|
|
|
|
+ public List<String> getIntersection(List<String> list1,List<String> list2,List<String> list3){
|
|
|
|
+ if(list1.size()!=0 && list2.size()!=0 && list3.size()!=0){
|
|
|
|
+ List<String> intersection = (List<String>) CollectionUtils.intersection(list1, list2);
|
|
|
|
+ return (List<String>) CollectionUtils.intersection(intersection, list3);
|
|
|
|
+ }else if(list1.size()!=0 && list2.size()!=0 && list3.size()==0) {
|
|
|
|
+ return (List<String>) CollectionUtils.intersection(list1, list2);
|
|
|
|
+ }else if(list1.size()!=0 && list2.size()==0 && list3.size()!=0) {
|
|
|
|
+ return (List<String>) CollectionUtils.intersection(list1, list3);
|
|
|
|
+ }else if(list1.size()==0 && list2.size()!=0 && list3.size()!=0) {
|
|
|
|
+ return (List<String>) CollectionUtils.intersection(list2, list3);
|
|
|
|
+ }else if(list1.size()!=0 && list2.size()==0 && list3.size()==0) {
|
|
|
|
+ return list1;
|
|
|
|
+ }else if(list1.size()==0 && list2.size()!=0 && list3.size()==0) {
|
|
|
|
+ return list2;
|
|
|
|
+ }else if(list1.size()==0 && list2.size()==0 && list3.size()!=0) {
|
|
|
|
+ return list3;
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
/**
|
|
/**
|
|
* 查询离职列表
|
|
* 查询离职列表
|
|
* @param changesDimissionDTO
|
|
* @param changesDimissionDTO
|
|
@@ -51,10 +73,47 @@ public class ChangesDimissionController {
|
|
QueryWrapper<ChangesDimission> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( changesDimission, ChangesDimission.class );
|
|
QueryWrapper<ChangesDimission> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( changesDimission, ChangesDimission.class );
|
|
if(ObjectUtil.isNotEmpty(changesDimissionDTO)){
|
|
if(ObjectUtil.isNotEmpty(changesDimissionDTO)){
|
|
if(ObjectUtil.isNotEmpty(changesDimissionDTO.getRosterBaseDTO())){
|
|
if(ObjectUtil.isNotEmpty(changesDimissionDTO.getRosterBaseDTO())){
|
|
- if(StringUtils.isNotBlank(changesDimissionDTO.getRosterBaseDTO().getName())){
|
|
|
|
- List<String> collect = rosterBaseService.list(new QueryWrapper<RosterBase>().lambda().like(RosterBase::getName, changesDimissionDTO.getRosterBaseDTO().getName()))
|
|
|
|
- .stream().map(RosterBase::getId).collect(Collectors.toList());
|
|
|
|
- queryWrapper.lambda().in(ChangesDimission::getRosterId,collect);
|
|
|
|
|
|
+ if(StringUtils.isNotBlank(changesDimissionDTO.getRosterBaseDTO().getName())
|
|
|
|
+ ||StringUtils.isNotBlank(changesDimissionDTO.getRosterBaseDTO().getOfficeId())
|
|
|
|
+ ||StringUtils.isNotBlank(changesDimissionDTO.getRosterBaseDTO().getMobile())){
|
|
|
|
+ List<String> rosterIdsName = new ArrayList<>();
|
|
|
|
+ List<String> rosterIdsOfficeId = new ArrayList<>();
|
|
|
|
+ List<String> rosterIdsMobile = new ArrayList<>();
|
|
|
|
+ if(StringUtils.isNotBlank(changesDimissionDTO.getRosterBaseDTO().getName())){
|
|
|
|
+ List<String> collect = rosterBaseService.list(new QueryWrapper<RosterBase>().lambda().like(RosterBase::getName, changesDimissionDTO.getRosterBaseDTO().getName()))
|
|
|
|
+ .stream().map(RosterBase::getId).collect(Collectors.toList());
|
|
|
|
+ if(CollectionUtil.isNotEmpty(collect)) {
|
|
|
|
+ rosterIdsName.addAll(collect);
|
|
|
|
+ }else{
|
|
|
|
+ return ResponseEntity.ok(null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotBlank(changesDimissionDTO.getRosterBaseDTO().getOfficeId())){
|
|
|
|
+ List<String> collect = rosterBaseService.list(new QueryWrapper<RosterBase>().lambda().eq(RosterBase::getOfficeId, changesDimissionDTO.getRosterBaseDTO().getOfficeId()))
|
|
|
|
+ .stream().map(RosterBase::getId).collect(Collectors.toList());
|
|
|
|
+ rosterIdsOfficeId.addAll(collect);
|
|
|
|
+ if(CollectionUtil.isNotEmpty(collect)) {
|
|
|
|
+ rosterIdsOfficeId.addAll(collect);
|
|
|
|
+ }else{
|
|
|
|
+ return ResponseEntity.ok(null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotBlank(changesDimissionDTO.getRosterBaseDTO().getMobile())){
|
|
|
|
+ List<String> collect = rosterBaseService.list(new QueryWrapper<RosterBase>().lambda().like(RosterBase::getMobile, changesDimissionDTO.getRosterBaseDTO().getMobile()))
|
|
|
|
+ .stream().map(RosterBase::getId).collect(Collectors.toList());
|
|
|
|
+ rosterIdsMobile.addAll(collect);
|
|
|
|
+ if(CollectionUtil.isNotEmpty(collect)) {
|
|
|
|
+ rosterIdsMobile.addAll(collect);
|
|
|
|
+ }else{
|
|
|
|
+ return ResponseEntity.ok(null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<String> ids = getIntersection(rosterIdsName,rosterIdsOfficeId,rosterIdsMobile);
|
|
|
|
+ if(CollectionUtil.isNotEmpty(ids)){
|
|
|
|
+ queryWrapper.lambda().in(ChangesDimission::getRosterId,ids);
|
|
|
|
+ }else{
|
|
|
|
+ return ResponseEntity.ok(null);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|