Browse Source

离职审批添加撤回功能

lizhenhao 2 years atrás
parent
commit
9a53bbb213

+ 63 - 4
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/changes/dimission/controller/ChangesDimissionController.java

@@ -1,5 +1,6 @@
 package com.jeeplus.test.changes.dimission.controller;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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.service.RosterBaseService;
 import io.swagger.annotations.Api;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -36,6 +39,25 @@ public class ChangesDimissionController {
     @Resource
     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
@@ -51,10 +73,47 @@ public class ChangesDimissionController {
         QueryWrapper<ChangesDimission> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( changesDimission, ChangesDimission.class );
         if(ObjectUtil.isNotEmpty(changesDimissionDTO)){
             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);
+                    }
                 }
             }
         }

+ 1 - 15
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/changes/dimission/service/ChangesDimissionHandoverService.java

@@ -49,21 +49,7 @@ public class ChangesDimissionHandoverService extends ServiceImpl<ChangesDimissio
 
         if(ObjectUtil.isNotEmpty(changesDimissionHandoverDTO)){
             if(StringUtils.isNotBlank(changesDimissionHandoverDTO.getCdId())){
-                if(CollectionUtil.isNotEmpty(changesDimissionHandoverDTO.getHandoverDTOList())){
-                    List<String> ids  = changesDimissionHandoverDTO.getHandoverDTOList().stream().distinct().filter(item -> {
-                        if (StringUtils.isNotBlank(item.getId())) {
-                            return true;
-                        }
-                        return false;
-                    }).map(ChangesDimissionHandoverDTO::getId).collect(Collectors.toList());
-                    if(CollectionUtil.isNotEmpty(ids)){
-                        this.remove(new QueryWrapper<ChangesDimissionHandover>().lambda()
-                                .eq(ChangesDimissionHandover::getCdId,changesDimissionHandoverDTO.getCdId())
-                                .notIn(ChangesDimissionHandover::getId,ids));
-                    }else{
-                        this.remove(new QueryWrapper<ChangesDimissionHandover>().lambda().eq(ChangesDimissionHandover::getCdId,changesDimissionHandoverDTO.getCdId()));
-                    }
-                }
+                this.remove(new QueryWrapper<ChangesDimissionHandover>().lambda().eq(ChangesDimissionHandover::getCdId,changesDimissionHandoverDTO.getCdId()));
             }
             if(CollectionUtil.isNotEmpty(changesDimissionHandoverDTO.getHandoverDTOList())){
                 List<ChangesDimissionHandover> changesDimissionHandoverList = new ArrayList<>();