| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Override |
| | | public PageInfo<TSamplingRecordVO> pageList(TSamplingRecordQuery query) { |
| | | List<TSamplingRecordVO> res = new ArrayList<>(); |
| | | PageInfo<TSamplingRecordVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | if(CollectionUtils.isEmpty(query.getDispatchIds())){ |
| | | return pageInfo; |
| | | } |
| | | List<TSamplingRecordVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | List<TSamplingRecordOperation> samplingRecordOperations = samplingRecordOperationMapper.selectList(null); |
| | | List<TSamplingRecordVO> list = this.baseMapper.pageList(query); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return pageInfo; |
| | | } |
| | | |
| | | for (TSamplingRecordVO tSamplingRecordVO : list) { |
| | | if (query.getRoleType()==5){ |
| | | if (tSamplingRecordVO.getStatus()==2){ |
| | | List<TSamplingRecordOperation> samplingRecordOperationsIds = samplingRecordOperations.stream().filter(e -> e.getSamplingId().equals(tSamplingRecordVO.getId())).collect(Collectors.toList()); |
| | | // 如果samplingRecordOperationsIds的状态全部都为3 |
| | | if(!samplingRecordOperationsIds.stream().allMatch(e -> e.getStatus() == 3)){ |
| | | res.add(tSamplingRecordVO); |
| | | } |
| | | } |
| | | }else{ |
| | | res.add(tSamplingRecordVO); |
| | | } |
| | | } |
| | | List<String> recordIds = list.stream().map(TSamplingRecordVO::getId).collect(Collectors.toList()); |
| | | List<TSamplingRecordOperation> recordOperationList = samplingRecordOperationMapper.selectList(Wrappers.lambdaQuery(TSamplingRecordOperation.class) |
| | | .in(TSamplingRecordOperation::getSamplingId, recordIds)); |
| | |
| | | tSamplingRecordVO.setTesterNames(experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getNickName).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | |
| | | pageInfo.setRecords(list); |
| | | // 手动对res进行分页 |
| | | res = res.stream().skip((long) (query.getPageNum() - 1) * query.getPageSize()).limit(query.getPageSize()).collect(Collectors.toList()); |
| | | pageInfo.setTotal(res.size()); |
| | | pageInfo.setRecords(res); |
| | | return pageInfo; |
| | | } |
| | | } |