@@ -51,6 +51,7 @@ public class AirWeatherVO implements Serializable { | |||
public static class WTHDTO { | |||
@ApiModelProperty(value = "parm") | |||
private ParmDTO parm; | |||
private ParmNewDTO parmNew; | |||
@ApiModelProperty(value = "mid") | |||
private Integer mid; | |||
@ApiModelProperty(value = "deviceid") | |||
@@ -88,6 +89,21 @@ public class AirWeatherVO implements Serializable { | |||
@ApiModelProperty(value = "WDIR") | |||
private Integer wdir; | |||
} | |||
@NoArgsConstructor | |||
@Data | |||
public static class ParmNewDTO { | |||
private Double hum; | |||
private Double noise; | |||
private Double rainfull; | |||
private Double tmp; | |||
private String wdirname; | |||
private Double dew; | |||
private Double wspd; | |||
private Double hpa; | |||
private Double wdir; | |||
private Double lux; | |||
} | |||
} | |||
@NoArgsConstructor |
@@ -231,13 +231,19 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper, | |||
try { | |||
jsonResult = JacksonUtil.json2pojo(weatherStr, JsonResult.class); | |||
if (ObjectUtil.isEmpty(jsonResult) || Objects.requireNonNull(jsonResult).getCode() != 0) { | |||
log.info("获取天气信息失败,返回为空或code不为0"); | |||
log.info("获取天气信息失败,url={}", url); | |||
log.info("获取天气信息失败,param={}", param); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取天气信息失败,请重试"); | |||
} | |||
if (ObjectUtil.isEmpty(jsonResult.getData())) { | |||
log.info("获取天气信息,返回数据为空"); | |||
return new AirWeatherVO(); | |||
} | |||
return JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()), AirWeatherVO.class); | |||
} catch (Exception e) { | |||
log.info("获取天气信息异常,url={}", url); | |||
log.info("获取天气信息异常,param={}", param); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取天气信息失败,请重试"); | |||
} | |||
} |
@@ -11,9 +11,9 @@ public class WeatherUtil { | |||
if(ObjectUtil.isEmpty(airWeather) ||ObjectUtil.isEmpty(airWeather.getWth())){ | |||
return ""; | |||
} | |||
return "气温:" + new BigDecimal(airWeather.getWth().getParm().getTmp()).divide(new BigDecimal(10))+"℃" | |||
+ ";湿度:" + new BigDecimal(airWeather.getWth().getParm().getHum()).divide(new BigDecimal(10))+"RH" | |||
+ ";风速:" + new BigDecimal(airWeather.getWth().getParm().getWspd()).divide(new BigDecimal(10))+"M/S" | |||
+ ";风向:" + airWeather.getWth().getParm().getWdir() + "°"; | |||
return "气温:" + airWeather.getWth().getParmNew().getTmp() + "℃" | |||
+ ";湿度:" + airWeather.getWth().getParmNew().getHum() + "RH" | |||
+ ";风速:" + airWeather.getWth().getParmNew().getWspd() + "M/S" | |||
+ ";风向:" + airWeather.getWth().getParmNew().getWdirname(); | |||
} | |||
} |