| | |
| | | package com.yssh.service; |
| | | |
| | | import com.yssh.entity.MonitorPointPosition; |
| | | import com.yssh.entity.SuYuan700; |
| | | import com.yssh.entity.xls.DayExcel; |
| | | import com.yssh.entity.xls.MonthExcel; |
| | | import com.yssh.entity.xls.WeekExcel; |
| | | import com.yssh.mapper.XlsReportMapper; |
| | | import com.yssh.utils.CalculateUtils; |
| | | import com.yssh.utils.DateUtils; |
| | | import com.yssh.utils.ExcelUtils; |
| | | import org.slf4j.Logger; |
| | |
| | | |
| | | @Resource |
| | | XlsReportMapper mapper; |
| | | |
| | | @Resource |
| | | CommonService commonService; |
| | | |
| | | /** |
| | | * 报告路径 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建日报 |
| | | * 获取受影响因素及原因 |
| | | */ |
| | | public String getYs(List<SuYuan700> suList) { |
| | | if (null == suList || 0 == suList.size()) return ""; |
| | | |
| | | List<String> list = new ArrayList<>(); |
| | | for (SuYuan700 su : suList) { |
| | | List<String> sub = new ArrayList<>(); |
| | | if (null != su.getAddr1()) |
| | | sub.add(su.getAddr1() + ",概率:" + (su.getOdds1() * 100) + "%,X:" + su.getX1() + ",Y:" + su.getY1()); |
| | | if (null != su.getAddr2()) |
| | | sub.add(su.getAddr2() + ",概率:" + (su.getOdds2() * 100) + "%,X:" + su.getX2() + ",Y:" + su.getY2()); |
| | | if (null != su.getAddr3()) |
| | | sub.add(su.getAddr3() + ",概率:" + (su.getOdds3() * 100) + "%,X:" + su.getX3() + ",Y:" + su.getY3()); |
| | | |
| | | list.add(String.join(";", sub)); |
| | | } |
| | | |
| | | return String.join("\n", list); |
| | | } |
| | | |
| | | /** |
| | | * 创建日报:DayExcel day = new DayExcel("AI-" + (i < 10 ? "0" : "") + i, "lj", "ljtb", "ys", "3m/s", "东南", "°c"); |
| | | */ |
| | | public void createDayReport(Date date) { |
| | | try { |
| | | Date yesterday = DateUtils.getAPeriodOfTime(date, -1, Calendar.DATE); |
| | | String yyyy = DateUtils.parseDateToStr(DateUtils.YYYY, yesterday); |
| | | String yyyymmdd = DateUtils.parseDateToStr(DateUtils.YYYYMMDD, yesterday); |
| | | String yyyy_mm_dd = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, yesterday); |
| | | Integer start = Integer.parseInt(yyyy + "0101"); |
| | | Integer end = Integer.parseInt(yyyymmdd); |
| | | String lastYear = DateUtils.parseDateToStr(DateUtils.YYYY, DateUtils.lastYear(yesterday)); |
| | | |
| | | List<DayExcel> list = new ArrayList<>(); |
| | | for (int i = 1; i < 47; i++) { |
| | | DayExcel day = new DayExcel("AI-" + (i < 10 ? "0" : "") + i, "lj", "ljtb", "ys", "3m/s", "东南", "°c"); |
| | | list.add(day); |
| | | String name = "AI-" + (i < 10 ? "0" : "") + i; |
| | | double rjz = mapper.selectDayAvg(yyyymmdd + "%", name); |
| | | double lj = mapper.selectAccumulate(start, 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"); |
| | | String ys = getYs(suList); |
| | | |
| | | list.add(new DayExcel("" + rjz, "" + lj, "" + ljtb, ys, "", "", "")); |
| | | } |
| | | |
| | | String filePath = createExcel("day", yesterday, list); |
| | | String filePath = createExcel("day", yesterday, list); |
| | | } catch (Exception ex) { |
| | | logger.error(ex.getMessage(), ex); |
| | | } |