From 16d50e1fd871b2306e7beb650463bc76263e5e98 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 28 七月 2026 10:03:30 +0800
Subject: [PATCH] fix: 异常图片上传、bug修改

---
 src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java b/src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java
index a8e2b85..b5301d6 100644
--- a/src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java
+++ b/src/main/java/com/ruoyi/safe/service/impl/SafeFacilityInspectionServiceImpl.java
@@ -2,6 +2,10 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.basic.dto.StorageBlobVO;
+import com.ruoyi.basic.enums.ApplicationTypeEnum;
+import com.ruoyi.basic.enums.RecordTypeEnum;
+import com.ruoyi.basic.utils.FileUtil;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.safe.pojo.SafeFacilityInspection;
@@ -35,6 +39,8 @@
     private SafeFacilityLedgerService safeFacilityLedgerService;
     @Autowired
     private SysUserMapper sysUserMapper;
+    @Autowired
+    private FileUtil fileUtil;
 
     @Override
     public SafeFacilityInspection getById(Serializable id) {
@@ -56,6 +62,20 @@
 
         fillExtraInfo(result.getRecords());
         return result;
+    }
+
+    @Override
+    public boolean save(SafeFacilityInspection entity) {
+        boolean saved = super.save(entity);
+        syncAttachments(saved, entity);
+        return saved;
+    }
+
+    @Override
+    public boolean updateById(SafeFacilityInspection entity) {
+        boolean updated = super.updateById(entity);
+        syncAttachments(updated, entity);
+        return updated;
     }
 
     private void fillExtraInfo(List<SafeFacilityInspection> records) {
@@ -105,6 +125,25 @@
             if (record.getInspectorId() != null) {
                 record.setInspectorName(userMap.getOrDefault(record.getInspectorId().longValue(), "鏈煡鐢ㄦ埛"));
             }
+            if (record.getId() != null) {
+                List<StorageBlobVO> attachments = fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(
+                        RecordTypeEnum.SAFE_FACILITY_INSPECTION,
+                        record.getId().longValue()
+                );
+                record.setStorageBlobVOs(attachments == null ? Collections.emptyList() : attachments);
+            }
         }
     }
+
+    private void syncAttachments(boolean success, SafeFacilityInspection entity) {
+        if (!success || entity == null || entity.getId() == null || entity.getStorageBlobDTOs() == null) {
+            return;
+        }
+        fileUtil.saveStorageAttachment(
+                ApplicationTypeEnum.IMAGE,
+                RecordTypeEnum.SAFE_FACILITY_INSPECTION,
+                entity.getId().longValue(),
+                entity.getStorageBlobDTOs()
+        );
+    }
 }

--
Gitblit v1.9.3