From d55278560d29562b341aafa1652209a8aae0af33 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期四, 30 四月 2026 17:08:16 +0800
Subject: [PATCH] 计量器具台账附件修改
---
src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerRecordServiceImpl.java | 97 ------------------------
src/main/java/com/ruoyi/project/common/CommonController.java | 90 ----------------------
src/main/java/com/ruoyi/measuringinstrumentledger/service/MeasuringInstrumentLedgerRecordService.java | 4
3 files changed, 2 insertions(+), 189 deletions(-)
diff --git a/src/main/java/com/ruoyi/measuringinstrumentledger/service/MeasuringInstrumentLedgerRecordService.java b/src/main/java/com/ruoyi/measuringinstrumentledger/service/MeasuringInstrumentLedgerRecordService.java
index bdb1135..2d7d38c 100644
--- a/src/main/java/com/ruoyi/measuringinstrumentledger/service/MeasuringInstrumentLedgerRecordService.java
+++ b/src/main/java/com/ruoyi/measuringinstrumentledger/service/MeasuringInstrumentLedgerRecordService.java
@@ -4,9 +4,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedgerRecord;
-
import jakarta.servlet.http.HttpServletResponse;
-import java.io.IOException;
/**
* @author :yys
@@ -25,5 +23,5 @@
void export(HttpServletResponse response);
- boolean updateMeasuringInstrumentLedgerRecord(MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord) throws IOException;
+ boolean updateMeasuringInstrumentLedgerRecord(MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord);
}
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 b178d75..7104c1a 100644
--- a/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerRecordServiceImpl.java
@@ -5,35 +5,21 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.enums.FileNameType;
-import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerMapper;
import com.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerRecordMapper;
import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedger;
import com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedgerRecord;
import com.ruoyi.measuringinstrumentledger.service.MeasuringInstrumentLedgerRecordService;
-import com.ruoyi.other.mapper.TempFileMapper;
-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.Value;
import org.springframework.stereotype.Service;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
-import java.util.UUID;
/**
* @author :yys
@@ -47,10 +33,6 @@
private final MeasuringInstrumentLedgerRecordMapper measuringInstrumentLedgerRecordMapper;
private final MeasuringInstrumentLedgerMapper measuringInstrumentLedgerMapper;
private final CommonFileMapper commonFileMapper;
- private final TempFileMapper tempFileMapper;
-
- @Value("${file.upload-dir}")
- private String uploadDir;
@Override
public IPage<MeasuringInstrumentLedgerRecord> listPage(Page page, MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord) {
@@ -73,7 +55,7 @@
}
@Override
- public boolean updateMeasuringInstrumentLedgerRecord(MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord) throws IOException {
+ public boolean updateMeasuringInstrumentLedgerRecord(MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord) {
MeasuringInstrumentLedgerRecord measuringInstrumentLedgerRecord1 = measuringInstrumentLedgerRecordMapper.selectById(measuringInstrumentLedgerRecord.getId());
if (measuringInstrumentLedgerRecord1 == null) {
return false;
@@ -88,83 +70,6 @@
measuringInstrumentLedgerMapper.updateById(measuringInstrumentLedger);
}
measuringInstrumentLedgerRecordMapper.updateById(measuringInstrumentLedgerRecord);
- // 璁板綍闄勪欢缁戝畾
- migrateTempFilesToFormal(measuringInstrumentLedgerRecord.getId(), measuringInstrumentLedgerRecord.getTempFileIds(), FileNameType.MEASURINGRecord.getValue());
return true;
- }
-
-
- /**
- * 灏嗕复鏃舵枃浠惰縼绉诲埌姝e紡鐩綍
- *
- * @param businessId 涓氬姟ID锛堥攢鍞彴璐D锛�
- * @param tempFileIds 涓存椂鏂囦欢ID鍒楄〃
- * @throws IOException 鏂囦欢鎿嶄綔寮傚父
- */
- private void migrateTempFilesToFormal(Long businessId, List<String> tempFileIds,Integer fileType) throws IOException {
- if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(tempFileIds)) {
- return;
- }
-
- // 鏋勫缓姝e紡鐩綍璺緞锛堟寜涓氬姟绫诲瀷鍜屾棩鏈熷垎缁勶級
- String formalDir = uploadDir + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
-
- Path formalDirPath = Paths.get(formalDir);
-
- // 纭繚姝e紡鐩綍瀛樺湪锛堥�掑綊鍒涘缓锛�
- if (!Files.exists(formalDirPath)) {
- Files.createDirectories(formalDirPath);
- }
-
- for (String tempFileId : tempFileIds) {
- // 鏌ヨ涓存椂鏂囦欢璁板綍
- TempFile tempFile = tempFileMapper.selectById(tempFileId);
- if (tempFile == null) {
- log.warn("涓存椂鏂囦欢涓嶅瓨鍦紝璺宠繃澶勭悊: {}", tempFileId);
- continue;
- }
-
- // 鏋勫缓姝e紡鏂囦欢鍚嶏紙鍖呭惈涓氬姟ID鍜屾椂闂存埑锛岄伩鍏嶅啿绐侊級
- String originalFilename = tempFile.getOriginalName();
- String fileExtension = FilenameUtils.getExtension(originalFilename);
- String formalFilename = businessId + "_" +
- System.currentTimeMillis() + "_" +
- UUID.randomUUID().toString().substring(0, 8) +
- (StringUtils.hasText(fileExtension) ? "." + fileExtension : "");
-
- Path formalFilePath = formalDirPath.resolve(formalFilename);
-
- try {
- // 鎵ц鏂囦欢杩佺Щ锛堜娇鐢ㄥ師瀛愭搷浣滅‘淇濆畨鍏ㄦ�э級
-// 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锛�
- CommonFile fileRecord = new CommonFile();
- fileRecord.setCommonId(businessId);
- fileRecord.setName(originalFilename);
- fileRecord.setUrl(formalFilePath.toString());
- fileRecord.setCreateTime(LocalDateTime.now());
- fileRecord.setType(fileType);
- commonFileMapper.insert(fileRecord);
-
- // 鍒犻櫎涓存椂鏂囦欢璁板綍
- tempFileMapper.deleteById(tempFile);
-
- log.info("鏂囦欢杩佺Щ鎴愬姛: {} -> {}", tempFile.getTempPath(), formalFilePath);
- } catch (IOException e) {
- log.error("鏂囦欢杩佺Щ澶辫触: {}", tempFile.getTempPath(), e);
- // 鍙�夋嫨鍥炴粴浜嬪姟鎴栬褰曞け璐ユ枃浠�
- throw new IOException("鏂囦欢杩佺Щ寮傚父", e);
- }
- }
}
}
diff --git a/src/main/java/com/ruoyi/project/common/CommonController.java b/src/main/java/com/ruoyi/project/common/CommonController.java
index 9ee3c93..093e132 100644
--- a/src/main/java/com/ruoyi/project/common/CommonController.java
+++ b/src/main/java/com/ruoyi/project/common/CommonController.java
@@ -8,8 +8,6 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ContentDisposition;
import org.springframework.http.MediaType;
@@ -33,99 +31,11 @@
@RestController
@RequestMapping("/common")
public class CommonController {
- private static final Logger log = LoggerFactory.getLogger(CommonController.class);
private final StorageBlobService storageBlobService;
private final FileUtil fileUtil;
-
-// /**
-// * 閫氱敤涓嬭浇璇锋眰
-// *
-// * @param fileName 鏂囦欢鍚嶇О
-// * @param delete 鏄惁鍒犻櫎
-// */
-// @GetMapping("/download")
-// public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
-// {
-// try
-// {
-// if (!FileUtils.checkAllowDownload(fileName))
-// {
-// throw new Exception(StringUtils.format("鏂囦欢鍚嶇О({})闈炴硶锛屼笉鍏佽涓嬭浇銆� ", fileName));
-// }
-// String realFileName = fileName.substring(fileName.indexOf("_") + 1);
-//
-// response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
-// FileUtils.setAttachmentResponseHeader(response, realFileName);
-// FileUtils.writeBytes(fileName, response.getOutputStream());
-
- /// / if (delete)
- /// / {
- /// / FileUtils.deleteFile(fileName);
- /// / }
-// }
-// catch (Exception e)
-// {
-// log.error("涓嬭浇鏂囦欢澶辫触", e);
-// }
-// }
-//
-// /**
-// * 閫氱敤涓婁紶璇锋眰锛堝崟涓級
-// */
-// @PostMapping("/upload")
-// public AjaxResult uploadFile(MultipartFile file) throws Exception
-// {
-// try
-// {
-// // 涓婁紶鏂囦欢璺緞
-// String filePath = RuoYiConfig.getUploadPath();
-// // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
-// String fileName = FileUploadUtils.upload(filePath, file);
-// String url = serverConfig.getUrl() + fileName;
-// AjaxResult ajax = AjaxResult.success();
-// ajax.put("url", url);
-// ajax.put("fileName", fileName);
-// ajax.put("newFileName", FileUtils.getName(fileName));
-// ajax.put("originalFilename", file.getOriginalFilename());
-// return ajax;
-// }
-// catch (Exception e)
-// {
-// return AjaxResult.error(e.getMessage());
-// }
-// }
-//
-// /**
-// * 鏈湴璧勬簮閫氱敤涓嬭浇
-// */
-// @GetMapping("/download/resource")
-// public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
-// throws Exception
-// {
-// try
-// {
-// if (!FileUtils.checkAllowDownload(resource))
-// {
-// throw new Exception(StringUtils.format("璧勬簮鏂囦欢({})闈炴硶锛屼笉鍏佽涓嬭浇銆� ", resource));
-// }
-// // 鏈湴璧勬簮璺緞
-// String localPath = RuoYiConfig.getProfile();
-// // 鏁版嵁搴撹祫婧愬湴鍧�
-// String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
-// // 涓嬭浇鍚嶇О
-// String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
-// response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
-// FileUtils.setAttachmentResponseHeader(response, downloadName);
-// FileUtils.writeBytes(downloadPath, response.getOutputStream());
-// }
-// catch (Exception e)
-// {
-// log.error("涓嬭浇鏂囦欢澶辫触", e);
-// }
-// }
@PostMapping({"/upload"})
@Operation(summary = "鏂囦欢涓婁紶")
public R upload(@RequestParam("files") List<MultipartFile> files) {
--
Gitblit v1.9.3