From d39e4f7d839167c16425086dfa2f8747bccfdff9 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 05 十一月 2026 17:39:01 +0800
Subject: [PATCH] feat: 打通销售采购财务闭环并完成累计业务优化

---
 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/util/storage/StorageFileUtil.java |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/util/storage/StorageFileUtil.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/util/storage/StorageFileUtil.java
index abc79c1..6c804e6 100644
--- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/util/storage/StorageFileUtil.java
+++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/util/storage/StorageFileUtil.java
@@ -41,7 +41,7 @@
  * - token浣跨敤娆℃暟鎺у埗锛圧edis锛�
  * - 鍥剧墖鍘嬬缉
  *
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
  */
 @Component
 @RequiredArgsConstructor
@@ -104,21 +104,20 @@
             throw new IllegalArgumentException("鍏宠仈璁板綍id涓嶈兘涓虹┖");
         }
 
-        // 鍒犻櫎鏃ч檮浠朵俊鎭�
+        // 鍙垹闄ゆ棫鐨勯檮浠跺叧鑱旇褰曪紝淇濈暀 blob 璁板綍锛堟枃浠舵湰韬笉鍒犻櫎锛�
         if (application == null || application.trim().isEmpty()) {
             for (SystemStorageAttachmentSaveReqVO.BlobItem item : blobItems) {
                 String itemApp = item.getApplication();
                 if (itemApp == null || itemApp.trim().isEmpty()) {
                     throw new IllegalArgumentException("鏂囦欢鐢ㄩ�斾笉鑳戒负绌�");
                 }
-                deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(itemApp, recordType.getType(), recordId);
+                storageAttachmentMapper.deleteByApplicationAndRecordTypeAndRecordId(itemApp, recordType.getType(), recordId);
             }
         } else {
-            deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordId(application, recordType.getType(), recordId);
+            storageAttachmentMapper.deleteByApplicationAndRecordTypeAndRecordId(application, recordType.getType(), recordId);
         }
 
         if (CollUtil.isEmpty(blobItems)) {
-            deleteStorageAttachmentsByRecordTypeAndRecordId(recordType.getType(), recordId);
             return;
         }
 
@@ -142,6 +141,14 @@
         if (CollUtil.isEmpty(storageBlobIds)) {
             return;
         }
+        // 鐢熶骇宸ュ崟渚濊禆鍘熷鏂囦欢鍙嶆槧鍘嗗彶鐗堟湰锛屼笉鍏佽閫氳繃鍏朵粬闄勪欢鍏ュ彛鍒犻櫎杩欎簺鍏变韩鏂囦欢銆�
+        Long snapshotReferences = storageAttachmentMapper.selectCount(
+                new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<SystemStorageAttachmentDO>()
+                        .eq(SystemStorageAttachmentDO::getRecordType, "mes_work_order_technical_file")
+                        .in(SystemStorageAttachmentDO::getStorageBlobId, storageBlobIds));
+        if (snapshotReferences != null && snapshotReferences > 0) {
+            throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400, "鎶�鏈枃浠跺凡琚敓浜у伐鍗曠暀瀛橈紝涓嶈兘鍒犻櫎");
+        }
         // 鍚屾椂鍒犻櫎纾佺洏鏂囦欢
         List<SystemStorageBlobDO> blobs = storageBlobMapper.selectByIds(storageBlobIds);
         for (SystemStorageBlobDO blob : blobs) {

--
Gitblit v1.9.3