| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.TClinicalTrialPointsDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.model.TClinicalTrialPoints; |
| | | import com.ruoyi.system.model.TProjectTeam; |
| | | import com.ruoyi.system.model.TProjectTeamStaff; |
| | | import com.ruoyi.system.query.TClinicalTrialPointsQuery; |
| | | import com.ruoyi.system.service.TClinicalTrialPointsService; |
| | | import com.ruoyi.system.service.TProjectTeamService; |
| | | import com.ruoyi.system.service.TProjectTeamStaffService; |
| | | import com.ruoyi.system.vo.TClinicalTrialPointsVO; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Api(tags = "临床试验积分") |
| | | @RestController |
| | | @RequestMapping("/t-clinical-trial-points") |
| | | @RequestMapping("") |
| | | public class TClinicalTrialPointsController { |
| | | |
| | | private final TClinicalTrialPointsService clinicalTrialPointsService; |
| | | private final TokenService tokenService; |
| | | private final TProjectTeamService projectTeamService; |
| | | private final TProjectTeamStaffService projectTeamStaffService; |
| | | private final SysUserMapper sysUserMapper; |
| | | @Autowired |
| | | public TClinicalTrialPointsController(TClinicalTrialPointsService clinicalTrialPointsService, TokenService tokenService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, SysUserMapper sysUserMapper) { |
| | | this.clinicalTrialPointsService = clinicalTrialPointsService; |
| | | this.tokenService = tokenService; |
| | | this.projectTeamService = projectTeamService; |
| | | this.projectTeamStaffService = projectTeamStaffService; |
| | | this.sysUserMapper = sysUserMapper; |
| | | } |
| | | |
| | | /** |
| | | * 获取临床试验积分列表 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:clinicalTrialPoints:list')") |
| | | @ApiOperation(value = "获取临床试验积分分页列表", response = TClinicalTrialPointsQuery.class) |
| | | @PostMapping(value = "/api/t-clinical-trial-points/pageList") |
| | | public R<PageInfo<TClinicalTrialPointsVO>> pageList(@RequestBody String param) { |
| | | TClinicalTrialPointsQuery query = JSON.parseObject(param, TClinicalTrialPointsQuery.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if(roleType != 1){ |
| | | // 查询用户所在项目组 |
| | | List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId)); |
| | | if(projectTeamStaffs.size() > 0){ |
| | | // 查询项目组id |
| | | List<String> teamIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getTeamId).distinct().collect(Collectors.toList()); |
| | | query.setTeamIds(teamIds); |
| | | } |
| | | } |
| | | return R.ok(clinicalTrialPointsService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 添加临床试验积分管理 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:clinicalTrialPoints:add')") |
| | | @Log(title = "临床试验积分信息-新增临床试验积分", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加临床试验积分",response = TClinicalTrialPointsDTO.class) |
| | | @PostMapping(value = "/api/t-clinical-trial-points/add") |
| | | public R<Boolean> add(@RequestBody String param) { |
| | | TClinicalTrialPointsDTO dto = JSON.parseObject(param,TClinicalTrialPointsDTO.class); |
| | | // 通过当前用户查询项目组 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); |
| | | if(roleType == 2){ |
| | | 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(dto.getTeamId()); |
| | | if(Objects.isNull(projectTeam)){ |
| | | return R.fail("项目组不存在"); |
| | | } |
| | | if(projectTeam.getStatus() == 2){ |
| | | return R.fail("项目组已封存,无法创建临床试验积分"); |
| | | } |
| | | // 查询项目组工艺工程师id |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getTeamId, dto.getTeamId()) |
| | | .eq(TProjectTeamStaff::getRoleType, 3) |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(projectTeamStaff)){ |
| | | return R.fail("当前项目组未分配工艺工程师,无法创建临床试验积分"); |
| | | } |
| | | dto.setProcessEngineerId(projectTeamStaff.getId()); |
| | | clinicalTrialPointsService.save(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改临床试验积分 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:clinicalTrialPoints:edit')") |
| | | @Log(title = "临床试验积分信息-修改临床试验积分", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改临床试验积分") |
| | | @PostMapping(value = "/api/t-clinical-trial-points/update") |
| | | public R<Boolean> update(@RequestBody String param) { |
| | | TClinicalTrialPointsDTO dto = JSON.parseObject(param,TClinicalTrialPointsDTO.class); |
| | | clinicalTrialPointsService.updateById(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 查看临床试验积分详情 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:clinicalTrialPoints:detail')") |
| | | @ApiOperation(value = "查看临床试验积分详情") |
| | | @GetMapping(value = "/open/t-clinical-trial-points/getDetailById") |
| | | public R<TClinicalTrialPointsVO> getDetailById(@RequestParam String id) { |
| | | TClinicalTrialPoints clinicalTrialPoints = clinicalTrialPointsService.getById(id); |
| | | TClinicalTrialPointsVO clinicalTrialPointsVO = new TClinicalTrialPointsVO(); |
| | | BeanUtils.copyProperties(clinicalTrialPoints, clinicalTrialPointsVO); |
| | | // 查询项目组 |
| | | TProjectTeam projectTeam = projectTeamService.getById(clinicalTrialPoints.getTeamId()); |
| | | // 查询项目组成员 |
| | | List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getTeamId, projectTeam.getId())); |
| | | List<Long> userIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getUserId).collect(Collectors.toList()); |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); |
| | | clinicalTrialPointsVO.setStaffNames(sysUsers.stream().map(SysUser::getNickName).collect(Collectors.joining(","))); |
| | | clinicalTrialPointsVO.setProjectTeam(projectTeam); |
| | | |
| | | return R.ok(clinicalTrialPointsVO); |
| | | } |
| | | |
| | | /** |
| | | * 删除临床试验积分 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:clinicalTrialPoints:delete')") |
| | | @Log(title = "临床试验积分信息-删除临床试验积分", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除临床试验积分") |
| | | @DeleteMapping(value = "/open/t-clinical-trial-points/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | return R.ok(clinicalTrialPointsService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除临床试验积分 |
| | | */ |
| | | //@PreAuthorize("@ss.hasPermi('system:clinicalTrialPoints:delete')") |
| | | @Log(title = "临床试验积分信息-删除临床试验积分", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除临床试验积分") |
| | | @DeleteMapping(value = "/open/t-clinical-trial-points/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | return R.ok(clinicalTrialPointsService.removeByIds(ids)); |
| | | } |
| | | |
| | | } |
| | | |