| | |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.mapper.TExperimentDispatchMapper; |
| | | import com.ruoyi.system.mapper.TExperimentDispatchParticipantsMapper; |
| | | import com.ruoyi.system.mapper.TProjectProposalMapper; |
| | | import com.ruoyi.system.model.TExperimentDispatch; |
| | | import com.ruoyi.system.model.TExperimentDispatchParticipants; |
| | | import com.ruoyi.system.model.TProjectTeamStaff; |
| | | import com.ruoyi.system.model.TProjectProposal; |
| | | 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.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private TExperimentDispatchParticipantsMapper experimentDispatchParticipantsMapper; |
| | | @Autowired |
| | | private TProjectProposalMapper projectProposalMapper; |
| | | @Autowired |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | @Override |
| | | public PageInfo<TExperimentDispatchVO> pageList(TExperimentDispatchQuery query) { |
| | | PageInfo<TExperimentDispatchVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | // 查询自己已通过的实验调度 |
| | | if(Objects.nonNull(query.getOtherStatus())){ |
| | | List<TExperimentDispatchParticipants> experimentDispatchParticipants1 = experimentDispatchParticipantsMapper.selectList(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getUserId, query.getUserId()) |
| | | .eq(TExperimentDispatchParticipants::getStatus, query.getOtherStatus())); |
| | | if(!CollectionUtils.isEmpty(experimentDispatchParticipants1)){ |
| | | List<String> dispatchIdList = experimentDispatchParticipants1.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); |
| | | query.setDispatchIdList(dispatchIdList); |
| | | }else{ |
| | | return pageInfo; |
| | | } |
| | | } |
| | | List<TExperimentDispatchVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | // 查询参与人员 |
| | | List<String> ids = list.stream().map(TExperimentDispatchVO::getId).collect(Collectors.toList()); |
| | |
| | | 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); |
| | | experimentDispatchParticipants.stream().filter(e->e.getUserId().equals(query.getUserId()) && e.getDispatchId().equals(tExperimentDispatchVO.getId())).findFirst().ifPresent(tExperimentDispatchParticipant -> { |
| | | tExperimentDispatchVO.setOtherStatus(tExperimentDispatchParticipant.getStatus()); |
| | | }); |
| | | } |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<TExperimentDispatch> chemistSignList(TExperimentDispatchQuery query) { |
| | | PageInfo<TExperimentDispatch> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TExperimentDispatch> list = this.baseMapper.chemistSignList(query,pageInfo); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return pageInfo; |
| | | } |
| | | // 查询参与人员 |
| | | List<String> ids = list.stream().map(TExperimentDispatch::getId).collect(Collectors.toList()); |
| | | List<String> proposalIds = list.stream().map(TExperimentDispatch::getProposalId).collect(Collectors.toList()); |
| | | List<TProjectProposal> projectProposals = projectProposalMapper.selectList(Wrappers.lambdaQuery(TProjectProposal.class).in(TProjectProposal::getId, proposalIds)); |
| | | |
| | | 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()); |
| | | } |
| | | }); |
| | | list.forEach(experimentDispatch -> { |
| | | projectProposals.stream().filter(projectProposal -> projectProposal.getId().equals(experimentDispatch.getProposalId())).findFirst().ifPresent(projectProposal -> { |
| | | experimentDispatch.setProjectName(projectProposal.getProjectName()); |
| | | }); |
| | | List<TExperimentDispatchParticipants> experimentDispatchParticipantsList = tExperimentDispatchParticipants.stream().filter(tExperimentDispatchParticipant -> tExperimentDispatchParticipant.getDispatchId().equals(experimentDispatch.getId())).collect(Collectors.toList()); |
| | | String participantsName = experimentDispatchParticipantsList.stream().map(TExperimentDispatchParticipants::getNickName).collect(Collectors.joining(";")); |
| | | experimentDispatch.setParticipantsName(participantsName); |
| | | }); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | } |