|
@@ -107,17 +107,24 @@ public class EmailParseApiServiceImpl implements EmailParseApiService {
|
|
|
for (MultipartFile file : files) {
|
|
|
String filename = file.getOriginalFilename();
|
|
|
File saveFile = this.emailParseService.generateSavePath("upload", new Date(), filename);
|
|
|
- String filepath = saveFile.getPath();
|
|
|
- try (InputStream is = file.getInputStream()) {
|
|
|
- Files.copy(is, saveFile.toPath());
|
|
|
- } catch (IOException e) {
|
|
|
- log.warn("文件{} 上传失败:{}", filename, ExceptionUtil.stacktraceToString(e));
|
|
|
- dataList.add(new ParseResult<>(ReportParseStatus.FILE_UPLOAD_FAIL, null));
|
|
|
+ if (!saveFile.exists()) {
|
|
|
+ if (!saveFile.getParentFile().exists()) {
|
|
|
+ saveFile.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+ try (InputStream is = file.getInputStream()) {
|
|
|
+ Files.copy(is, saveFile.toPath());
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.warn("文件{} 上传失败:{}", filename, ExceptionUtil.stacktraceToString(e));
|
|
|
+ dataList.add(new ParseResult<>(ReportParseStatus.FILE_UPLOAD_FAIL, null));
|
|
|
+ }
|
|
|
}
|
|
|
- params.getReportInfos().add(new UploadReportParams.ReportInfo(filepath));
|
|
|
+ params.getReportInfos().add(new UploadReportParams.ReportInfo(saveFile.getAbsolutePath()));
|
|
|
}
|
|
|
+ params.setTitle("确认单上传解析");
|
|
|
List<ParseResult<ReportData>> tempList = this.emailParseService.uploadReportResults(params);
|
|
|
- dataList.addAll(tempList);
|
|
|
+ if (CollUtil.isNotEmpty(tempList)) {
|
|
|
+ dataList.addAll(tempList);
|
|
|
+ }
|
|
|
return dataList;
|
|
|
}
|
|
|
|