生成文件自定义文件名称

This commit is contained in:
xy
2026-04-14 19:07:11 +08:00
parent 46f521c7a7
commit 59f2588488
2 changed files with 8 additions and 3 deletions

View File

@@ -32,5 +32,5 @@ public interface CommMonitorEventReportService {
* @param index * @param index
* @return * @return
*/ */
String saveStableEventReport(List<String> index, Map<String, AreaLineInfoVO> map); String saveStableEventReport(List<String> index, Map<String, AreaLineInfoVO> map, String fileName);
} }

View File

@@ -658,7 +658,7 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
} }
@Override @Override
public String saveStableEventReport(List<String> eventIndex, Map<String, AreaLineInfoVO> map) { public String saveStableEventReport(List<String> eventIndex, Map<String, AreaLineInfoVO> map, String fileName) {
WordUtil wordUtil = new WordUtil(); WordUtil wordUtil = new WordUtil();
for (String index : eventIndex) { for (String index : eventIndex) {
RmpEventDetailPO detail = rmpEventDetailMapper.selectById(index); RmpEventDetailPO detail = rmpEventDetailMapper.selectById(index);
@@ -709,7 +709,12 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
} }
try { try {
InputStream inputStream = wordUtil.createReport2(eventIndex); InputStream inputStream = wordUtil.createReport2(eventIndex);
String filePath = fileStorageUtil.uploadStream(inputStream, OssPath.APP_EVENT_REPORT, "暂降事件报告.docx"); String filePath;
if (Objects.isNull(fileName)) {
filePath = fileStorageUtil.uploadStream(inputStream, OssPath.APP_EVENT_REPORT, null);
} else {
filePath = fileStorageUtil.uploadStreamSpecifyName(inputStream, OssPath.APP_EVENT_REPORT, fileName);
}
return filePath; return filePath;
} catch (IOException | InvalidFormatException e) { } catch (IOException | InvalidFormatException e) {
throw new RuntimeException(e); throw new RuntimeException(e);