|
|
@ -10,6 +10,7 @@ import com.zc.business.domain.DcRegion; |
|
|
|
import com.zc.business.service.impl.DcRegionServiceImpl; |
|
|
|
import com.zc.common.core.httpclient.OkHttp; |
|
|
|
import com.zc.common.core.httpclient.exception.HttpException; |
|
|
|
import com.zc.common.core.httpclient.request.RequestParams; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import okhttp3.Response; |
|
|
@ -51,6 +52,103 @@ public class WeatherForecastController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private ISysConfigService configService; |
|
|
|
|
|
|
|
/* |
|
|
|
* 当前气象及预报信息查询 |
|
|
|
* */ |
|
|
|
@ApiOperation("当前气象及预报信息查询") |
|
|
|
@PostMapping(value = "/currentWeatherAndForecastInformation") |
|
|
|
public AjaxResult currentWeatherAndForecastInformation(@RequestBody HashMap<String,Object> parameter) { |
|
|
|
|
|
|
|
String stakeNum = String.valueOf(parameter.get("stakeNum")); |
|
|
|
String[] split = stakeNum.split("[|]"); |
|
|
|
|
|
|
|
StringBuilder numStake = new StringBuilder(); |
|
|
|
|
|
|
|
for (int i = 0; i < split.length; i++) { |
|
|
|
String[] split1 = split[i].split("[+]"); |
|
|
|
String k = split1[0].replace("K", ""); |
|
|
|
int parseInt = Integer.parseInt(k); |
|
|
|
numStake.append("K").append(parseInt).append("+000"); |
|
|
|
if (i != split.length - 1) { |
|
|
|
numStake.append("|"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
parameter.put("stakeNum", numStake); |
|
|
|
|
|
|
|
|
|
|
|
JSONObject weather = JSONObject.parseObject(configService.selectConfigByKey("weather")); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
|
|
|
|
|
RequestParams requestParams = new RequestParams(parameter); |
|
|
|
Response response // 请求响应
|
|
|
|
= okHttp |
|
|
|
.headers(new HashMap<>()) |
|
|
|
.url(weather.getString("get_weather_info")) // 请求地址
|
|
|
|
//.url("http://10.166.133.9:38999/api/weather_service/get_weather_info") // 请求地址
|
|
|
|
.data(requestParams) |
|
|
|
.post(); // 请求方法
|
|
|
|
|
|
|
|
if (response.body() != null) { |
|
|
|
|
|
|
|
JSONObject jsonResult = JSONObject.parseObject(response.body().string()); |
|
|
|
if (jsonResult.getInteger("code") == 200) { |
|
|
|
return AjaxResult.success(jsonResult.getJSONArray("data")); |
|
|
|
} else { |
|
|
|
return AjaxResult.error(jsonResult.getInteger("code"), "请求失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception ignored) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
return AjaxResult.error("请求失败"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
* 当前气象预警信息查询 |
|
|
|
* */ |
|
|
|
@ApiOperation("当前气象预警信息查询") |
|
|
|
@PostMapping(value = "/currentWeatherWarningInformationQuery") |
|
|
|
public AjaxResult currentWeatherWarningInformationQuery(@RequestBody HashMap<String, Object> parameter) { |
|
|
|
|
|
|
|
|
|
|
|
JSONObject weather = JSONObject.parseObject(configService.selectConfigByKey("weather")); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
|
|
|
|
|
RequestParams requestParams = new RequestParams(parameter); |
|
|
|
Response response // 请求响应
|
|
|
|
= okHttp |
|
|
|
.headers(new HashMap<>()) |
|
|
|
.url(weather.getString("get_earlyworning_info")) // 请求地址
|
|
|
|
//.url("http://10.166.133.9:38999/api/weather_service/get_earlyworning_info") // 请求地址
|
|
|
|
.data(requestParams) |
|
|
|
.post(); // 请求方法
|
|
|
|
|
|
|
|
if (response.body() != null) { |
|
|
|
|
|
|
|
JSONObject jsonResult = JSONObject.parseObject(response.body().string()); |
|
|
|
if (jsonResult.getInteger("code") == 200) { |
|
|
|
return AjaxResult.success(jsonResult.getJSONArray("data")); |
|
|
|
} else { |
|
|
|
return AjaxResult.error(jsonResult.getInteger("code"), "请求失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception ignored) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
return AjaxResult.error("请求失败"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
* 天气实况查询 |
|
|
|
* */ |
|
|
@ -71,6 +169,17 @@ public class WeatherForecastController extends BaseController { |
|
|
|
return getAjaxResult(weather.getString("METEOROLOGICALEARLYWARNINGURI"), weather.getString("METEOROLOGICALEARLYWARNINGKEY"), weather.getString("METEOROLOGICALEARLYWARNING")); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 逐小时天气查询 |
|
|
|
* */ |
|
|
|
@ApiOperation("逐小时天气查询") |
|
|
|
@PostMapping(value = "/hourlyWeather") |
|
|
|
public AjaxResult hourlyWeather() { |
|
|
|
JSONObject weather = JSONObject.parseObject(configService.selectConfigByKey("weather")); |
|
|
|
return getAjaxResult(weather.getString("HOURLYWEATHERURI"), weather.getString("HOURLYWEATHERKEY"), weather.getString("HOURLYWEATHER")); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
* 气象预警数量查询 |
|
|
|
* */ |
|
|
@ -135,16 +244,6 @@ public class WeatherForecastController extends BaseController { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 逐小时天气查询 |
|
|
|
* */ |
|
|
|
@ApiOperation("逐小时天气查询") |
|
|
|
@PostMapping(value = "/hourlyWeather") |
|
|
|
public AjaxResult hourlyWeather() { |
|
|
|
JSONObject weather = JSONObject.parseObject(configService.selectConfigByKey("weather")); |
|
|
|
return getAjaxResult(weather.getString("HOURLYWEATHERURI"), weather.getString("HOURLYWEATHERKEY"), weather.getString("HOURLYWEATHER")); |
|
|
|
} |
|
|
|
|
|
|
|
private AjaxResult getAjaxResult(String uri, String accessKey, String redisKey) { |
|
|
|
JSONObject weather = JSONObject.parseObject(configService.selectConfigByKey("weather")); |
|
|
|
|
|
|
|