From 616a6b2e9a7824da8d11a4e11730fd2f9b615299 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 06 十一月 2026 09:46:53 +0800
Subject: [PATCH] fix(qc): 修复巡检记录校验缺少租户隔离问题

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/attachment/MesQcAttachmentController.java |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/attachment/MesQcAttachmentController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/attachment/MesQcAttachmentController.java
index 2489fd3..b32f889 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/attachment/MesQcAttachmentController.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/attachment/MesQcAttachmentController.java
@@ -2,6 +2,7 @@
 
 import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
 import cn.iocoder.yudao.module.mes.service.qc.iqc.MesQcIqcService;
 import cn.iocoder.yudao.module.mes.service.qc.ipqc.MesQcIpqcService;
 import cn.iocoder.yudao.module.mes.service.qc.oqc.MesQcOqcService;
@@ -37,7 +38,7 @@
     @GetMapping("/list")
     @PreAuthorize("@ss.hasPermission('mes:qc-' + #type.toLowerCase() + ':query')")
     public CommonResult<List<StorageBlobRespDTO>> list(
-            @RequestParam @Pattern(regexp = "iqc|ipqc|oqc|rqc") String type,
+            @RequestParam @Pattern(regexp = "iqc|ipqc|oqc|rqc|patrol") String type,
             @RequestParam @NotNull Long id) {
         validateDocument(type, id);
         var files = storageApi.listAttachments(recordType(type), id);
@@ -74,7 +75,7 @@
     @PreAuthorize("@ss.hasPermission('mes:qc-' + #type.toLowerCase() + ':update')")
     @Transactional(rollbackFor = Exception.class)
     public CommonResult<Boolean> remove(
-            @RequestParam @Pattern(regexp = "iqc|ipqc|oqc|rqc") String type,
+            @RequestParam @Pattern(regexp = "iqc|ipqc|oqc|rqc|patrol") String type,
             @RequestParam @NotNull Long id, @RequestParam @NotNull Long blobId) {
         lockDocument(type, id);
         validateDocument(type, id);
@@ -84,7 +85,7 @@
 
     private String recordType(String type) {
         return switch (type) {
-            case "iqc", "ipqc", "oqc", "rqc" -> "mes_qc_" + type + "_attachment";
+            case "iqc", "ipqc", "oqc", "rqc", "patrol" -> "mes_qc_" + type + "_attachment";
             default -> throw new ServiceException(400, "璐ㄦ绫诲瀷鏃犳晥");
         };
     }
@@ -95,6 +96,7 @@
             case "ipqc" -> "mes_qc_ipqc";
             case "oqc" -> "mes_qc_oqc";
             case "rqc" -> "mes_qc_rqc";
+            case "patrol" -> "mes_qc_patrol";
             default -> throw new ServiceException(400, "璐ㄦ绫诲瀷鏃犳晥");
         };
         var ids = jdbcTemplate.queryForList("SELECT id FROM " + table + " WHERE id = ? AND deleted = 0 FOR UPDATE", Long.class, id);
@@ -107,17 +109,24 @@
             case "ipqc" -> ipqcService.validateIpqcExists(id).getStatus();
             case "oqc" -> oqcService.validateOqcExists(id).getStatus();
             case "rqc" -> rqcService.validateRqcExists(id).getStatus();
+            case "patrol" -> {
+                var ids = jdbcTemplate.queryForList(
+                        "SELECT id FROM mes_qc_patrol WHERE id = ? AND tenant_id = ? AND deleted = 0",
+                        Long.class, id, TenantContextHolder.getRequiredTenantId());
+                if (ids.isEmpty()) throw new ServiceException(400, "宸℃璁板綍涓嶅瓨鍦�");
+                yield 0;
+            }
             default -> throw new ServiceException(400, "璐ㄦ绫诲瀷鏃犳晥");
         };
     }
 
     @Data public static class SaveReq {
-        @NotNull @Pattern(regexp = "iqc|ipqc|oqc|rqc") private String type;
+        @NotNull @Pattern(regexp = "iqc|ipqc|oqc|rqc|patrol") private String type;
         @NotNull private Long id;
         @NotEmpty @Size(max = 50) private List<@NotNull Long> blobIds;
     }
     @Data public static class AppendReq {
-        @NotNull @Pattern(regexp = "iqc|ipqc|oqc|rqc") private String type;
+        @NotNull @Pattern(regexp = "iqc|ipqc|oqc|rqc|patrol") private String type;
         @NotNull private Long id;
         @NotNull private Long blobId;
     }

--
Gitblit v1.9.3