From de1d6cf24efebced674fbaa46123648bf50bd74a Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 06 五月 2026 14:08:02 +0800
Subject: [PATCH] feat(device): 添加物联网设备支持功能

---
 src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java b/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java
index d34a291..a71cb5a 100644
--- a/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java
@@ -8,7 +8,6 @@
 import com.ruoyi.common.enums.FileNameType;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.measuringinstrumentledger.dto.MeasuringInstrumentLedgerDto;
 import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerMapper;
 import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerRecordMapper;
@@ -71,6 +70,9 @@
     @Override
     public IPage<MeasuringInstrumentLedger> listPage(Page page, MeasuringInstrumentLedger measuringInstrumentLedger) {
         IPage<MeasuringInstrumentLedger> measuringInstrumentLedgerIPage = measuringInstrumentLedgerMapper.listPage(page, measuringInstrumentLedger);
+        List<Integer>  types = new ArrayList<>();
+        types.add(FileNameType.MEASURING.getValue());
+        types.add(FileNameType.MEASURINGRecord.getValue());
         measuringInstrumentLedgerIPage.getRecords().forEach(item -> {
             LambdaQueryWrapper<MeasuringInstrumentLedgerRecord> measuringInstrumentLedgerRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
             measuringInstrumentLedgerRecordLambdaQueryWrapper.eq(MeasuringInstrumentLedgerRecord::getMeasuringInstrumentLedgerId, item.getId());
@@ -81,7 +83,8 @@
             }
             collect.add(item.getId());
             LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>();
-            salesLedgerFileWrapper.in(CommonFile::getCommonId, collect);
+            salesLedgerFileWrapper.in(CommonFile::getCommonId, collect)
+                    .in(CommonFile::getType,types);
             List<CommonFile> commonFiles = commonFileMapper.selectList(salesLedgerFileWrapper);
             item.setCommonFiles(commonFiles);
 
@@ -106,7 +109,7 @@
             measuringInstrumentLedgerRecord.setEntryDate(req.getEntryDate());
             measuringInstrumentLedgerRecord.setValid(req.getValid());
             measuringInstrumentLedgerRecord.setUserId(req.getUserId());
-            measuringInstrumentLedgerRecord.setUserName(sysUser.getUserName());
+            measuringInstrumentLedgerRecord.setUserName(sysUser.getNickName());
             measuringInstrumentLedgerRecordMapper.insert(measuringInstrumentLedgerRecord);
             // 鍙拌处缁戝畾涓�娆�
 //            if(!CollectionUtils.isEmpty(req.getTempFileIds())){
@@ -134,7 +137,7 @@
         if (sysUser == null) {
             return false;
         }
-        measuringInstrumentLedger.setUserName(sysUser.getUserName());
+        measuringInstrumentLedger.setUserName(sysUser.getNickName());
         measuringInstrumentLedgerMapper.insert(measuringInstrumentLedger);
         if(!CollectionUtils.isEmpty(measuringInstrumentLedger.getTempFileIds())){
             migrateTempFilesToFormal(measuringInstrumentLedger.getId(), measuringInstrumentLedger.getTempFileIds(), FileNameType.MEASURING.getValue());
@@ -185,12 +188,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