¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |