From 8c8f19c87c9dfa7576f04ad80d864b37d0617786 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期四, 15 一月 2026 09:38:46 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New' into dev_New
---
src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java | 93 ++++++++++++++++++++++------------------------
1 files changed, 44 insertions(+), 49 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 72ce890..e695b97 100644
--- a/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java
@@ -5,11 +5,14 @@
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.dto.StorageBlobDTO;
+import com.ruoyi.basic.pojo.StorageAttachment;
+import com.ruoyi.basic.service.StorageAttachmentService;
import com.ruoyi.common.enums.FileNameType;
+import com.ruoyi.common.enums.StorageAttachmentRecordType;
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.dto.MeasuringInstrumentLedgerRecordDTO;
import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerMapper;
import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerRecordMapper;
import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedger;
@@ -37,10 +40,12 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
+
+import static com.ruoyi.common.constant.StorageAttachmentConstants.StorageAttachmentFile;
/**
* @author :yys
@@ -65,64 +70,54 @@
@Autowired
private SysUserMapper sysUserMapper;
+ @Autowired
+ private StorageAttachmentService attachmentService;
+
@Value("${file.upload-dir}")
private String uploadDir;
@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());
- List<MeasuringInstrumentLedgerRecord> measuringInstrumentLedgerRecords = measuringInstrumentLedgerRecordMapper.selectList(measuringInstrumentLedgerRecordLambdaQueryWrapper);
- List<Long> collect = new ArrayList<>();
- if(!CollectionUtils.isEmpty(measuringInstrumentLedgerRecords)){
- collect = measuringInstrumentLedgerRecords.stream().map(MeasuringInstrumentLedgerRecord::getId).collect(Collectors.toList());
- }
- collect.add(item.getId());
- LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>();
- salesLedgerFileWrapper.in(CommonFile::getCommonId, collect)
- .in(CommonFile::getType,types);
- List<CommonFile> commonFiles = commonFileMapper.selectList(salesLedgerFileWrapper);
- item.setCommonFiles(commonFiles);
+ IPage<MeasuringInstrumentLedger> iPage = measuringInstrumentLedgerMapper.listPage(page, measuringInstrumentLedger);
+ List<MeasuringInstrumentLedger> records = iPage.getRecords();
+ List<Long> ids = records.stream().map(MeasuringInstrumentLedger::getId).collect(Collectors.toList());
- });
- return measuringInstrumentLedgerIPage;
+ List<MeasuringInstrumentLedgerRecord> measuringInstrumentLedgerRecords = measuringInstrumentLedgerRecordMapper.selectList(new LambdaQueryWrapper<MeasuringInstrumentLedgerRecord>()
+ .in(MeasuringInstrumentLedgerRecord::getMeasuringInstrumentLedgerId, ids)
+ .orderByDesc(MeasuringInstrumentLedgerRecord::getCreateTime));
+ if (!CollectionUtils.isEmpty(measuringInstrumentLedgerRecords)) {
+ Map<Long, List<MeasuringInstrumentLedgerRecord>> collect = measuringInstrumentLedgerRecords.stream().collect(Collectors.groupingBy(MeasuringInstrumentLedgerRecord::getMeasuringInstrumentLedgerId));
+ for (MeasuringInstrumentLedger ledger : records) {
+ if (collect.containsKey(ledger.getId())) {
+ ledger.setMostDate(collect.get(ledger.getId()).get(0).getRecordDate());
+ }
+ }
+ }
+ return iPage;
}
@Override
- public boolean verifying(MeasuringInstrumentLedgerDto req) throws IOException {
- MeasuringInstrumentLedger measuringInstrumentLedger = measuringInstrumentLedgerMapper.selectById(req.getId());
- if(measuringInstrumentLedger == null) {
- return false;
+ public boolean verifying(MeasuringInstrumentLedgerRecordDTO req) throws IOException {
+ MeasuringInstrumentLedger measuringInstrumentLedger = measuringInstrumentLedgerMapper.selectById(req.getMeasuringInstrumentLedgerId());
+ if (measuringInstrumentLedger == null) {
+ throw new RuntimeException("璁¢噺鍣ㄥ叿鍙拌处涓嶅瓨鍦�");
}
- SysUser sysUser = sysUserMapper.selectUserById(measuringInstrumentLedger.getUserId());
- measuringInstrumentLedger.setValid(req.getValid());
- measuringInstrumentLedger.setMostDate(req.getRecordDate());
- measuringInstrumentLedger.setNextDate(new Date(req.getRecordDate().getTime() + 1000L * 60 * 60 * 24 * req.getValid()));
- MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord = new MeasuringInstrumentLedgerRecord();
- if(measuringInstrumentLedgerMapper.updateById(measuringInstrumentLedger) > 0) {
- measuringInstrumentLedgerRecord.setMeasuringInstrumentLedgerId(req.getId());
- measuringInstrumentLedgerRecord.setRecordDate(req.getRecordDate());
- measuringInstrumentLedgerRecord.setEntryDate(req.getEntryDate());
- measuringInstrumentLedgerRecord.setValid(req.getValid());
- measuringInstrumentLedgerRecord.setUserId(req.getUserId());
- measuringInstrumentLedgerRecord.setUserName(sysUser.getUserName());
- measuringInstrumentLedgerRecordMapper.insert(measuringInstrumentLedgerRecord);
- // 鍙拌处缁戝畾涓�娆�
-// if(!CollectionUtils.isEmpty(req.getTempFileIds())){
-// migrateTempFilesToFormal(measuringInstrumentLedger.getId(), req.getTempFileIds(), FileNameType.MEASURING.getValue());
-// }
- // 鍙拌处璁板綍缁戝畾涓�娆�
- if(!CollectionUtils.isEmpty(req.getTempFileIds())){
- migrateTempFilesToFormal(measuringInstrumentLedgerRecord.getId(), req.getTempFileIds(), FileNameType.MEASURINGRecord.getValue());
+ measuringInstrumentLedgerRecordMapper.insert(req);
+ if (req.getBlobs() != null && !req.getBlobs().isEmpty()) {
+ List<StorageAttachment> attachments = new ArrayList<>();
+
+ for (StorageBlobDTO storageBlobDTO : req.getBlobs()) {
+ StorageAttachment storageAttachment = new StorageAttachment(
+ StorageAttachmentFile,
+ (long) StorageAttachmentRecordType.MeasuringInstrumentLedgerRecord.ordinal(),
+ req.getId()
+ );
+ storageAttachment.setStorageBlobDTO(storageBlobDTO);
+ attachments.add(storageAttachment);
}
- return true;
+ attachmentService.saveStorageAttachment(attachments, req.getId(), StorageAttachmentRecordType.MeasuringInstrumentLedgerRecord, StorageAttachmentFile);
}
- return false;
+ return true;
}
@Override
--
Gitblit v1.9.3