diff --git a/rdms-project/rdms-project-boot/src/main/java/com/njcn/rdms/module/project/service/workreport/export/WorkReportContentExportService.java b/rdms-project/rdms-project-boot/src/main/java/com/njcn/rdms/module/project/service/workreport/export/WorkReportContentExportService.java index 0a526d9..1b45936 100644 --- a/rdms-project/rdms-project-boot/src/main/java/com/njcn/rdms/module/project/service/workreport/export/WorkReportContentExportService.java +++ b/rdms-project/rdms-project-boot/src/main/java/com/njcn/rdms/module/project/service/workreport/export/WorkReportContentExportService.java @@ -39,6 +39,7 @@ import java.math.BigInteger; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.time.temporal.IsoFields; import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -187,7 +188,8 @@ public class WorkReportContentExportService { replacePlaceholders(document, buildWeeklyTemplateData(report)); renderPersonalReviewTable(document, report.getReviewItems()); renderPersonalPlanTable(document, report.getPlanItems()); - return new DocumentContent(buildFilename("个人周报", report.getReporterName(), report.getPeriodLabel()), + return new DocumentContent(buildWeeklyFilename("个人周报", report.getReporterName(), + report.getPeriodStartDate(), report.getPeriodLabel()), toBytes(document)); } catch (IOException | Docx4JException e) { throw new IllegalStateException("生成周报模板导出文件失败", e); @@ -214,7 +216,8 @@ public class WorkReportContentExportService { addSectionTitle(document, "下周期重点工作计划"); 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)); } catch (Docx4JException | IOException e) { throw new IllegalStateException("生成周报导出文件失败", e); @@ -1821,6 +1824,16 @@ public class WorkReportContentExportService { 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) { return filename.replaceAll("[\\\\/:*?\"<>|\\r\\n]+", "_"); } @@ -1866,4 +1879,4 @@ public class WorkReportContentExportService { private record DocumentContent(String filename, byte[] content) { } -} \ No newline at end of file +}