Browse Source

修改 甘肃 日天气数据转为接xmo

xiaowang 4 days ago
parent
commit
01ee672efb
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/main/java/com/example/getweather/service/GetWeather.java

+ 4 - 2
src/main/java/com/example/getweather/service/GetWeather.java

@@ -364,13 +364,13 @@ public class GetWeather {
                         List<DistrictCodeDO> quList = districtCodeDOList.stream().filter(item -> item.getPid().toString().equals(d.getCode().toString())).collect(Collectors.toList());
                         String xmoUrl;
                         //彩云综合数据查询
-                        xmoUrl = "https://weather-api.xm-opt.com/v1/forecastDaily?latitude=" + d.getLat() + "&longitude=" + d.getLng() + "&daily=weather_code,temperature_2m_max,rain_sum,wind_speed_10m_max,wind_direction_10m_dominant,shortwave_radiation_sum&timezone=Asia%2FShanghai&start_date=" + startDate + "&end_date=" + endDate;
+                        xmoUrl = "https://weather-api.xm-opt.com/v1/forecastDaily?latitude=" + d.getLat() + "&longitude=" + d.getLng() + "&daily=weather_code,temperature_2m_max,rain_sum,wind_speed_10m_max,wind_direction_10m_dominant,shortwave_radiation_sum,temperature_2m_min&timezone=Asia%2FShanghai&start_date=" + startDate + "&end_date=" + endDate;
                         isApiQuotaExhausted = analysisXMO(xmoUrl, d.getCode(), d.getName(), conn); // 传递标志变量
                         if (isApiQuotaExhausted) break; // 检查标志变量
                         //区
                         for (DistrictCodeDO q : quList) {
                             if (isApiQuotaExhausted) break; // 检查标志变量
-                            xmoUrl = "https://weather-api.xm-opt.com/v1/forecastDaily?latitude=" + q.getLat() + "&longitude=" + q.getLng() + "&daily=weather_code,temperature_2m_max,rain_sum,wind_speed_10m_max,wind_direction_10m_dominant,shortwave_radiation_sum&timezone=Asia%2FShanghai&start_date=" + startDate + "&end_date=" + endDate;
+                            xmoUrl = "https://weather-api.xm-opt.com/v1/forecastDaily?latitude=" + q.getLat() + "&longitude=" + q.getLng() + "&daily=weather_code,temperature_2m_max,rain_sum,wind_speed_10m_max,wind_direction_10m_dominant,shortwave_radiation_sum,temperature_2m_min&timezone=Asia%2FShanghai&start_date=" + startDate + "&end_date=" + endDate;
                             isApiQuotaExhausted = analysisXMO(xmoUrl, q.getCode(), q.getName(), conn); // 传递标志变量
                             if (isApiQuotaExhausted) break; // 检查标志变量
                             //线程睡5秒 防止请求过快
@@ -574,6 +574,7 @@ public class GetWeather {
             JSONArray precip = JSONUtil.parseArray(daily.get("rain_sum"));
             //2m温度
             JSONArray temp = JSONUtil.parseArray(daily.get("temperature_2m_max"));
+            JSONArray tempMin = JSONUtil.parseArray(daily.get("temperature_2m_min"));
             //10米风向
             JSONArray direction = JSONUtil.parseArray(daily.get("wind_direction_10m_dominant"));
             //天气代码
@@ -590,6 +591,7 @@ public class GetWeather {
                     heFengDay.setPrecip(precip.get(i) == null ? -0.99f : new BigDecimal(precip.get(i).toString()).floatValue());
                     heFengDay.setTextDay(ConversionWeatherCodeXmo(code.get(i).toString() == null ? "0" : code.get(i).toString()));
                     heFengDay.setTempMax(temp.get(i) == null ? -0.99f : new BigDecimal(temp.get(i).toString()).floatValue());
+                    heFengDay.setTempMin(tempMin.get(i) == null ? -0.99f : new BigDecimal(tempMin.get(i).toString()).floatValue());
                     heFengDay.setDswrf(dswrfDay.get(i) == null ? -0.99f : new BigDecimal(dswrfDay.get(i).toString()).floatValue());
                     heFengDayList.add(heFengDay);
                 }