修改污染溯源接口,从history表中获取改为从history天表获取
| | |
| | | public ModelAndView pollutionSource(ModelAndView model, HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | String timeStr = parameters.get("time").toString(); |
| | | String YearAndDay = timeStr.substring(0, timeStr.lastIndexOf("-")); |
| | | String yearAndDay = timeStr.substring(0, timeStr.lastIndexOf("-")); |
| | | String Hour = timeStr.substring(timeStr.lastIndexOf("-") + 1); |
| | | String time = YearAndDay + " " + Hour + ":00:00"; |
| | | String time = yearAndDay + " " + Hour + ":00:00"; |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | LocalDateTime timeLocalDateTime = LocalDateTime.parse(time, dateTimeFormatter); |
| | | int month = timeLocalDateTime.getMonth().getValue(); |
| | | parameters.put("yearAndDay",yearAndDay); |
| | | Point dirPoint = historyHourlyService.getDirPoint(parameters); |
| | | Map<String, Object> getPollutionSourceData = historyHourlyService.getPollutionSourceDataByHour(parameters); |
| | | if (MapUtils.isEmpty(getPollutionSourceData)) { |
| | |
| | | |
| | | @Override |
| | | public Map<String, Object> getPollutionSourceDataByHour(Map<String, Object> parameters) throws Exception { |
| | | String yearAndDay = String.valueOf(parameters.get("yearAndDay")); |
| | | yearAndDay = yearAndDay.replace("-",""); |
| | | parameters.put("yearAndDay",yearAndDay); |
| | | List<Sensor> sensors = sensorMapper.getSensorsByMac(parameters); |
| | | List<String> sensorKeys = new ArrayList<>(); |
| | | for (Sensor sensor : sensors) { |
| | |
| | | |
| | | @Override |
| | | public Map<String, Object> getPollutionSourceDataAll(Map<String, Object> parameters) throws Exception { |
| | | String yearAndDay = String.valueOf(parameters.get("yearAndDay")); |
| | | yearAndDay = yearAndDay.replace("-",""); |
| | | parameters.put("yearAndDay",yearAndDay); |
| | | List<Sensor> sensors = sensorMapper.getSensorsByMac(parameters); |
| | | List<String> sensorKeys = new ArrayList<>(); |
| | | for (Sensor sensor : sensors) { |
| | |
| | | </foreach> |
| | | FROM |
| | | <if test="mac!=null and time!=null"> |
| | | (select mac,value,time,version from history |
| | | (select mac,value,time,version from history_${yearAndDay} |
| | | where mac = #{mac} and time BETWEEN DATE_SUB(#{time}, INTERVAL 1 HOUR) and #{time}) h |
| | | </if> |
| | | GROUP BY |
| | |
| | | </foreach> |
| | | FROM |
| | | <if test="mac!=null"> |
| | | (select mac,value,time,version from history |
| | | (select mac,value,time,version from history_${yearAndDay} |
| | | where mac = #{mac} and time BETWEEN DATE_SUB(#{time}, INTERVAL 1 DAY) and #{time}) h |
| | | </if> |
| | | GROUP BY |