From 14c9af5c6a07df489581d5a6b837bf7b97819d5c Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 09 八月 2023 17:17:22 +0800 Subject: [PATCH] 1 --- src/main/java/com/yssh/service/XlsExportService.java | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/yssh/service/XlsExportService.java b/src/main/java/com/yssh/service/XlsExportService.java index 19f710f..b538306 100644 --- a/src/main/java/com/yssh/service/XlsExportService.java +++ b/src/main/java/com/yssh/service/XlsExportService.java @@ -3,6 +3,7 @@ import com.yssh.entity.xls.DayExcel; import com.yssh.entity.xls.MonthExcel; import com.yssh.entity.xls.WeekExcel; +import com.yssh.utils.DateUtils; import com.yssh.utils.ExcelUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,15 +65,18 @@ */ public void createDayReport(Date date) { try { + Date yesterday = DateUtils.getAPeriodOfTime(date, -1, Calendar.DATE); + String type = "day"; List<DayExcel> list = new ArrayList<>(); for (int i = 1; i < 47; i++) { - DayExcel day = new DayExcel("AI-" + (i < 10 ? "0" : "") + i, "lj", "ljtb", "ys", "fs", "fx", "wd"); + DayExcel day = new DayExcel("AI-" + (i < 10 ? "0" : "") + i, "lj", "ljtb", "ys", "3m/s", "涓滃崡", "掳c"); list.add(day); } String source = getXslTemplate(type); - String target = String.format("%s\\%d.xlsx", getExpPath(type), 20230809); + String strData = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, yesterday); + String target = String.format("%s\\%s.xlsx", getExpPath(type), strData); createExcel(source, target, list); } catch (Exception ex) { @@ -85,15 +89,19 @@ */ public void createWeekReport(Date date) { try { + Date start = DateUtils.getAPeriodOfTime(date, -7, Calendar.DATE); + Date end = DateUtils.getAPeriodOfTime(date, -1, Calendar.DATE); + String type = "week"; List<WeekExcel> list = new ArrayList<>(); for (int i = 1; i < 47; i++) { - WeekExcel day = new WeekExcel("AI-" + (i < 10 ? "0" : "") + i, "zhb", "ztq", "ztb", "zhb2", "lj", "ljtb", "syn", "ys", "fs", "fx", "wd"); + WeekExcel day = new WeekExcel("AI-" + (i < 10 ? "0" : "") + i, "zhb", "ztq", "ztb", "zhb2", "lj", "ljtb", "syn", "ys", "fs", "fx", "掳c"); list.add(day); } String source = getXslTemplate(type); - String target = String.format("%s\\%d.xlsx", getExpPath(type), 20230807); + String strData = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, end); + String target = String.format("%s\\%s.xlsx", getExpPath(type), strData); createExcel(source, target, list); } catch (Exception ex) { @@ -106,15 +114,21 @@ */ public void createMonthReport(Date date) { try { + Date yesterday = DateUtils.getAPeriodOfTime(date, -1, Calendar.DATE); + Date start = DateUtils.getMonthStart(yesterday); + Date end = DateUtils.getMonthEnd(yesterday); + + String type = "month"; List<MonthExcel> list = new ArrayList<>(); for (int i = 1; i < 47; i++) { - MonthExcel day = new MonthExcel("AI-" + (i < 10 ? "0" : "") + i, "yhb", "ytq", "ytb", "yhb2", "lj", "ljtb", "qyn", "ys", "fs", "fx", "wd"); + MonthExcel day = new MonthExcel("AI-" + (i < 10 ? "0" : "") + i, "yhb", "ytq", "ytb", "yhb2", "lj", "ljtb", "qyn", "ys", "fs", "fx", "掳c"); list.add(day); } String source = getXslTemplate(type); - String target = String.format("%s\\%d.xlsx", getExpPath(type), 202308); + String strData = DateUtils.parseDateToStr(DateUtils.YYYYMM, end); + String target = String.format("%s\\%s.xlsx", getExpPath(type), strData); createExcel(source, target, list); } catch (Exception ex) { -- Gitblit v1.9.3