| | |
| | | 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.SecurityUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.ApplicationTerminationAuditDTO; |
| | | import com.ruoyi.system.dto.ApplicationTerminationDTO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | |
| | | public R<Boolean> update(@RequestBody String param) { |
| | | TExperimentSchemeDTO dto = JSON.parseObject(param,TExperimentSchemeDTO.class); |
| | | |
| | | if (SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | if (Objects.equals(tokenService.getLoginUser().getUser().getRoleType(), 1)){ |
| | | dto.setStatus(null); |
| | | } |
| | | |
| | |
| | | @PostMapping(value = "/api/t-experiment-scheme/applicationTermination") |
| | | public R<Boolean> applicationTermination(@RequestBody String param) { |
| | | ApplicationTerminationDTO applicationTerminationDTO = JSON.parseObject(param, ApplicationTerminationDTO.class); |
| | | TExperimentScheme currentScheme = experimentSchemeService.getById(applicationTerminationDTO.getId()); |
| | | if (Objects.isNull(currentScheme)) { |
| | | return R.fail("实验方案不存在"); |
| | | } |
| | | Integer oldStatus = currentScheme.getOldStatus(); |
| | | if (!Arrays.asList(2, 3, 4).contains(currentScheme.getStatus())) { |
| | | oldStatus = currentScheme.getStatus(); |
| | | } |
| | | experimentSchemeService.update(Wrappers.lambdaUpdate(TExperimentScheme.class) |
| | | .eq(TExperimentScheme::getId, applicationTerminationDTO.getId()) |
| | | .set(TExperimentScheme::getStatus, 2) |
| | | .set(TExperimentScheme::getOldStatus, oldStatus) |
| | | .set(TExperimentScheme::getStopReason, applicationTerminationDTO.getStopReason()) |
| | | .set(TExperimentScheme::getStopFile, applicationTerminationDTO.getStopFile()) |
| | | .set(TExperimentScheme::getStopFileName, applicationTerminationDTO.getStopFileName()) |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Log(title = "实验方案信息-删除中止申请", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除中止申请(保留实验方案)") |
| | | @DeleteMapping(value = "/open/t-experiment-scheme/deleteTerminationApplication") |
| | | public R<Boolean> deleteTerminationApplication(@RequestParam String id) { |
| | | if (tokenService.getLoginUser().getUser().getRoleType() != 1) { |
| | | return R.fail("仅管理员可以删除中止申请"); |
| | | } |
| | | TExperimentScheme scheme = experimentSchemeService.getById(id); |
| | | if (Objects.isNull(scheme)) { |
| | | return R.fail("实验方案不存在"); |
| | | } |
| | | if (!Arrays.asList(2, 3).contains(scheme.getStatus())) { |
| | | return R.fail("仅待审核或已通过的实验中止审批可以删除"); |
| | | } |
| | | Integer restoredStatus = scheme.getOldStatus() == null ? 6 : scheme.getOldStatus(); |
| | | return R.ok(experimentSchemeService.update(Wrappers.lambdaUpdate(TExperimentScheme.class) |
| | | .eq(TExperimentScheme::getId, id) |
| | | .set(TExperimentScheme::getStatus, restoredStatus) |
| | | .set(TExperimentScheme::getStopReason, null) |
| | | .set(TExperimentScheme::getStopFile, null) |
| | | .set(TExperimentScheme::getStopFileName, null) |
| | | .set(TExperimentScheme::getCommitSign, null) |
| | | .set(TExperimentScheme::getAuditPersonId, null) |
| | | .set(TExperimentScheme::getAuditTime, null) |
| | | .set(TExperimentScheme::getAuditRemark, null) |
| | | .set(TExperimentScheme::getOldStatus, null))); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除实验方案 |
| | | */ |