| | |
| | | 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.TExperimentDispatchMapper; |
| | | import com.ruoyi.system.mapper.TExperimentDispatchParticipantsMapper; |
| | | import com.ruoyi.system.model.TExperimentDispatch; |
| | | import com.ruoyi.system.model.TExperimentDispatchParticipants; |
| | | import com.ruoyi.system.model.TProjectTeamStaff; |
| | | import com.ruoyi.system.query.TExperimentDispatchQuery; |
| | | import com.ruoyi.system.service.TExperimentDispatchService; |
| | | import com.ruoyi.system.vo.TExperimentDispatchVO; |
| | | import com.ruoyi.system.vo.TProjectTeamVO; |
| | | 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 TExperimentDispatchServiceImpl extends ServiceImpl<TExperimentDispatchMapper, TExperimentDispatch> implements TExperimentDispatchService { |
| | | |
| | | @Autowired |
| | | private TExperimentDispatchParticipantsMapper experimentDispatchParticipantsMapper; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Override |
| | | public PageInfo<TExperimentDispatchVO> pageList(TExperimentDispatchQuery query) { |
| | | PageInfo<TExperimentDispatchVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TExperimentDispatchVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | // 查询参与人员 |
| | | List<String> ids = list.stream().map(TExperimentDispatchVO::getId).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(ids)){ |
| | | List<TExperimentDispatchParticipants> tExperimentDispatchParticipants = experimentDispatchParticipantsMapper.selectList(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .in(TExperimentDispatchParticipants::getDispatchId, ids)); |
| | | List<Long> userIds = tExperimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getUserId).collect(Collectors.toList()); |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); |
| | | tExperimentDispatchParticipants.forEach(tExperimentDispatchParticipant -> { |
| | | SysUser sysUser = sysUsers.stream().filter(user -> user.getUserId().equals(tExperimentDispatchParticipant.getUserId())).findFirst().orElse(null); |
| | | if(sysUser != null){ |
| | | tExperimentDispatchParticipant.setNickName(sysUser.getNickName()); |
| | | } |
| | | }); |
| | | for (TExperimentDispatchVO tExperimentDispatchVO : list) { |
| | | List<TExperimentDispatchParticipants> experimentDispatchParticipants = tExperimentDispatchParticipants.stream().filter(tExperimentDispatchParticipant -> tExperimentDispatchParticipant.getDispatchId().equals(tExperimentDispatchVO.getId())).collect(Collectors.toList()); |
| | | String participantsName = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getNickName).collect(Collectors.joining(";")); |
| | | tExperimentDispatchVO.setParticipantsName(participantsName); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | } |