| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.mapper.TExperimentDispatchParticipantsMapper; |
| | | import com.ruoyi.system.mapper.TSamplingRecordMapper; |
| | | import com.ruoyi.system.mapper.TSamplingRecordOperationMapper; |
| | | import com.ruoyi.system.model.TExperimentDispatchParticipants; |
| | | import com.ruoyi.system.model.TSamplingRecord; |
| | | import com.ruoyi.system.model.TSamplingRecordOperation; |
| | | import com.ruoyi.system.query.TSamplingRecordQuery; |
| | | import com.ruoyi.system.service.TSamplingRecordService; |
| | | import com.ruoyi.system.vo.SysOperLogVO; |
| | | import com.ruoyi.system.vo.TSamplingRecordVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TSamplingRecordServiceImpl extends ServiceImpl<TSamplingRecordMapper, TSamplingRecord> implements TSamplingRecordService { |
| | | |
| | | @Autowired |
| | | private TSamplingRecordOperationMapper samplingRecordOperationMapper; |
| | | @Autowired |
| | | private TExperimentDispatchParticipantsMapper experimentDispatchParticipantsMapper; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Override |
| | | public PageInfo<TSamplingRecordVO> pageList(TSamplingRecordQuery query) { |
| | | PageInfo<TSamplingRecordVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TSamplingRecordVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return pageInfo; |
| | | } |
| | | |
| | | List<String> recordIds = list.stream().map(TSamplingRecordVO::getId).collect(Collectors.toList()); |
| | | List<TSamplingRecordOperation> recordOperationList = samplingRecordOperationMapper.selectList(Wrappers.lambdaQuery(TSamplingRecordOperation.class) |
| | | .in(TSamplingRecordOperation::getSamplingId, recordIds)); |
| | | |
| | | list.forEach(item->{ |
| | | item.setSendCount(recordOperationList.stream().filter(recordOperation -> recordOperation.getSamplingId().equals(item.getId()) && recordOperation.getStatus() == 1).count()); |
| | | item.setReceiveCount(recordOperationList.stream().filter(recordOperation -> recordOperation.getSamplingId().equals(item.getId()) && recordOperation.getStatus() == 2).count()); |
| | | item.setReceivedCount(recordOperationList.stream().filter(recordOperation -> recordOperation.getSamplingId().equals(item.getId()) && recordOperation.getStatus() == 3).count()); |
| | | }); |
| | | |
| | | // 查询实验调度参与实验员 |
| | | List<String> dispatchIds = list.stream().map(TSamplingRecordVO::getDispatchId).collect(Collectors.toList()); |
| | | List<TExperimentDispatchParticipants> teamStaffs = experimentDispatchParticipantsMapper.selectList(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .in(TExperimentDispatchParticipants::getDispatchId, dispatchIds) |
| | | .eq(TExperimentDispatchParticipants::getRoleType, 5)); |
| | | List<Long> userIds = teamStaffs.stream().map(TExperimentDispatchParticipants::getUserId).collect(Collectors.toList()); |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); |
| | | teamStaffs.stream().forEach(teamStaff -> { |
| | | sysUsers.stream().filter(sysUser -> sysUser.getUserId().equals(teamStaff.getUserId())).findFirst().ifPresent(sysUser -> { |
| | | teamStaff.setNickName(sysUser.getNickName()); |
| | | }); |
| | | }); |
| | | |
| | | for (TSamplingRecordVO tSamplingRecordVO : list) { |
| | | List<TExperimentDispatchParticipants> experimentDispatchParticipants = teamStaffs.stream().filter(teamStaff -> teamStaff.getDispatchId().equals(tSamplingRecordVO.getDispatchId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(experimentDispatchParticipants)){ |
| | | tSamplingRecordVO.setTesterNames(experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getNickName).collect(Collectors.joining(","))); |
| | | } |
| | | } |
| | | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |