| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if(roleType != 1){ |
| | | if(roleType ==2){ |
| | | // 查询项目组 |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId)); |
| | | // 查询项目的工艺工程师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(experimentDispatchParticipants.size() > 0){ |
| | | if (!CollectionUtils.isEmpty(experimentDispatchParticipants)) { |
| | | // 查询项目组id |
| | | List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); |
| | | query.setDispatchIds(dispatchIds); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(experimentResultReportService.pageList(query)); |
| | |
| | | @PostMapping(value = "/api/t-experiment-result-report/add") |
| | | public R<Boolean> add(@RequestBody String param) { |
| | | TExperimentResultReportDTO dto = JSON.parseObject(param,TExperimentResultReportDTO.class); |
| | | // 判断是否已存在实验结果 |
| | | Long count = experimentResultReportService.count(Wrappers.lambdaQuery(TExperimentResultReport.class) |
| | | .eq(TExperimentResultReport::getDispatchId, dto.getDispatchId())); |
| | | if(count > 0){ |
| | | return R.fail("已存在实验结果汇报"); |
| | | } |
| | | experimentResultReportService.save(dto); |
| | | // 获取当前用户的项目组id |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId)); |
| | | // 添加实验结果工作评价 |
| | | List<TResultWorkEvaluate> resultWorkEvaluates = dto.getResultWorkEvaluates(); |
| | | for (TResultWorkEvaluate resultWorkEvaluate : resultWorkEvaluates) { |
| | | resultWorkEvaluate.setResultReportId(dto.getId()); |
| | | resultWorkEvaluate.setTeamId(projectTeamStaff.getTeamId()); |
| | | } |
| | | resultWorkEvaluateService.saveBatch(resultWorkEvaluates); |
| | | resultWorkEvaluateService.saveOrUpdateBatch(resultWorkEvaluates); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); |
| | | String participantsName = sysUsers.stream().map(SysUser::getNickName).collect(Collectors.joining(";")); |
| | | experimentDispatchVO.setParticipantsName(participantsName); |
| | | // 设置nickName |
| | | experimentDispatchParticipants.forEach(tExperimentDispatchParticipant -> { |
| | | SysUser sysUser = sysUsers.stream().filter(user -> user.getUserId().equals(tExperimentDispatchParticipant.getUserId())).findFirst().orElse(null); |
| | | if(sysUser != null){ |
| | | tExperimentDispatchParticipant.setNickName(sysUser.getNickName()); |
| | | tExperimentDispatchParticipant.setAvatar(sysUser.getAvatar()); |
| | | } |
| | | }); |
| | | experimentResultReportVO.setExperimentDispatchVO(experimentDispatchVO); |
| | | return R.ok(experimentResultReportVO); |
| | | } |