From 6bf77f70ff3396fc1b7050c9454225523f506b1f Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期二, 01 七月 2025 09:20:08 +0800 Subject: [PATCH] bug修改 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java | 73 +++++++++++++++++++++++++++++++++--- 1 files changed, 66 insertions(+), 7 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java index 5fb30dd..adeefcc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java @@ -27,9 +27,7 @@ import java.text.SimpleDateFormat; import java.time.LocalDateTime; -import java.util.Date; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -55,8 +53,10 @@ private final TProjectTeamService projectTeamService; private final TProjectTeamStaffService projectTeamStaffService; private final TExperimentDispatchParticipantsService experimentDispatchParticipantsService; + private final TNoticeService noticeService; + private final TInspectionReportService inspectionReportService; @Autowired - public TSamplingRecordController(TSamplingRecordService samplingRecordService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TSamplingRecordOperationService samplingRecordOperationService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService) { + public TSamplingRecordController(TSamplingRecordService samplingRecordService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TSamplingRecordOperationService samplingRecordOperationService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService, TExperimentDispatchParticipantsService experimentDispatchParticipantsService, TNoticeService noticeService, TInspectionReportService inspectionReportService) { this.samplingRecordService = samplingRecordService; this.tokenService = tokenService; this.sysUserService = sysUserService; @@ -67,6 +67,8 @@ this.projectTeamService = projectTeamService; this.projectTeamStaffService = projectTeamStaffService; this.experimentDispatchParticipantsService = experimentDispatchParticipantsService; + this.noticeService = noticeService; + this.inspectionReportService = inspectionReportService; } /** @@ -80,12 +82,16 @@ // 获取当前用户 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)); + if(Objects.isNull(projectTeamStaff)){ + return R.fail("当前用户未加入项目组,无法进行操作"); + } // 查询项目的工艺工程师id TProjectTeamStaff teamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) .eq(TProjectTeamStaff::getTeamId, projectTeamStaff.getTeamId()) @@ -105,6 +111,46 @@ if (!CollectionUtils.isEmpty(experimentDispatchParticipants)) { List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList()); query.setDispatchIds(dispatchIds); + } + } + if(roleType == 4){ + // 查询当前用户所在的项目组 + List<TProjectTeamStaff> projectTeamStaffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class) + .eq(TProjectTeamStaff::getUserId, userId)); + if (!CollectionUtils.isEmpty(projectTeamStaffs)) { + List<String> teamIds = projectTeamStaffs.stream().map(TProjectTeamStaff::getTeamId).distinct().collect(Collectors.toList()); + List<TProjectProposal> projectProposals = projectProposalService.list(Wrappers.lambdaQuery(TProjectProposal.class) + .in(TProjectProposal::getTeamId, teamIds)); + if (!CollectionUtils.isEmpty(projectProposals)) { + List<String> projectIds = projectProposals.stream().map(TProjectProposal::getId).collect(Collectors.toList()); + List<TExperimentDispatch> experimentDispatches = experimentDispatchService.list(Wrappers.lambdaQuery(TExperimentDispatch.class) + .in(TExperimentDispatch::getProposalId, projectIds)); + if (!CollectionUtils.isEmpty(experimentDispatches)) { + List<String> dispatchIds2 = experimentDispatches.stream().map(TExperimentDispatch::getId).collect(Collectors.toList()); + // 查询检验报告 + List<TInspectionReport> inspectionReports = inspectionReportService.list(Wrappers.lambdaQuery(TInspectionReport.class) + .eq(TInspectionReport::getStatus, 2) + .in(TInspectionReport::getDispatchId, dispatchIds2)); + if (!CollectionUtils.isEmpty(inspectionReports)) { + List<String> dispatchIds = inspectionReports.stream().map(TInspectionReport::getDispatchId).distinct().collect(Collectors.toList()); + List<String> dispatchIds1 = query.getDispatchIds(); + Iterator<String> iterator = dispatchIds1.iterator(); + while (iterator.hasNext()) { + String next = iterator.next(); + if (dispatchIds.contains(next)) { + iterator.remove(); + } + } + // if(CollectionUtils.isEmpty(dispatchIds1)){ + // List<String> id = new ArrayList<>(); + // id.add("-1"); + // query.setDispatchIds(id); + // }else { + query.setDispatchIds(dispatchIds1); + // } + } + } + } } } } @@ -317,6 +363,19 @@ samplingRecordOperation.setSendTime(LocalDateTime.now()); } samplingRecordOperationService.updateBatchById(samplingRecordOperations); + + // 查询取样记录信息 + TSamplingRecord samplingRecord = samplingRecordService.getById(samplingRecordOperations.get(0).getSamplingId()); + // 查询实验调度 + TExperimentDispatch experimentDispatch = experimentDispatchService.getById(samplingRecord.getDispatchId()); + // 查询实验调度参与人员 + List<TExperimentDispatchParticipants> teamStaffs = experimentDispatchParticipantsService.list(Wrappers.lambdaQuery(TExperimentDispatchParticipants.class) + .eq(TExperimentDispatchParticipants::getDispatchId, experimentDispatch.getId()) + .eq(TExperimentDispatchParticipants::getRoleType, 4)); + // MESSAGE 添加消息 + teamStaffs.forEach(teamStaff -> { + noticeService.saveNotice(teamStaff.getUserId(), "您有【1】条【送样单】等待确认接收样品", tokenService.getLoginUser().getUser().getNickName(),13); + }); return R.ok(); } @@ -336,9 +395,9 @@ .in(TSamplingRecordOperation::getId, ids)); for (TSamplingRecordOperation samplingRecordOperation : samplingRecordOperations) { samplingRecordOperation.setStatus(3); - samplingRecordOperation.setSendPersonId(userId); - samplingRecordOperation.setSendSign(samplingRecordOperation.getReceiptsSign()); - samplingRecordOperation.setSendTime(LocalDateTime.now()); + samplingRecordOperation.setReceiptsPersonId(userId); + samplingRecordOperation.setReceiptsSign(samplingRecordOperation.getReceiptsSign()); + samplingRecordOperation.setReceiptsTime(LocalDateTime.now()); } samplingRecordOperationService.updateBatchById(samplingRecordOperations); return R.ok(); -- Gitblit v1.7.1