Browse Source

获取天气添加日志

tags/v1.2.0^2
wanjing 1 year ago
parent
commit
08ec86cf5b
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java

+ 4
- 3
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java View File

String url = CommonConfig.airportURL + "/api/airportInterface/getWeather"; String url = CommonConfig.airportURL + "/api/airportInterface/getWeather";
String param = "airportId=" + airportId; String param = "airportId=" + airportId;
String weatherStr = HttpUtils.sendGet(url, param); String weatherStr = HttpUtils.sendGet(url, param);
log.info("获取天气信息,weatherStr={}", weatherStr);
JsonResult jsonResult; JsonResult jsonResult;
try { try {
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 new AirWeatherVO(); return new AirWeatherVO();
} }
return JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()), AirWeatherVO.class);
log.info("获取天气信息,jsonResult Data={}", jsonResult.getData());
AirWeatherVO airWeatherVO = JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()), AirWeatherVO.class);
log.info("获取天气信息,airWeatherVO={}", airWeatherVO);
return airWeatherVO;
} catch (Exception e) { } catch (Exception e) {
log.info("获取天气信息异常,url={}", url); log.info("获取天气信息异常,url={}", url);
log.info("获取天气信息异常,param={}", param); log.info("获取天气信息异常,param={}", param);

Loading…
Cancel
Save