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/SafeLineInspectionRecordServiceImpl.java | 61 ++++++++++++++++++++++++++++--
1 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionRecordServiceImpl.java b/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionRecordServiceImpl.java
index 89da3f0..bca99c5 100644
--- a/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/safe/service/impl/SafeLineInspectionRecordServiceImpl.java
@@ -1,11 +1,17 @@
package com.ruoyi.safe.service.impl;
-import com.ruoyi.safe.pojo.SafeLineInspectionRecord;
-import com.ruoyi.safe.mapper.SafeLineInspectionRecordMapper;
-import com.ruoyi.safe.service.SafeLineInspectionRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+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.safe.mapper.SafeLineInspectionRecordMapper;
+import com.ruoyi.safe.pojo.SafeLineInspectionRecord;
+import com.ruoyi.safe.service.SafeLineInspectionRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.Collections;
import java.util.List;
/**
@@ -19,11 +25,58 @@
@Service
public class SafeLineInspectionRecordServiceImpl extends ServiceImpl<SafeLineInspectionRecordMapper, SafeLineInspectionRecord> implements SafeLineInspectionRecordService {
+ @Autowired
+ private FileUtil fileUtil;
+
@Override
public List<SafeLineInspectionRecord> listByInspectionId(Integer inspectionId) {
- return this.lambdaQuery()
+ List<SafeLineInspectionRecord> records = this.lambdaQuery()
.eq(SafeLineInspectionRecord::getInspectionId, inspectionId)
.orderByDesc(SafeLineInspectionRecord::getCheckTime)
.list();
+ fillAttachments(records);
+ return records;
+ }
+
+ @Override
+ public boolean save(SafeLineInspectionRecord entity) {
+ boolean saved = super.save(entity);
+ syncAttachments(saved, entity);
+ return saved;
+ }
+
+ @Override
+ public boolean updateById(SafeLineInspectionRecord entity) {
+ boolean updated = super.updateById(entity);
+ syncAttachments(updated, entity);
+ return updated;
+ }
+
+ private void syncAttachments(boolean success, SafeLineInspectionRecord entity) {
+ if (!success || entity == null || entity.getId() == null || entity.getStorageBlobDTOs() == null) {
+ return;
+ }
+ fileUtil.saveStorageAttachment(
+ ApplicationTypeEnum.IMAGE,
+ RecordTypeEnum.SAFE_LINE_INSPECTION_RECORD,
+ entity.getId().longValue(),
+ entity.getStorageBlobDTOs()
+ );
+ }
+
+ private void fillAttachments(List<SafeLineInspectionRecord> records) {
+ if (records == null || records.isEmpty()) {
+ return;
+ }
+ records.forEach(record -> {
+ if (record.getId() == null) {
+ return;
+ }
+ List<StorageBlobVO> attachments = fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(
+ RecordTypeEnum.SAFE_LINE_INSPECTION_RECORD,
+ record.getId().longValue()
+ );
+ record.setStorageBlobVOs(attachments == null ? Collections.emptyList() : attachments);
+ });
}
}
--
Gitblit v1.9.3