Merge branch 'caihaohan'
This commit is contained in:
+1
-1
@@ -109,7 +109,7 @@ public class IReportContentServiceImpl extends ServiceImpl<ReportContentDao, Rep
|
|||||||
//将内容存入
|
//将内容存入
|
||||||
ReportContentEntity reportContent = query().eq("report_id", reportId).one();
|
ReportContentEntity reportContent = query().eq("report_id", reportId).one();
|
||||||
if (reportContent == null) {
|
if (reportContent == null) {
|
||||||
ReportContentEntity reportContentEntity = new ReportContentEntity(UUID.randomUUID10(), reportId, reportContentFileIds,content.toString());
|
ReportContentEntity reportContentEntity = new ReportContentEntity(UUID.randomUUID10(), reportId, reportContentFileIds, content.toString());
|
||||||
save(reportContentEntity);
|
save(reportContentEntity);
|
||||||
} else {
|
} else {
|
||||||
reportContent.setReportContent(content.toString());
|
reportContent.setReportContent(content.toString());
|
||||||
|
|||||||
@@ -262,8 +262,8 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
|
|||||||
//修改报表内容表(先删后增)
|
//修改报表内容表(先删后增)
|
||||||
iReportContentService.removeByReportId(reportId);
|
iReportContentService.removeByReportId(reportId);
|
||||||
try {
|
try {
|
||||||
iReportContentService.insertReportContent(reportId);
|
|
||||||
log.info("抽取reportId为{}报告内容", reportId);
|
log.info("抽取reportId为{}报告内容", reportId);
|
||||||
|
iReportContentService.insertReportContent(reportId);
|
||||||
count++;
|
count++;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("获取reportId为{}的报告内容失败", reportId);
|
log.error("获取reportId为{}的报告内容失败", reportId);
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.adc.da.report.util;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.CharsetEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.adc.da.report.constant.ReportConstants;
|
import com.adc.da.report.constant.ReportConstants;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -92,9 +94,21 @@ public class FileContentUtil {
|
|||||||
fis.close();
|
fis.close();
|
||||||
log.info("文件内容抽取失败,原因可能是上传的文件为空文件");
|
log.info("文件内容抽取失败,原因可能是上传的文件为空文件");
|
||||||
}
|
}
|
||||||
return content.toString();
|
return cleanInvalidCharacters(content.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String cleanInvalidCharacters(String input) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
|
||||||
|
for (char ch : input.toCharArray()) {
|
||||||
|
if (encoder.canEncode(ch)) {
|
||||||
|
stringBuilder.append(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String readExcelContent(org.apache.poi.ss.usermodel.Workbook workbook) {
|
private static String readExcelContent(org.apache.poi.ss.usermodel.Workbook workbook) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
int numberOfSheets = workbook.getNumberOfSheets();
|
int numberOfSheets = workbook.getNumberOfSheets();
|
||||||
|
|||||||
Reference in New Issue
Block a user