| | |
| | | import com.yssh.entity.xls.DayExcel; |
| | | import com.yssh.entity.xls.MonthExcel; |
| | | import com.yssh.entity.xls.WeekExcel; |
| | | import com.yssh.entity.xls.XlsReport; |
| | | import com.yssh.mapper.XlsReportMapper; |
| | | import com.yssh.utils.CalculateUtils; |
| | | import com.yssh.utils.DateUtils; |
| | |
| | | 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); |
| | | File f = new File(target); |
| | | if (!f.exists() || f.isDirectory()) { |
| | | createExcel(source, target, list); |
| | | } |
| | | |
| | | return String.format("%s\\%s.xlsx", type, strData); |
| | | } |
| | | |
| | | /** |
| | | * 保存结果 |
| | | */ |
| | | private <T> void saveResult(String type, Date date, List<T> list) throws Exception { |
| | | date = DateUtils.trimTime(date); |
| | | String filePath = createExcel(type, date, list); |
| | | String name = filePath.replace(type + "\\", ""); |
| | | |
| | | int rows = mapper.reportExists(type, name); |
| | | if (rows > 0) return; |
| | | |
| | | XlsReport xls = new XlsReport(); |
| | | xls.setName(name); |
| | | xls.setType(type); |
| | | xls.setPath(filePath); |
| | | xls.setCreateTime(date); |
| | | |
| | | mapper.insertReport(xls); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | list.add(new DayExcel("" + rjz, "" + lj, ljtb + "%", ys, "", "", "")); |
| | | } |
| | | |
| | | String filePath = createExcel("day", yesterday, list); |
| | | saveResult("day", yesterday, list); |
| | | } catch (Exception ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | } |