From 0c989fbcca1cd4b53d59e8ba288227a5a68d92a4 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期五, 27 六月 2025 18:08:25 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/laboratory --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTestMethodConfirmSheetController.java | 194 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 167 insertions(+), 27 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 cbc001b..b1c7cbc 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,30 +8,27 @@ 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; import com.ruoyi.system.mapper.SysUserMapper; -import com.ruoyi.system.model.TTestMethodConfirmSheet; -import com.ruoyi.system.model.TTestMethodConfirmSheetOriginal; -import com.ruoyi.system.model.TTestMethodConfirmSheetTerm; +import com.ruoyi.system.model.*; import com.ruoyi.system.query.TTestMethodConfirmSheetQuery; -import com.ruoyi.system.service.ISysUserService; -import com.ruoyi.system.service.TTestMethodConfirmSheetOriginalService; -import com.ruoyi.system.service.TTestMethodConfirmSheetService; -import com.ruoyi.system.service.TTestMethodConfirmSheetTermService; +import com.ruoyi.system.service.*; import com.ruoyi.system.vo.TTestMethodConfirmSheetVO; 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.text.SimpleDateFormat; import java.time.LocalDateTime; -import java.util.ArrayList; +import java.util.Date; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -52,36 +49,117 @@ private final SysUserMapper sysUserMapper; private final TTestMethodConfirmSheetTermService testMethodConfirmSheetTermService; private final TTestMethodConfirmSheetOriginalService testMethodConfirmSheetOriginalService; + private final TProjectTeamService projectTeamService; + private final TProjectTeamStaffService projectTeamStaffService; + private final TExperimentDispatchService experimentDispatchService; + private final TProjectProposalService projectProposalService; + private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService; + private final TNoticeService noticeService; @Autowired - public TTestMethodConfirmSheetController(TTestMethodConfirmSheetService testMethodConfirmSheetService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TTestMethodConfirmSheetTermService testMethodConfirmSheetTermService, TTestMethodConfirmSheetOriginalService testMethodConfirmSheetOriginalService) { + public TTestMethodConfirmSheetController(TTestMethodConfirmSheetService testMethodConfirmSheetService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TTestMethodConfirmSheetTermService testMethodConfirmSheetTermService, TTestMethodConfirmSheetOriginalService testMethodConfirmSheetOriginalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TNoticeService noticeService) { this.testMethodConfirmSheetService = testMethodConfirmSheetService; this.tokenService = tokenService; this.sysUserService = sysUserService; this.sysUserMapper = sysUserMapper; this.testMethodConfirmSheetTermService = testMethodConfirmSheetTermService; this.testMethodConfirmSheetOriginalService = testMethodConfirmSheetOriginalService; + this.projectTeamService = projectTeamService; + this.projectTeamStaffService = projectTeamStaffService; + this.experimentDispatchService = experimentDispatchService; + this.projectProposalService = projectProposalService; + this.experimentDispatchParticipantsService = experimentDispatchParticipantsService; + this.noticeService = noticeService; } /** * 获取检验方法确认单管理列表 */ - @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:list')") - @ApiOperation(value = "获取检验方法确认单分页列表") + //@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(); + query.setRoleType(roleType); + 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") public R<Boolean> add(@RequestBody String param) { TTestMethodConfirmSheetDTO dto = JSON.parseObject(param,TTestMethodConfirmSheetDTO.class); + Long userId = tokenService.getLoginUser().getUserId(); + + TExperimentDispatch experimentDispatch = experimentDispatchService.getOne(Wrappers.lambdaQuery(TExperimentDispatch.class) + .eq(TExperimentDispatch::getId, dto.getDispatchId())); + if(Objects.isNull(experimentDispatch)){ + return R.fail("实验调度不存在"); + } + + // 查询调度的参与人员 + TExperimentDispatchParticipants experimentDispatchParticipant = experimentDispatchParticipantsService.getOne(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) + .eq(TExperimentDispatchParticipants::getDispatchId, dto.getDispatchId()) + .eq(TExperimentDispatchParticipants::getRoleType,3) + .last("LIMIT 1")); + if(Objects.isNull(experimentDispatchParticipant)){ + return R.fail("实验调度参与人员不存在"); + } + + // 查询工艺工程师所在的项目组 + TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) + .eq(TProjectTeamStaff::getUserId, experimentDispatchParticipant.getUserId()) + .eq(TProjectTeamStaff::getRoleType, 3) + .last("LIMIT 1")); + + // 通过当前用户查询项目组 + if(Objects.isNull(projectTeamStaff)){ + return R.fail("当前用户未分配项目组,无法创建项目课题方案"); + } + // 查询项目组 + TProjectTeam projectTeam = projectTeamService.getById(projectTeamStaff.getTeamId()); + if(Objects.isNull(projectTeam)){ + return R.fail("项目组不存在"); + } + if(projectTeam.getStatus() == 2){ + return R.fail("项目组已封存,无法创建项目课题方案"); + } + + dto.setCommitUserId(userId); testMethodConfirmSheetService.save(dto); List<TTestMethodConfirmSheetTerm> testMethodConfirmSheetTerms = dto.getTestMethodConfirmSheetTerms(); testMethodConfirmSheetTerms.forEach(testMethodConfirmSheetTerm -> { @@ -89,24 +167,38 @@ testMethodConfirmSheetTerm.setStatus(1); }); testMethodConfirmSheetTermService.saveBatch(testMethodConfirmSheetTerms); - List<TTestMethodConfirmSheetOriginal> testMethodConfirmSheetOriginals = new ArrayList<>(); + // 生成原始记录编号 + String format = new SimpleDateFormat("yyyyMMdd").format(new Date()); + String originalCode = projectTeam.getTeamName() + format.substring(2) + "-JL"; for (TTestMethodConfirmSheetTerm testMethodConfirmSheetTerm : testMethodConfirmSheetTerms) { // 添加原始记录 TTestMethodConfirmSheetOriginal testMethodConfirmSheetOriginal = new TTestMethodConfirmSheetOriginal(); testMethodConfirmSheetOriginal.setTermId(testMethodConfirmSheetTerm.getId()); - // TODO 生成原始记录编号 - testMethodConfirmSheetOriginal.setOriginalCode(""); + // 查询上个项目课题方案的序号 + long count = testMethodConfirmSheetOriginalService.count(Wrappers.lambdaQuery(TTestMethodConfirmSheetOriginal.class) + .like(TTestMethodConfirmSheetOriginal::getOriginalCode, originalCode)); + originalCode = originalCode + String.format("%02d", count+1); + testMethodConfirmSheetOriginal.setOriginalCode(originalCode); testMethodConfirmSheetOriginal.setStatus(1); - testMethodConfirmSheetOriginals.add(testMethodConfirmSheetOriginal); + testMethodConfirmSheetOriginalService.save(testMethodConfirmSheetOriginal); } - testMethodConfirmSheetOriginalService.saveBatch(testMethodConfirmSheetOriginals); + + // MESSAGE 添加消息 + TProjectTeamStaff teamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) + .eq(TProjectTeamStaff::getTeamId, projectTeam.getId()) + .eq(TProjectTeamStaff::getRoleType, 3) + .last("LIMIT 1")); + if(Objects.nonNull(teamStaff)){ + noticeService.saveNotice(teamStaff.getUserId(), "您有【1】条【检验方法确认单】等待审批", tokenService.getLoginUser().getUser().getNickName(),6); + } + return R.ok(); } /** * 修改检验方法确认单 */ - @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") @@ -126,7 +218,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) { @@ -139,13 +231,42 @@ .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()); + testMethodConfirmSheetVO.setExperimentStartTime(experimentDispatch.getExperimentStartTime()); + testMethodConfirmSheetVO.setExperimentEndTime(experimentDispatch.getExperimentEndTime()); + testMethodConfirmSheetVO.setExperimentDate(experimentDispatch.getExperimentDate()); + // 查询项目课题方案 + TProjectProposal projectProposal = projectProposalService.getById(experimentDispatch.getProposalId()); + if(Objects.nonNull(projectProposal)){ + testMethodConfirmSheetVO.setProjectName(projectProposal.getProjectName()); + } + // 查询参与人员 + List<TExperimentDispatchParticipants> tExperimentDispatchParticipants = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) + .eq(TExperimentDispatchParticipants::getDispatchId, experimentDispatch.getId())); + List<Long> userIds = tExperimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getUserId).distinct().collect(Collectors.toList()); + List<SysUser> sysUsers = sysUserMapper.selectUserByIds(userIds); + String participantsName = sysUsers.stream().map(SysUser::getNickName).collect(Collectors.joining(";")); + testMethodConfirmSheetVO.setParticipantsName(participantsName); + testMethodConfirmSheetVO.setStatus(experimentDispatch.getStatus()); + } + + // 查询审核人姓名 + 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") @@ -158,7 +279,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") @@ -171,19 +292,38 @@ /** * 批量删除检验方法确认单 */ - @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())); + + // MESSAGE 添加消息 + TTestMethodConfirmSheet testMethodConfirmSheet = testMethodConfirmSheetService.getById(testMethodConfirmSheetSign.getTestMethodConfirmSheetId()); + noticeService.saveNotice(testMethodConfirmSheet.getCommitUserId(), "您的【检验方案确认单】已被确认", tokenService.getLoginUser().getUser().getNickName(),12); + + 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