| | |
| | | import java.text.DecimalFormat;
|
| | | import java.time.LocalDate;
|
| | | import java.time.LocalDateTime;
|
| | | import java.time.Month;
|
| | | import java.time.format.DateTimeFormatter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | |
| | | @ApiImplicitParam(name = "time", value = "查询时间(格式:2019-08-22)", required = true, paramType = "query", dataType = "String")})
|
| | | public ModelAndView pollutionSource(ModelAndView model, HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
|
| | | LocalDate today=LocalDate.now();
|
| | | String time=parameters.get("time").toString();
|
| | | LocalDate today = LocalDate.now();
|
| | | String time = parameters.get("time").toString();
|
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
| | | LocalDate selectTime = LocalDate.parse(time, dateTimeFormatter);
|
| | | LocalDate yesterday=today.minusDays(1);
|
| | | LocalDate futureDay=today.plusDays(14);
|
| | | Boolean isAfterYesterday=selectTime.isAfter(yesterday)||selectTime.isEqual(yesterday);
|
| | | Boolean isAfterFutureDay=selectTime.isAfter(futureDay);
|
| | | Map<String, Object> weatherInfoToday=weatherService.getWeatherDataByRegion(parameters);
|
| | | Map<String, Object> weatherInfoForecast=new HashMap<>();
|
| | | if(isAfterYesterday&&!isAfterFutureDay){
|
| | | weatherInfoForecast= weatherService.get15DayWeatherDataByRegion(parameters);
|
| | | int month = selectTime.getMonth().getValue();
|
| | | LocalDate yesterday = today.minusDays(1);
|
| | | LocalDate futureDay = today.plusDays(14);
|
| | | Boolean isAfterYesterday = selectTime.isAfter(yesterday) || selectTime.isEqual(yesterday);
|
| | | Boolean isAfterFutureDay = selectTime.isAfter(futureDay);
|
| | | Map<String, Object> weatherInfoToday = weatherService.getWeatherDataByRegion(parameters);
|
| | | Map<String, Object> weatherInfoForecast = new HashMap<>();
|
| | | if (isAfterYesterday && !isAfterFutureDay) {
|
| | | weatherInfoForecast = weatherService.get15DayWeatherDataByRegion(parameters);
|
| | | }
|
| | | Boolean isToday=selectTime.isEqual(today);
|
| | | String mac=parameters.get("mac").toString();
|
| | | Boolean isToday = selectTime.isEqual(today);
|
| | | String mac = parameters.get("mac").toString();
|
| | | Device device = deviceService.getDeviceByMac(mac, false);
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("weatherInfoToday", weatherInfoToday);
|
| | | params.put("weatherInfoForecast", weatherInfoForecast);
|
| | | params.put("device", device);
|
| | | params.put("isToday",isToday);
|
| | | params.put("isToday", isToday);
|
| | | params.put("month", month);
|
| | | String paramsJson = params.toJSONString();
|
| | | model.addObject("pollutionSourceParams", paramsJson);
|
| | | model.setViewName("pollutionsource");
|