Browse Source

Merge branch 'develop' of gitadmin/tuoheng_lc into release

tags/v1.2.0^2
wanjing 1 year ago
parent
commit
52d4d5a70b
3 changed files with 26 additions and 4 deletions
  1. +16
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/AirWeatherVO.java
  2. +6
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java
  3. +4
    -4
      tuoheng-admin/src/main/java/com/tuoheng/admin/utils/WeatherUtil.java

+ 16
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/AirWeatherVO.java View File

@@ -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

+ 6
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java View File

@@ -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(), "获取天气信息失败,请重试");
}
}

+ 4
- 4
tuoheng-admin/src/main/java/com/tuoheng/admin/utils/WeatherUtil.java View File

@@ -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();
}
}

Loading…
Cancel
Save