|
|
@@ -1,6 +1,7 @@
|
|
|
package com.ruoyi.project.production.service.impl;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -54,6 +55,9 @@ public class TDailyProductionReportServiceImpl implements ITDailyProductionRepor
|
|
|
@Autowired
|
|
|
private IMailService mailService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
+
|
|
|
/**
|
|
|
* 查询日期最新的每日生产报告
|
|
|
*
|
|
|
@@ -194,9 +198,11 @@ public class TDailyProductionReportServiceImpl implements ITDailyProductionRepor
|
|
|
public String importData(MultipartFile file) throws IOException {
|
|
|
// 用户提示信息
|
|
|
String message = "";
|
|
|
+ InputStream inputStream = null;
|
|
|
try {
|
|
|
// 获取用户上传的excel
|
|
|
- Workbook wb = WorkbookFactory.create(file.getInputStream());
|
|
|
+ inputStream = file.getInputStream();
|
|
|
+ Workbook wb = WorkbookFactory.create(inputStream);
|
|
|
// 获取第一个sheet
|
|
|
Sheet sheet = wb.getSheetAt(0);
|
|
|
// 用户上传的生产日报
|
|
|
@@ -865,10 +871,9 @@ public class TDailyProductionReportServiceImpl implements ITDailyProductionRepor
|
|
|
String staffName = staffmgr.getName();
|
|
|
String email = sysUser.getEmail();
|
|
|
if (email != null) {
|
|
|
- // 发送邮件
|
|
|
+ // 发送邮件 - 使用线程池而非创建新线程,避免线程泄漏
|
|
|
DailyProductionReportMailThread mailThread = new DailyProductionReportMailThread(mailService, email, staffName, loginName);
|
|
|
- Thread thread = new Thread(mailThread);
|
|
|
- thread.start();
|
|
|
+ threadPoolTaskExecutor.execute(mailThread);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -877,6 +882,14 @@ public class TDailyProductionReportServiceImpl implements ITDailyProductionRepor
|
|
|
message = "导入失败,请联系管理员!";
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
+ // 关闭输入流,防止内存泄漏
|
|
|
+ if (inputStream != null) {
|
|
|
+ try {
|
|
|
+ inputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ // 忽略关闭异常
|
|
|
+ }
|
|
|
+ }
|
|
|
return message;
|
|
|
}
|
|
|
}
|