Browse Source

获取天气增加日志

tags/v1.2.0^2
wanjing 1 year ago
parent
commit
b2a91e81d7
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/status/UpdateWaittStatusService.java

+ 14
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/status/UpdateWaittStatusService.java View File

} }


public JsonResult getWeather(String airportUrl, Integer airportId) { public JsonResult getWeather(String airportUrl, Integer airportId) {
log.info("获取天气信息begin");
String url = airportUrl + SystemConstant.API_AIRPORT_GET_WEATHER; String url = airportUrl + SystemConstant.API_AIRPORT_GET_WEATHER;
String param = "airportId=" + airportId; String param = "airportId=" + airportId;

log.info("获取天气信息, url={}", url);
log.info("获取天气信息, param={}", param);

String weatherStr = HttpUtils.sendGet(url, param); String weatherStr = HttpUtils.sendGet(url, param);

log.info("获取天气信息, weatherStr1={}", weatherStr);

JsonResult jsonResult; JsonResult jsonResult;
try { try {
log.info("获取天气信息, weatherStr2={}", weatherStr);
jsonResult = JacksonUtil.json2pojo(weatherStr, JsonResult.class); jsonResult = JacksonUtil.json2pojo(weatherStr, JsonResult.class);

log.info("获取天气信息, jsonResult={}", jsonResult);

if (ObjectUtil.isEmpty(jsonResult) || Objects.requireNonNull(jsonResult).getCode() != 0) { if (ObjectUtil.isEmpty(jsonResult) || Objects.requireNonNull(jsonResult).getCode() != 0) {
log.info("获取天气信息失败,返回为空或code不为0"); log.info("获取天气信息失败,返回为空或code不为0");
log.info("获取天气信息失败,url={}", url); log.info("获取天气信息失败,url={}", url);
log.info("获取天气信息,返回数据为空"); log.info("获取天气信息,返回数据为空");
return JsonResult.success(new AirWeatherVO()); return JsonResult.success(new AirWeatherVO());
} }
log.info("获取天气信息, jsonResult.getData={}", jsonResult.getData());
AirWeatherVO airWeatherVO = JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()), AirWeatherVO.class); AirWeatherVO airWeatherVO = JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()), AirWeatherVO.class);
log.info("获取天气信息,airWeatherVO={}", airWeatherVO);
return JsonResult.success(airWeatherVO); return JsonResult.success(airWeatherVO);
} catch (Exception e) { } catch (Exception e) {
log.info("获取天气信息异常,url={}", url); log.info("获取天气信息异常,url={}", url);

Loading…
Cancel
Save