导入物料BUG修改
This commit is contained in:
+3
-3
@@ -457,7 +457,7 @@ public class MaterialBaseInfoApplicationService {
|
|||||||
throw new ServiceException("请上传xls或xlsx格式文件");
|
throw new ServiceException("请上传xls或xlsx格式文件");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存文件到临时目录
|
// 流式写入临时文件,避免大文件 getBytes() 导致内存溢出和接口超时
|
||||||
String tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "material_import";
|
String tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "material_import";
|
||||||
File dir = new File(tmpDir);
|
File dir = new File(tmpDir);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
@@ -465,8 +465,8 @@ public class MaterialBaseInfoApplicationService {
|
|||||||
}
|
}
|
||||||
String tmpFileName = System.currentTimeMillis() + "_" + fileName;
|
String tmpFileName = System.currentTimeMillis() + "_" + fileName;
|
||||||
File tmpFile = new File(dir, tmpFileName);
|
File tmpFile = new File(dir, tmpFileName);
|
||||||
try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
|
try {
|
||||||
fos.write(file.getBytes());
|
file.transferTo(tmpFile);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException("文件保存失败:" + e.getMessage());
|
throw new ServiceException("文件保存失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user