|
@@ -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,temperature_2m_min&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,precipitation_sum&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,temperature_2m_min&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,precipitation_sum&timezone=Asia%2FShanghai&start_date=" + startDate + "&end_date=" + endDate;
|
|
|
isApiQuotaExhausted = analysisXMO(xmoUrl, q.getCode(), q.getName(), conn); // 传递标志变量
|
|
|
if (isApiQuotaExhausted) break; // 检查标志变量
|
|
|
//线程睡5秒 防止请求过快
|
|
@@ -575,6 +575,7 @@ public class GetWeather {
|
|
|
//2m温度
|
|
|
JSONArray temp = JSONUtil.parseArray(daily.get("temperature_2m_max"));
|
|
|
JSONArray tempMin = JSONUtil.parseArray(daily.get("temperature_2m_min"));
|
|
|
+ JSONArray precipitationSum = JSONUtil.parseArray(daily.get("precipitation_sum"));
|
|
|
//10米风向
|
|
|
JSONArray direction = JSONUtil.parseArray(daily.get("wind_direction_10m_dominant"));
|
|
|
//天气代码
|
|
@@ -592,6 +593,7 @@ public class GetWeather {
|
|
|
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.setHumidity(precipitationSum.get(i) == null ? -0.99f : new BigDecimal(precipitationSum.get(i).toString()).floatValue());
|
|
|
heFengDay.setDswrf(dswrfDay.get(i) == null ? -0.99f : new BigDecimal(dswrfDay.get(i).toString()).floatValue());
|
|
|
heFengDayList.add(heFengDay);
|
|
|
}
|
|
@@ -600,9 +602,10 @@ public class GetWeather {
|
|
|
}
|
|
|
for (HeFengDay item : heFengDayList) {
|
|
|
String insertSQL = "INSERT INTO hefeng_day_unit_" + areaCode + " USING hefeng_day_unit TAGS('" + areaCode + "') " +
|
|
|
- "(ts,wind_speed_day,wind_360_Day,precip,text_day,temp_max,dswrf) values('"
|
|
|
+ "(ts,wind_speed_day,wind_360_Day,precip,text_day,temp_max,temp_min,humidity,dswrf) values('"
|
|
|
+ item.getTs() + "', " + item.getWindSpeedDay() + ", " + item.getWind360Day() + ", " + item.getPrecip() + ", '"
|
|
|
- + item.getTextDay() + "', " + item.getTempMax() + ", " + item.getDswrf() + ")";
|
|
|
+ + item.getTextDay() + "', " + item.getTempMax() + ", " + item.getTempMin() + ", " + item.getHumidity() + ", "
|
|
|
+ + item.getDswrf() + ")";
|
|
|
int affectedRows = ps.executeUpdate(insertSQL);
|
|
|
}
|
|
|
if (ps != null)
|