fix(工作报告、我的绩效、产品/项目、消息通知): 修复已知的一些问题。

This commit is contained in:
dk
2026-06-30 11:58:19 +08:00
parent 9f265c6dd1
commit 30c1a4a13c

View File

@@ -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]+", "_");
} }
@@ -1866,4 +1879,4 @@ public class WorkReportContentExportService {
private record DocumentContent(String filename, byte[] content) { private record DocumentContent(String filename, byte[] content) {
} }
} }