fix(工作报告): 修复导出时文件后缀格式的问题。
This commit is contained in:
@@ -39,6 +39,7 @@ import java.math.BigInteger;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.IsoFields;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
@@ -187,7 +188,8 @@ public class WorkReportContentExportService {
|
|||||||
replacePlaceholders(document, buildWeeklyTemplateData(report));
|
replacePlaceholders(document, buildWeeklyTemplateData(report));
|
||||||
renderPersonalReviewTable(document, report.getReviewItems());
|
renderPersonalReviewTable(document, report.getReviewItems());
|
||||||
renderPersonalPlanTable(document, report.getPlanItems());
|
renderPersonalPlanTable(document, report.getPlanItems());
|
||||||
return new DocumentContent(buildFilename("个人周报", report.getReporterName(), report.getPeriodLabel()),
|
return new DocumentContent(buildWeeklyFilename("个人周报", report.getReporterName(),
|
||||||
|
report.getPeriodStartDate(), report.getPeriodLabel()),
|
||||||
toBytes(document));
|
toBytes(document));
|
||||||
} catch (IOException | Docx4JException e) {
|
} catch (IOException | Docx4JException e) {
|
||||||
throw new IllegalStateException("生成周报模板导出文件失败", e);
|
throw new IllegalStateException("生成周报模板导出文件失败", e);
|
||||||
@@ -214,7 +216,8 @@ public class WorkReportContentExportService {
|
|||||||
|
|
||||||
addSectionTitle(document, "下周期重点工作计划");
|
addSectionTitle(document, "下周期重点工作计划");
|
||||||
addPersonalPlanTable(document, report.getPlanItems(), false);
|
addPersonalPlanTable(document, report.getPlanItems(), false);
|
||||||
return new DocumentContent(buildFilename("个人周报", report.getReporterName(), report.getPeriodLabel()),
|
return new DocumentContent(buildWeeklyFilename("个人周报", report.getReporterName(),
|
||||||
|
report.getPeriodStartDate(), report.getPeriodLabel()),
|
||||||
toBytes(document));
|
toBytes(document));
|
||||||
} catch (Docx4JException | IOException e) {
|
} catch (Docx4JException | IOException e) {
|
||||||
throw new IllegalStateException("生成周报导出文件失败", e);
|
throw new IllegalStateException("生成周报导出文件失败", e);
|
||||||
@@ -1821,6 +1824,16 @@ public class WorkReportContentExportService {
|
|||||||
return sanitizeFilename(reportTypeName + "_" + text(ownerName) + "_" + text(periodLabel)) + ".docx";
|
return sanitizeFilename(reportTypeName + "_" + text(ownerName) + "_" + text(periodLabel)) + ".docx";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildWeeklyFilename(String reportTypeName, String ownerName, LocalDate periodStartDate, String periodLabel) {
|
||||||
|
if (periodStartDate == null) {
|
||||||
|
return buildFilename(reportTypeName, ownerName, periodLabel);
|
||||||
|
}
|
||||||
|
int weekBasedYear = periodStartDate.get(IsoFields.WEEK_BASED_YEAR);
|
||||||
|
int weekOfYear = periodStartDate.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
|
||||||
|
return sanitizeFilename(reportTypeName + "_" + text(ownerName) + "_"
|
||||||
|
+ weekBasedYear + "年第" + weekOfYear + "周") + ".docx";
|
||||||
|
}
|
||||||
|
|
||||||
private String sanitizeFilename(String filename) {
|
private String sanitizeFilename(String filename) {
|
||||||
return filename.replaceAll("[\\\\/:*?\"<>|\\r\\n]+", "_");
|
return filename.replaceAll("[\\\\/:*?\"<>|\\r\\n]+", "_");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user