| | |
| | | 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.AuditStatusDTO; |
| | | import com.ruoyi.system.dto.ExperimentDispatchSignDTO; |
| | | import com.ruoyi.system.dto.TExperimentDispatchDTO; |
| | | import com.ruoyi.system.dto.UpAndDownDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.model.TExperimentDispatch; |
| | | import com.ruoyi.system.model.TExperimentDispatchGroup; |
| | | import com.ruoyi.system.model.TExperimentDispatchParticipants; |
| | | import com.ruoyi.system.model.TExperimentDispatchTask; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TExperimentDispatchQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.TExperimentDispatchVO; |
| | |
| | | */ |
| | | @Api(tags = "实验调度管理") |
| | | @RestController |
| | | @RequestMapping("/t-experiment-dispatch") |
| | | @RequestMapping("") |
| | | public class TExperimentDispatchController { |
| | | |
| | | private final TExperimentDispatchService experimentDispatchService; |
| | |
| | | private final TExperimentDispatchGroupService experimentDispatchGroupService; |
| | | private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService; |
| | | private final TExperimentDispatchTaskService experimentDispatchTaskService; |
| | | private final TProjectTeamService projectTeamService; |
| | | private final TProjectTeamStaffService projectTeamStaffService; |
| | | private final TProjectProposalService projectProposalService; |
| | | @Autowired |
| | | public TExperimentDispatchController(TExperimentDispatchService experimentDispatchService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TExperimentDispatchGroupService experimentDispatchGroupService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TExperimentDispatchTaskService experimentDispatchTaskService) { |
| | | public TExperimentDispatchController(TExperimentDispatchService experimentDispatchService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TExperimentDispatchGroupService experimentDispatchGroupService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TExperimentDispatchTaskService experimentDispatchTaskService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TProjectProposalService projectProposalService) { |
| | | this.experimentDispatchService = experimentDispatchService; |
| | | this.tokenService = tokenService; |
| | | this.sysUserService = sysUserService; |
| | |
| | | this.experimentDispatchGroupService = experimentDispatchGroupService; |
| | | this.experimentDispatchParticipantsService = experimentDispatchParticipantsService; |
| | | this.experimentDispatchTaskService = experimentDispatchTaskService; |
| | | this.projectTeamService = projectTeamService; |
| | | this.projectTeamStaffService = projectTeamStaffService; |
| | | this.projectProposalService = projectProposalService; |
| | | } |
| | | |
| | | /** |
| | | * 获取实验调度管理列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:experimentDispatch:list')") |
| | | @ApiOperation(value = "获取实验调度分页列表") |
| | | //@PreAuthorize("@ss.hasPermi('system:experimentDispatch:list')") |
| | | @ApiOperation(value = "获取实验调度分页列表",response = TExperimentDispatchQuery.class) |
| | | @PostMapping(value = "/api/t-experiment-dispatch/pageList") |
| | | public R<PageInfo<TExperimentDispatchVO>> pageList(@RequestBody String param) { |
| | | TExperimentDispatchQuery query = JSON.parseObject(param, TExperimentDispatchQuery.class); |
| | |
| | | /** |
| | | * 添加实验调度管理 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:experimentDispatch:add')") |
| | | //@PreAuthorize("@ss.hasPermi('system:experimentDispatch:add')") |
| | | @Log(title = "实验调度信息-新增实验调度", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加实验调度",response = TExperimentDispatchDTO.class) |
| | | @PostMapping(value = "/api/t-experiment-dispatch/add") |
| | | public R<Boolean> add(@RequestBody String param) { |
| | | TExperimentDispatchDTO dto = JSON.parseObject(param,TExperimentDispatchDTO.class); |
| | | // TODO 生成实验调度编号 |
| | | // 通过当前用户查询项目组 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(projectTeamStaff)){ |
| | | return R.fail("当前用户未分配项目组,无法创建项目课题方案"); |
| | | } |
| | | // 查询项目组 |
| | | TProjectTeam projectTeam = projectTeamService.getById(projectTeamStaff.getTeamId()); |
| | | if(Objects.isNull(projectTeam)){ |
| | | return R.fail("项目组不存在"); |
| | | } |
| | | if(projectTeam.getStatus() == 2){ |
| | | return R.fail("项目组已封存,无法创建项目课题方案"); |
| | | } |
| | | |
| | | // 生成实验调度编号 |
| | | String experimentCode = projectTeam.getTeamName() + "-EX"; |
| | | |
| | | // 查询上个项目课题方案的序号 |
| | | long count = experimentDispatchService.count(Wrappers.lambdaQuery(TExperimentDispatch.class) |
| | | .like(TExperimentDispatch::getExperimentCode, experimentCode)); |
| | | experimentCode = experimentCode + String.format("%03d", count+1);; |
| | | dto.setExperimentCode(experimentCode); |
| | | |
| | | experimentDispatchService.save(dto); |
| | | // 添加实验分组 |
| | | List<TExperimentDispatchGroup> experimentDispatchGroups = dto.getExperimentDispatchGroups(); |
| | |
| | | /** |
| | | * 修改实验调度 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:experimentDispatch:edit')") |
| | | //@PreAuthorize("@ss.hasPermi('system:experimentDispatch:edit')") |
| | | @Log(title = "实验调度信息-修改实验调度", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改实验调度") |
| | | @PostMapping(value = "/api/t-experiment-dispatch/update") |
| | |
| | | /** |
| | | * 查看实验调度详情 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:experimentDispatch:detail')") |
| | | //@PreAuthorize("@ss.hasPermi('system:experimentDispatch:detail')") |
| | | @ApiOperation(value = "查看实验调度详情") |
| | | @GetMapping(value = "/open/t-experiment-dispatch/getDetailById") |
| | | public R<TExperimentDispatchVO> getDetailById(@RequestParam String id) { |
| | |
| | | TExperimentDispatchVO experimentDispatchVO = new TExperimentDispatchVO(); |
| | | BeanUtils.copyProperties(experimentDispatch, experimentDispatchVO); |
| | | |
| | | // 查询项目课题 |
| | | TProjectProposal proposal = projectProposalService.getById(experimentDispatch.getProposalId()); |
| | | if(Objects.nonNull(proposal)){ |
| | | experimentDispatchVO.setProjectName(proposal.getProjectName()); |
| | | experimentDispatchVO.setProjectCode(proposal.getProjectCode()); |
| | | experimentDispatchVO.setProjectStage(proposal.getProjectStage()); |
| | | } |
| | | // 查询组别 |
| | | experimentDispatchVO.setExperimentDispatchGroups(experimentDispatchGroupService.list(Wrappers.lambdaQuery(TExperimentDispatchGroup.class).eq(TExperimentDispatchGroup::getDispatchId, id))); |
| | | // 查询参与人员 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询化验师的通过签字的实验调度 |
| | | */ |
| | | @ApiOperation(value = "查询化验师的通过签字的实验调度") |
| | | @GetMapping(value = "/open/t-experiment-dispatch/chemistSignList") |
| | | public R<List<TExperimentDispatch>> chemistSignList() { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if(roleType != 4){ |
| | | return R.fail("您不是化验师,无法查看"); |
| | | } |
| | | List<TExperimentDispatchParticipants> experimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getRoleType, roleType) |
| | | .eq(TExperimentDispatchParticipants::getUserId, userId) |
| | | .eq(TExperimentDispatchParticipants::getStatus, 2)); |
| | | if(CollectionUtils.isEmpty(experimentDispatchParticipants)){ |
| | | return R.fail("您没有通过签字的实验调度"); |
| | | } |
| | | List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); |
| | | List<TExperimentDispatch> experimentDispatches = experimentDispatchService.list(Wrappers.lambdaQuery(TExperimentDispatch.class) |
| | | .in(TExperimentDispatch::getId, dispatchIds) |
| | | .in(TExperimentDispatch::getStatus, 1, 2)); |
| | | List<String> proposalIds = experimentDispatches.stream().map(TExperimentDispatch::getProposalId).collect(Collectors.toList()); |
| | | List<TProjectProposal> list = projectProposalService.list(Wrappers.lambdaQuery(TProjectProposal.class).in(TProjectProposal::getId, proposalIds)); |
| | | |
| | | // 查询参与人员 |
| | | List<String> ids = experimentDispatches.stream().map(TExperimentDispatch::getId).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(ids)){ |
| | | List<TExperimentDispatchParticipants> tExperimentDispatchParticipants = experimentDispatchParticipantsService.list(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()); |
| | | } |
| | | }); |
| | | experimentDispatches.forEach(experimentDispatch -> { |
| | | list.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); |
| | | }); |
| | | } |
| | | |
| | | return R.ok(experimentDispatches); |
| | | } |
| | | |
| | | /** |
| | | * 删除实验调度 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:experimentDispatch:delete')") |
| | | //@PreAuthorize("@ss.hasPermi('system:experimentDispatch:delete')") |
| | | @Log(title = "实验调度信息-删除实验调度", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除实验调度") |
| | | @DeleteMapping(value = "/open/t-experiment-dispatch/deleteById") |
| | |
| | | /** |
| | | * 批量删除实验调度 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:experimentDispatch:delete')") |
| | | //@PreAuthorize("@ss.hasPermi('system:experimentDispatch:delete')") |
| | | @Log(title = "实验调度信息-删除实验调度", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除实验调度") |
| | | @DeleteMapping(value = "/api/t-experiment-dispatch/deleteByIds") |
| | | @DeleteMapping(value = "/open/t-experiment-dispatch/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | // 删除组别 |
| | | experimentDispatchGroupService.remove(Wrappers.lambdaQuery(TExperimentDispatchGroup.class).in(TExperimentDispatchGroup::getDispatchId, ids)); |
| | |
| | | return R.ok(experimentDispatchService.removeByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除实验调度 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:experimentDispatch:sign')") |
| | | @Log(title = "实验调度信息-实验调度签字", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "实验调度签字",response = ExperimentDispatchSignDTO.class) |
| | | @PostMapping(value = "/api/t-experiment-dispatch/sign") |
| | | public R<Boolean> sign(@RequestBody String param) { |
| | | ExperimentDispatchSignDTO experimentDispatchSign = JSON.parseObject(param, ExperimentDispatchSignDTO.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | TExperimentDispatchParticipants experimentDispatchParticipants = experimentDispatchParticipantsService.getOne(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getDispatchId, experimentDispatchSign.getDispatchId()) |
| | | .eq(TExperimentDispatchParticipants::getRoleType, roleType) |
| | | .eq(TExperimentDispatchParticipants::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | if(experimentDispatchParticipants != null){ |
| | | experimentDispatchParticipants.setStatus(2); |
| | | experimentDispatchParticipants.setSignTime(LocalDateTime.now()); |
| | | experimentDispatchParticipants.setConfirmSign(experimentDispatchSign.getConfirmSign()); |
| | | experimentDispatchParticipantsService.updateById(experimentDispatchParticipants); |
| | | } |
| | | long count = experimentDispatchParticipantsService.count(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getDispatchId, experimentDispatchSign.getDispatchId()) |
| | | .in(TExperimentDispatchParticipants::getRoleType, 4, 5) |
| | | .eq(TExperimentDispatchParticipants::getStatus, 1)); |
| | | if(count == 0){ |
| | | TExperimentDispatch tExperimentDispatch = experimentDispatchService.getById(experimentDispatchSign.getDispatchId()); |
| | | tExperimentDispatch.setStatus(2); |
| | | experimentDispatchService.updateById(tExperimentDispatch); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |