| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.ApplicationTerminationAuditDTO; |
| | | import com.ruoyi.system.dto.ApplicationTerminationDTO; |
| | |
| | | // 获取当前用户 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | query.setRoleType(roleType); |
| | | if (roleType != 1){ |
| | | query.setUserId(userId); |
| | | if(roleType ==2){ |
| | | // 查询项目组 |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId)); |
| | | if(Objects.isNull(projectTeamStaff)){ |
| | | return R.fail("当前用户未加入项目组,无法进行操作"); |
| | | } |
| | | // 查询项目的工艺工程师id |
| | | TProjectTeamStaff teamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getTeamId, projectTeamStaff.getTeamId()) |
| | |
| | | // 获取当前用户 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | query.setRoleType(roleType); |
| | | if (roleType != 1){ |
| | | query.setUserId(userId); |
| | | // 查询实验参与人员 |
| | | List<TExperimentDispatchParticipants> experimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getUserId, userId)); |
| | | if(!CollectionUtils.isEmpty(experimentDispatchParticipants)){ |
| | | List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); |
| | | query.setDispatchIds(dispatchIds); |
| | | if(roleType ==2){ |
| | | // 查询项目组 |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId)); |
| | | if(Objects.isNull(projectTeamStaff)){ |
| | | return R.fail("当前用户未加入项目组,无法进行操作"); |
| | | } |
| | | // 查询项目的工艺工程师id |
| | | TProjectTeamStaff teamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getTeamId, projectTeamStaff.getTeamId()) |
| | | .eq(TProjectTeamStaff::getRoleType, 3) |
| | | .last("LIMIT 1")); |
| | | // 查询实验参与人员 |
| | | List<TExperimentDispatchParticipants> experimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getUserId, teamStaff.getUserId())); |
| | | if(!CollectionUtils.isEmpty(experimentDispatchParticipants)){ |
| | | List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); |
| | | query.setDispatchIds(dispatchIds); |
| | | } |
| | | }else { |
| | | // 查询实验参与人员 |
| | | List<TExperimentDispatchParticipants> experimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getUserId, userId)); |
| | | if(!CollectionUtils.isEmpty(experimentDispatchParticipants)){ |
| | | List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); |
| | | query.setDispatchIds(dispatchIds); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(experimentSchemeService.auditPageList(query)); |
| | |
| | | @PostMapping(value = "/api/t-experiment-scheme/update") |
| | | public R<Boolean> update(@RequestBody String param) { |
| | | TExperimentSchemeDTO dto = JSON.parseObject(param,TExperimentSchemeDTO.class); |
| | | |
| | | if (SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | dto.setStatus(null); |
| | | } |
| | | |
| | | experimentSchemeService.updateById(dto); |
| | | experimentSchemePersonService.remove(Wrappers.lambdaQuery(TExperimentSchemePerson.class).eq(TExperimentSchemePerson::getSchemeId,dto.getId())); |
| | | List<TExperimentSchemePerson> experimentSchemePersons = dto.getExperimentSchemePersons(); |
| | | experimentSchemePersons.forEach(experimentSchemePerson -> { |
| | | experimentSchemePerson.setSchemeId(dto.getId()); |
| | | experimentSchemePerson.setCommitTime(LocalDateTime.now()); |
| | | }); |
| | | experimentSchemePersonService.saveBatch(experimentSchemePersons); |
| | | if (experimentSchemePersons != null) { |
| | | experimentSchemePersons.forEach(experimentSchemePerson -> { |
| | | experimentSchemePerson.setSchemeId(dto.getId()); |
| | | experimentSchemePerson.setCommitTime(LocalDateTime.now()); |
| | | }); |
| | | experimentSchemePersonService.saveBatch(experimentSchemePersons); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @PostMapping(value = "/api/t-experiment-scheme/updateTester") |
| | | public R<Boolean> updateTester(@RequestBody String param) { |
| | | TExperimentSchemeDTO dto = JSON.parseObject(param,TExperimentSchemeDTO.class); |
| | | dto.setStatus(6); |
| | | experimentSchemeService.updateById(dto); |
| | | |
| | | // 通过当前用户查询项目组 |
| | |
| | | List<TExperimentSchemePerson> experimentSchemePersons = experimentSchemePersonService.list(Wrappers.lambdaQuery(TExperimentSchemePerson.class) |
| | | .eq(TExperimentSchemePerson::getSchemeId, id)); |
| | | List<Long> userIds = experimentSchemePersons.stream().map(TExperimentSchemePerson::getUserId).collect(Collectors.toList()); |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); |
| | | sysUsers.forEach(sysUser -> { |
| | | experimentSchemePersons.stream().filter(experimentSchemePerson -> experimentSchemePerson.getUserId().equals(sysUser.getUserId())).forEach(experimentSchemePerson -> { |
| | | experimentSchemePerson.setNickName(sysUser.getNickName()); |
| | | experimentSchemePerson.setAvatar(sysUser.getAvatar()); |
| | | |
| | | if (!userIds.isEmpty()) { |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); |
| | | sysUsers.forEach(sysUser -> { |
| | | experimentSchemePersons.stream().filter(experimentSchemePerson -> experimentSchemePerson.getUserId().equals(sysUser.getUserId())).forEach(experimentSchemePerson -> { |
| | | experimentSchemePerson.setNickName(sysUser.getNickName()); |
| | | experimentSchemePerson.setAvatar(sysUser.getAvatar()); |
| | | }); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | experimentSchemeVO.setExperimentSchemePersons(experimentSchemePersons); |
| | | // 查询实验调度信息 |
| | | TExperimentDispatch experimentDispatch = experimentDispatchService.getById(experimentSchemeVO.getDispatchId()); |