| | |
| | | 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.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.ApplicationTerminationAuditDTO; |
| | | import com.ruoyi.system.dto.ApplicationTerminationDTO; |
| | | import com.ruoyi.system.dto.TExperimentSchemeDTO; |
| | | import com.ruoyi.system.dto.TestMethodConfirmSheetSignDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TExperimentSchemeQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.TExperimentSchemeVO; |
| | | 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.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Api(tags = "实验方案管理") |
| | | @RestController |
| | | @RequestMapping("/t-experiment-scheme") |
| | | @RequestMapping("") |
| | | public class TExperimentSchemeController { |
| | | |
| | | private final TExperimentSchemeService experimentSchemeService; |
| | | private final TokenService tokenService; |
| | | private final ISysUserService sysUserService; |
| | | private final SysUserMapper sysUserMapper; |
| | | private final TExperimentSchemePersonService experimentSchemePersonService; |
| | | private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService; |
| | | private final TExperimentDispatchService experimentDispatchService; |
| | | private final TProjectProposalService projectProposalService; |
| | | @Autowired |
| | | public TExperimentSchemeController(TExperimentSchemeService experimentSchemeService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TExperimentSchemePersonService experimentSchemePersonService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService) { |
| | | this.experimentSchemeService = experimentSchemeService; |
| | | this.tokenService = tokenService; |
| | | this.sysUserService = sysUserService; |
| | | this.sysUserMapper = sysUserMapper; |
| | | this.experimentSchemePersonService = experimentSchemePersonService; |
| | | this.experimentDispatchParticipantsService = experimentDispatchParticipantsService; |
| | | this.experimentDispatchService = experimentDispatchService; |
| | | this.projectProposalService = projectProposalService; |
| | | } |
| | | |
| | | /** |
| | | * 获取实验方案管理列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:list')") |
| | | @ApiOperation(value = "获取实验方案分页列表") |
| | | @PostMapping(value = "/api/t-experiment-scheme/pageList") |
| | | public R<PageInfo<TExperimentSchemeVO>> pageList(@RequestBody String param) { |
| | | TExperimentSchemeQuery query = JSON.parseObject(param, TExperimentSchemeQuery.class); |
| | | return R.ok(experimentSchemeService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 通过实验调度查询查询组别列表 |
| | | */ |
| | | @ApiOperation(value = "通过实验调度查询查询组别列表") |
| | | @GetMapping(value = "/open/t-experiment-scheme/getGroupByDispatchId") |
| | | public R<List<TExperimentDispatchParticipants>> getGroupByDispatchId(@RequestParam String dispatchId) { |
| | | List<TExperimentDispatchParticipants> list = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getDispatchId, dispatchId)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 添加实验方案管理 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:add')") |
| | | @Log(title = "实验方案信息-新增实验方案", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加实验方案",response = TExperimentSchemeDTO.class) |
| | | @PostMapping(value = "/api/t-experiment-scheme/add") |
| | | public R<Boolean> add(@RequestBody String param) { |
| | | TExperimentSchemeDTO dto = JSON.parseObject(param,TExperimentSchemeDTO.class); |
| | | experimentSchemeService.save(dto); |
| | | List<TExperimentSchemePerson> experimentSchemePersons = dto.getExperimentSchemePersons(); |
| | | experimentSchemePersons.forEach(experimentSchemePerson -> { |
| | | experimentSchemePerson.setSchemeId(dto.getId()); |
| | | experimentSchemePerson.setCommitTime(LocalDateTime.now()); |
| | | }); |
| | | experimentSchemePersonService.saveBatch(experimentSchemePersons); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改实验方案 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:edit')") |
| | | @Log(title = "实验方案信息-修改实验方案", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改实验方案") |
| | | @PostMapping(value = "/api/t-experiment-scheme/update") |
| | | public R<Boolean> update(@RequestBody String param) { |
| | | TExperimentSchemeDTO dto = JSON.parseObject(param,TExperimentSchemeDTO.class); |
| | | 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); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 查看实验方案详情 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:detail')") |
| | | @ApiOperation(value = "查看实验方案详情") |
| | | @GetMapping(value = "/open/t-experiment-scheme/getDetailById") |
| | | public R<TExperimentSchemeVO> getDetailById(@RequestParam String id) { |
| | | TExperimentScheme experimentScheme = experimentSchemeService.getById(id); |
| | | TExperimentSchemeVO experimentSchemeVO = new TExperimentSchemeVO(); |
| | | BeanUtils.copyProperties(experimentScheme, experimentSchemeVO); |
| | | |
| | | // 查询实验调度信息 |
| | | TExperimentDispatch experimentDispatch = experimentDispatchService.getById(experimentSchemeVO.getDispatchId()); |
| | | if(Objects.nonNull(experimentDispatch)){ |
| | | // 查询课题方案名称 |
| | | TProjectProposal projectProposal = projectProposalService.getById(experimentDispatch.getProposalId()); |
| | | if(Objects.nonNull(projectProposal)){ |
| | | experimentDispatch.setProjectName(projectProposal.getProjectName()); |
| | | } |
| | | } |
| | | experimentSchemeVO.setExperimentDispatch(experimentDispatch); |
| | | |
| | | // 查询组别 |
| | | List<TExperimentDispatchParticipants> list = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) |
| | | .eq(TExperimentDispatchParticipants::getDispatchId, experimentSchemeVO.getDispatchId())); |
| | | experimentSchemeVO.setExperimentDispatchParticipants(list); |
| | | |
| | | // 获取实验人员 |
| | | List<TExperimentSchemePerson> experimentSchemePersons = experimentSchemePersonService.list(Wrappers.lambdaQuery(TExperimentSchemePerson.class) |
| | | .eq(TExperimentSchemePerson::getSchemeId, id)); |
| | | experimentSchemeVO.setExperimentSchemePersons(experimentSchemePersons); |
| | | |
| | | return R.ok(experimentSchemeVO); |
| | | } |
| | | |
| | | /** |
| | | * 删除实验方案 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:delete')") |
| | | @Log(title = "实验方案信息-删除实验方案", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除实验方案") |
| | | @DeleteMapping(value = "/open/t-experiment-scheme/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | // 删除试验方案人员 |
| | | experimentSchemePersonService.remove(Wrappers.lambdaQuery(TExperimentSchemePerson.class).eq(TExperimentSchemePerson::getSchemeId, id)); |
| | | return R.ok(experimentSchemeService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除实验方案 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:delete')") |
| | | @Log(title = "实验方案信息-删除实验方案", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除实验方案") |
| | | @DeleteMapping(value = "/open/t-experiment-scheme/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | // 删除试验方案人员 |
| | | experimentSchemePersonService.remove(Wrappers.lambdaQuery(TExperimentSchemePerson.class).in(TExperimentSchemePerson::getSchemeId, ids)); |
| | | return R.ok(experimentSchemeService.removeByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除实验方案 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:sign')") |
| | | @Log(title = "实验方案信息-申请中止实验", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "申请中止实验") |
| | | @PostMapping(value = "/api/t-experiment-scheme/applicationTermination") |
| | | public R<Boolean> applicationTermination(@RequestBody String param) { |
| | | ApplicationTerminationDTO applicationTerminationDTO = JSON.parseObject(param, ApplicationTerminationDTO.class); |
| | | experimentSchemeService.update(Wrappers.lambdaUpdate(TExperimentScheme.class) |
| | | .eq(TExperimentScheme::getId, applicationTerminationDTO.getId()) |
| | | .set(TExperimentScheme::getStatus, 2) |
| | | .set(TExperimentScheme::getStopReason, applicationTerminationDTO.getStopReason()) |
| | | .set(TExperimentScheme::getStopFile, applicationTerminationDTO.getStopFile()) |
| | | .set(TExperimentScheme::getStopFileName, applicationTerminationDTO.getStopFileName()) |
| | | .set(TExperimentScheme::getCommitSign, applicationTerminationDTO.getCommitSign())); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除实验方案 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:audit')") |
| | | @Log(title = "实验方案信息-申请中止实验审核", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "申请中止实验审核") |
| | | @PostMapping(value = "/api/t-experiment-scheme/audit") |
| | | public R<Boolean> audit(@RequestBody String param) { |
| | | ApplicationTerminationAuditDTO applicationTerminationAuditDTO = JSON.parseObject(param, ApplicationTerminationAuditDTO.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | experimentSchemeService.update(Wrappers.lambdaUpdate(TExperimentScheme.class) |
| | | .eq(TExperimentScheme::getId, applicationTerminationAuditDTO.getId()) |
| | | .set(TExperimentScheme::getStatus, applicationTerminationAuditDTO.getStatus()) |
| | | .set(TExperimentScheme::getAuditRemark, applicationTerminationAuditDTO.getAuditRemark()) |
| | | .set(TExperimentScheme::getAuditPersonId, userId) |
| | | .set(TExperimentScheme::getAuditTime, LocalDateTime.now())); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |