From 6ae35089a05b58dc31c243b9bb4f6a80b20c3a7b Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期五, 23 五月 2025 17:44:42 +0800 Subject: [PATCH] 修改接口 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTestMethodConfirmSheetController.java | 96 +++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 82 insertions(+), 14 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTestMethodConfirmSheetController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTestMethodConfirmSheetController.java index 680a2fe..8157d3b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTestMethodConfirmSheetController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTestMethodConfirmSheetController.java @@ -8,6 +8,7 @@ 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.enums.QATestItemReportStatusEnum; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.dto.TTestMethodConfirmSheetDTO; import com.ruoyi.system.dto.TestMethodConfirmSheetSignDTO; @@ -20,13 +21,11 @@ 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.text.SimpleDateFormat; import java.time.LocalDateTime; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Objects; @@ -52,8 +51,11 @@ private final TTestMethodConfirmSheetOriginalService testMethodConfirmSheetOriginalService; private final TProjectTeamService projectTeamService; private final TProjectTeamStaffService projectTeamStaffService; + private final TExperimentDispatchService experimentDispatchService; + private final TProjectProposalService projectProposalService; + private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService; @Autowired - public TTestMethodConfirmSheetController(TTestMethodConfirmSheetService testMethodConfirmSheetService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TTestMethodConfirmSheetTermService testMethodConfirmSheetTermService, TTestMethodConfirmSheetOriginalService testMethodConfirmSheetOriginalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService) { + public TTestMethodConfirmSheetController(TTestMethodConfirmSheetService testMethodConfirmSheetService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TTestMethodConfirmSheetTermService testMethodConfirmSheetTermService, TTestMethodConfirmSheetOriginalService testMethodConfirmSheetOriginalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService) { this.testMethodConfirmSheetService = testMethodConfirmSheetService; this.tokenService = tokenService; this.sysUserService = sysUserService; @@ -62,23 +64,57 @@ this.testMethodConfirmSheetOriginalService = testMethodConfirmSheetOriginalService; this.projectTeamService = projectTeamService; this.projectTeamStaffService = projectTeamStaffService; + this.experimentDispatchService = experimentDispatchService; + this.projectProposalService = projectProposalService; + this.experimentDispatchParticipantsService = experimentDispatchParticipantsService; } /** * 获取检验方法确认单管理列表 */ - @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:list')") + //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:list')") @ApiOperation(value = "获取检验方法确认单分页列表",response = TTestMethodConfirmSheetQuery.class) @PostMapping(value = "/api/t-test-method-confirm-sheet/pageList") public R<PageInfo<TTestMethodConfirmSheetVO>> pageList(@RequestBody String param) { TTestMethodConfirmSheetQuery query = JSON.parseObject(param, TTestMethodConfirmSheetQuery.class); + // 获取当前用户 + Long userId = tokenService.getLoginUser().getUserId(); + Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); + if (roleType != 1){ + query.setUserId(userId); + if(roleType ==2){ + // 查询项目组 + TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) + .eq(TProjectTeamStaff::getUserId, userId)); + // 查询项目的工艺工程师id + TProjectTeamStaff teamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) + .eq(TProjectTeamStaff::getTeamId, projectTeamStaff.getTeamId()) + .eq(TProjectTeamStaff::getRoleType, 3) + .last("LIMIT 1")); + // 查询实验参与人员 + List<TExperimentDispatchParticipants> experimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) + .eq(TExperimentDispatchParticipants::getUserId, teamStaff.getUserId())); + if(!CollectionUtils.isEmpty(experimentDispatchParticipants)){ + List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); + query.setDispatchIds(dispatchIds); + } + }else { + // 查询实验参与人员 + List<TExperimentDispatchParticipants> experimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) + .eq(TExperimentDispatchParticipants::getUserId, userId)); + if (!CollectionUtils.isEmpty(experimentDispatchParticipants)) { + List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); + query.setDispatchIds(dispatchIds); + } + } + } return R.ok(testMethodConfirmSheetService.pageList(query)); } /** * 添加检验方法确认单管理 */ - @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:add')") + //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:add')") @Log(title = "检验方法确认单信息-新增检验方法确认单", businessType = BusinessType.INSERT) @ApiOperation(value = "添加检验方法确认单",response = TTestMethodConfirmSheetDTO.class) @PostMapping(value = "/api/t-test-method-confirm-sheet/add") @@ -129,7 +165,7 @@ /** * 修改检验方法确认单 */ - @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:edit')") + //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:edit')") @Log(title = "检验方法确认单信息-修改检验方法确认单", businessType = BusinessType.UPDATE) @ApiOperation(value = "修改检验方法确认单") @PostMapping(value = "/api/t-test-method-confirm-sheet/update") @@ -149,7 +185,7 @@ /** * 查看检验方法确认单详情 */ - @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:detail')") + //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:detail')") @ApiOperation(value = "查看检验方法确认单详情") @GetMapping(value = "/open/t-test-method-confirm-sheet/getDetailById") public R<TTestMethodConfirmSheetVO> getDetailById(@RequestParam String id) { @@ -162,13 +198,31 @@ .eq(TTestMethodConfirmSheetTerm::getTestId, id)); testMethodConfirmSheetVO.setTestMethodConfirmSheetTerms(testMethodConfirmSheetTerms); + // 查询实验调度信息 + TExperimentDispatch experimentDispatch = experimentDispatchService.getById(testMethodConfirmSheetVO.getDispatchId()); + if(Objects.nonNull(experimentDispatch)){ + testMethodConfirmSheetVO.setExperimentName(experimentDispatch.getExperimentName()); + testMethodConfirmSheetVO.setExperimentCode(experimentDispatch.getExperimentCode()); + // 查询项目课题方案 + TProjectProposal projectProposal = projectProposalService.getById(experimentDispatch.getProposalId()); + if(Objects.nonNull(projectProposal)){ + testMethodConfirmSheetVO.setProjectName(projectProposal.getProjectName()); + } + } + + // 查询审核人姓名 + SysUser sysUser = sysUserService.selectUserById(testMethodConfirmSheet.getAuditPersonId()); + if(Objects.nonNull(sysUser)){ + testMethodConfirmSheetVO.setAuditPersonName(sysUser.getNickName()); + } + return R.ok(testMethodConfirmSheetVO); } /** * 删除检验方法确认单 */ - @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:delete')") + //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:delete')") @Log(title = "检验方法确认单信息-删除检验方法确认单", businessType = BusinessType.DELETE) @ApiOperation(value = "删除检验方法确认单") @DeleteMapping(value = "/open/t-test-method-confirm-sheet/deleteById") @@ -181,7 +235,7 @@ /** * 批量删除检验方法确认单 */ - @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:delete')") + //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:delete')") @Log(title = "检验方法确认单信息-删除检验方法确认单", businessType = BusinessType.DELETE) @ApiOperation(value = "批量删除检验方法确认单") @DeleteMapping(value = "/open/t-test-method-confirm-sheet/deleteByIds") @@ -194,19 +248,33 @@ /** * 批量删除检验方法确认单 */ - @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:sign')") + //@PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:sign')") @Log(title = "检验方法确认单信息-检验方法确认单签字", businessType = BusinessType.UPDATE) - @ApiOperation(value = "检验方法确认单签字") + @ApiOperation(value = "检验方法确认单签字",response = TestMethodConfirmSheetSignDTO.class) @PostMapping(value = "/api/t-test-method-confirm-sheet/sign") public R<Boolean> sign(@RequestBody String param) { TestMethodConfirmSheetSignDTO testMethodConfirmSheetSign = JSON.parseObject(param, TestMethodConfirmSheetSignDTO.class); Long userId = tokenService.getLoginUser().getUserId(); testMethodConfirmSheetService.update(Wrappers.lambdaUpdate(TTestMethodConfirmSheet.class) .eq(TTestMethodConfirmSheet::getId, testMethodConfirmSheetSign.getTestMethodConfirmSheetId()) - .set(TTestMethodConfirmSheet::getAuditStatus, testMethodConfirmSheetSign.getAuditStatus()) - .set(TTestMethodConfirmSheet::getSignTime, LocalDateTime.now()) + .set(TTestMethodConfirmSheet::getAuditStatus, 2) + .set(TTestMethodConfirmSheet::getAuditTime, LocalDateTime.now()) .set(TTestMethodConfirmSheet::getAuditPersonId, userId) - .set(TTestMethodConfirmSheet::getConfirmSign, testMethodConfirmSheetSign.getConfirmSign())); + .set(TTestMethodConfirmSheet::getAuditSign, testMethodConfirmSheetSign.getConfirmSign())); + return R.ok(); + } + + /** + * 撤销QA检测项报告管理 + */ + //@PreAuthorize("@ss.hasPermi('system:qaTestItemReport:revokedReport')") + @Log(title = "检验方法确认单信息-撤销检验方法确认单信息状态", businessType = BusinessType.UPDATE) + @ApiOperation(value = "撤销检验方法确认单信息状态") + @PutMapping(value = "/open/t-test-method-confirm-sheet/revokedSheet") + public R<Boolean> revokedSheet(@RequestParam String id) { + TTestMethodConfirmSheet testMethodConfirmSheet = testMethodConfirmSheetService.getById(id); + testMethodConfirmSheet.setAuditStatus(QATestItemReportStatusEnum.REVOKED.getCode()); + testMethodConfirmSheetService.updateById(testMethodConfirmSheet); return R.ok(); } } -- Gitblit v1.7.1