From fa3428b4bb32179a42d5618357c22fe2695716ae Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期三, 22 四月 2026 13:58:23 +0800
Subject: [PATCH] 修改全局的注入方式

---
 src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerRecordServiceImpl.java |   40 ++++++++++++++++++----------------------
 1 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerRecordServiceImpl.java b/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerRecordServiceImpl.java
index bca4629..b178d75 100644
--- a/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerRecordServiceImpl.java
@@ -16,14 +16,13 @@
 import com.ruoyi.other.pojo.TempFile;
 import com.ruoyi.sales.mapper.CommonFileMapper;
 import com.ruoyi.sales.pojo.CommonFile;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FilenameUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 
-import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -35,7 +34,6 @@
 import java.util.Date;
 import java.util.List;
 import java.util.UUID;
-import java.util.stream.Collectors;
 
 /**
  * @author :yys
@@ -43,19 +41,13 @@
  */
 @Service
 @Slf4j
+@RequiredArgsConstructor
 public class MeasuringInstrumentLedgerRecordServiceImpl extends ServiceImpl<MeasuringInstrumentLedgerRecordMapper, MeasuringInstrumentLedgerRecord> implements MeasuringInstrumentLedgerRecordService {
 
-    @Autowired
-    private MeasuringInstrumentLedgerRecordMapper measuringInstrumentLedgerRecordMapper;
-
-    @Autowired
-    private MeasuringInstrumentLedgerMapper measuringInstrumentLedgerMapper;
-
-    @Autowired
-    private CommonFileMapper commonFileMapper;
-
-    @Autowired
-    private TempFileMapper tempFileMapper;
+    private final MeasuringInstrumentLedgerRecordMapper measuringInstrumentLedgerRecordMapper;
+    private final MeasuringInstrumentLedgerMapper measuringInstrumentLedgerMapper;
+    private final CommonFileMapper commonFileMapper;
+    private final TempFileMapper tempFileMapper;
 
     @Value("${file.upload-dir}")
     private String uploadDir;
@@ -65,7 +57,8 @@
         IPage<MeasuringInstrumentLedgerRecord> measuringInstrumentLedgerRecordIPage = measuringInstrumentLedgerRecordMapper.listPage(page, measuringInstrumentLedgerRecord);
         measuringInstrumentLedgerRecordIPage.getRecords().forEach(item -> {
             LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>();
-            salesLedgerFileWrapper.eq(CommonFile::getCommonId, item.getId());
+            salesLedgerFileWrapper.eq(CommonFile::getCommonId, item.getId())
+                    .eq(CommonFile::getType, FileNameType.MEASURINGRecord.getValue());
             List<CommonFile> commonFiles = commonFileMapper.selectList(salesLedgerFileWrapper);
             item.setCommonFiles(commonFiles);
         });
@@ -143,12 +136,15 @@
 
             try {
                 // 鎵ц鏂囦欢杩佺Щ锛堜娇鐢ㄥ師瀛愭搷浣滅‘淇濆畨鍏ㄦ�э級
-                Files.move(
-                        Paths.get(tempFile.getTempPath()),
-                        formalFilePath,
-                        StandardCopyOption.REPLACE_EXISTING,
-                        StandardCopyOption.ATOMIC_MOVE
-                );
+//                Files.move(
+//                        Paths.get(tempFile.getTempPath()),
+//                        formalFilePath,
+//                        StandardCopyOption.REPLACE_EXISTING,
+//                        StandardCopyOption.ATOMIC_MOVE
+//                );
+                // 鍘熷瓙绉诲姩澶辫触锛屼娇鐢ㄥ鍒�+鍒犻櫎
+                Files.copy(Paths.get(tempFile.getTempPath()), formalFilePath, StandardCopyOption.REPLACE_EXISTING);
+                Files.deleteIfExists(Paths.get(tempFile.getTempPath()));
                 log.info("鏂囦欢杩佺Щ鎴愬姛: {} -> {}", tempFile.getTempPath(), formalFilePath);
 
                 // 鏇存柊鏂囦欢璁板綍锛堝叧鑱斿埌涓氬姟ID锛�

--
Gitblit v1.9.3