| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建Excel |
| | | */ |
| | | private <T> String createExcel(String type, Date date, List<T> list) throws Exception { |
| | | String source = getXslTemplate(type); |
| | | String strData = DateUtils.parseDateToStr("month".equals(type) ? DateUtils.YYYYMM : DateUtils.YYYYMMDD, date); |
| | | String target = String.format("%s\\%s.xlsx", getExpPath(type), strData); |
| | | |
| | | createExcel(source, target, list); |
| | | |
| | | return String.format("%s\\%s.xlsx", type, strData); |
| | | } |
| | | |
| | | /** |
| | | * 创建日报 |
| | | */ |
| | | public void createDayReport(Date date) { |
| | | try { |
| | | String type = "day"; |
| | | Date yesterday = DateUtils.getAPeriodOfTime(date, -1, Calendar.DATE); |
| | | |
| | | 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); |
| | | |
| | | createExcel(source, target, list); |
| | | String filePath = createExcel("day", yesterday, list); |
| | | } catch (Exception ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | } |
| | |
| | | */ |
| | | public void createWeekReport(Date date) { |
| | | try { |
| | | String type = "week"; |
| | | Date start = DateUtils.getAPeriodOfTime(date, -7, Calendar.DATE); |
| | | Date end = DateUtils.getAPeriodOfTime(date, -1, Calendar.DATE); |
| | | |
| | | 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); |
| | | |
| | | createExcel(source, target, list); |
| | | String filePath = createExcel("week", end, list); |
| | | } catch (Exception ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | } |
| | |
| | | */ |
| | | public void createMonthReport(Date date) { |
| | | try { |
| | | String type = "month"; |
| | | Date yesterday = DateUtils.getAPeriodOfTime(date, -1, Calendar.DATE); |
| | | Date start = DateUtils.getMonthStart(yesterday); |
| | | Date end = DateUtils.getMonthEnd(yesterday); |
| | | |
| | | 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); |
| | | |
| | | createExcel(source, target, list); |
| | | String filePath = createExcel("month", end, list); |
| | | } catch (Exception ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | } |