lyh
2025-04-17 990ad5f6db0bb3ad5a3795e77c5d6f3971c12ff3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package org.jeecg.modules.dnc.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.ListUtils;
import org.jeecg.modules.dnc.entity.WorkStepDepartment;
import org.jeecg.modules.dnc.mapper.WorkStepDepartmentMapper;
import org.jeecg.modules.dnc.service.IWorkStepDepartmentService;
import org.jeecg.modules.system.entity.MdcProduction;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
@Service
public class WorkStepDepartmentService extends ServiceImpl<WorkStepDepartmentMapper, WorkStepDepartment> implements IWorkStepDepartmentService {
 
    @Override
    public boolean deleteByStepId(String stepId) {
        return false;
    }
 
    @Override
    public List<MdcProduction> getDepartPermsByStepId(String stepId) {
        return super.getBaseMapper().getDepartPermsByStepId(stepId);
    }
 
    @Override
    public List<MdcProduction> getDepartNonPermsByStepId(String stepId) {
        return super.getBaseMapper().getDepartNonPermsByStepId(stepId);
    }
 
    @Override
    public boolean removeByCollection(List<WorkStepDepartment> workStepDepartmentList) {
        if(workStepDepartmentList == null || workStepDepartmentList.isEmpty())
            return false;
        if(workStepDepartmentList.size() == 1)
            return super.removeById(workStepDepartmentList.get(0).getId());
        List<String> ids = new ArrayList<>();
        workStepDepartmentList.forEach(item -> {
            ids.add(item.getId());
        });
        if(ids.size() > 1000){
            List<List<String>> idsArr = ListUtils.partition(ids, 1000);
            for(List<String> arr : idsArr){
                super.removeByIds(arr);
            }
            return true;
        }else {
            return super.removeByIds(ids);
        }
    }
 
    @Override
    public WorkStepDepartment getByStepIdAndDepartId(String stepId, String departId) {
        return null;
    }
 
    /**
     * 查询一组部门权限
     * @param stepIds
     * @param departIds
     * @return
     */
    public List<WorkStepDepartment> getByPartsIdsAndDepartIds(List<String> stepIds, List<String> departIds){
        if(stepIds == null || stepIds.isEmpty() || departIds == null || departIds.isEmpty())
            return null;
        List<WorkStepDepartment> total = new ArrayList<>();
        List<List<String>> stepListArr;
        List<List<String>> departListArr;
        if(stepIds.size() > 1000){
            stepListArr = ListUtils.partition(stepIds, 100);
        }else {
            stepListArr = ListUtils.partition(stepIds, 1000);
        }
        if(departIds.size() > 1000){
            departListArr = ListUtils.partition(departIds, 100);
        }else {
            departListArr = ListUtils.partition(departIds, 1000);
        }
        for(List<String> stringList : stepListArr) {
            for(List<String> departList : departListArr){
                LambdaQueryWrapper<WorkStepDepartment> queryWrapper = Wrappers.lambdaQuery();
                queryWrapper.in(WorkStepDepartment::getStepId, stringList);
                queryWrapper.in(WorkStepDepartment::getDepartId, departList);
                List<WorkStepDepartment> list = super.list(queryWrapper);
                if(list != null && !list.isEmpty()){
                    total.addAll(list);
                }
            }
        }
        return total;
    }
}