| | |
| | | private double bjz; |
| | | |
| | | /** |
| | | * Excel是否已存在 |
| | | */ |
| | | private boolean xlsExists(String type, String name) { |
| | | int rows = mapper.reportExists(type, name); |
| | | |
| | | return rows > 0; |
| | | } |
| | | |
| | | /** |
| | | * 获取导出路径 |
| | | */ |
| | | private String getExpPath(String type) { |
| | |
| | | List<DayExcel> list = new ArrayList<>(); |
| | | for (int i = 1; i < 47; i++) { |
| | | String name = "AI-" + (i < 10 ? "0" : "") + i; |
| | | double rjz = mapper.selectDayAvg(yyyymmdd + "%", name); |
| | | double lj = mapper.selectAccumulate(yearStart, end, name); |
| | | double lastLj = mapper.selectYearAccumulate(lastYear + "%", name); |
| | | double ljtb = CalculateUtils.round2((lj - lastLj) / lastLj * 100); |
| | | double rjz = mapper.selectDayAvg(yyyymmdd + "%", name); // 日均值 |
| | | double lj = mapper.selectAccumulate(yearStart, end, name); // 累计 |
| | | double lastLj = mapper.selectYearAccumulate(lastYear + "%", name); // 去年累计 |
| | | double ljtb = CalculateUtils.round2((lj - lastLj) / lastLj * 100); // 累计同比 |
| | | MonitorPointPosition point = commonService.select3dCheckPointByName(name); |
| | | String id = point.getId().substring(0, point.getId().lastIndexOf("_") + 1) + "0"; |
| | | // List<SuYuan700> suList = mapper.selectSuYuanByTime(id, yyyy_mm_dd + " 00:00:00", yyyy_mm_dd + " 23:00:00"); |
| | |
| | | try { |
| | | Date mon = DateUtils.getAPeriodOfTime(date, -7, Calendar.DATE); |
| | | Date sun = DateUtils.getAPeriodOfTime(date, -1, Calendar.DATE); |
| | | Date lastMon = DateUtils.getAPeriodOfTime(date, -14, Calendar.DATE); |
| | | Date lastSun = DateUtils.getAPeriodOfTime(date, -8, Calendar.DATE); |
| | | Date lastYearMon = DateUtils.getAPeriodOfTime(mon, -1, Calendar.YEAR); |
| | | Date lastYearSun = DateUtils.getAPeriodOfTime(sun, -1, Calendar.YEAR); |
| | | Integer intMon = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, mon) + "00"); // 2023072400 |
| | | Integer intSun = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, sun) + "23"); // 2023073023 |
| | | Integer intLastMon = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, lastMon) + "00"); // 2023071700 |
| | | Integer intLastSun = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, lastSun) + "23"); // 2023072323 |
| | | Integer intLastYearMon = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, lastYearMon) + "00"); // 2022071700 |
| | | Integer intLastYearSun = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, lastYearSun) + "23"); // 2022072323 |
| | | String yyyy = DateUtils.parseDateToStr(DateUtils.YYYY, sun); // 2023 |
| | | Integer yearStart = Integer.parseInt(yyyy + "010100"); // 2023010100 |
| | | String lastYear = DateUtils.parseDateToStr(DateUtils.YYYY, DateUtils.lastYear(sun)); // 2022 |
| | | |
| | | List<WeekExcel> list = new ArrayList<>(); |
| | | for (int i = 1; i < 47; i++) { |
| | | String name = "AI-" + (i < 10 ? "0" : "") + i; |
| | | double sz = mapper.selectAccumulate(intMon, intSun, name); // 上周 |
| | | double ssz = mapper.selectAccumulate(intLastMon, intLastSun, name); // 上上周 |
| | | double zhb = CalculateUtils.round2((sz - ssz) / ssz * 100); // 周环比 |
| | | double qntq = mapper.selectAccumulate(intLastYearMon, intLastYearSun, name); // 去年同期 |
| | | double ztb = CalculateUtils.round2((sz - qntq) / qntq * 100); // 周同比 |
| | | double lj = mapper.selectAccumulate(yearStart, intSun, name); // 累计 |
| | | double lastLj = mapper.selectYearAccumulate(lastYear + "%", name); // 去年累计 |
| | | double ljtb = CalculateUtils.round2((lj - lastLj) / lastLj * 100); // 累计同比 |
| | | MonitorPointPosition point = commonService.select3dCheckPointByName(name); |
| | | String id = point.getId().substring(0, point.getId().lastIndexOf("_") + 1) + "0"; |
| | | List<SuYuan700> suList = mapper.selectSuYuanByStartAndEnd(id, name, yjz, intMon, intSun); |
| | | String ys = getYs(suList); |
| | | list.add(new WeekExcel("" + sz, zhb + "%", "", ztb + "%", "", "" + lj, "" + ljtb, "", ys, "", "", "")); |
| | | } |
| | | |
| | | //String filePath = createExcel("week", end, list); |
| | | saveResult("week", sun, list); |
| | | } catch (Exception ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建月报 |
| | | * 创建月报:new MonthExcel("AI-" + (i < 10 ? "0" : "") + i, "yhb", "ytq", "ytb", "yhb2", "lj", "ljtb", "qyn", "ys", "fs", "fx", "°c"); |
| | | */ |
| | | public void createMonthReport(Date date) { |
| | | try { |
| | |
| | | |
| | | 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", "°c"); |
| | | list.add(day); |
| | | // |
| | | } |
| | | |
| | | String filePath = createExcel("month", end, list); |