From 1a2e22a27627b40689257442cc5a46598c634f8e Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期五, 23 五月 2025 14:16:28 +0800 Subject: [PATCH] 测评接口完成,添加数据权限 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInspectionReportController.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 49 insertions(+), 4 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInspectionReportController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInspectionReportController.java index 48647b2..eaecd3c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInspectionReportController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInspectionReportController.java @@ -2,25 +2,31 @@ 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.TInspectionReportDTO; +import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.model.TExperimentDispatch; +import com.ruoyi.system.model.TExperimentDispatchParticipants; import com.ruoyi.system.model.TInspectionReport; +import com.ruoyi.system.model.TProjectProposal; import com.ruoyi.system.query.TInspectionReportQuery; -import com.ruoyi.system.service.ISysUserService; -import com.ruoyi.system.service.TInspectionReportService; +import com.ruoyi.system.service.*; import com.ruoyi.system.vo.TInspectionReportVO; import io.swagger.annotations.Api; 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.*; import java.util.List; +import java.util.stream.Collectors; /** * <p> @@ -36,13 +42,21 @@ public class TInspectionReportController { private final TInspectionReportService inspectionReportService; + private final TExperimentDispatchService experimentDispatchService; + private final TProjectProposalService projectProposalService; + private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService; private final TokenService tokenService; private final ISysUserService sysUserService; + private final SysUserMapper sysUserMapper; @Autowired - public TInspectionReportController(TInspectionReportService inspectionReportService, TokenService tokenService, ISysUserService sysUserService) { + public TInspectionReportController(TInspectionReportService inspectionReportService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper) { this.inspectionReportService = inspectionReportService; + this.experimentDispatchService = experimentDispatchService; + this.projectProposalService = projectProposalService; + this.experimentDispatchParticipantsService = experimentDispatchParticipantsService; this.tokenService = tokenService; this.sysUserService = sysUserService; + this.sysUserMapper = sysUserMapper; } /** @@ -92,6 +106,22 @@ TInspectionReport inspectionReport = inspectionReportService.getById(id); TInspectionReportVO inspectionReportVO = new TInspectionReportVO(); BeanUtils.copyProperties(inspectionReport, inspectionReportVO); + // 查询实验调度 + TExperimentDispatch experimentDispatch = experimentDispatchService.getById(inspectionReportVO.getDispatchId()); + // 查询项目课题 + TProjectProposal projectProposal = projectProposalService.getById(experimentDispatch.getProposalId()); + experimentDispatch.setProjectName(projectProposal.getProjectName()); + // 查询实验调度人员 + List<TExperimentDispatchParticipants> experimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) + .eq(TExperimentDispatchParticipants::getDispatchId, inspectionReportVO.getDispatchId())); + // 将参与人员名字拼接 + List<Long> userIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getUserId).distinct().collect(Collectors.toList()); + List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); + if(!CollectionUtils.isEmpty(sysUsers)){ + String nickNames = sysUsers.stream().map(SysUser::getNickName).collect(Collectors.joining(",")); + experimentDispatch.setParticipantsName(nickNames); + } + inspectionReportVO.setExperimentDispatch(experimentDispatch); return R.ok(inspectionReportVO); } @@ -117,5 +147,20 @@ return R.ok(inspectionReportService.removeByIds(ids)); } + /** + * 提交检验报告 + */ + //@PreAuthorize("@ss.hasPermi('system:inspectionReport:commit')") + @Log(title = "检验报告信息-提交检验报告", businessType = BusinessType.UPDATE) + @ApiOperation(value = "提交检验报告") + @PutMapping(value = "/open/t-inspection-report/commit") + public R<Boolean> commit(@RequestParam(value = "id") String id) { + // 修改状态为已提交 + TInspectionReport inspectionReport = inspectionReportService.getById(id); + inspectionReport.setStatus(2); + inspectionReportService.updateById(inspectionReport); + return R.ok(); + } + } -- Gitblit v1.7.1