From 30c1a4a13c4fdc41324629eb0e411c47b4b5c679 Mon Sep 17 00:00:00 2001 From: dk <1260500659@qq.com> Date: Tue, 30 Jun 2026 11:58:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=B7=A5=E4=BD=9C=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E3=80=81=E6=88=91=E7=9A=84=E7=BB=A9=E6=95=88=E3=80=81=E4=BA=A7?= =?UTF-8?q?=E5=93=81/=E9=A1=B9=E7=9B=AE=E3=80=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=80=9A=E7=9F=A5):=20=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WorkReportContentExportService.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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 +}