| | |
| | | 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.uuid.IdUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.ExperimentDispatchSignDTO; |
| | | import com.ruoyi.system.dto.TExperimentDispatchDTO; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private final TProjectTeamService projectTeamService; |
| | | private final TProjectTeamStaffService projectTeamStaffService; |
| | | private final TProjectProposalService projectProposalService; |
| | | private final TNoticeService noticeService; |
| | | @Autowired |
| | | public TExperimentDispatchController(TExperimentDispatchService experimentDispatchService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TExperimentDispatchGroupService experimentDispatchGroupService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TExperimentDispatchTaskService experimentDispatchTaskService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TProjectProposalService projectProposalService) { |
| | | public TExperimentDispatchController(TExperimentDispatchService experimentDispatchService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TExperimentDispatchGroupService experimentDispatchGroupService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TExperimentDispatchTaskService experimentDispatchTaskService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TProjectProposalService projectProposalService, TNoticeService noticeService) { |
| | | this.experimentDispatchService = experimentDispatchService; |
| | | this.tokenService = tokenService; |
| | | this.sysUserService = sysUserService; |
| | |
| | | this.projectTeamService = projectTeamService; |
| | | this.projectTeamStaffService = projectTeamStaffService; |
| | | this.projectProposalService = projectProposalService; |
| | | this.noticeService = noticeService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping(value = "/api/t-experiment-dispatch/pageList") |
| | | public R<PageInfo<TExperimentDispatchVO>> pageList(@RequestBody String param) { |
| | | TExperimentDispatchQuery query = JSON.parseObject(param, TExperimentDispatchQuery.class); |
| | | // 获取当前用户 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if (roleType != 1){ |
| | | query.setUserId(userId); |
| | | 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(!CollectionUtils.isEmpty(experimentDispatchParticipants)){ |
| | | List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); |
| | | query.setDispatchIds(dispatchIds); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(experimentDispatchService.pageList(query)); |
| | | } |
| | | |
| | |
| | | experimentDispatchTask.setDispatchId(dto.getId()); |
| | | }); |
| | | experimentDispatchTaskService.saveBatch(experimentDispatchTasks); |
| | | |
| | | // MESSAGE 添加消息 |
| | | experimentDispatchParticipants.stream().filter(e->e.getRoleType().equals(4)).forEach(teamStaff -> { |
| | | noticeService.saveNotice(teamStaff.getUserId(), "您有【1】条【实验调度】等待确认", tokenService.getLoginUser().getUser().getNickName(),11); |
| | | }); |
| | | experimentDispatchParticipants.stream().filter(e->e.getRoleType().equals(5)).forEach(teamStaff -> { |
| | | noticeService.saveNotice(teamStaff.getUserId(), "您有【1】条【实验调度】等待确认", tokenService.getLoginUser().getUser().getNickName(),14); |
| | | }); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |