导入物料BUG修改

This commit is contained in:
秦鸿展
2026-07-24 19:42:40 +08:00
parent 82909efe6b
commit 5b98ae9435
@@ -457,7 +457,7 @@ public class MaterialBaseInfoApplicationService {
throw new ServiceException("请上传xls或xlsx格式文件");
}
// 保存文件到临时目录
// 流式写入临时文件,避免大文件 getBytes() 导致内存溢出和接口超时
String tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "material_import";
File dir = new File(tmpDir);
if (!dir.exists()) {
@@ -465,8 +465,8 @@ public class MaterialBaseInfoApplicationService {
}
String tmpFileName = System.currentTimeMillis() + "_" + fileName;
File tmpFile = new File(dir, tmpFileName);
try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
fos.write(file.getBytes());
try {
file.transferTo(tmpFile);
} catch (Exception e) {
throw new ServiceException("文件保存失败:" + e.getMessage());
}