From b7ec3aff011f05e236e76be844540dbe776f7353 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期五, 27 六月 2025 19:12:03 +0800
Subject: [PATCH] bug修改

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSamplingRecordController.java |   38 +++++++++++++++++++++++++++++++-------
 1 files changed, 31 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 ab10daa..3db12d7 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;
 
 /**
@@ -56,8 +54,9 @@
     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, TNoticeService noticeService) {
+    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;
@@ -69,6 +68,7 @@
         this.projectTeamStaffService = projectTeamStaffService;
         this.experimentDispatchParticipantsService = experimentDispatchParticipantsService;
         this.noticeService = noticeService;
+        this.inspectionReportService = inspectionReportService;
     }
 
     /**
@@ -82,6 +82,7 @@
         // 获取当前用户
         Long userId = tokenService.getLoginUser().getUserId();
         Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
+        query.setRoleType(roleType);
         if (roleType != 1){
             query.setUserId(userId);
             if(roleType ==2){
@@ -107,6 +108,29 @@
                 if (!CollectionUtils.isEmpty(experimentDispatchParticipants)) {
                     List<String> dispatchIds = experimentDispatchParticipants.stream().map(TExperimentDispatchParticipants::getDispatchId).distinct().collect(Collectors.toList());
                     query.setDispatchIds(dispatchIds);
+                }
+            }
+            if(roleType == 4){
+                // 查询检验报告
+                List<TInspectionReport> inspectionReports = inspectionReportService.list(Wrappers.lambdaQuery(TInspectionReport.class)
+                        .eq(TInspectionReport::getStatus, 1));
+                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);
+                    }
                 }
             }
         }
@@ -351,9 +375,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