¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.ProcessSpecVersionDepartment; |
| | | import org.jeecg.modules.dnc.mapper.ProcessSpecVersionDepartmentMapper; |
| | | import org.jeecg.modules.dnc.service.IProcessSpecVersionDepartmentService; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class ProcessSpecVersionDepartmentServiceImpl extends ServiceImpl<ProcessSpecVersionDepartmentMapper, ProcessSpecVersionDepartment> implements IProcessSpecVersionDepartmentService { |
| | | |
| | | /** |
| | | * æ ¹æ®å·¥èºè§ç¨çæ¬idå é¤é¨é¨æé |
| | | * @param psvId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean deleteByPsvId(String psvId) { |
| | | if(!ValidateUtil.validateString(psvId)) |
| | | return false; |
| | | LambdaQueryWrapper<ProcessSpecVersionDepartment> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
| | | lambdaQueryWrapper.eq(ProcessSpecVersionDepartment::getPsvId, psvId); |
| | | return super.remove(lambdaQueryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * è·åå·²åé
çé¨é¨ |
| | | * @param psvId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcProduction> getDepartPermsByPsvId(String psvId){ |
| | | return super.baseMapper.getDepartPermsByPsvId(psvId); |
| | | } |
| | | |
| | | /** |
| | | * è·åå·²åé
çé¨é¨ |
| | | * @param psvId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcProduction> getDepartNonPermsByPsvId(String psvId){ |
| | | return super.baseMapper.getDepartNonPermsByPsvId(psvId); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢é¨é¨æé |
| | | * @param psvId |
| | | * @param departId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ProcessSpecVersionDepartment getByProcessSpecVersionIdAndDepartId(String psvId, String departId){ |
| | | if(!ValidateUtil.validateString(psvId) || !ValidateUtil.validateString(psvId)) |
| | | return null; |
| | | List<ProcessSpecVersionDepartment> list = super.lambdaQuery().eq(ProcessSpecVersionDepartment::getPsvId, psvId).eq(ProcessSpecVersionDepartment::getDepartId, departId).list(); |
| | | if(list == null || list.isEmpty()) |
| | | return null; |
| | | return list.get(0); |
| | | } |
| | | |
| | | /** |
| | | * ç§»é¤é¨é¨æé |
| | | * @param processSpecVersionDepartments |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean removeByCollection(List<ProcessSpecVersionDepartment> processSpecVersionDepartments){ |
| | | if(processSpecVersionDepartments == null || processSpecVersionDepartments.isEmpty()) |
| | | return false; |
| | | if(processSpecVersionDepartments.size() == 1) |
| | | return super.removeById(processSpecVersionDepartments.get(0).getId()); |
| | | List<String> ids = new ArrayList<>(); |
| | | processSpecVersionDepartments.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); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸ç»é¨é¨æé |
| | | * @param psvIds |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ProcessSpecVersionDepartment> getByPsvIdsAndDepartIds(List<String> psvIds, List<String> ids){ |
| | | if(psvIds == null || psvIds.isEmpty() || ids == null || ids.isEmpty()) |
| | | return null; |
| | | List<ProcessSpecVersionDepartment> total = new ArrayList<>(); |
| | | List<List<String>> compListArr; |
| | | List<List<String>> departListArr; |
| | | if(psvIds.size() > 1000){ |
| | | compListArr = ListUtils.partition(psvIds, 100); |
| | | }else { |
| | | compListArr = ListUtils.partition(psvIds, 1000); |
| | | } |
| | | if(ids.size() > 1000){ |
| | | departListArr = ListUtils.partition(ids, 100); |
| | | }else { |
| | | departListArr = ListUtils.partition(ids, 1000); |
| | | } |
| | | for(List<String> compList : compListArr) { |
| | | for(List<String> departList : departListArr){ |
| | | LambdaQueryWrapper<ProcessSpecVersionDepartment> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.in(ProcessSpecVersionDepartment::getPsvId, compList); |
| | | queryWrapper.in(ProcessSpecVersionDepartment::getDepartId, departList); |
| | | List<ProcessSpecVersionDepartment> list = super.list(queryWrapper); |
| | | if(list != null && !list.isEmpty()){ |
| | | total.addAll(list); |
| | | } |
| | | } |
| | | } |
| | | return total; |
| | | } |
| | | } |