| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.ZonedDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.ArrayList; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getAreaAvgDataByAreaCode(Map<String, Object> parameters) throws Exception { |
| | | convertQueryParam(parameters); |
| | | if (!ObjectUtils.isEmpty(parameters.get("compensate"))) { |
| | | parameters.put("timeUnits", "10min"); |
| | | } |
| | | return historyMinutelyMapper.getAreaAvgDataByAreaCode(parameters); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void convertQueryParam(Map<String, Object> parameters) throws ParseException { |
| | | if (!parameters.containsKey("field")) { |
| | | // String type = (String) parameters.get("type"); |
| | | // parameters.putAll(getElementByType(type)); |
| | | ParameterUtils.getElementByType(parameters); |
| | | if (parameters.containsKey("timeUnits")) { |
| | | if ("minutely".equals(parameters.get("timeUnits"))) { |
| | | if (parameters.containsKey("time")) { |
| | | String[] timeStr = parameters.get("time").toString().split("-"); |
| | | int year = Integer.valueOf(timeStr[0]); |
| | | int month = Integer.valueOf(timeStr[1]); |
| | | if (year >= 2020) { |
| | | String yearAndMonth; |
| | | if (month < 10) { |
| | | yearAndMonth = "minutely_" + year + "0" + month; |
| | | } else { |
| | | yearAndMonth = "minutely_" + year + month; |
| | | } |
| | | parameters.put("timeUnits", yearAndMonth); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | String time = (String) parameters.get("time"); |
| | | String format = (String) parameters.get("format"); |
| | |
| | | */ |
| | | public Map<String, List<Double>> queryOneLineChartDateByCrieria(List<String> sensorKeys, TimePeriod timePeriod, DataCondition dataCondition) { |
| | | List<String> timeList = ReportTimeFormat.makeTimeList(timePeriod); |
| | | List<Map<String, Object>> lineChartDatas = historyMinutelyMapper.selectLineChartDateByCrieria(sensorKeys, timePeriod, dataCondition); |
| | | Instant instant = timePeriod.getStartTime().toInstant(); |
| | | ZonedDateTime zdt = instant.atZone(ZoneId.systemDefault()); |
| | | LocalDate localDate = zdt.toLocalDate(); |
| | | int year = localDate.getYear(); |
| | | int month = localDate.getMonthValue(); |
| | | String timeUnits; |
| | | if (year < 2020) { |
| | | timeUnits = "minutely"; |
| | | } else { |
| | | if (month < 10) { |
| | | timeUnits = "minutely_" + year + "0" + month; |
| | | } else { |
| | | timeUnits = "minutely_" + year + month; |
| | | } |
| | | } |
| | | List<Map<String, Object>> lineChartDatas = historyMinutelyMapper.selectLineChartDateByCrieria(sensorKeys, timePeriod, timeUnits, dataCondition); |
| | | Map<String, List<Double>> lineChartDatasWithEmpty = new HashMap<>(); |
| | | // lineChartDatasWithEmpty 初始化 |
| | | sensorKeys.forEach(sensorKey -> { |